Initial commit: Email alerts application
This commit is contained in:
@@ -0,0 +1,724 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
|
||||
from twilio.base.client_base import ClientBase
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from twilio.rest.accounts import Accounts
|
||||
from twilio.rest.api import Api
|
||||
from twilio.rest.autopilot import Autopilot
|
||||
from twilio.rest.bulkexports import Bulkexports
|
||||
from twilio.rest.chat import Chat
|
||||
from twilio.rest.content import Content
|
||||
from twilio.rest.conversations import Conversations
|
||||
from twilio.rest.events import Events
|
||||
from twilio.rest.flex_api import FlexApi
|
||||
from twilio.rest.frontline_api import FrontlineApi
|
||||
from twilio.rest.insights import Insights
|
||||
from twilio.rest.intelligence import Intelligence
|
||||
from twilio.rest.ip_messaging import IpMessaging
|
||||
from twilio.rest.lookups import Lookups
|
||||
from twilio.rest.media import Media
|
||||
from twilio.rest.messaging import Messaging
|
||||
from twilio.rest.microvisor import Microvisor
|
||||
from twilio.rest.monitor import Monitor
|
||||
from twilio.rest.notify import Notify
|
||||
from twilio.rest.numbers import Numbers
|
||||
from twilio.rest.oauth import Oauth
|
||||
from twilio.rest.preview import Preview
|
||||
from twilio.rest.pricing import Pricing
|
||||
from twilio.rest.proxy import Proxy
|
||||
from twilio.rest.routes import Routes
|
||||
from twilio.rest.serverless import Serverless
|
||||
from twilio.rest.studio import Studio
|
||||
from twilio.rest.supersim import Supersim
|
||||
from twilio.rest.sync import Sync
|
||||
from twilio.rest.taskrouter import Taskrouter
|
||||
from twilio.rest.trunking import Trunking
|
||||
from twilio.rest.trusthub import Trusthub
|
||||
from twilio.rest.verify import Verify
|
||||
from twilio.rest.video import Video
|
||||
from twilio.rest.voice import Voice
|
||||
from twilio.rest.wireless import Wireless
|
||||
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_country import (
|
||||
AvailablePhoneNumberCountryList,
|
||||
)
|
||||
from twilio.rest.api.v2010.account.balance import BalanceList
|
||||
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.new_key import NewKeyList
|
||||
from twilio.rest.api.v2010.account.message import MessageList
|
||||
from twilio.rest.api.v2010.account.signing_key import SigningKeyList
|
||||
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.validation_request import ValidationRequestList
|
||||
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.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
|
||||
|
||||
|
||||
class Client(ClientBase):
|
||||
"""A client for accessing the Twilio API."""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
username=None,
|
||||
password=None,
|
||||
account_sid=None,
|
||||
region=None,
|
||||
http_client=None,
|
||||
environment=None,
|
||||
edge=None,
|
||||
user_agent_extensions=None,
|
||||
):
|
||||
"""
|
||||
Initializes the Twilio Client
|
||||
|
||||
:param str username: Username to authenticate with, either account_sid or api_key
|
||||
:param str password: Password to authenticate with, auth_token (if using account_sid) or api_secret (if using api_key)
|
||||
:param str account_sid: Account SID, required if using api_key to authenticate.
|
||||
:param str region: Twilio Region to make requests to, defaults to 'us1' if an edge is provided
|
||||
:param HttpClient http_client: HttpClient, defaults to TwilioHttpClient
|
||||
:param dict environment: Environment to look for auth details, defaults to os.environ
|
||||
:param str edge: Twilio Edge to make requests to, defaults to None
|
||||
:param list[str] user_agent_extensions: Additions to the user agent string
|
||||
|
||||
:returns: Twilio Client
|
||||
:rtype: twilio.rest.Client
|
||||
"""
|
||||
super().__init__(
|
||||
username,
|
||||
password,
|
||||
account_sid,
|
||||
region,
|
||||
http_client,
|
||||
environment,
|
||||
edge,
|
||||
user_agent_extensions,
|
||||
)
|
||||
|
||||
# Domains
|
||||
self._accounts: Optional["Accounts"] = None
|
||||
self._api: Optional["Api"] = None
|
||||
self._autopilot: Optional["Autopilot"] = None
|
||||
self._bulkexports: Optional["Bulkexports"] = None
|
||||
self._chat: Optional["Chat"] = None
|
||||
self._content: Optional["Content"] = None
|
||||
self._conversations: Optional["Conversations"] = None
|
||||
self._events: Optional["Events"] = None
|
||||
self._flex_api: Optional["FlexApi"] = None
|
||||
self._frontline_api: Optional["FrontlineApi"] = None
|
||||
self._insights: Optional["Insights"] = None
|
||||
self._intelligence: Optional["Intelligence"] = None
|
||||
self._ip_messaging: Optional["IpMessaging"] = None
|
||||
self._lookups: Optional["Lookups"] = None
|
||||
self._media: Optional["Media"] = None
|
||||
self._messaging: Optional["Messaging"] = None
|
||||
self._microvisor: Optional["Microvisor"] = None
|
||||
self._monitor: Optional["Monitor"] = None
|
||||
self._notify: Optional["Notify"] = None
|
||||
self._numbers: Optional["Numbers"] = None
|
||||
self._oauth: Optional["Oauth"] = None
|
||||
self._preview: Optional["Preview"] = None
|
||||
self._pricing: Optional["Pricing"] = None
|
||||
self._proxy: Optional["Proxy"] = None
|
||||
self._routes: Optional["Routes"] = None
|
||||
self._serverless: Optional["Serverless"] = None
|
||||
self._studio: Optional["Studio"] = None
|
||||
self._supersim: Optional["Supersim"] = None
|
||||
self._sync: Optional["Sync"] = None
|
||||
self._taskrouter: Optional["Taskrouter"] = None
|
||||
self._trunking: Optional["Trunking"] = None
|
||||
self._trusthub: Optional["Trusthub"] = None
|
||||
self._verify: Optional["Verify"] = None
|
||||
self._video: Optional["Video"] = None
|
||||
self._voice: Optional["Voice"] = None
|
||||
self._wireless: Optional["Wireless"] = None
|
||||
|
||||
@property
|
||||
def accounts(self) -> "Accounts":
|
||||
"""
|
||||
Access the Accounts Twilio Domain
|
||||
|
||||
:returns: Accounts Twilio Domain
|
||||
"""
|
||||
if self._accounts is None:
|
||||
from twilio.rest.accounts import Accounts
|
||||
|
||||
self._accounts = Accounts(self)
|
||||
return self._accounts
|
||||
|
||||
@property
|
||||
def api(self) -> "Api":
|
||||
"""
|
||||
Access the Api Twilio Domain
|
||||
|
||||
:returns: Api Twilio Domain
|
||||
"""
|
||||
if self._api is None:
|
||||
from twilio.rest.api import Api
|
||||
|
||||
self._api = Api(self)
|
||||
return self._api
|
||||
|
||||
@property
|
||||
def autopilot(self) -> "Autopilot":
|
||||
"""
|
||||
Access the Autopilot Twilio Domain
|
||||
|
||||
:returns: Autopilot Twilio Domain
|
||||
"""
|
||||
if self._autopilot is None:
|
||||
from twilio.rest.autopilot import Autopilot
|
||||
|
||||
self._autopilot = Autopilot(self)
|
||||
return self._autopilot
|
||||
|
||||
@property
|
||||
def bulkexports(self) -> "Bulkexports":
|
||||
"""
|
||||
Access the Bulkexports Twilio Domain
|
||||
|
||||
:returns: Bulkexports Twilio Domain
|
||||
"""
|
||||
if self._bulkexports is None:
|
||||
from twilio.rest.bulkexports import Bulkexports
|
||||
|
||||
self._bulkexports = Bulkexports(self)
|
||||
return self._bulkexports
|
||||
|
||||
@property
|
||||
def chat(self) -> "Chat":
|
||||
"""
|
||||
Access the Chat Twilio Domain
|
||||
|
||||
:returns: Chat Twilio Domain
|
||||
"""
|
||||
if self._chat is None:
|
||||
from twilio.rest.chat import Chat
|
||||
|
||||
self._chat = Chat(self)
|
||||
return self._chat
|
||||
|
||||
@property
|
||||
def content(self) -> "Content":
|
||||
"""
|
||||
Access the Content Twilio Domain
|
||||
|
||||
:returns: Content Twilio Domain
|
||||
"""
|
||||
if self._content is None:
|
||||
from twilio.rest.content import Content
|
||||
|
||||
self._content = Content(self)
|
||||
return self._content
|
||||
|
||||
@property
|
||||
def conversations(self) -> "Conversations":
|
||||
"""
|
||||
Access the Conversations Twilio Domain
|
||||
|
||||
:returns: Conversations Twilio Domain
|
||||
"""
|
||||
if self._conversations is None:
|
||||
from twilio.rest.conversations import Conversations
|
||||
|
||||
self._conversations = Conversations(self)
|
||||
return self._conversations
|
||||
|
||||
@property
|
||||
def events(self) -> "Events":
|
||||
"""
|
||||
Access the Events Twilio Domain
|
||||
|
||||
:returns: Events Twilio Domain
|
||||
"""
|
||||
if self._events is None:
|
||||
from twilio.rest.events import Events
|
||||
|
||||
self._events = Events(self)
|
||||
return self._events
|
||||
|
||||
@property
|
||||
def flex_api(self) -> "FlexApi":
|
||||
"""
|
||||
Access the FlexApi Twilio Domain
|
||||
|
||||
:returns: FlexApi Twilio Domain
|
||||
"""
|
||||
if self._flex_api is None:
|
||||
from twilio.rest.flex_api import FlexApi
|
||||
|
||||
self._flex_api = FlexApi(self)
|
||||
return self._flex_api
|
||||
|
||||
@property
|
||||
def frontline_api(self) -> "FrontlineApi":
|
||||
"""
|
||||
Access the FrontlineApi Twilio Domain
|
||||
|
||||
:returns: FrontlineApi Twilio Domain
|
||||
"""
|
||||
if self._frontline_api is None:
|
||||
from twilio.rest.frontline_api import FrontlineApi
|
||||
|
||||
self._frontline_api = FrontlineApi(self)
|
||||
return self._frontline_api
|
||||
|
||||
@property
|
||||
def insights(self) -> "Insights":
|
||||
"""
|
||||
Access the Insights Twilio Domain
|
||||
|
||||
:returns: Insights Twilio Domain
|
||||
"""
|
||||
if self._insights is None:
|
||||
from twilio.rest.insights import Insights
|
||||
|
||||
self._insights = Insights(self)
|
||||
return self._insights
|
||||
|
||||
@property
|
||||
def intelligence(self) -> "Intelligence":
|
||||
"""
|
||||
Access the Intelligence Twilio Domain
|
||||
|
||||
:returns: Intelligence Twilio Domain
|
||||
"""
|
||||
if self._intelligence is None:
|
||||
from twilio.rest.intelligence import Intelligence
|
||||
|
||||
self._intelligence = Intelligence(self)
|
||||
return self._intelligence
|
||||
|
||||
@property
|
||||
def ip_messaging(self) -> "IpMessaging":
|
||||
"""
|
||||
Access the IpMessaging Twilio Domain
|
||||
|
||||
:returns: IpMessaging Twilio Domain
|
||||
"""
|
||||
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) -> "Lookups":
|
||||
"""
|
||||
Access the Lookups Twilio Domain
|
||||
|
||||
:returns: Lookups Twilio Domain
|
||||
"""
|
||||
if self._lookups is None:
|
||||
from twilio.rest.lookups import Lookups
|
||||
|
||||
self._lookups = Lookups(self)
|
||||
return self._lookups
|
||||
|
||||
@property
|
||||
def media(self) -> "Media":
|
||||
"""
|
||||
Access the Media Twilio Domain
|
||||
|
||||
:returns: Media Twilio Domain
|
||||
"""
|
||||
if self._media is None:
|
||||
from twilio.rest.media import Media
|
||||
|
||||
self._media = Media(self)
|
||||
return self._media
|
||||
|
||||
@property
|
||||
def messaging(self) -> "Messaging":
|
||||
"""
|
||||
Access the Messaging Twilio Domain
|
||||
|
||||
:returns: Messaging Twilio Domain
|
||||
"""
|
||||
if self._messaging is None:
|
||||
from twilio.rest.messaging import Messaging
|
||||
|
||||
self._messaging = Messaging(self)
|
||||
return self._messaging
|
||||
|
||||
@property
|
||||
def microvisor(self) -> "Microvisor":
|
||||
"""
|
||||
Access the Microvisor Twilio Domain
|
||||
|
||||
:returns: Microvisor Twilio Domain
|
||||
"""
|
||||
if self._microvisor is None:
|
||||
from twilio.rest.microvisor import Microvisor
|
||||
|
||||
self._microvisor = Microvisor(self)
|
||||
return self._microvisor
|
||||
|
||||
@property
|
||||
def monitor(self) -> "Monitor":
|
||||
"""
|
||||
Access the Monitor Twilio Domain
|
||||
|
||||
:returns: Monitor Twilio Domain
|
||||
"""
|
||||
if self._monitor is None:
|
||||
from twilio.rest.monitor import Monitor
|
||||
|
||||
self._monitor = Monitor(self)
|
||||
return self._monitor
|
||||
|
||||
@property
|
||||
def notify(self) -> "Notify":
|
||||
"""
|
||||
Access the Notify Twilio Domain
|
||||
|
||||
:returns: Notify Twilio Domain
|
||||
"""
|
||||
if self._notify is None:
|
||||
from twilio.rest.notify import Notify
|
||||
|
||||
self._notify = Notify(self)
|
||||
return self._notify
|
||||
|
||||
@property
|
||||
def numbers(self) -> "Numbers":
|
||||
"""
|
||||
Access the Numbers Twilio Domain
|
||||
|
||||
:returns: Numbers Twilio Domain
|
||||
"""
|
||||
if self._numbers is None:
|
||||
from twilio.rest.numbers import Numbers
|
||||
|
||||
self._numbers = Numbers(self)
|
||||
return self._numbers
|
||||
|
||||
@property
|
||||
def oauth(self) -> "Oauth":
|
||||
"""
|
||||
Access the Oauth Twilio Domain
|
||||
|
||||
:returns: Oauth Twilio Domain
|
||||
"""
|
||||
if self._oauth is None:
|
||||
from twilio.rest.oauth import Oauth
|
||||
|
||||
self._oauth = Oauth(self)
|
||||
return self._oauth
|
||||
|
||||
@property
|
||||
def preview(self) -> "Preview":
|
||||
"""
|
||||
Access the Preview Twilio Domain
|
||||
|
||||
:returns: Preview Twilio Domain
|
||||
"""
|
||||
if self._preview is None:
|
||||
from twilio.rest.preview import Preview
|
||||
|
||||
self._preview = Preview(self)
|
||||
return self._preview
|
||||
|
||||
@property
|
||||
def pricing(self) -> "Pricing":
|
||||
"""
|
||||
Access the Pricing Twilio Domain
|
||||
|
||||
:returns: Pricing Twilio Domain
|
||||
"""
|
||||
if self._pricing is None:
|
||||
from twilio.rest.pricing import Pricing
|
||||
|
||||
self._pricing = Pricing(self)
|
||||
return self._pricing
|
||||
|
||||
@property
|
||||
def proxy(self) -> "Proxy":
|
||||
"""
|
||||
Access the Proxy Twilio Domain
|
||||
|
||||
:returns: Proxy Twilio Domain
|
||||
"""
|
||||
if self._proxy is None:
|
||||
from twilio.rest.proxy import Proxy
|
||||
|
||||
self._proxy = Proxy(self)
|
||||
return self._proxy
|
||||
|
||||
@property
|
||||
def routes(self) -> "Routes":
|
||||
"""
|
||||
Access the Routes Twilio Domain
|
||||
|
||||
:returns: Routes Twilio Domain
|
||||
"""
|
||||
if self._routes is None:
|
||||
from twilio.rest.routes import Routes
|
||||
|
||||
self._routes = Routes(self)
|
||||
return self._routes
|
||||
|
||||
@property
|
||||
def serverless(self) -> "Serverless":
|
||||
"""
|
||||
Access the Serverless Twilio Domain
|
||||
|
||||
:returns: Serverless Twilio Domain
|
||||
"""
|
||||
if self._serverless is None:
|
||||
from twilio.rest.serverless import Serverless
|
||||
|
||||
self._serverless = Serverless(self)
|
||||
return self._serverless
|
||||
|
||||
@property
|
||||
def studio(self) -> "Studio":
|
||||
"""
|
||||
Access the Studio Twilio Domain
|
||||
|
||||
:returns: Studio Twilio Domain
|
||||
"""
|
||||
if self._studio is None:
|
||||
from twilio.rest.studio import Studio
|
||||
|
||||
self._studio = Studio(self)
|
||||
return self._studio
|
||||
|
||||
@property
|
||||
def supersim(self) -> "Supersim":
|
||||
"""
|
||||
Access the Supersim Twilio Domain
|
||||
|
||||
:returns: Supersim Twilio Domain
|
||||
"""
|
||||
if self._supersim is None:
|
||||
from twilio.rest.supersim import Supersim
|
||||
|
||||
self._supersim = Supersim(self)
|
||||
return self._supersim
|
||||
|
||||
@property
|
||||
def sync(self) -> "Sync":
|
||||
"""
|
||||
Access the Sync Twilio Domain
|
||||
|
||||
:returns: Sync Twilio Domain
|
||||
"""
|
||||
if self._sync is None:
|
||||
from twilio.rest.sync import Sync
|
||||
|
||||
self._sync = Sync(self)
|
||||
return self._sync
|
||||
|
||||
@property
|
||||
def taskrouter(self) -> "Taskrouter":
|
||||
"""
|
||||
Access the Taskrouter Twilio Domain
|
||||
|
||||
:returns: Taskrouter Twilio Domain
|
||||
"""
|
||||
if self._taskrouter is None:
|
||||
from twilio.rest.taskrouter import Taskrouter
|
||||
|
||||
self._taskrouter = Taskrouter(self)
|
||||
return self._taskrouter
|
||||
|
||||
@property
|
||||
def trunking(self) -> "Trunking":
|
||||
"""
|
||||
Access the Trunking Twilio Domain
|
||||
|
||||
:returns: Trunking Twilio Domain
|
||||
"""
|
||||
if self._trunking is None:
|
||||
from twilio.rest.trunking import Trunking
|
||||
|
||||
self._trunking = Trunking(self)
|
||||
return self._trunking
|
||||
|
||||
@property
|
||||
def trusthub(self) -> "Trusthub":
|
||||
"""
|
||||
Access the Trusthub Twilio Domain
|
||||
|
||||
:returns: Trusthub Twilio Domain
|
||||
"""
|
||||
if self._trusthub is None:
|
||||
from twilio.rest.trusthub import Trusthub
|
||||
|
||||
self._trusthub = Trusthub(self)
|
||||
return self._trusthub
|
||||
|
||||
@property
|
||||
def verify(self) -> "Verify":
|
||||
"""
|
||||
Access the Verify Twilio Domain
|
||||
|
||||
:returns: Verify Twilio Domain
|
||||
"""
|
||||
if self._verify is None:
|
||||
from twilio.rest.verify import Verify
|
||||
|
||||
self._verify = Verify(self)
|
||||
return self._verify
|
||||
|
||||
@property
|
||||
def video(self) -> "Video":
|
||||
"""
|
||||
Access the Video Twilio Domain
|
||||
|
||||
:returns: Video Twilio Domain
|
||||
"""
|
||||
if self._video is None:
|
||||
from twilio.rest.video import Video
|
||||
|
||||
self._video = Video(self)
|
||||
return self._video
|
||||
|
||||
@property
|
||||
def voice(self) -> "Voice":
|
||||
"""
|
||||
Access the Voice Twilio Domain
|
||||
|
||||
:returns: Voice Twilio Domain
|
||||
"""
|
||||
if self._voice is None:
|
||||
from twilio.rest.voice import Voice
|
||||
|
||||
self._voice = Voice(self)
|
||||
return self._voice
|
||||
|
||||
@property
|
||||
def wireless(self) -> "Wireless":
|
||||
"""
|
||||
Access the Wireless Twilio Domain
|
||||
|
||||
:returns: Wireless Twilio Domain
|
||||
"""
|
||||
if self._wireless is None:
|
||||
from twilio.rest.wireless import Wireless
|
||||
|
||||
self._wireless = Wireless(self)
|
||||
return self._wireless
|
||||
|
||||
@property
|
||||
def addresses(self) -> "AddressList":
|
||||
return self.api.account.addresses
|
||||
|
||||
@property
|
||||
def applications(self) -> "ApplicationList":
|
||||
return self.api.account.applications
|
||||
|
||||
@property
|
||||
def authorized_connect_apps(self) -> "AuthorizedConnectAppList":
|
||||
return self.api.account.authorized_connect_apps
|
||||
|
||||
@property
|
||||
def available_phone_numbers(self) -> "AvailablePhoneNumberCountryList":
|
||||
return self.api.account.available_phone_numbers
|
||||
|
||||
@property
|
||||
def balance(self) -> "BalanceList":
|
||||
return self.api.account.balance
|
||||
|
||||
@property
|
||||
def calls(self) -> "CallList":
|
||||
return self.api.account.calls
|
||||
|
||||
@property
|
||||
def conferences(self) -> "ConferenceList":
|
||||
return self.api.account.conferences
|
||||
|
||||
@property
|
||||
def connect_apps(self) -> "ConnectAppList":
|
||||
return self.api.account.connect_apps
|
||||
|
||||
@property
|
||||
def incoming_phone_numbers(self) -> "IncomingPhoneNumberList":
|
||||
return self.api.account.incoming_phone_numbers
|
||||
|
||||
@property
|
||||
def keys(self) -> "KeyList":
|
||||
return self.api.account.keys
|
||||
|
||||
@property
|
||||
def new_keys(self) -> "NewKeyList":
|
||||
return self.api.account.new_keys
|
||||
|
||||
@property
|
||||
def messages(self) -> "MessageList":
|
||||
return self.api.account.messages
|
||||
|
||||
@property
|
||||
def signing_keys(self) -> "SigningKeyList":
|
||||
return self.api.account.signing_keys
|
||||
|
||||
@property
|
||||
def new_signing_keys(self) -> "NewSigningKeyList":
|
||||
return self.api.account.new_signing_keys
|
||||
|
||||
@property
|
||||
def notifications(self) -> "NotificationList":
|
||||
return self.api.account.notifications
|
||||
|
||||
@property
|
||||
def outgoing_caller_ids(self) -> "OutgoingCallerIdList":
|
||||
return self.api.account.outgoing_caller_ids
|
||||
|
||||
@property
|
||||
def validation_requests(self) -> "ValidationRequestList":
|
||||
return self.api.account.validation_requests
|
||||
|
||||
@property
|
||||
def queues(self) -> "QueueList":
|
||||
return self.api.account.queues
|
||||
|
||||
@property
|
||||
def recordings(self) -> "RecordingList":
|
||||
return self.api.account.recordings
|
||||
|
||||
@property
|
||||
def short_codes(self) -> "ShortCodeList":
|
||||
return self.api.account.short_codes
|
||||
|
||||
@property
|
||||
def sip(self) -> "SipList":
|
||||
return self.api.account.sip
|
||||
|
||||
@property
|
||||
def tokens(self) -> "TokenList":
|
||||
return self.api.account.tokens
|
||||
|
||||
@property
|
||||
def transcriptions(self) -> "TranscriptionList":
|
||||
return self.api.account.transcriptions
|
||||
|
||||
@property
|
||||
def usage(self) -> "UsageList":
|
||||
return self.api.account.usage
|
||||
Binary file not shown.
@@ -0,0 +1,43 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
from typing import Optional
|
||||
|
||||
from twilio.base.domain import Domain
|
||||
from twilio.rest import Client
|
||||
from twilio.rest.accounts.v1 import V1
|
||||
|
||||
|
||||
class AccountsBase(Domain):
|
||||
def __init__(self, twilio: Client):
|
||||
"""
|
||||
Initialize the Accounts Domain
|
||||
|
||||
:returns: Domain for Accounts
|
||||
"""
|
||||
super().__init__(twilio, "https://accounts.twilio.com")
|
||||
self._v1: Optional[V1] = None
|
||||
|
||||
@property
|
||||
def v1(self) -> V1:
|
||||
"""
|
||||
:returns: Versions v1 of Accounts
|
||||
"""
|
||||
if self._v1 is None:
|
||||
self._v1 = V1(self)
|
||||
return self._v1
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Accounts>"
|
||||
@@ -0,0 +1,35 @@
|
||||
from warnings import warn
|
||||
|
||||
from twilio.rest.accounts.AccountsBase import AccountsBase
|
||||
from twilio.rest.accounts.v1.auth_token_promotion import AuthTokenPromotionList
|
||||
from twilio.rest.accounts.v1.credential import CredentialList
|
||||
from twilio.rest.accounts.v1.secondary_auth_token import SecondaryAuthTokenList
|
||||
|
||||
|
||||
class Accounts(AccountsBase):
|
||||
@property
|
||||
def auth_token_promotion(self) -> AuthTokenPromotionList:
|
||||
warn(
|
||||
"auth_token_promotion is deprecated. Use v1.auth_token_promotion instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.v1.auth_token_promotion
|
||||
|
||||
@property
|
||||
def credentials(self) -> CredentialList:
|
||||
warn(
|
||||
"credentials is deprecated. Use v1.credentials instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.v1.credentials
|
||||
|
||||
@property
|
||||
def secondary_auth_token(self) -> SecondaryAuthTokenList:
|
||||
warn(
|
||||
"secondary_auth_token is deprecated. Use v1.secondary_auth_token instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.v1.secondary_auth_token
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -0,0 +1,66 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Accounts
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
from typing import Optional
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.domain import Domain
|
||||
from twilio.rest.accounts.v1.auth_token_promotion import AuthTokenPromotionList
|
||||
from twilio.rest.accounts.v1.credential import CredentialList
|
||||
from twilio.rest.accounts.v1.safelist import SafelistList
|
||||
from twilio.rest.accounts.v1.secondary_auth_token import SecondaryAuthTokenList
|
||||
|
||||
|
||||
class V1(Version):
|
||||
def __init__(self, domain: Domain):
|
||||
"""
|
||||
Initialize the V1 version of Accounts
|
||||
|
||||
:param domain: The Twilio.accounts domain
|
||||
"""
|
||||
super().__init__(domain, "v1")
|
||||
self._auth_token_promotion: Optional[AuthTokenPromotionList] = None
|
||||
self._credentials: Optional[CredentialList] = None
|
||||
self._safelist: Optional[SafelistList] = None
|
||||
self._secondary_auth_token: Optional[SecondaryAuthTokenList] = None
|
||||
|
||||
@property
|
||||
def auth_token_promotion(self) -> AuthTokenPromotionList:
|
||||
if self._auth_token_promotion is None:
|
||||
self._auth_token_promotion = AuthTokenPromotionList(self)
|
||||
return self._auth_token_promotion
|
||||
|
||||
@property
|
||||
def credentials(self) -> CredentialList:
|
||||
if self._credentials is None:
|
||||
self._credentials = CredentialList(self)
|
||||
return self._credentials
|
||||
|
||||
@property
|
||||
def safelist(self) -> SafelistList:
|
||||
if self._safelist is None:
|
||||
self._safelist = SafelistList(self)
|
||||
return self._safelist
|
||||
|
||||
@property
|
||||
def secondary_auth_token(self) -> SecondaryAuthTokenList:
|
||||
if self._secondary_auth_token is None:
|
||||
self._secondary_auth_token = SecondaryAuthTokenList(self)
|
||||
return self._secondary_auth_token
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Accounts.V1>"
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -0,0 +1,177 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Accounts
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, Optional
|
||||
from twilio.base import deserialize, values
|
||||
from twilio.base.instance_context import InstanceContext
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
|
||||
|
||||
class AuthTokenPromotionInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that the secondary Auth Token was created for.
|
||||
:ivar auth_token: The promoted Auth Token that must be used to authenticate future API requests.
|
||||
:ivar date_created: The date and time in UTC when the resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:ivar date_updated: The date and time in GMT when the resource was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:ivar url: The URI for this resource, relative to `https://accounts.twilio.com`
|
||||
"""
|
||||
|
||||
def __init__(self, version: Version, payload: Dict[str, Any]):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.auth_token: Optional[str] = payload.get("auth_token")
|
||||
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
|
||||
self._context: Optional[AuthTokenPromotionContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "AuthTokenPromotionContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: AuthTokenPromotionContext for this AuthTokenPromotionInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = AuthTokenPromotionContext(
|
||||
self._version,
|
||||
)
|
||||
return self._context
|
||||
|
||||
def update(self) -> "AuthTokenPromotionInstance":
|
||||
"""
|
||||
Update the AuthTokenPromotionInstance
|
||||
|
||||
|
||||
:returns: The updated AuthTokenPromotionInstance
|
||||
"""
|
||||
return self._proxy.update()
|
||||
|
||||
async def update_async(self) -> "AuthTokenPromotionInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the AuthTokenPromotionInstance
|
||||
|
||||
|
||||
:returns: The updated AuthTokenPromotionInstance
|
||||
"""
|
||||
return await self._proxy.update_async()
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
|
||||
return "<Twilio.Accounts.V1.AuthTokenPromotionInstance>"
|
||||
|
||||
|
||||
class AuthTokenPromotionContext(InstanceContext):
|
||||
def __init__(self, version: Version):
|
||||
"""
|
||||
Initialize the AuthTokenPromotionContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
self._uri = "/AuthTokens/Promote"
|
||||
|
||||
def update(self) -> AuthTokenPromotionInstance:
|
||||
"""
|
||||
Update the AuthTokenPromotionInstance
|
||||
|
||||
|
||||
:returns: The updated AuthTokenPromotionInstance
|
||||
"""
|
||||
data = values.of({})
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return AuthTokenPromotionInstance(self._version, payload)
|
||||
|
||||
async def update_async(self) -> AuthTokenPromotionInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the AuthTokenPromotionInstance
|
||||
|
||||
|
||||
:returns: The updated AuthTokenPromotionInstance
|
||||
"""
|
||||
data = values.of({})
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return AuthTokenPromotionInstance(self._version, payload)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
|
||||
return "<Twilio.Accounts.V1.AuthTokenPromotionContext>"
|
||||
|
||||
|
||||
class AuthTokenPromotionList(ListResource):
|
||||
def __init__(self, version: Version):
|
||||
"""
|
||||
Initialize the AuthTokenPromotionList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
def get(self) -> AuthTokenPromotionContext:
|
||||
"""
|
||||
Constructs a AuthTokenPromotionContext
|
||||
|
||||
"""
|
||||
return AuthTokenPromotionContext(self._version)
|
||||
|
||||
def __call__(self) -> AuthTokenPromotionContext:
|
||||
"""
|
||||
Constructs a AuthTokenPromotionContext
|
||||
|
||||
"""
|
||||
return AuthTokenPromotionContext(self._version)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Accounts.V1.AuthTokenPromotionList>"
|
||||
@@ -0,0 +1,65 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Accounts
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from typing import Optional
|
||||
|
||||
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
|
||||
from twilio.rest.accounts.v1.credential.aws import AwsList
|
||||
from twilio.rest.accounts.v1.credential.public_key import PublicKeyList
|
||||
|
||||
|
||||
class CredentialList(ListResource):
|
||||
def __init__(self, version: Version):
|
||||
"""
|
||||
Initialize the CredentialList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
self._uri = "/Credentials"
|
||||
|
||||
self._aws: Optional[AwsList] = None
|
||||
self._public_key: Optional[PublicKeyList] = None
|
||||
|
||||
@property
|
||||
def aws(self) -> AwsList:
|
||||
"""
|
||||
Access the aws
|
||||
"""
|
||||
if self._aws is None:
|
||||
self._aws = AwsList(self._version)
|
||||
return self._aws
|
||||
|
||||
@property
|
||||
def public_key(self) -> PublicKeyList:
|
||||
"""
|
||||
Access the public_key
|
||||
"""
|
||||
if self._public_key is None:
|
||||
self._public_key = PublicKeyList(self._version)
|
||||
return self._public_key
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Accounts.V1.CredentialList>"
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -0,0 +1,576 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Accounts
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, values
|
||||
from twilio.base.instance_context import InstanceContext
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.page import Page
|
||||
|
||||
|
||||
class AwsInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar sid: The unique string that we created to identify the AWS resource.
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the AWS resource.
|
||||
:ivar friendly_name: The string that you assigned to describe the resource.
|
||||
:ivar date_created: The date and time in GMT when the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar date_updated: The date and time in GMT when the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar url: The URI for this resource, relative to `https://accounts.twilio.com`
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self, version: Version, payload: Dict[str, Any], sid: Optional[str] = None
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.friendly_name: Optional[str] = payload.get("friendly_name")
|
||||
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
|
||||
self._solution = {
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[AwsContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "AwsContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: AwsContext for this AwsInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = AwsContext(
|
||||
self._version,
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the AwsInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the AwsInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
def fetch(self) -> "AwsInstance":
|
||||
"""
|
||||
Fetch the AwsInstance
|
||||
|
||||
|
||||
:returns: The fetched AwsInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "AwsInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the AwsInstance
|
||||
|
||||
|
||||
:returns: The fetched AwsInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(self, friendly_name: Union[str, object] = values.unset) -> "AwsInstance":
|
||||
"""
|
||||
Update the AwsInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long.
|
||||
|
||||
:returns: The updated AwsInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
friendly_name=friendly_name,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self, friendly_name: Union[str, object] = values.unset
|
||||
) -> "AwsInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the AwsInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long.
|
||||
|
||||
:returns: The updated AwsInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
friendly_name=friendly_name,
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Accounts.V1.AwsInstance {}>".format(context)
|
||||
|
||||
|
||||
class AwsContext(InstanceContext):
|
||||
def __init__(self, version: Version, sid: str):
|
||||
"""
|
||||
Initialize the AwsContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param sid: The Twilio-provided string that uniquely identifies the AWS resource to update.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Credentials/AWS/{sid}".format(**self._solution)
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the AwsInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._version.delete(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the AwsInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
def fetch(self) -> AwsInstance:
|
||||
"""
|
||||
Fetch the AwsInstance
|
||||
|
||||
|
||||
:returns: The fetched AwsInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return AwsInstance(
|
||||
self._version,
|
||||
payload,
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> AwsInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the AwsInstance
|
||||
|
||||
|
||||
:returns: The fetched AwsInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return AwsInstance(
|
||||
self._version,
|
||||
payload,
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def update(self, friendly_name: Union[str, object] = values.unset) -> AwsInstance:
|
||||
"""
|
||||
Update the AwsInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long.
|
||||
|
||||
:returns: The updated AwsInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return AwsInstance(self._version, payload, sid=self._solution["sid"])
|
||||
|
||||
async def update_async(
|
||||
self, friendly_name: Union[str, object] = values.unset
|
||||
) -> AwsInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the AwsInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long.
|
||||
|
||||
:returns: The updated AwsInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return AwsInstance(self._version, payload, sid=self._solution["sid"])
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Accounts.V1.AwsContext {}>".format(context)
|
||||
|
||||
|
||||
class AwsPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> AwsInstance:
|
||||
"""
|
||||
Build an instance of AwsInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return AwsInstance(self._version, payload)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Accounts.V1.AwsPage>"
|
||||
|
||||
|
||||
class AwsList(ListResource):
|
||||
def __init__(self, version: Version):
|
||||
"""
|
||||
Initialize the AwsList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
self._uri = "/Credentials/AWS"
|
||||
|
||||
def create(
|
||||
self,
|
||||
credentials: str,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
account_sid: Union[str, object] = values.unset,
|
||||
) -> AwsInstance:
|
||||
"""
|
||||
Create the AwsInstance
|
||||
|
||||
:param credentials: A string that contains the AWS access credentials in the format `<AWS_ACCESS_KEY_ID>:<AWS_SECRET_ACCESS_KEY>`. For example, `AKIAIOSFODNN7EXAMPLE:wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY`
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long.
|
||||
:param account_sid: The SID of the Subaccount that this Credential should be associated with. Must be a valid Subaccount of the account issuing the request.
|
||||
|
||||
:returns: The created AwsInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Credentials": credentials,
|
||||
"FriendlyName": friendly_name,
|
||||
"AccountSid": account_sid,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return AwsInstance(self._version, payload)
|
||||
|
||||
async def create_async(
|
||||
self,
|
||||
credentials: str,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
account_sid: Union[str, object] = values.unset,
|
||||
) -> AwsInstance:
|
||||
"""
|
||||
Asynchronously create the AwsInstance
|
||||
|
||||
:param credentials: A string that contains the AWS access credentials in the format `<AWS_ACCESS_KEY_ID>:<AWS_SECRET_ACCESS_KEY>`. For example, `AKIAIOSFODNN7EXAMPLE:wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY`
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long.
|
||||
:param account_sid: The SID of the Subaccount that this Credential should be associated with. Must be a valid Subaccount of the account issuing the request.
|
||||
|
||||
:returns: The created AwsInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Credentials": credentials,
|
||||
"FriendlyName": friendly_name,
|
||||
"AccountSid": account_sid,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return AwsInstance(self._version, payload)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[AwsInstance]:
|
||||
"""
|
||||
Streams AwsInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[AwsInstance]:
|
||||
"""
|
||||
Asynchronously streams AwsInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[AwsInstance]:
|
||||
"""
|
||||
Lists AwsInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return list(
|
||||
self.stream(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[AwsInstance]:
|
||||
"""
|
||||
Asynchronously lists AwsInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return [
|
||||
record
|
||||
async for record in await self.stream_async(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> AwsPage:
|
||||
"""
|
||||
Retrieve a single page of AwsInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of AwsInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return AwsPage(self._version, response)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> AwsPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of AwsInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of AwsInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return AwsPage(self._version, response)
|
||||
|
||||
def get_page(self, target_url: str) -> AwsPage:
|
||||
"""
|
||||
Retrieve a specific page of AwsInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of AwsInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return AwsPage(self._version, response)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> AwsPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of AwsInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of AwsInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return AwsPage(self._version, response)
|
||||
|
||||
def get(self, sid: str) -> AwsContext:
|
||||
"""
|
||||
Constructs a AwsContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the AWS resource to update.
|
||||
"""
|
||||
return AwsContext(self._version, sid=sid)
|
||||
|
||||
def __call__(self, sid: str) -> AwsContext:
|
||||
"""
|
||||
Constructs a AwsContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the AWS resource to update.
|
||||
"""
|
||||
return AwsContext(self._version, sid=sid)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Accounts.V1.AwsList>"
|
||||
@@ -0,0 +1,580 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Accounts
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, values
|
||||
from twilio.base.instance_context import InstanceContext
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.page import Page
|
||||
|
||||
|
||||
class PublicKeyInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar sid: The unique string that that we created to identify the PublicKey resource.
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Credential that the PublicKey resource belongs to.
|
||||
:ivar friendly_name: The string that you assigned to describe the resource.
|
||||
:ivar date_created: The date and time in GMT when the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar date_updated: The date and time in GMT when the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar url: The URI for this resource, relative to `https://accounts.twilio.com`
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self, version: Version, payload: Dict[str, Any], sid: Optional[str] = None
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.friendly_name: Optional[str] = payload.get("friendly_name")
|
||||
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
|
||||
self._solution = {
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[PublicKeyContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "PublicKeyContext":
|
||||
"""
|
||||
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
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = PublicKeyContext(
|
||||
self._version,
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the PublicKeyInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the PublicKeyInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
def fetch(self) -> "PublicKeyInstance":
|
||||
"""
|
||||
Fetch the PublicKeyInstance
|
||||
|
||||
|
||||
:returns: The fetched PublicKeyInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "PublicKeyInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the PublicKeyInstance
|
||||
|
||||
|
||||
:returns: The fetched PublicKeyInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self, friendly_name: Union[str, object] = values.unset
|
||||
) -> "PublicKeyInstance":
|
||||
"""
|
||||
Update the PublicKeyInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long.
|
||||
|
||||
:returns: The updated PublicKeyInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
friendly_name=friendly_name,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self, friendly_name: Union[str, object] = values.unset
|
||||
) -> "PublicKeyInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the PublicKeyInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long.
|
||||
|
||||
:returns: The updated PublicKeyInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
friendly_name=friendly_name,
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Accounts.V1.PublicKeyInstance {}>".format(context)
|
||||
|
||||
|
||||
class PublicKeyContext(InstanceContext):
|
||||
def __init__(self, version: Version, sid: str):
|
||||
"""
|
||||
Initialize the PublicKeyContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param sid: The Twilio-provided string that uniquely identifies the PublicKey resource to update.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Credentials/PublicKeys/{sid}".format(**self._solution)
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the PublicKeyInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._version.delete(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the PublicKeyInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
def fetch(self) -> PublicKeyInstance:
|
||||
"""
|
||||
Fetch the PublicKeyInstance
|
||||
|
||||
|
||||
:returns: The fetched PublicKeyInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return PublicKeyInstance(
|
||||
self._version,
|
||||
payload,
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> PublicKeyInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the PublicKeyInstance
|
||||
|
||||
|
||||
:returns: The fetched PublicKeyInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return PublicKeyInstance(
|
||||
self._version,
|
||||
payload,
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self, friendly_name: Union[str, object] = values.unset
|
||||
) -> PublicKeyInstance:
|
||||
"""
|
||||
Update the PublicKeyInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long.
|
||||
|
||||
:returns: The updated PublicKeyInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return PublicKeyInstance(self._version, payload, sid=self._solution["sid"])
|
||||
|
||||
async def update_async(
|
||||
self, friendly_name: Union[str, object] = values.unset
|
||||
) -> PublicKeyInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the PublicKeyInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long.
|
||||
|
||||
:returns: The updated PublicKeyInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return PublicKeyInstance(self._version, payload, sid=self._solution["sid"])
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Accounts.V1.PublicKeyContext {}>".format(context)
|
||||
|
||||
|
||||
class PublicKeyPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> PublicKeyInstance:
|
||||
"""
|
||||
Build an instance of PublicKeyInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return PublicKeyInstance(self._version, payload)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Accounts.V1.PublicKeyPage>"
|
||||
|
||||
|
||||
class PublicKeyList(ListResource):
|
||||
def __init__(self, version: Version):
|
||||
"""
|
||||
Initialize the PublicKeyList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
self._uri = "/Credentials/PublicKeys"
|
||||
|
||||
def create(
|
||||
self,
|
||||
public_key: str,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
account_sid: Union[str, object] = values.unset,
|
||||
) -> PublicKeyInstance:
|
||||
"""
|
||||
Create the PublicKeyInstance
|
||||
|
||||
:param public_key: A URL encoded representation of the public key. For example, `-----BEGIN PUBLIC KEY-----MIIBIjANB.pa9xQIDAQAB-----END PUBLIC KEY-----`
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long.
|
||||
:param account_sid: The SID of the Subaccount that this Credential should be associated with. Must be a valid Subaccount of the account issuing the request
|
||||
|
||||
:returns: The created PublicKeyInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PublicKey": public_key,
|
||||
"FriendlyName": friendly_name,
|
||||
"AccountSid": account_sid,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return PublicKeyInstance(self._version, payload)
|
||||
|
||||
async def create_async(
|
||||
self,
|
||||
public_key: str,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
account_sid: Union[str, object] = values.unset,
|
||||
) -> PublicKeyInstance:
|
||||
"""
|
||||
Asynchronously create the PublicKeyInstance
|
||||
|
||||
:param public_key: A URL encoded representation of the public key. For example, `-----BEGIN PUBLIC KEY-----MIIBIjANB.pa9xQIDAQAB-----END PUBLIC KEY-----`
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long.
|
||||
:param account_sid: The SID of the Subaccount that this Credential should be associated with. Must be a valid Subaccount of the account issuing the request
|
||||
|
||||
:returns: The created PublicKeyInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PublicKey": public_key,
|
||||
"FriendlyName": friendly_name,
|
||||
"AccountSid": account_sid,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return PublicKeyInstance(self._version, payload)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[PublicKeyInstance]:
|
||||
"""
|
||||
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 limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[PublicKeyInstance]:
|
||||
"""
|
||||
Asynchronously 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 limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[PublicKeyInstance]:
|
||||
"""
|
||||
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 limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return list(
|
||||
self.stream(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[PublicKeyInstance]:
|
||||
"""
|
||||
Asynchronously 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 limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return [
|
||||
record
|
||||
async for record in await self.stream_async(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> PublicKeyPage:
|
||||
"""
|
||||
Retrieve a single page of PublicKeyInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of PublicKeyInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return PublicKeyPage(self._version, response)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> PublicKeyPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of PublicKeyInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of PublicKeyInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return PublicKeyPage(self._version, response)
|
||||
|
||||
def get_page(self, target_url: str) -> PublicKeyPage:
|
||||
"""
|
||||
Retrieve a specific page of PublicKeyInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of PublicKeyInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return PublicKeyPage(self._version, response)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> PublicKeyPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of PublicKeyInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of PublicKeyInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return PublicKeyPage(self._version, response)
|
||||
|
||||
def get(self, sid: str) -> PublicKeyContext:
|
||||
"""
|
||||
Constructs a PublicKeyContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the PublicKey resource to update.
|
||||
"""
|
||||
return PublicKeyContext(self._version, sid=sid)
|
||||
|
||||
def __call__(self, sid: str) -> PublicKeyContext:
|
||||
"""
|
||||
Constructs a PublicKeyContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the PublicKey resource to update.
|
||||
"""
|
||||
return PublicKeyContext(self._version, sid=sid)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Accounts.V1.PublicKeyList>"
|
||||
@@ -0,0 +1,129 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Accounts
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from typing import Any, Dict, Optional
|
||||
from twilio.base import values
|
||||
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
|
||||
|
||||
class SafelistInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar sid: The unique string that we created to identify the SafeList resource.
|
||||
:ivar phone_number: The phone number in SafeList.
|
||||
"""
|
||||
|
||||
def __init__(self, version: Version, payload: Dict[str, Any]):
|
||||
super().__init__(version)
|
||||
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.phone_number: Optional[str] = payload.get("phone_number")
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
|
||||
return "<Twilio.Accounts.V1.SafelistInstance>"
|
||||
|
||||
|
||||
class SafelistList(ListResource):
|
||||
def __init__(self, version: Version):
|
||||
"""
|
||||
Initialize the SafelistList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
self._uri = "/SafeList/Numbers"
|
||||
|
||||
def create(self, phone_number: str) -> SafelistInstance:
|
||||
"""
|
||||
Create the SafelistInstance
|
||||
|
||||
:param phone_number: The phone number to be added in SafeList. Phone numbers must be in [E.164 format](https://www.twilio.com/docs/glossary/what-e164).
|
||||
|
||||
:returns: The created SafelistInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PhoneNumber": phone_number,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return SafelistInstance(self._version, payload)
|
||||
|
||||
async def create_async(self, phone_number: str) -> SafelistInstance:
|
||||
"""
|
||||
Asynchronously create the SafelistInstance
|
||||
|
||||
:param phone_number: The phone number to be added in SafeList. Phone numbers must be in [E.164 format](https://www.twilio.com/docs/glossary/what-e164).
|
||||
|
||||
:returns: The created SafelistInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PhoneNumber": phone_number,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return SafelistInstance(self._version, payload)
|
||||
|
||||
def fetch(self) -> SafelistInstance:
|
||||
"""
|
||||
Asynchronously fetch the SafelistInstance
|
||||
|
||||
:returns: The fetched SafelistInstance
|
||||
"""
|
||||
payload = self._version.fetch(method="GET", uri=self._uri)
|
||||
|
||||
return SafelistInstance(self._version, payload)
|
||||
|
||||
async def fetch_async(self) -> SafelistInstance:
|
||||
"""
|
||||
Asynchronously fetch the SafelistInstance
|
||||
|
||||
:returns: The fetched SafelistInstance
|
||||
"""
|
||||
payload = await self._version.fetch_async(method="GET", uri=self._uri)
|
||||
|
||||
return SafelistInstance(self._version, payload)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Accounts.V1.SafelistList>"
|
||||
@@ -0,0 +1,213 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Accounts
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, Optional
|
||||
from twilio.base import deserialize, values
|
||||
from twilio.base.instance_context import InstanceContext
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
|
||||
|
||||
class SecondaryAuthTokenInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that the secondary Auth Token was created for.
|
||||
:ivar date_created: The date and time in UTC when the resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:ivar date_updated: The date and time in UTC when the resource was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:ivar secondary_auth_token: The generated secondary Auth Token that can be used to authenticate future API requests.
|
||||
:ivar url: The URI for this resource, relative to `https://accounts.twilio.com`
|
||||
"""
|
||||
|
||||
def __init__(self, version: Version, payload: Dict[str, Any]):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.secondary_auth_token: Optional[str] = payload.get("secondary_auth_token")
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
|
||||
self._context: Optional[SecondaryAuthTokenContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "SecondaryAuthTokenContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: SecondaryAuthTokenContext for this SecondaryAuthTokenInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = SecondaryAuthTokenContext(
|
||||
self._version,
|
||||
)
|
||||
return self._context
|
||||
|
||||
def create(self) -> "SecondaryAuthTokenInstance":
|
||||
"""
|
||||
Create the SecondaryAuthTokenInstance
|
||||
|
||||
|
||||
:returns: The created SecondaryAuthTokenInstance
|
||||
"""
|
||||
return self._proxy.create()
|
||||
|
||||
async def create_async(self) -> "SecondaryAuthTokenInstance":
|
||||
"""
|
||||
Asynchronous coroutine to create the SecondaryAuthTokenInstance
|
||||
|
||||
|
||||
:returns: The created SecondaryAuthTokenInstance
|
||||
"""
|
||||
return await self._proxy.create_async()
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the SecondaryAuthTokenInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the SecondaryAuthTokenInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
|
||||
return "<Twilio.Accounts.V1.SecondaryAuthTokenInstance>"
|
||||
|
||||
|
||||
class SecondaryAuthTokenContext(InstanceContext):
|
||||
def __init__(self, version: Version):
|
||||
"""
|
||||
Initialize the SecondaryAuthTokenContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
self._uri = "/AuthTokens/Secondary"
|
||||
|
||||
def create(self) -> SecondaryAuthTokenInstance:
|
||||
"""
|
||||
Create the SecondaryAuthTokenInstance
|
||||
|
||||
|
||||
:returns: The created SecondaryAuthTokenInstance
|
||||
"""
|
||||
data = values.of({})
|
||||
|
||||
payload = self._version.create(method="POST", uri=self._uri, data=data)
|
||||
|
||||
return SecondaryAuthTokenInstance(self._version, payload)
|
||||
|
||||
async def create_async(self) -> SecondaryAuthTokenInstance:
|
||||
"""
|
||||
Asynchronous coroutine to create the SecondaryAuthTokenInstance
|
||||
|
||||
|
||||
:returns: The created SecondaryAuthTokenInstance
|
||||
"""
|
||||
data = values.of({})
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST", uri=self._uri, data=data
|
||||
)
|
||||
|
||||
return SecondaryAuthTokenInstance(self._version, payload)
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the SecondaryAuthTokenInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._version.delete(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the SecondaryAuthTokenInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
|
||||
return "<Twilio.Accounts.V1.SecondaryAuthTokenContext>"
|
||||
|
||||
|
||||
class SecondaryAuthTokenList(ListResource):
|
||||
def __init__(self, version: Version):
|
||||
"""
|
||||
Initialize the SecondaryAuthTokenList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
def get(self) -> SecondaryAuthTokenContext:
|
||||
"""
|
||||
Constructs a SecondaryAuthTokenContext
|
||||
|
||||
"""
|
||||
return SecondaryAuthTokenContext(self._version)
|
||||
|
||||
def __call__(self) -> SecondaryAuthTokenContext:
|
||||
"""
|
||||
Constructs a SecondaryAuthTokenContext
|
||||
|
||||
"""
|
||||
return SecondaryAuthTokenContext(self._version)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Accounts.V1.SecondaryAuthTokenList>"
|
||||
@@ -0,0 +1,43 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
from typing import Optional
|
||||
|
||||
from twilio.base.domain import Domain
|
||||
from twilio.rest import Client
|
||||
from twilio.rest.api.v2010 import V2010
|
||||
|
||||
|
||||
class ApiBase(Domain):
|
||||
def __init__(self, twilio: Client):
|
||||
"""
|
||||
Initialize the Api Domain
|
||||
|
||||
:returns: Domain for Api
|
||||
"""
|
||||
super().__init__(twilio, "https://api.twilio.com")
|
||||
self._v2010: Optional[V2010] = None
|
||||
|
||||
@property
|
||||
def v2010(self) -> V2010:
|
||||
"""
|
||||
:returns: Versions v2010 of Api
|
||||
"""
|
||||
if self._v2010 is None:
|
||||
self._v2010 = V2010(self)
|
||||
return self._v2010
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api>"
|
||||
@@ -0,0 +1,258 @@
|
||||
from warnings import warn
|
||||
|
||||
from twilio.rest.api.ApiBase import ApiBase
|
||||
from twilio.rest.api.v2010.account import AccountContext, AccountList
|
||||
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_country import (
|
||||
AvailablePhoneNumberCountryList,
|
||||
)
|
||||
from twilio.rest.api.v2010.account.balance import BalanceList
|
||||
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 Api(ApiBase):
|
||||
@property
|
||||
def account(self) -> AccountContext:
|
||||
return self.v2010.account
|
||||
|
||||
@property
|
||||
def accounts(self) -> AccountList:
|
||||
return self.v2010.accounts
|
||||
|
||||
@property
|
||||
def addresses(self) -> AddressList:
|
||||
warn(
|
||||
"addresses is deprecated. Use account.addresses instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.account.addresses
|
||||
|
||||
@property
|
||||
def applications(self) -> ApplicationList:
|
||||
warn(
|
||||
"applications is deprecated. Use account.applications instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.account.applications
|
||||
|
||||
@property
|
||||
def authorized_connect_apps(self) -> AuthorizedConnectAppList:
|
||||
warn(
|
||||
"authorized_connect_apps is deprecated. Use account.authorized_connect_apps instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.account.authorized_connect_apps
|
||||
|
||||
@property
|
||||
def available_phone_numbers(self) -> AvailablePhoneNumberCountryList:
|
||||
warn(
|
||||
"available_phone_numbers is deprecated. Use account.available_phone_numbers instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.account.available_phone_numbers
|
||||
|
||||
@property
|
||||
def balance(self) -> BalanceList:
|
||||
warn(
|
||||
"balance is deprecated. Use account.balance instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.account.balance
|
||||
|
||||
@property
|
||||
def calls(self) -> CallList:
|
||||
warn(
|
||||
"calls is deprecated. Use account.calls instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.account.calls
|
||||
|
||||
@property
|
||||
def conferences(self) -> ConferenceList:
|
||||
warn(
|
||||
"conferences is deprecated. Use account.conferences instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.account.conferences
|
||||
|
||||
@property
|
||||
def connect_apps(self) -> ConnectAppList:
|
||||
warn(
|
||||
"connect_apps is deprecated. Use account.connect_apps instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.account.connect_apps
|
||||
|
||||
@property
|
||||
def incoming_phone_numbers(self) -> IncomingPhoneNumberList:
|
||||
warn(
|
||||
"incoming_phone_numbers is deprecated. Use account.incoming_phone_numbers instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.account.incoming_phone_numbers
|
||||
|
||||
@property
|
||||
def keys(self) -> KeyList:
|
||||
warn(
|
||||
"keys is deprecated. Use account.keys instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.account.keys
|
||||
|
||||
@property
|
||||
def messages(self) -> MessageList:
|
||||
warn(
|
||||
"messages is deprecated. Use account.messages instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.account.messages
|
||||
|
||||
@property
|
||||
def new_keys(self) -> NewKeyList:
|
||||
warn(
|
||||
"new_keys is deprecated. Use account.new_keys instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.account.new_keys
|
||||
|
||||
@property
|
||||
def new_signing_keys(self) -> NewSigningKeyList:
|
||||
warn(
|
||||
"new_signing_keys is deprecated. Use account.new_signing_keys instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.account.new_signing_keys
|
||||
|
||||
@property
|
||||
def notifications(self) -> NotificationList:
|
||||
warn(
|
||||
"notifications is deprecated. Use account.notifications instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.account.notifications
|
||||
|
||||
@property
|
||||
def outgoing_caller_ids(self) -> OutgoingCallerIdList:
|
||||
warn(
|
||||
"outgoing_caller_ids is deprecated. Use account.outgoing_caller_ids instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.account.outgoing_caller_ids
|
||||
|
||||
@property
|
||||
def queues(self) -> QueueList:
|
||||
warn(
|
||||
"queues is deprecated. Use account.queues instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.account.queues
|
||||
|
||||
@property
|
||||
def recordings(self) -> RecordingList:
|
||||
warn(
|
||||
"recordings is deprecated. Use account.recordings instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.account.recordings
|
||||
|
||||
@property
|
||||
def signing_keys(self) -> SigningKeyList:
|
||||
warn(
|
||||
"signing_keys is deprecated. Use account.signing_keys instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.account.signing_keys
|
||||
|
||||
@property
|
||||
def sip(self) -> SipList:
|
||||
warn(
|
||||
"sip is deprecated. Use account.sip instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.account.sip
|
||||
|
||||
@property
|
||||
def short_codes(self) -> ShortCodeList:
|
||||
warn(
|
||||
"short_codes is deprecated. Use account.short_codes instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.account.short_codes
|
||||
|
||||
@property
|
||||
def tokens(self) -> TokenList:
|
||||
warn(
|
||||
"tokens is deprecated. Use account.tokens instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.account.tokens
|
||||
|
||||
@property
|
||||
def transcriptions(self) -> TranscriptionList:
|
||||
warn(
|
||||
"transcriptions is deprecated. Use account.transcriptions instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.account.transcriptions
|
||||
|
||||
@property
|
||||
def usage(self) -> UsageList:
|
||||
warn(
|
||||
"usage is deprecated. Use account.usage instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.account.usage
|
||||
|
||||
@property
|
||||
def validation_requests(self) -> ValidationRequestList:
|
||||
warn(
|
||||
"validation_requests is deprecated. Use account.validation_requests instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.account.validation_requests
|
||||
Binary file not shown.
BIN
Binary file not shown.
@@ -0,0 +1,58 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
from typing import Optional
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.domain import Domain
|
||||
from twilio.rest.api.v2010.account import AccountList
|
||||
from twilio.rest.api.v2010.account import AccountContext
|
||||
|
||||
|
||||
class V2010(Version):
|
||||
def __init__(self, domain: Domain):
|
||||
"""
|
||||
Initialize the V2010 version of Api
|
||||
|
||||
:param domain: The Twilio.api domain
|
||||
"""
|
||||
super().__init__(domain, "2010-04-01")
|
||||
self._accounts: Optional[AccountList] = None
|
||||
self._account: Optional[AccountContext] = None
|
||||
|
||||
@property
|
||||
def accounts(self) -> AccountList:
|
||||
if self._accounts is None:
|
||||
self._accounts = AccountList(self)
|
||||
return self._accounts
|
||||
|
||||
@property
|
||||
def account(self) -> AccountContext:
|
||||
if self._account is None:
|
||||
self._account = AccountContext(self, self.domain.twilio.account_sid)
|
||||
return self._account
|
||||
|
||||
@account.setter
|
||||
def account(self, value: AccountContext) -> None:
|
||||
"""
|
||||
Setter to override account
|
||||
:param value: value to use as account
|
||||
"""
|
||||
self._account = value
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010>"
|
||||
BIN
Binary file not shown.
File diff suppressed because it is too large
Load Diff
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -0,0 +1,862 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, values
|
||||
from twilio.base.instance_context import InstanceContext
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.page import Page
|
||||
from twilio.rest.api.v2010.account.address.dependent_phone_number import (
|
||||
DependentPhoneNumberList,
|
||||
)
|
||||
|
||||
|
||||
class AddressInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that is responsible for the Address resource.
|
||||
:ivar city: The city in which the address is located.
|
||||
:ivar customer_name: The name associated with the address.This property has a maximum length of 16 4-byte characters, or 21 3-byte characters.
|
||||
:ivar date_created: The date and time in GMT that the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar date_updated: The date and time in GMT that the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar friendly_name: The string that you assigned to describe the resource.
|
||||
:ivar iso_country: The ISO country code of the address.
|
||||
:ivar postal_code: The postal code of the address.
|
||||
:ivar region: The state or region of the address.
|
||||
:ivar sid: The unique string that that we created to identify the Address resource.
|
||||
:ivar street: The number and street address of the address.
|
||||
:ivar uri: The URI of the resource, relative to `https://api.twilio.com`.
|
||||
:ivar emergency_enabled: Whether emergency calling has been enabled on this number.
|
||||
:ivar validated: Whether the address has been validated to comply with local regulation. In countries that require valid addresses, an invalid address will not be accepted. `true` indicates the Address has been validated. `false` indicate the country doesn't require validation or the Address is not valid.
|
||||
:ivar verified: Whether the address has been verified to comply with regulation. In countries that require valid addresses, an invalid address will not be accepted. `true` indicates the Address has been verified. `false` indicate the country doesn't require verified or the Address is not valid.
|
||||
:ivar street_secondary: The additional number and street address of the address.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
account_sid: str,
|
||||
sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.city: Optional[str] = payload.get("city")
|
||||
self.customer_name: Optional[str] = payload.get("customer_name")
|
||||
self.date_created: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.friendly_name: Optional[str] = payload.get("friendly_name")
|
||||
self.iso_country: Optional[str] = payload.get("iso_country")
|
||||
self.postal_code: Optional[str] = payload.get("postal_code")
|
||||
self.region: Optional[str] = payload.get("region")
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.street: Optional[str] = payload.get("street")
|
||||
self.uri: Optional[str] = payload.get("uri")
|
||||
self.emergency_enabled: Optional[bool] = payload.get("emergency_enabled")
|
||||
self.validated: Optional[bool] = payload.get("validated")
|
||||
self.verified: Optional[bool] = payload.get("verified")
|
||||
self.street_secondary: Optional[str] = payload.get("street_secondary")
|
||||
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[AddressContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "AddressContext":
|
||||
"""
|
||||
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
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = AddressContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the AddressInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the AddressInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
def fetch(self) -> "AddressInstance":
|
||||
"""
|
||||
Fetch the AddressInstance
|
||||
|
||||
|
||||
:returns: The fetched AddressInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "AddressInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the AddressInstance
|
||||
|
||||
|
||||
:returns: The fetched AddressInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
customer_name: Union[str, object] = values.unset,
|
||||
street: Union[str, object] = values.unset,
|
||||
city: Union[str, object] = values.unset,
|
||||
region: Union[str, object] = values.unset,
|
||||
postal_code: Union[str, object] = values.unset,
|
||||
emergency_enabled: Union[bool, object] = values.unset,
|
||||
auto_correct_address: Union[bool, object] = values.unset,
|
||||
street_secondary: Union[str, object] = values.unset,
|
||||
) -> "AddressInstance":
|
||||
"""
|
||||
Update the AddressInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the address. It can be up to 64 characters long.
|
||||
:param customer_name: The name to associate with the address.
|
||||
:param street: The number and street address of the address.
|
||||
:param city: The city of the address.
|
||||
:param region: The state or region of the address.
|
||||
:param postal_code: The postal code of the address.
|
||||
:param emergency_enabled: Whether to enable emergency calling on the address. Can be: `true` or `false`.
|
||||
:param auto_correct_address: Whether we should automatically correct the address. Can be: `true` or `false` and the default is `true`. If empty or `true`, we will correct the address you provide if necessary. If `false`, we won't alter the address you provide.
|
||||
:param street_secondary: The additional number and street address of the address.
|
||||
|
||||
:returns: The updated 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,
|
||||
street_secondary=street_secondary,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
customer_name: Union[str, object] = values.unset,
|
||||
street: Union[str, object] = values.unset,
|
||||
city: Union[str, object] = values.unset,
|
||||
region: Union[str, object] = values.unset,
|
||||
postal_code: Union[str, object] = values.unset,
|
||||
emergency_enabled: Union[bool, object] = values.unset,
|
||||
auto_correct_address: Union[bool, object] = values.unset,
|
||||
street_secondary: Union[str, object] = values.unset,
|
||||
) -> "AddressInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the AddressInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the address. It can be up to 64 characters long.
|
||||
:param customer_name: The name to associate with the address.
|
||||
:param street: The number and street address of the address.
|
||||
:param city: The city of the address.
|
||||
:param region: The state or region of the address.
|
||||
:param postal_code: The postal code of the address.
|
||||
:param emergency_enabled: Whether to enable emergency calling on the address. Can be: `true` or `false`.
|
||||
:param auto_correct_address: Whether we should automatically correct the address. Can be: `true` or `false` and the default is `true`. If empty or `true`, we will correct the address you provide if necessary. If `false`, we won't alter the address you provide.
|
||||
:param street_secondary: The additional number and street address of the address.
|
||||
|
||||
:returns: The updated AddressInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
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,
|
||||
street_secondary=street_secondary,
|
||||
)
|
||||
|
||||
@property
|
||||
def dependent_phone_numbers(self) -> DependentPhoneNumberList:
|
||||
"""
|
||||
Access the dependent_phone_numbers
|
||||
"""
|
||||
return self._proxy.dependent_phone_numbers
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.AddressInstance {}>".format(context)
|
||||
|
||||
|
||||
class AddressContext(InstanceContext):
|
||||
def __init__(self, version: Version, account_sid: str, sid: str):
|
||||
"""
|
||||
Initialize the AddressContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that is responsible for the Address resource to update.
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Address resource to update.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/Addresses/{sid}.json".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
self._dependent_phone_numbers: Optional[DependentPhoneNumberList] = None
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the AddressInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._version.delete(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the AddressInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
def fetch(self) -> AddressInstance:
|
||||
"""
|
||||
Fetch the AddressInstance
|
||||
|
||||
|
||||
:returns: The fetched AddressInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return AddressInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> AddressInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the AddressInstance
|
||||
|
||||
|
||||
:returns: The fetched AddressInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return AddressInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
customer_name: Union[str, object] = values.unset,
|
||||
street: Union[str, object] = values.unset,
|
||||
city: Union[str, object] = values.unset,
|
||||
region: Union[str, object] = values.unset,
|
||||
postal_code: Union[str, object] = values.unset,
|
||||
emergency_enabled: Union[bool, object] = values.unset,
|
||||
auto_correct_address: Union[bool, object] = values.unset,
|
||||
street_secondary: Union[str, object] = values.unset,
|
||||
) -> AddressInstance:
|
||||
"""
|
||||
Update the AddressInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the address. It can be up to 64 characters long.
|
||||
:param customer_name: The name to associate with the address.
|
||||
:param street: The number and street address of the address.
|
||||
:param city: The city of the address.
|
||||
:param region: The state or region of the address.
|
||||
:param postal_code: The postal code of the address.
|
||||
:param emergency_enabled: Whether to enable emergency calling on the address. Can be: `true` or `false`.
|
||||
:param auto_correct_address: Whether we should automatically correct the address. Can be: `true` or `false` and the default is `true`. If empty or `true`, we will correct the address you provide if necessary. If `false`, we won't alter the address you provide.
|
||||
:param street_secondary: The additional number and street address of the address.
|
||||
|
||||
:returns: The updated 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,
|
||||
"StreetSecondary": street_secondary,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return AddressInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
customer_name: Union[str, object] = values.unset,
|
||||
street: Union[str, object] = values.unset,
|
||||
city: Union[str, object] = values.unset,
|
||||
region: Union[str, object] = values.unset,
|
||||
postal_code: Union[str, object] = values.unset,
|
||||
emergency_enabled: Union[bool, object] = values.unset,
|
||||
auto_correct_address: Union[bool, object] = values.unset,
|
||||
street_secondary: Union[str, object] = values.unset,
|
||||
) -> AddressInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the AddressInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the address. It can be up to 64 characters long.
|
||||
:param customer_name: The name to associate with the address.
|
||||
:param street: The number and street address of the address.
|
||||
:param city: The city of the address.
|
||||
:param region: The state or region of the address.
|
||||
:param postal_code: The postal code of the address.
|
||||
:param emergency_enabled: Whether to enable emergency calling on the address. Can be: `true` or `false`.
|
||||
:param auto_correct_address: Whether we should automatically correct the address. Can be: `true` or `false` and the default is `true`. If empty or `true`, we will correct the address you provide if necessary. If `false`, we won't alter the address you provide.
|
||||
:param street_secondary: The additional number and street address of the address.
|
||||
|
||||
:returns: The updated 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,
|
||||
"StreetSecondary": street_secondary,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=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) -> DependentPhoneNumberList:
|
||||
"""
|
||||
Access the dependent_phone_numbers
|
||||
"""
|
||||
if self._dependent_phone_numbers is None:
|
||||
self._dependent_phone_numbers = DependentPhoneNumberList(
|
||||
self._version,
|
||||
self._solution["account_sid"],
|
||||
self._solution["sid"],
|
||||
)
|
||||
return self._dependent_phone_numbers
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.AddressContext {}>".format(context)
|
||||
|
||||
|
||||
class AddressPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> AddressInstance:
|
||||
"""
|
||||
Build an instance of AddressInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return AddressInstance(
|
||||
self._version, payload, account_sid=self._solution["account_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.AddressPage>"
|
||||
|
||||
|
||||
class AddressList(ListResource):
|
||||
def __init__(self, version: Version, account_sid: str):
|
||||
"""
|
||||
Initialize the AddressList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that is responsible for the Address resource to read.
|
||||
|
||||
"""
|
||||
super().__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: str,
|
||||
street: str,
|
||||
city: str,
|
||||
region: str,
|
||||
postal_code: str,
|
||||
iso_country: str,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
emergency_enabled: Union[bool, object] = values.unset,
|
||||
auto_correct_address: Union[bool, object] = values.unset,
|
||||
street_secondary: Union[str, object] = values.unset,
|
||||
) -> AddressInstance:
|
||||
"""
|
||||
Create the AddressInstance
|
||||
|
||||
:param customer_name: The name to associate with the new address.
|
||||
:param street: The number and street address of the new address.
|
||||
:param city: The city of the new address.
|
||||
:param region: The state or region of the new address.
|
||||
:param postal_code: The postal code of the new address.
|
||||
:param iso_country: The ISO country code of the new address.
|
||||
:param friendly_name: A descriptive string that you create to describe the new address. It can be up to 64 characters long.
|
||||
:param emergency_enabled: Whether to enable emergency calling on the new address. Can be: `true` or `false`.
|
||||
:param auto_correct_address: Whether we should automatically correct the address. Can be: `true` or `false` and the default is `true`. If empty or `true`, we will correct the address you provide if necessary. If `false`, we won't alter the address you provide.
|
||||
:param street_secondary: The additional number and street address of the address.
|
||||
|
||||
:returns: The created 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,
|
||||
"StreetSecondary": street_secondary,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return AddressInstance(
|
||||
self._version, payload, account_sid=self._solution["account_sid"]
|
||||
)
|
||||
|
||||
async def create_async(
|
||||
self,
|
||||
customer_name: str,
|
||||
street: str,
|
||||
city: str,
|
||||
region: str,
|
||||
postal_code: str,
|
||||
iso_country: str,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
emergency_enabled: Union[bool, object] = values.unset,
|
||||
auto_correct_address: Union[bool, object] = values.unset,
|
||||
street_secondary: Union[str, object] = values.unset,
|
||||
) -> AddressInstance:
|
||||
"""
|
||||
Asynchronously create the AddressInstance
|
||||
|
||||
:param customer_name: The name to associate with the new address.
|
||||
:param street: The number and street address of the new address.
|
||||
:param city: The city of the new address.
|
||||
:param region: The state or region of the new address.
|
||||
:param postal_code: The postal code of the new address.
|
||||
:param iso_country: The ISO country code of the new address.
|
||||
:param friendly_name: A descriptive string that you create to describe the new address. It can be up to 64 characters long.
|
||||
:param emergency_enabled: Whether to enable emergency calling on the new address. Can be: `true` or `false`.
|
||||
:param auto_correct_address: Whether we should automatically correct the address. Can be: `true` or `false` and the default is `true`. If empty or `true`, we will correct the address you provide if necessary. If `false`, we won't alter the address you provide.
|
||||
:param street_secondary: The additional number and street address of the address.
|
||||
|
||||
:returns: The created 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,
|
||||
"StreetSecondary": street_secondary,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return AddressInstance(
|
||||
self._version, payload, account_sid=self._solution["account_sid"]
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
customer_name: Union[str, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
iso_country: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[AddressInstance]:
|
||||
"""
|
||||
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 str customer_name: The `customer_name` of the Address resources to read.
|
||||
:param str friendly_name: The string that identifies the Address resources to read.
|
||||
:param str iso_country: The ISO country code of the Address resources to read.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(
|
||||
customer_name=customer_name,
|
||||
friendly_name=friendly_name,
|
||||
iso_country=iso_country,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
customer_name: Union[str, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
iso_country: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[AddressInstance]:
|
||||
"""
|
||||
Asynchronously 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 str customer_name: The `customer_name` of the Address resources to read.
|
||||
:param str friendly_name: The string that identifies the Address resources to read.
|
||||
:param str iso_country: The ISO country code of the Address resources to read.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(
|
||||
customer_name=customer_name,
|
||||
friendly_name=friendly_name,
|
||||
iso_country=iso_country,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
customer_name: Union[str, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
iso_country: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[AddressInstance]:
|
||||
"""
|
||||
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 str customer_name: The `customer_name` of the Address resources to read.
|
||||
:param str friendly_name: The string that identifies the Address resources to read.
|
||||
:param str iso_country: The ISO country code of the Address resources to read.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return list(
|
||||
self.stream(
|
||||
customer_name=customer_name,
|
||||
friendly_name=friendly_name,
|
||||
iso_country=iso_country,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
customer_name: Union[str, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
iso_country: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[AddressInstance]:
|
||||
"""
|
||||
Asynchronously 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 str customer_name: The `customer_name` of the Address resources to read.
|
||||
:param str friendly_name: The string that identifies the Address resources to read.
|
||||
:param str iso_country: The ISO country code of the Address resources to read.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return [
|
||||
record
|
||||
async for record in await self.stream_async(
|
||||
customer_name=customer_name,
|
||||
friendly_name=friendly_name,
|
||||
iso_country=iso_country,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
customer_name: Union[str, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
iso_country: Union[str, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> AddressPage:
|
||||
"""
|
||||
Retrieve a single page of AddressInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param customer_name: The `customer_name` of the Address resources to read.
|
||||
:param friendly_name: The string that identifies the Address resources to read.
|
||||
:param iso_country: The ISO country code of the Address resources to read.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of AddressInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"CustomerName": customer_name,
|
||||
"FriendlyName": friendly_name,
|
||||
"IsoCountry": iso_country,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return AddressPage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
customer_name: Union[str, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
iso_country: Union[str, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> AddressPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of AddressInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param customer_name: The `customer_name` of the Address resources to read.
|
||||
:param friendly_name: The string that identifies the Address resources to read.
|
||||
:param iso_country: The ISO country code of the Address resources to read.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of AddressInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"CustomerName": customer_name,
|
||||
"FriendlyName": friendly_name,
|
||||
"IsoCountry": iso_country,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return AddressPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> AddressPage:
|
||||
"""
|
||||
Retrieve a specific page of AddressInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of AddressInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return AddressPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> AddressPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of AddressInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of AddressInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return AddressPage(self._version, response, self._solution)
|
||||
|
||||
def get(self, sid: str) -> AddressContext:
|
||||
"""
|
||||
Constructs a AddressContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Address resource to update.
|
||||
"""
|
||||
return AddressContext(
|
||||
self._version, account_sid=self._solution["account_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> AddressContext:
|
||||
"""
|
||||
Constructs a AddressContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Address resource to update.
|
||||
"""
|
||||
return AddressContext(
|
||||
self._version, account_sid=self._solution["account_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.AddressList>"
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
+362
@@ -0,0 +1,362 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, values
|
||||
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.page import Page
|
||||
|
||||
|
||||
class DependentPhoneNumberInstance(InstanceResource):
|
||||
class AddressRequirement(object):
|
||||
NONE = "none"
|
||||
ANY = "any"
|
||||
LOCAL = "local"
|
||||
FOREIGN = "foreign"
|
||||
|
||||
class EmergencyStatus(object):
|
||||
ACTIVE = "Active"
|
||||
INACTIVE = "Inactive"
|
||||
|
||||
"""
|
||||
:ivar sid: The unique string that that we created to identify the DependentPhoneNumber resource.
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the DependentPhoneNumber resource.
|
||||
:ivar friendly_name: The string that you assigned to describe the resource.
|
||||
:ivar phone_number: The phone number in [E.164](https://www.twilio.com/docs/glossary/what-e164) format, which consists of a + followed by the country code and subscriber number.
|
||||
:ivar voice_url: The URL we call when the phone number receives a call. The `voice_url` will not be used if a `voice_application_sid` or a `trunk_sid` is set.
|
||||
:ivar voice_method: The HTTP method we use to call `voice_url`. Can be: `GET` or `POST`.
|
||||
:ivar voice_fallback_method: The HTTP method we use to call `voice_fallback_url`. Can be: `GET` or `POST`.
|
||||
:ivar voice_fallback_url: The URL that we call when an error occurs retrieving or executing the TwiML requested by `url`.
|
||||
:ivar voice_caller_id_lookup: Whether we look up the caller's caller-ID name from the CNAM database. Can be: `true` or `false`. Caller ID lookups can cost $0.01 each.
|
||||
:ivar date_created: The date and time in GMT that the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar date_updated: The date and time in GMT that the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar sms_fallback_method: The HTTP method we use to call `sms_fallback_url`. Can be: `GET` or `POST`.
|
||||
:ivar sms_fallback_url: The URL that we call when an error occurs while retrieving or executing the TwiML from `sms_url`.
|
||||
:ivar sms_method: The HTTP method we use to call `sms_url`. Can be: `GET` or `POST`.
|
||||
:ivar sms_url: The URL we call when the phone number receives an incoming SMS message.
|
||||
:ivar address_requirements:
|
||||
:ivar capabilities: The set of Boolean properties that indicates whether a phone number can receive calls or messages. Capabilities are `Voice`, `SMS`, and `MMS` and each capability can be: `true` or `false`.
|
||||
:ivar status_callback: The URL we call using the `status_callback_method` to send status information to your application.
|
||||
:ivar status_callback_method: The HTTP method we use to call `status_callback`. Can be: `GET` or `POST`.
|
||||
:ivar api_version: The API version used to start a new TwiML session.
|
||||
:ivar sms_application_sid: The SID of the application that handles SMS messages sent to the phone number. If an `sms_application_sid` is present, we ignore all `sms_*_url` values and use those of the application.
|
||||
:ivar voice_application_sid: The SID of the application that handles calls to the phone number. If a `voice_application_sid` is present, we ignore all of the voice urls and use those set on the application. Setting a `voice_application_sid` will automatically delete your `trunk_sid` and vice versa.
|
||||
:ivar trunk_sid: The SID of the Trunk that handles calls to the phone number. If a `trunk_sid` is present, we ignore all of the voice urls and voice applications and use those set on the Trunk. Setting a `trunk_sid` will automatically delete your `voice_application_sid` and vice versa.
|
||||
:ivar emergency_status:
|
||||
:ivar emergency_address_sid: The SID of the emergency address configuration that we use for emergency calling from the phone number.
|
||||
:ivar uri: The URI of the resource, relative to `https://api.twilio.com`.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
account_sid: str,
|
||||
address_sid: str,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.friendly_name: Optional[str] = payload.get("friendly_name")
|
||||
self.phone_number: Optional[str] = payload.get("phone_number")
|
||||
self.voice_url: Optional[str] = payload.get("voice_url")
|
||||
self.voice_method: Optional[str] = payload.get("voice_method")
|
||||
self.voice_fallback_method: Optional[str] = payload.get("voice_fallback_method")
|
||||
self.voice_fallback_url: Optional[str] = payload.get("voice_fallback_url")
|
||||
self.voice_caller_id_lookup: Optional[bool] = payload.get(
|
||||
"voice_caller_id_lookup"
|
||||
)
|
||||
self.date_created: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.sms_fallback_method: Optional[str] = payload.get("sms_fallback_method")
|
||||
self.sms_fallback_url: Optional[str] = payload.get("sms_fallback_url")
|
||||
self.sms_method: Optional[str] = payload.get("sms_method")
|
||||
self.sms_url: Optional[str] = payload.get("sms_url")
|
||||
self.address_requirements: Optional[
|
||||
"DependentPhoneNumberInstance.AddressRequirement"
|
||||
] = payload.get("address_requirements")
|
||||
self.capabilities: Optional[Dict[str, object]] = payload.get("capabilities")
|
||||
self.status_callback: Optional[str] = payload.get("status_callback")
|
||||
self.status_callback_method: Optional[str] = payload.get(
|
||||
"status_callback_method"
|
||||
)
|
||||
self.api_version: Optional[str] = payload.get("api_version")
|
||||
self.sms_application_sid: Optional[str] = payload.get("sms_application_sid")
|
||||
self.voice_application_sid: Optional[str] = payload.get("voice_application_sid")
|
||||
self.trunk_sid: Optional[str] = payload.get("trunk_sid")
|
||||
self.emergency_status: Optional[
|
||||
"DependentPhoneNumberInstance.EmergencyStatus"
|
||||
] = payload.get("emergency_status")
|
||||
self.emergency_address_sid: Optional[str] = payload.get("emergency_address_sid")
|
||||
self.uri: Optional[str] = payload.get("uri")
|
||||
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"address_sid": address_sid,
|
||||
}
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.DependentPhoneNumberInstance {}>".format(context)
|
||||
|
||||
|
||||
class DependentPhoneNumberPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> DependentPhoneNumberInstance:
|
||||
"""
|
||||
Build an instance of DependentPhoneNumberInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return DependentPhoneNumberInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
address_sid=self._solution["address_sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.DependentPhoneNumberPage>"
|
||||
|
||||
|
||||
class DependentPhoneNumberList(ListResource):
|
||||
def __init__(self, version: Version, account_sid: str, address_sid: str):
|
||||
"""
|
||||
Initialize the DependentPhoneNumberList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the DependentPhoneNumber resources to read.
|
||||
:param address_sid: The SID of the Address resource associated with the phone number.
|
||||
|
||||
"""
|
||||
super().__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: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[DependentPhoneNumberInstance]:
|
||||
"""
|
||||
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 limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[DependentPhoneNumberInstance]:
|
||||
"""
|
||||
Asynchronously 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 limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[DependentPhoneNumberInstance]:
|
||||
"""
|
||||
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 limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return list(
|
||||
self.stream(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[DependentPhoneNumberInstance]:
|
||||
"""
|
||||
Asynchronously 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 limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return [
|
||||
record
|
||||
async for record in await self.stream_async(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> DependentPhoneNumberPage:
|
||||
"""
|
||||
Retrieve a single page of DependentPhoneNumberInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of DependentPhoneNumberInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return DependentPhoneNumberPage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> DependentPhoneNumberPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of DependentPhoneNumberInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of DependentPhoneNumberInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return DependentPhoneNumberPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> DependentPhoneNumberPage:
|
||||
"""
|
||||
Retrieve a specific page of DependentPhoneNumberInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of DependentPhoneNumberInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return DependentPhoneNumberPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> DependentPhoneNumberPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of DependentPhoneNumberInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of DependentPhoneNumberInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return DependentPhoneNumberPage(self._version, response, self._solution)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.DependentPhoneNumberList>"
|
||||
@@ -0,0 +1,935 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, values
|
||||
from twilio.base.instance_context import InstanceContext
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.page import Page
|
||||
|
||||
|
||||
class ApplicationInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Application resource.
|
||||
:ivar api_version: The API version used to start a new TwiML session.
|
||||
:ivar date_created: The date and time in GMT that the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar date_updated: The date and time in GMT that the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar friendly_name: The string that you assigned to describe the resource.
|
||||
:ivar message_status_callback: The URL we call using a POST method to send message status information to your application.
|
||||
:ivar sid: The unique string that that we created to identify the Application resource.
|
||||
:ivar sms_fallback_method: The HTTP method we use to call `sms_fallback_url`. Can be: `GET` or `POST`.
|
||||
:ivar sms_fallback_url: The URL that we call when an error occurs while retrieving or executing the TwiML from `sms_url`.
|
||||
:ivar sms_method: The HTTP method we use to call `sms_url`. Can be: `GET` or `POST`.
|
||||
:ivar sms_status_callback: The URL we call using a POST method to send status information to your application about SMS messages that refer to the application.
|
||||
:ivar sms_url: The URL we call when the phone number receives an incoming SMS message.
|
||||
:ivar status_callback: The URL we call using the `status_callback_method` to send status information to your application.
|
||||
:ivar status_callback_method: The HTTP method we use to call `status_callback`. Can be: `GET` or `POST`.
|
||||
:ivar uri: The URI of the resource, relative to `https://api.twilio.com`.
|
||||
:ivar voice_caller_id_lookup: Whether we look up the caller's caller-ID name from the CNAM database (additional charges apply). Can be: `true` or `false`.
|
||||
:ivar voice_fallback_method: The HTTP method we use to call `voice_fallback_url`. Can be: `GET` or `POST`.
|
||||
:ivar voice_fallback_url: The URL that we call when an error occurs retrieving or executing the TwiML requested by `url`.
|
||||
:ivar voice_method: The HTTP method we use to call `voice_url`. Can be: `GET` or `POST`.
|
||||
:ivar voice_url: The URL we call when the phone number assigned to this application receives a call.
|
||||
:ivar public_application_connect_enabled: Whether to allow other Twilio accounts to dial this applicaton using Dial verb. Can be: `true` or `false`.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
account_sid: str,
|
||||
sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.api_version: Optional[str] = payload.get("api_version")
|
||||
self.date_created: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.friendly_name: Optional[str] = payload.get("friendly_name")
|
||||
self.message_status_callback: Optional[str] = payload.get(
|
||||
"message_status_callback"
|
||||
)
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.sms_fallback_method: Optional[str] = payload.get("sms_fallback_method")
|
||||
self.sms_fallback_url: Optional[str] = payload.get("sms_fallback_url")
|
||||
self.sms_method: Optional[str] = payload.get("sms_method")
|
||||
self.sms_status_callback: Optional[str] = payload.get("sms_status_callback")
|
||||
self.sms_url: Optional[str] = payload.get("sms_url")
|
||||
self.status_callback: Optional[str] = payload.get("status_callback")
|
||||
self.status_callback_method: Optional[str] = payload.get(
|
||||
"status_callback_method"
|
||||
)
|
||||
self.uri: Optional[str] = payload.get("uri")
|
||||
self.voice_caller_id_lookup: Optional[bool] = payload.get(
|
||||
"voice_caller_id_lookup"
|
||||
)
|
||||
self.voice_fallback_method: Optional[str] = payload.get("voice_fallback_method")
|
||||
self.voice_fallback_url: Optional[str] = payload.get("voice_fallback_url")
|
||||
self.voice_method: Optional[str] = payload.get("voice_method")
|
||||
self.voice_url: Optional[str] = payload.get("voice_url")
|
||||
self.public_application_connect_enabled: Optional[bool] = payload.get(
|
||||
"public_application_connect_enabled"
|
||||
)
|
||||
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[ApplicationContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "ApplicationContext":
|
||||
"""
|
||||
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
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = ApplicationContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the ApplicationInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the ApplicationInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
def fetch(self) -> "ApplicationInstance":
|
||||
"""
|
||||
Fetch the ApplicationInstance
|
||||
|
||||
|
||||
:returns: The fetched ApplicationInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "ApplicationInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the ApplicationInstance
|
||||
|
||||
|
||||
:returns: The fetched ApplicationInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
api_version: Union[str, object] = values.unset,
|
||||
voice_url: Union[str, object] = values.unset,
|
||||
voice_method: Union[str, object] = values.unset,
|
||||
voice_fallback_url: Union[str, object] = values.unset,
|
||||
voice_fallback_method: Union[str, object] = values.unset,
|
||||
status_callback: Union[str, object] = values.unset,
|
||||
status_callback_method: Union[str, object] = values.unset,
|
||||
voice_caller_id_lookup: Union[bool, object] = values.unset,
|
||||
sms_url: Union[str, object] = values.unset,
|
||||
sms_method: Union[str, object] = values.unset,
|
||||
sms_fallback_url: Union[str, object] = values.unset,
|
||||
sms_fallback_method: Union[str, object] = values.unset,
|
||||
sms_status_callback: Union[str, object] = values.unset,
|
||||
message_status_callback: Union[str, object] = values.unset,
|
||||
public_application_connect_enabled: Union[bool, object] = values.unset,
|
||||
) -> "ApplicationInstance":
|
||||
"""
|
||||
Update the ApplicationInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long.
|
||||
:param api_version: The API version to use to start a new TwiML session. Can be: `2010-04-01` or `2008-08-01`. The default value is your account's default API version.
|
||||
:param voice_url: The URL we should call when the phone number assigned to this application receives a call.
|
||||
:param voice_method: The HTTP method we should use to call `voice_url`. Can be: `GET` or `POST`.
|
||||
:param voice_fallback_url: The URL that we should call when an error occurs retrieving or executing the TwiML requested by `url`.
|
||||
:param voice_fallback_method: The HTTP method we should use to call `voice_fallback_url`. Can be: `GET` or `POST`.
|
||||
:param status_callback: The URL we should call using the `status_callback_method` to send status information to your application.
|
||||
:param status_callback_method: The HTTP method we should use to call `status_callback`. Can be: `GET` or `POST`.
|
||||
:param voice_caller_id_lookup: Whether we should look up the caller's caller-ID name from the CNAM database (additional charges apply). Can be: `true` or `false`.
|
||||
:param sms_url: The URL we should call when the phone number receives an incoming SMS message.
|
||||
:param sms_method: The HTTP method we should use to call `sms_url`. Can be: `GET` or `POST`.
|
||||
:param sms_fallback_url: The URL that we should call when an error occurs while retrieving or executing the TwiML from `sms_url`.
|
||||
:param sms_fallback_method: The HTTP method we should use to call `sms_fallback_url`. Can be: `GET` or `POST`.
|
||||
:param sms_status_callback: Same as message_status_callback: The URL we should call using a POST method to send status information about SMS messages sent by the application. Deprecated, included for backwards compatibility.
|
||||
:param message_status_callback: The URL we should call using a POST method to send message status information to your application.
|
||||
:param public_application_connect_enabled: Whether to allow other Twilio accounts to dial this applicaton using Dial verb. Can be: `true` or `false`.
|
||||
|
||||
:returns: The updated 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,
|
||||
public_application_connect_enabled=public_application_connect_enabled,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
api_version: Union[str, object] = values.unset,
|
||||
voice_url: Union[str, object] = values.unset,
|
||||
voice_method: Union[str, object] = values.unset,
|
||||
voice_fallback_url: Union[str, object] = values.unset,
|
||||
voice_fallback_method: Union[str, object] = values.unset,
|
||||
status_callback: Union[str, object] = values.unset,
|
||||
status_callback_method: Union[str, object] = values.unset,
|
||||
voice_caller_id_lookup: Union[bool, object] = values.unset,
|
||||
sms_url: Union[str, object] = values.unset,
|
||||
sms_method: Union[str, object] = values.unset,
|
||||
sms_fallback_url: Union[str, object] = values.unset,
|
||||
sms_fallback_method: Union[str, object] = values.unset,
|
||||
sms_status_callback: Union[str, object] = values.unset,
|
||||
message_status_callback: Union[str, object] = values.unset,
|
||||
public_application_connect_enabled: Union[bool, object] = values.unset,
|
||||
) -> "ApplicationInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the ApplicationInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long.
|
||||
:param api_version: The API version to use to start a new TwiML session. Can be: `2010-04-01` or `2008-08-01`. The default value is your account's default API version.
|
||||
:param voice_url: The URL we should call when the phone number assigned to this application receives a call.
|
||||
:param voice_method: The HTTP method we should use to call `voice_url`. Can be: `GET` or `POST`.
|
||||
:param voice_fallback_url: The URL that we should call when an error occurs retrieving or executing the TwiML requested by `url`.
|
||||
:param voice_fallback_method: The HTTP method we should use to call `voice_fallback_url`. Can be: `GET` or `POST`.
|
||||
:param status_callback: The URL we should call using the `status_callback_method` to send status information to your application.
|
||||
:param status_callback_method: The HTTP method we should use to call `status_callback`. Can be: `GET` or `POST`.
|
||||
:param voice_caller_id_lookup: Whether we should look up the caller's caller-ID name from the CNAM database (additional charges apply). Can be: `true` or `false`.
|
||||
:param sms_url: The URL we should call when the phone number receives an incoming SMS message.
|
||||
:param sms_method: The HTTP method we should use to call `sms_url`. Can be: `GET` or `POST`.
|
||||
:param sms_fallback_url: The URL that we should call when an error occurs while retrieving or executing the TwiML from `sms_url`.
|
||||
:param sms_fallback_method: The HTTP method we should use to call `sms_fallback_url`. Can be: `GET` or `POST`.
|
||||
:param sms_status_callback: Same as message_status_callback: The URL we should call using a POST method to send status information about SMS messages sent by the application. Deprecated, included for backwards compatibility.
|
||||
:param message_status_callback: The URL we should call using a POST method to send message status information to your application.
|
||||
:param public_application_connect_enabled: Whether to allow other Twilio accounts to dial this applicaton using Dial verb. Can be: `true` or `false`.
|
||||
|
||||
:returns: The updated ApplicationInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
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,
|
||||
public_application_connect_enabled=public_application_connect_enabled,
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.ApplicationInstance {}>".format(context)
|
||||
|
||||
|
||||
class ApplicationContext(InstanceContext):
|
||||
def __init__(self, version: Version, account_sid: str, sid: str):
|
||||
"""
|
||||
Initialize the ApplicationContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Application resources to update.
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Application resource to update.
|
||||
"""
|
||||
super().__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) -> bool:
|
||||
"""
|
||||
Deletes the ApplicationInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._version.delete(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the ApplicationInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
def fetch(self) -> ApplicationInstance:
|
||||
"""
|
||||
Fetch the ApplicationInstance
|
||||
|
||||
|
||||
:returns: The fetched ApplicationInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return ApplicationInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> ApplicationInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the ApplicationInstance
|
||||
|
||||
|
||||
:returns: The fetched ApplicationInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return ApplicationInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
api_version: Union[str, object] = values.unset,
|
||||
voice_url: Union[str, object] = values.unset,
|
||||
voice_method: Union[str, object] = values.unset,
|
||||
voice_fallback_url: Union[str, object] = values.unset,
|
||||
voice_fallback_method: Union[str, object] = values.unset,
|
||||
status_callback: Union[str, object] = values.unset,
|
||||
status_callback_method: Union[str, object] = values.unset,
|
||||
voice_caller_id_lookup: Union[bool, object] = values.unset,
|
||||
sms_url: Union[str, object] = values.unset,
|
||||
sms_method: Union[str, object] = values.unset,
|
||||
sms_fallback_url: Union[str, object] = values.unset,
|
||||
sms_fallback_method: Union[str, object] = values.unset,
|
||||
sms_status_callback: Union[str, object] = values.unset,
|
||||
message_status_callback: Union[str, object] = values.unset,
|
||||
public_application_connect_enabled: Union[bool, object] = values.unset,
|
||||
) -> ApplicationInstance:
|
||||
"""
|
||||
Update the ApplicationInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long.
|
||||
:param api_version: The API version to use to start a new TwiML session. Can be: `2010-04-01` or `2008-08-01`. The default value is your account's default API version.
|
||||
:param voice_url: The URL we should call when the phone number assigned to this application receives a call.
|
||||
:param voice_method: The HTTP method we should use to call `voice_url`. Can be: `GET` or `POST`.
|
||||
:param voice_fallback_url: The URL that we should call when an error occurs retrieving or executing the TwiML requested by `url`.
|
||||
:param voice_fallback_method: The HTTP method we should use to call `voice_fallback_url`. Can be: `GET` or `POST`.
|
||||
:param status_callback: The URL we should call using the `status_callback_method` to send status information to your application.
|
||||
:param status_callback_method: The HTTP method we should use to call `status_callback`. Can be: `GET` or `POST`.
|
||||
:param voice_caller_id_lookup: Whether we should look up the caller's caller-ID name from the CNAM database (additional charges apply). Can be: `true` or `false`.
|
||||
:param sms_url: The URL we should call when the phone number receives an incoming SMS message.
|
||||
:param sms_method: The HTTP method we should use to call `sms_url`. Can be: `GET` or `POST`.
|
||||
:param sms_fallback_url: The URL that we should call when an error occurs while retrieving or executing the TwiML from `sms_url`.
|
||||
:param sms_fallback_method: The HTTP method we should use to call `sms_fallback_url`. Can be: `GET` or `POST`.
|
||||
:param sms_status_callback: Same as message_status_callback: The URL we should call using a POST method to send status information about SMS messages sent by the application. Deprecated, included for backwards compatibility.
|
||||
:param message_status_callback: The URL we should call using a POST method to send message status information to your application.
|
||||
:param public_application_connect_enabled: Whether to allow other Twilio accounts to dial this applicaton using Dial verb. Can be: `true` or `false`.
|
||||
|
||||
:returns: The updated 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,
|
||||
"PublicApplicationConnectEnabled": public_application_connect_enabled,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return ApplicationInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
api_version: Union[str, object] = values.unset,
|
||||
voice_url: Union[str, object] = values.unset,
|
||||
voice_method: Union[str, object] = values.unset,
|
||||
voice_fallback_url: Union[str, object] = values.unset,
|
||||
voice_fallback_method: Union[str, object] = values.unset,
|
||||
status_callback: Union[str, object] = values.unset,
|
||||
status_callback_method: Union[str, object] = values.unset,
|
||||
voice_caller_id_lookup: Union[bool, object] = values.unset,
|
||||
sms_url: Union[str, object] = values.unset,
|
||||
sms_method: Union[str, object] = values.unset,
|
||||
sms_fallback_url: Union[str, object] = values.unset,
|
||||
sms_fallback_method: Union[str, object] = values.unset,
|
||||
sms_status_callback: Union[str, object] = values.unset,
|
||||
message_status_callback: Union[str, object] = values.unset,
|
||||
public_application_connect_enabled: Union[bool, object] = values.unset,
|
||||
) -> ApplicationInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the ApplicationInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long.
|
||||
:param api_version: The API version to use to start a new TwiML session. Can be: `2010-04-01` or `2008-08-01`. The default value is your account's default API version.
|
||||
:param voice_url: The URL we should call when the phone number assigned to this application receives a call.
|
||||
:param voice_method: The HTTP method we should use to call `voice_url`. Can be: `GET` or `POST`.
|
||||
:param voice_fallback_url: The URL that we should call when an error occurs retrieving or executing the TwiML requested by `url`.
|
||||
:param voice_fallback_method: The HTTP method we should use to call `voice_fallback_url`. Can be: `GET` or `POST`.
|
||||
:param status_callback: The URL we should call using the `status_callback_method` to send status information to your application.
|
||||
:param status_callback_method: The HTTP method we should use to call `status_callback`. Can be: `GET` or `POST`.
|
||||
:param voice_caller_id_lookup: Whether we should look up the caller's caller-ID name from the CNAM database (additional charges apply). Can be: `true` or `false`.
|
||||
:param sms_url: The URL we should call when the phone number receives an incoming SMS message.
|
||||
:param sms_method: The HTTP method we should use to call `sms_url`. Can be: `GET` or `POST`.
|
||||
:param sms_fallback_url: The URL that we should call when an error occurs while retrieving or executing the TwiML from `sms_url`.
|
||||
:param sms_fallback_method: The HTTP method we should use to call `sms_fallback_url`. Can be: `GET` or `POST`.
|
||||
:param sms_status_callback: Same as message_status_callback: The URL we should call using a POST method to send status information about SMS messages sent by the application. Deprecated, included for backwards compatibility.
|
||||
:param message_status_callback: The URL we should call using a POST method to send message status information to your application.
|
||||
:param public_application_connect_enabled: Whether to allow other Twilio accounts to dial this applicaton using Dial verb. Can be: `true` or `false`.
|
||||
|
||||
:returns: The updated 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,
|
||||
"PublicApplicationConnectEnabled": public_application_connect_enabled,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return ApplicationInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.ApplicationContext {}>".format(context)
|
||||
|
||||
|
||||
class ApplicationPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> ApplicationInstance:
|
||||
"""
|
||||
Build an instance of ApplicationInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return ApplicationInstance(
|
||||
self._version, payload, account_sid=self._solution["account_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.ApplicationPage>"
|
||||
|
||||
|
||||
class ApplicationList(ListResource):
|
||||
def __init__(self, version: Version, account_sid: str):
|
||||
"""
|
||||
Initialize the ApplicationList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Application resources to read.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/Applications.json".format(**self._solution)
|
||||
|
||||
def create(
|
||||
self,
|
||||
api_version: Union[str, object] = values.unset,
|
||||
voice_url: Union[str, object] = values.unset,
|
||||
voice_method: Union[str, object] = values.unset,
|
||||
voice_fallback_url: Union[str, object] = values.unset,
|
||||
voice_fallback_method: Union[str, object] = values.unset,
|
||||
status_callback: Union[str, object] = values.unset,
|
||||
status_callback_method: Union[str, object] = values.unset,
|
||||
voice_caller_id_lookup: Union[bool, object] = values.unset,
|
||||
sms_url: Union[str, object] = values.unset,
|
||||
sms_method: Union[str, object] = values.unset,
|
||||
sms_fallback_url: Union[str, object] = values.unset,
|
||||
sms_fallback_method: Union[str, object] = values.unset,
|
||||
sms_status_callback: Union[str, object] = values.unset,
|
||||
message_status_callback: Union[str, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
public_application_connect_enabled: Union[bool, object] = values.unset,
|
||||
) -> ApplicationInstance:
|
||||
"""
|
||||
Create the ApplicationInstance
|
||||
|
||||
:param api_version: The API version to use to start a new TwiML session. Can be: `2010-04-01` or `2008-08-01`. The default value is the account's default API version.
|
||||
:param voice_url: The URL we should call when the phone number assigned to this application receives a call.
|
||||
:param voice_method: The HTTP method we should use to call `voice_url`. Can be: `GET` or `POST`.
|
||||
:param voice_fallback_url: The URL that we should call when an error occurs retrieving or executing the TwiML requested by `url`.
|
||||
:param voice_fallback_method: The HTTP method we should use to call `voice_fallback_url`. Can be: `GET` or `POST`.
|
||||
:param status_callback: The URL we should call using the `status_callback_method` to send status information to your application.
|
||||
:param status_callback_method: The HTTP method we should use to call `status_callback`. Can be: `GET` or `POST`.
|
||||
:param voice_caller_id_lookup: Whether we should look up the caller's caller-ID name from the CNAM database (additional charges apply). Can be: `true` or `false`.
|
||||
:param sms_url: The URL we should call when the phone number receives an incoming SMS message.
|
||||
:param sms_method: The HTTP method we should use to call `sms_url`. Can be: `GET` or `POST`.
|
||||
:param sms_fallback_url: The URL that we should call when an error occurs while retrieving or executing the TwiML from `sms_url`.
|
||||
:param sms_fallback_method: The HTTP method we should use to call `sms_fallback_url`. Can be: `GET` or `POST`.
|
||||
:param sms_status_callback: The URL we should call using a POST method to send status information about SMS messages sent by the application.
|
||||
:param message_status_callback: The URL we should call using a POST method to send message status information to your application.
|
||||
:param friendly_name: A descriptive string that you create to describe the new application. It can be up to 64 characters long.
|
||||
:param public_application_connect_enabled: Whether to allow other Twilio accounts to dial this applicaton using Dial verb. Can be: `true` or `false`.
|
||||
|
||||
:returns: The created ApplicationInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"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,
|
||||
"FriendlyName": friendly_name,
|
||||
"PublicApplicationConnectEnabled": public_application_connect_enabled,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return ApplicationInstance(
|
||||
self._version, payload, account_sid=self._solution["account_sid"]
|
||||
)
|
||||
|
||||
async def create_async(
|
||||
self,
|
||||
api_version: Union[str, object] = values.unset,
|
||||
voice_url: Union[str, object] = values.unset,
|
||||
voice_method: Union[str, object] = values.unset,
|
||||
voice_fallback_url: Union[str, object] = values.unset,
|
||||
voice_fallback_method: Union[str, object] = values.unset,
|
||||
status_callback: Union[str, object] = values.unset,
|
||||
status_callback_method: Union[str, object] = values.unset,
|
||||
voice_caller_id_lookup: Union[bool, object] = values.unset,
|
||||
sms_url: Union[str, object] = values.unset,
|
||||
sms_method: Union[str, object] = values.unset,
|
||||
sms_fallback_url: Union[str, object] = values.unset,
|
||||
sms_fallback_method: Union[str, object] = values.unset,
|
||||
sms_status_callback: Union[str, object] = values.unset,
|
||||
message_status_callback: Union[str, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
public_application_connect_enabled: Union[bool, object] = values.unset,
|
||||
) -> ApplicationInstance:
|
||||
"""
|
||||
Asynchronously create the ApplicationInstance
|
||||
|
||||
:param api_version: The API version to use to start a new TwiML session. Can be: `2010-04-01` or `2008-08-01`. The default value is the account's default API version.
|
||||
:param voice_url: The URL we should call when the phone number assigned to this application receives a call.
|
||||
:param voice_method: The HTTP method we should use to call `voice_url`. Can be: `GET` or `POST`.
|
||||
:param voice_fallback_url: The URL that we should call when an error occurs retrieving or executing the TwiML requested by `url`.
|
||||
:param voice_fallback_method: The HTTP method we should use to call `voice_fallback_url`. Can be: `GET` or `POST`.
|
||||
:param status_callback: The URL we should call using the `status_callback_method` to send status information to your application.
|
||||
:param status_callback_method: The HTTP method we should use to call `status_callback`. Can be: `GET` or `POST`.
|
||||
:param voice_caller_id_lookup: Whether we should look up the caller's caller-ID name from the CNAM database (additional charges apply). Can be: `true` or `false`.
|
||||
:param sms_url: The URL we should call when the phone number receives an incoming SMS message.
|
||||
:param sms_method: The HTTP method we should use to call `sms_url`. Can be: `GET` or `POST`.
|
||||
:param sms_fallback_url: The URL that we should call when an error occurs while retrieving or executing the TwiML from `sms_url`.
|
||||
:param sms_fallback_method: The HTTP method we should use to call `sms_fallback_url`. Can be: `GET` or `POST`.
|
||||
:param sms_status_callback: The URL we should call using a POST method to send status information about SMS messages sent by the application.
|
||||
:param message_status_callback: The URL we should call using a POST method to send message status information to your application.
|
||||
:param friendly_name: A descriptive string that you create to describe the new application. It can be up to 64 characters long.
|
||||
:param public_application_connect_enabled: Whether to allow other Twilio accounts to dial this applicaton using Dial verb. Can be: `true` or `false`.
|
||||
|
||||
:returns: The created ApplicationInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"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,
|
||||
"FriendlyName": friendly_name,
|
||||
"PublicApplicationConnectEnabled": public_application_connect_enabled,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return ApplicationInstance(
|
||||
self._version, payload, account_sid=self._solution["account_sid"]
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[ApplicationInstance]:
|
||||
"""
|
||||
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 str friendly_name: The string that identifies the Application resources to read.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(friendly_name=friendly_name, page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[ApplicationInstance]:
|
||||
"""
|
||||
Asynchronously 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 str friendly_name: The string that identifies the Application resources to read.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(
|
||||
friendly_name=friendly_name, page_size=limits["page_size"]
|
||||
)
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[ApplicationInstance]:
|
||||
"""
|
||||
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 str friendly_name: The string that identifies the Application resources to read.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return list(
|
||||
self.stream(
|
||||
friendly_name=friendly_name,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[ApplicationInstance]:
|
||||
"""
|
||||
Asynchronously 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 str friendly_name: The string that identifies the Application resources to read.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return [
|
||||
record
|
||||
async for record in await self.stream_async(
|
||||
friendly_name=friendly_name,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> ApplicationPage:
|
||||
"""
|
||||
Retrieve a single page of ApplicationInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param friendly_name: The string that identifies the Application resources to read.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of ApplicationInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return ApplicationPage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> ApplicationPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of ApplicationInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param friendly_name: The string that identifies the Application resources to read.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of ApplicationInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return ApplicationPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> ApplicationPage:
|
||||
"""
|
||||
Retrieve a specific page of ApplicationInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of ApplicationInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return ApplicationPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> ApplicationPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of ApplicationInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of ApplicationInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return ApplicationPage(self._version, response, self._solution)
|
||||
|
||||
def get(self, sid: str) -> ApplicationContext:
|
||||
"""
|
||||
Constructs a ApplicationContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Application resource to update.
|
||||
"""
|
||||
return ApplicationContext(
|
||||
self._version, account_sid=self._solution["account_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> ApplicationContext:
|
||||
"""
|
||||
Constructs a ApplicationContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Application resource to update.
|
||||
"""
|
||||
return ApplicationContext(
|
||||
self._version, account_sid=self._solution["account_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.ApplicationList>"
|
||||
+450
@@ -0,0 +1,450 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, values
|
||||
from twilio.base.instance_context import InstanceContext
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.page import Page
|
||||
|
||||
|
||||
class AuthorizedConnectAppInstance(InstanceResource):
|
||||
class Permission(object):
|
||||
GET_ALL = "get-all"
|
||||
POST_ALL = "post-all"
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the AuthorizedConnectApp resource.
|
||||
:ivar connect_app_company_name: The company name set for the Connect App.
|
||||
:ivar connect_app_description: A detailed description of the Connect App.
|
||||
:ivar connect_app_friendly_name: The name of the Connect App.
|
||||
:ivar connect_app_homepage_url: The public URL for the Connect App.
|
||||
:ivar connect_app_sid: The SID that we assigned to the Connect App.
|
||||
:ivar date_created: The date and time in GMT that the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar date_updated: The date and time in GMT that the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar permissions: The set of permissions that you authorized for the Connect App. Can be: `get-all` or `post-all`.
|
||||
:ivar uri: The URI of the resource, relative to `https://api.twilio.com`.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
account_sid: str,
|
||||
connect_app_sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.connect_app_company_name: Optional[str] = payload.get(
|
||||
"connect_app_company_name"
|
||||
)
|
||||
self.connect_app_description: Optional[str] = payload.get(
|
||||
"connect_app_description"
|
||||
)
|
||||
self.connect_app_friendly_name: Optional[str] = payload.get(
|
||||
"connect_app_friendly_name"
|
||||
)
|
||||
self.connect_app_homepage_url: Optional[str] = payload.get(
|
||||
"connect_app_homepage_url"
|
||||
)
|
||||
self.connect_app_sid: Optional[str] = payload.get("connect_app_sid")
|
||||
self.date_created: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.permissions: Optional[
|
||||
List["AuthorizedConnectAppInstance.Permission"]
|
||||
] = payload.get("permissions")
|
||||
self.uri: Optional[str] = payload.get("uri")
|
||||
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"connect_app_sid": connect_app_sid or self.connect_app_sid,
|
||||
}
|
||||
self._context: Optional[AuthorizedConnectAppContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "AuthorizedConnectAppContext":
|
||||
"""
|
||||
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
|
||||
"""
|
||||
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
|
||||
|
||||
def fetch(self) -> "AuthorizedConnectAppInstance":
|
||||
"""
|
||||
Fetch the AuthorizedConnectAppInstance
|
||||
|
||||
|
||||
:returns: The fetched AuthorizedConnectAppInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "AuthorizedConnectAppInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the AuthorizedConnectAppInstance
|
||||
|
||||
|
||||
:returns: The fetched AuthorizedConnectAppInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.AuthorizedConnectAppInstance {}>".format(context)
|
||||
|
||||
|
||||
class AuthorizedConnectAppContext(InstanceContext):
|
||||
def __init__(self, version: Version, account_sid: str, connect_app_sid: str):
|
||||
"""
|
||||
Initialize the AuthorizedConnectAppContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the AuthorizedConnectApp resource to fetch.
|
||||
:param connect_app_sid: The SID of the Connect App to fetch.
|
||||
"""
|
||||
super().__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) -> AuthorizedConnectAppInstance:
|
||||
"""
|
||||
Fetch the AuthorizedConnectAppInstance
|
||||
|
||||
|
||||
:returns: The fetched AuthorizedConnectAppInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return AuthorizedConnectAppInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
connect_app_sid=self._solution["connect_app_sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> AuthorizedConnectAppInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the AuthorizedConnectAppInstance
|
||||
|
||||
|
||||
:returns: The fetched AuthorizedConnectAppInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return AuthorizedConnectAppInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
connect_app_sid=self._solution["connect_app_sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.AuthorizedConnectAppContext {}>".format(context)
|
||||
|
||||
|
||||
class AuthorizedConnectAppPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> AuthorizedConnectAppInstance:
|
||||
"""
|
||||
Build an instance of AuthorizedConnectAppInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return AuthorizedConnectAppInstance(
|
||||
self._version, payload, account_sid=self._solution["account_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.AuthorizedConnectAppPage>"
|
||||
|
||||
|
||||
class AuthorizedConnectAppList(ListResource):
|
||||
def __init__(self, version: Version, account_sid: str):
|
||||
"""
|
||||
Initialize the AuthorizedConnectAppList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the AuthorizedConnectApp resources to read.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/AuthorizedConnectApps.json".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[AuthorizedConnectAppInstance]:
|
||||
"""
|
||||
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 limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[AuthorizedConnectAppInstance]:
|
||||
"""
|
||||
Asynchronously 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 limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[AuthorizedConnectAppInstance]:
|
||||
"""
|
||||
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 limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return list(
|
||||
self.stream(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[AuthorizedConnectAppInstance]:
|
||||
"""
|
||||
Asynchronously 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 limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return [
|
||||
record
|
||||
async for record in await self.stream_async(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> AuthorizedConnectAppPage:
|
||||
"""
|
||||
Retrieve a single page of AuthorizedConnectAppInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of AuthorizedConnectAppInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return AuthorizedConnectAppPage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> AuthorizedConnectAppPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of AuthorizedConnectAppInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of AuthorizedConnectAppInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return AuthorizedConnectAppPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> AuthorizedConnectAppPage:
|
||||
"""
|
||||
Retrieve a specific page of AuthorizedConnectAppInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of AuthorizedConnectAppInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return AuthorizedConnectAppPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> AuthorizedConnectAppPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of AuthorizedConnectAppInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of AuthorizedConnectAppInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return AuthorizedConnectAppPage(self._version, response, self._solution)
|
||||
|
||||
def get(self, connect_app_sid: str) -> AuthorizedConnectAppContext:
|
||||
"""
|
||||
Constructs a AuthorizedConnectAppContext
|
||||
|
||||
:param connect_app_sid: The SID of the Connect App to fetch.
|
||||
"""
|
||||
return AuthorizedConnectAppContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
connect_app_sid=connect_app_sid,
|
||||
)
|
||||
|
||||
def __call__(self, connect_app_sid: str) -> AuthorizedConnectAppContext:
|
||||
"""
|
||||
Constructs a AuthorizedConnectAppContext
|
||||
|
||||
:param connect_app_sid: The SID of the Connect App to fetch.
|
||||
"""
|
||||
return AuthorizedConnectAppContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
connect_app_sid=connect_app_sid,
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.AuthorizedConnectAppList>"
|
||||
+597
@@ -0,0 +1,597 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import values
|
||||
from twilio.base.instance_context import InstanceContext
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.page import Page
|
||||
from twilio.rest.api.v2010.account.available_phone_number_country.local import LocalList
|
||||
from twilio.rest.api.v2010.account.available_phone_number_country.machine_to_machine import (
|
||||
MachineToMachineList,
|
||||
)
|
||||
from twilio.rest.api.v2010.account.available_phone_number_country.mobile import (
|
||||
MobileList,
|
||||
)
|
||||
from twilio.rest.api.v2010.account.available_phone_number_country.national import (
|
||||
NationalList,
|
||||
)
|
||||
from twilio.rest.api.v2010.account.available_phone_number_country.shared_cost import (
|
||||
SharedCostList,
|
||||
)
|
||||
from twilio.rest.api.v2010.account.available_phone_number_country.toll_free import (
|
||||
TollFreeList,
|
||||
)
|
||||
from twilio.rest.api.v2010.account.available_phone_number_country.voip import VoipList
|
||||
|
||||
|
||||
class AvailablePhoneNumberCountryInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar country_code: The [ISO-3166-1](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code of the country.
|
||||
:ivar country: The name of the country.
|
||||
:ivar uri: The URI of the Country resource, relative to `https://api.twilio.com`.
|
||||
:ivar beta: Whether all phone numbers available in the country are new to the Twilio platform. `true` if they are and `false` if all numbers are not in the Twilio Phone Number Beta program.
|
||||
:ivar subresource_uris: A list of related AvailablePhoneNumber resources identified by their URIs relative to `https://api.twilio.com`.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
account_sid: str,
|
||||
country_code: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.country_code: Optional[str] = payload.get("country_code")
|
||||
self.country: Optional[str] = payload.get("country")
|
||||
self.uri: Optional[str] = payload.get("uri")
|
||||
self.beta: Optional[bool] = payload.get("beta")
|
||||
self.subresource_uris: Optional[Dict[str, object]] = payload.get(
|
||||
"subresource_uris"
|
||||
)
|
||||
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"country_code": country_code or self.country_code,
|
||||
}
|
||||
self._context: Optional[AvailablePhoneNumberCountryContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "AvailablePhoneNumberCountryContext":
|
||||
"""
|
||||
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
|
||||
"""
|
||||
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
|
||||
|
||||
def fetch(self) -> "AvailablePhoneNumberCountryInstance":
|
||||
"""
|
||||
Fetch the AvailablePhoneNumberCountryInstance
|
||||
|
||||
|
||||
:returns: The fetched AvailablePhoneNumberCountryInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "AvailablePhoneNumberCountryInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the AvailablePhoneNumberCountryInstance
|
||||
|
||||
|
||||
:returns: The fetched AvailablePhoneNumberCountryInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
@property
|
||||
def local(self) -> LocalList:
|
||||
"""
|
||||
Access the local
|
||||
"""
|
||||
return self._proxy.local
|
||||
|
||||
@property
|
||||
def machine_to_machine(self) -> MachineToMachineList:
|
||||
"""
|
||||
Access the machine_to_machine
|
||||
"""
|
||||
return self._proxy.machine_to_machine
|
||||
|
||||
@property
|
||||
def mobile(self) -> MobileList:
|
||||
"""
|
||||
Access the mobile
|
||||
"""
|
||||
return self._proxy.mobile
|
||||
|
||||
@property
|
||||
def national(self) -> NationalList:
|
||||
"""
|
||||
Access the national
|
||||
"""
|
||||
return self._proxy.national
|
||||
|
||||
@property
|
||||
def shared_cost(self) -> SharedCostList:
|
||||
"""
|
||||
Access the shared_cost
|
||||
"""
|
||||
return self._proxy.shared_cost
|
||||
|
||||
@property
|
||||
def toll_free(self) -> TollFreeList:
|
||||
"""
|
||||
Access the toll_free
|
||||
"""
|
||||
return self._proxy.toll_free
|
||||
|
||||
@property
|
||||
def voip(self) -> VoipList:
|
||||
"""
|
||||
Access the voip
|
||||
"""
|
||||
return self._proxy.voip
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.AvailablePhoneNumberCountryInstance {}>".format(
|
||||
context
|
||||
)
|
||||
|
||||
|
||||
class AvailablePhoneNumberCountryContext(InstanceContext):
|
||||
def __init__(self, version: Version, account_sid: str, country_code: str):
|
||||
"""
|
||||
Initialize the AvailablePhoneNumberCountryContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) requesting the available phone number Country resource.
|
||||
:param country_code: The [ISO-3166-1](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code of the country to fetch available phone number information about.
|
||||
"""
|
||||
super().__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
|
||||
)
|
||||
)
|
||||
|
||||
self._local: Optional[LocalList] = None
|
||||
self._machine_to_machine: Optional[MachineToMachineList] = None
|
||||
self._mobile: Optional[MobileList] = None
|
||||
self._national: Optional[NationalList] = None
|
||||
self._shared_cost: Optional[SharedCostList] = None
|
||||
self._toll_free: Optional[TollFreeList] = None
|
||||
self._voip: Optional[VoipList] = None
|
||||
|
||||
def fetch(self) -> AvailablePhoneNumberCountryInstance:
|
||||
"""
|
||||
Fetch the AvailablePhoneNumberCountryInstance
|
||||
|
||||
|
||||
:returns: The fetched AvailablePhoneNumberCountryInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return AvailablePhoneNumberCountryInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
country_code=self._solution["country_code"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> AvailablePhoneNumberCountryInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the AvailablePhoneNumberCountryInstance
|
||||
|
||||
|
||||
:returns: The fetched AvailablePhoneNumberCountryInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return AvailablePhoneNumberCountryInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
country_code=self._solution["country_code"],
|
||||
)
|
||||
|
||||
@property
|
||||
def local(self) -> LocalList:
|
||||
"""
|
||||
Access the local
|
||||
"""
|
||||
if self._local is None:
|
||||
self._local = LocalList(
|
||||
self._version,
|
||||
self._solution["account_sid"],
|
||||
self._solution["country_code"],
|
||||
)
|
||||
return self._local
|
||||
|
||||
@property
|
||||
def machine_to_machine(self) -> MachineToMachineList:
|
||||
"""
|
||||
Access the machine_to_machine
|
||||
"""
|
||||
if self._machine_to_machine is None:
|
||||
self._machine_to_machine = MachineToMachineList(
|
||||
self._version,
|
||||
self._solution["account_sid"],
|
||||
self._solution["country_code"],
|
||||
)
|
||||
return self._machine_to_machine
|
||||
|
||||
@property
|
||||
def mobile(self) -> MobileList:
|
||||
"""
|
||||
Access the mobile
|
||||
"""
|
||||
if self._mobile is None:
|
||||
self._mobile = MobileList(
|
||||
self._version,
|
||||
self._solution["account_sid"],
|
||||
self._solution["country_code"],
|
||||
)
|
||||
return self._mobile
|
||||
|
||||
@property
|
||||
def national(self) -> NationalList:
|
||||
"""
|
||||
Access the national
|
||||
"""
|
||||
if self._national is None:
|
||||
self._national = NationalList(
|
||||
self._version,
|
||||
self._solution["account_sid"],
|
||||
self._solution["country_code"],
|
||||
)
|
||||
return self._national
|
||||
|
||||
@property
|
||||
def shared_cost(self) -> SharedCostList:
|
||||
"""
|
||||
Access the shared_cost
|
||||
"""
|
||||
if self._shared_cost is None:
|
||||
self._shared_cost = SharedCostList(
|
||||
self._version,
|
||||
self._solution["account_sid"],
|
||||
self._solution["country_code"],
|
||||
)
|
||||
return self._shared_cost
|
||||
|
||||
@property
|
||||
def toll_free(self) -> TollFreeList:
|
||||
"""
|
||||
Access the toll_free
|
||||
"""
|
||||
if self._toll_free is None:
|
||||
self._toll_free = TollFreeList(
|
||||
self._version,
|
||||
self._solution["account_sid"],
|
||||
self._solution["country_code"],
|
||||
)
|
||||
return self._toll_free
|
||||
|
||||
@property
|
||||
def voip(self) -> VoipList:
|
||||
"""
|
||||
Access the voip
|
||||
"""
|
||||
if self._voip is None:
|
||||
self._voip = VoipList(
|
||||
self._version,
|
||||
self._solution["account_sid"],
|
||||
self._solution["country_code"],
|
||||
)
|
||||
return self._voip
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.AvailablePhoneNumberCountryContext {}>".format(
|
||||
context
|
||||
)
|
||||
|
||||
|
||||
class AvailablePhoneNumberCountryPage(Page):
|
||||
def get_instance(
|
||||
self, payload: Dict[str, Any]
|
||||
) -> AvailablePhoneNumberCountryInstance:
|
||||
"""
|
||||
Build an instance of AvailablePhoneNumberCountryInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return AvailablePhoneNumberCountryInstance(
|
||||
self._version, payload, account_sid=self._solution["account_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.AvailablePhoneNumberCountryPage>"
|
||||
|
||||
|
||||
class AvailablePhoneNumberCountryList(ListResource):
|
||||
def __init__(self, version: Version, account_sid: str):
|
||||
"""
|
||||
Initialize the AvailablePhoneNumberCountryList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) requesting the available phone number Country resources.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/AvailablePhoneNumbers.json".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[AvailablePhoneNumberCountryInstance]:
|
||||
"""
|
||||
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 limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[AvailablePhoneNumberCountryInstance]:
|
||||
"""
|
||||
Asynchronously 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 limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[AvailablePhoneNumberCountryInstance]:
|
||||
"""
|
||||
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 limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return list(
|
||||
self.stream(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[AvailablePhoneNumberCountryInstance]:
|
||||
"""
|
||||
Asynchronously 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 limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return [
|
||||
record
|
||||
async for record in await self.stream_async(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> AvailablePhoneNumberCountryPage:
|
||||
"""
|
||||
Retrieve a single page of AvailablePhoneNumberCountryInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of AvailablePhoneNumberCountryInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return AvailablePhoneNumberCountryPage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> AvailablePhoneNumberCountryPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of AvailablePhoneNumberCountryInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of AvailablePhoneNumberCountryInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return AvailablePhoneNumberCountryPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> AvailablePhoneNumberCountryPage:
|
||||
"""
|
||||
Retrieve a specific page of AvailablePhoneNumberCountryInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of AvailablePhoneNumberCountryInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return AvailablePhoneNumberCountryPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> AvailablePhoneNumberCountryPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of AvailablePhoneNumberCountryInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of AvailablePhoneNumberCountryInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return AvailablePhoneNumberCountryPage(self._version, response, self._solution)
|
||||
|
||||
def get(self, country_code: str) -> AvailablePhoneNumberCountryContext:
|
||||
"""
|
||||
Constructs a AvailablePhoneNumberCountryContext
|
||||
|
||||
:param country_code: The [ISO-3166-1](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code of the country to fetch available phone number information about.
|
||||
"""
|
||||
return AvailablePhoneNumberCountryContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
country_code=country_code,
|
||||
)
|
||||
|
||||
def __call__(self, country_code: str) -> AvailablePhoneNumberCountryContext:
|
||||
"""
|
||||
Constructs a AvailablePhoneNumberCountryContext
|
||||
|
||||
:param country_code: The [ISO-3166-1](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code of the country to fetch available phone number information about.
|
||||
"""
|
||||
return AvailablePhoneNumberCountryContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
country_code=country_code,
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.AvailablePhoneNumberCountryList>"
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
+642
@@ -0,0 +1,642 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, values
|
||||
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.page import Page
|
||||
|
||||
|
||||
class LocalInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar friendly_name: A formatted version of the phone number.
|
||||
:ivar phone_number: The phone number in [E.164](https://www.twilio.com/docs/glossary/what-e164) format, which consists of a + followed by the country code and subscriber number.
|
||||
:ivar lata: The [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) of this phone number. Available for only phone numbers from the US and Canada.
|
||||
:ivar locality: The locality or city of this phone number's location.
|
||||
:ivar rate_center: The [rate center](https://en.wikipedia.org/wiki/Telephone_exchange) of this phone number. Available for only phone numbers from the US and Canada.
|
||||
:ivar latitude: The latitude of this phone number's location. Available for only phone numbers from the US and Canada.
|
||||
:ivar longitude: The longitude of this phone number's location. Available for only phone numbers from the US and Canada.
|
||||
:ivar region: The two-letter state or province abbreviation of this phone number's location. Available for only phone numbers from the US and Canada.
|
||||
:ivar postal_code: The postal or ZIP code of this phone number's location. Available for only phone numbers from the US and Canada.
|
||||
:ivar iso_country: The [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of this phone number.
|
||||
:ivar address_requirements: The type of [Address](https://www.twilio.com/docs/usage/api/address) resource the phone number requires. Can be: `none`, `any`, `local`, or `foreign`. `none` means no address is required. `any` means an address is required, but it can be anywhere in the world. `local` means an address in the phone number's country is required. `foreign` means an address outside of the phone number's country is required.
|
||||
:ivar beta: Whether the phone number is new to the Twilio platform. Can be: `true` or `false`.
|
||||
:ivar capabilities:
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
account_sid: str,
|
||||
country_code: str,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.friendly_name: Optional[str] = payload.get("friendly_name")
|
||||
self.phone_number: Optional[str] = payload.get("phone_number")
|
||||
self.lata: Optional[str] = payload.get("lata")
|
||||
self.locality: Optional[str] = payload.get("locality")
|
||||
self.rate_center: Optional[str] = payload.get("rate_center")
|
||||
self.latitude: Optional[float] = deserialize.decimal(payload.get("latitude"))
|
||||
self.longitude: Optional[float] = deserialize.decimal(payload.get("longitude"))
|
||||
self.region: Optional[str] = payload.get("region")
|
||||
self.postal_code: Optional[str] = payload.get("postal_code")
|
||||
self.iso_country: Optional[str] = payload.get("iso_country")
|
||||
self.address_requirements: Optional[str] = payload.get("address_requirements")
|
||||
self.beta: Optional[bool] = payload.get("beta")
|
||||
self.capabilities: Optional[str] = payload.get("capabilities")
|
||||
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"country_code": country_code,
|
||||
}
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.LocalInstance {}>".format(context)
|
||||
|
||||
|
||||
class LocalPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> LocalInstance:
|
||||
"""
|
||||
Build an instance of LocalInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return LocalInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
country_code=self._solution["country_code"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.LocalPage>"
|
||||
|
||||
|
||||
class LocalList(ListResource):
|
||||
def __init__(self, version: Version, account_sid: str, country_code: str):
|
||||
"""
|
||||
Initialize the LocalList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) requesting the AvailablePhoneNumber resources.
|
||||
:param country_code: The [ISO-3166-1](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code of the country from which to read phone numbers.
|
||||
|
||||
"""
|
||||
super().__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: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[LocalInstance]:
|
||||
"""
|
||||
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 int area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param str contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumberlocal-resource?code-sample=code-find-phone-numbers-by-number-pattern) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumberlocal-resource?code-sample=code-find-phone-numbers-by-character-pattern). If specified, this value must have at least two characters.
|
||||
:param bool sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param bool mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param bool voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param bool exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param str near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param int distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param bool fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(
|
||||
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"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[LocalInstance]:
|
||||
"""
|
||||
Asynchronously 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 int area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param str contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumberlocal-resource?code-sample=code-find-phone-numbers-by-number-pattern) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumberlocal-resource?code-sample=code-find-phone-numbers-by-character-pattern). If specified, this value must have at least two characters.
|
||||
:param bool sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param bool mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param bool voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param bool exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param str near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param int distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param bool fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(
|
||||
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_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[LocalInstance]:
|
||||
"""
|
||||
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 int area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param str contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumberlocal-resource?code-sample=code-find-phone-numbers-by-number-pattern) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumberlocal-resource?code-sample=code-find-phone-numbers-by-character-pattern). If specified, this value must have at least two characters.
|
||||
:param bool sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param bool mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param bool voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param bool exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param str near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param int distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param bool fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return list(
|
||||
self.stream(
|
||||
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,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[LocalInstance]:
|
||||
"""
|
||||
Asynchronously 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 int area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param str contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumberlocal-resource?code-sample=code-find-phone-numbers-by-number-pattern) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumberlocal-resource?code-sample=code-find-phone-numbers-by-character-pattern). If specified, this value must have at least two characters.
|
||||
:param bool sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param bool mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param bool voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param bool exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param str near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param int distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param bool fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return [
|
||||
record
|
||||
async for record in await self.stream_async(
|
||||
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: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> LocalPage:
|
||||
"""
|
||||
Retrieve a single page of LocalInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumberlocal-resource?code-sample=code-find-phone-numbers-by-number-pattern) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumberlocal-resource?code-sample=code-find-phone-numbers-by-character-pattern). If specified, this value must have at least two characters.
|
||||
:param sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of LocalInstance
|
||||
"""
|
||||
data = 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(method="GET", uri=self._uri, params=data)
|
||||
return LocalPage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> LocalPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of LocalInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumberlocal-resource?code-sample=code-find-phone-numbers-by-number-pattern) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumberlocal-resource?code-sample=code-find-phone-numbers-by-character-pattern). If specified, this value must have at least two characters.
|
||||
:param sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of LocalInstance
|
||||
"""
|
||||
data = 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 = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return LocalPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> LocalPage:
|
||||
"""
|
||||
Retrieve a specific page of LocalInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of LocalInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return LocalPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> LocalPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of LocalInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of LocalInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return LocalPage(self._version, response, self._solution)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.LocalList>"
|
||||
+642
@@ -0,0 +1,642 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, values
|
||||
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.page import Page
|
||||
|
||||
|
||||
class MachineToMachineInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar friendly_name: A formatted version of the phone number.
|
||||
:ivar phone_number: The phone number in [E.164](https://www.twilio.com/docs/glossary/what-e164) format, which consists of a + followed by the country code and subscriber number.
|
||||
:ivar lata: The [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) of this phone number. Available for only phone numbers from the US and Canada.
|
||||
:ivar locality: The locality or city of this phone number's location.
|
||||
:ivar rate_center: The [rate center](https://en.wikipedia.org/wiki/Telephone_exchange) of this phone number. Available for only phone numbers from the US and Canada.
|
||||
:ivar latitude: The latitude of this phone number's location. Available for only phone numbers from the US and Canada.
|
||||
:ivar longitude: The longitude of this phone number's location. Available for only phone numbers from the US and Canada.
|
||||
:ivar region: The two-letter state or province abbreviation of this phone number's location. Available for only phone numbers from the US and Canada.
|
||||
:ivar postal_code: The postal or ZIP code of this phone number's location. Available for only phone numbers from the US and Canada.
|
||||
:ivar iso_country: The [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of this phone number.
|
||||
:ivar address_requirements: The type of [Address](https://www.twilio.com/docs/usage/api/address) resource the phone number requires. Can be: `none`, `any`, `local`, or `foreign`. `none` means no address is required. `any` means an address is required, but it can be anywhere in the world. `local` means an address in the phone number's country is required. `foreign` means an address outside of the phone number's country is required.
|
||||
:ivar beta: Whether the phone number is new to the Twilio platform. Can be: `true` or `false`.
|
||||
:ivar capabilities:
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
account_sid: str,
|
||||
country_code: str,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.friendly_name: Optional[str] = payload.get("friendly_name")
|
||||
self.phone_number: Optional[str] = payload.get("phone_number")
|
||||
self.lata: Optional[str] = payload.get("lata")
|
||||
self.locality: Optional[str] = payload.get("locality")
|
||||
self.rate_center: Optional[str] = payload.get("rate_center")
|
||||
self.latitude: Optional[float] = deserialize.decimal(payload.get("latitude"))
|
||||
self.longitude: Optional[float] = deserialize.decimal(payload.get("longitude"))
|
||||
self.region: Optional[str] = payload.get("region")
|
||||
self.postal_code: Optional[str] = payload.get("postal_code")
|
||||
self.iso_country: Optional[str] = payload.get("iso_country")
|
||||
self.address_requirements: Optional[str] = payload.get("address_requirements")
|
||||
self.beta: Optional[bool] = payload.get("beta")
|
||||
self.capabilities: Optional[str] = payload.get("capabilities")
|
||||
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"country_code": country_code,
|
||||
}
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.MachineToMachineInstance {}>".format(context)
|
||||
|
||||
|
||||
class MachineToMachinePage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> MachineToMachineInstance:
|
||||
"""
|
||||
Build an instance of MachineToMachineInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return MachineToMachineInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
country_code=self._solution["country_code"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.MachineToMachinePage>"
|
||||
|
||||
|
||||
class MachineToMachineList(ListResource):
|
||||
def __init__(self, version: Version, account_sid: str, country_code: str):
|
||||
"""
|
||||
Initialize the MachineToMachineList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) requesting the AvailablePhoneNumber resources.
|
||||
:param country_code: The [ISO-3166-1](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code of the country from which to read phone numbers.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"country_code": country_code,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/AvailablePhoneNumbers/{country_code}/MachineToMachine.json".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[MachineToMachineInstance]:
|
||||
"""
|
||||
Streams MachineToMachineInstance records from the API as a generator stream.
|
||||
This operation lazily loads 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 area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param str contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param bool sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param bool mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param bool voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param bool exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param str near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param int distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param bool fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(
|
||||
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"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[MachineToMachineInstance]:
|
||||
"""
|
||||
Asynchronously streams MachineToMachineInstance records from the API as a generator stream.
|
||||
This operation lazily loads 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 area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param str contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param bool sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param bool mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param bool voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param bool exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param str near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param int distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param bool fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(
|
||||
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_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[MachineToMachineInstance]:
|
||||
"""
|
||||
Lists MachineToMachineInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param int area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param str contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param bool sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param bool mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param bool voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param bool exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param str near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param int distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param bool fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return list(
|
||||
self.stream(
|
||||
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,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[MachineToMachineInstance]:
|
||||
"""
|
||||
Asynchronously lists MachineToMachineInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param int area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param str contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param bool sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param bool mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param bool voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param bool exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param str near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param int distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param bool fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return [
|
||||
record
|
||||
async for record in await self.stream_async(
|
||||
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: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> MachineToMachinePage:
|
||||
"""
|
||||
Retrieve a single page of MachineToMachineInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of MachineToMachineInstance
|
||||
"""
|
||||
data = 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(method="GET", uri=self._uri, params=data)
|
||||
return MachineToMachinePage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> MachineToMachinePage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of MachineToMachineInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of MachineToMachineInstance
|
||||
"""
|
||||
data = 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 = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return MachineToMachinePage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> MachineToMachinePage:
|
||||
"""
|
||||
Retrieve a specific page of MachineToMachineInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of MachineToMachineInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return MachineToMachinePage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> MachineToMachinePage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of MachineToMachineInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of MachineToMachineInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return MachineToMachinePage(self._version, response, self._solution)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.MachineToMachineList>"
|
||||
+642
@@ -0,0 +1,642 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, values
|
||||
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.page import Page
|
||||
|
||||
|
||||
class MobileInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar friendly_name: A formatted version of the phone number.
|
||||
:ivar phone_number: The phone number in [E.164](https://www.twilio.com/docs/glossary/what-e164) format, which consists of a + followed by the country code and subscriber number.
|
||||
:ivar lata: The [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) of this phone number. Available for only phone numbers from the US and Canada.
|
||||
:ivar locality: The locality or city of this phone number's location.
|
||||
:ivar rate_center: The [rate center](https://en.wikipedia.org/wiki/Telephone_exchange) of this phone number. Available for only phone numbers from the US and Canada.
|
||||
:ivar latitude: The latitude of this phone number's location. Available for only phone numbers from the US and Canada.
|
||||
:ivar longitude: The longitude of this phone number's location. Available for only phone numbers from the US and Canada.
|
||||
:ivar region: The two-letter state or province abbreviation of this phone number's location. Available for only phone numbers from the US and Canada.
|
||||
:ivar postal_code: The postal or ZIP code of this phone number's location. Available for only phone numbers from the US and Canada.
|
||||
:ivar iso_country: The [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of this phone number.
|
||||
:ivar address_requirements: The type of [Address](https://www.twilio.com/docs/usage/api/address) resource the phone number requires. Can be: `none`, `any`, `local`, or `foreign`. `none` means no address is required. `any` means an address is required, but it can be anywhere in the world. `local` means an address in the phone number's country is required. `foreign` means an address outside of the phone number's country is required.
|
||||
:ivar beta: Whether the phone number is new to the Twilio platform. Can be: `true` or `false`.
|
||||
:ivar capabilities:
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
account_sid: str,
|
||||
country_code: str,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.friendly_name: Optional[str] = payload.get("friendly_name")
|
||||
self.phone_number: Optional[str] = payload.get("phone_number")
|
||||
self.lata: Optional[str] = payload.get("lata")
|
||||
self.locality: Optional[str] = payload.get("locality")
|
||||
self.rate_center: Optional[str] = payload.get("rate_center")
|
||||
self.latitude: Optional[float] = deserialize.decimal(payload.get("latitude"))
|
||||
self.longitude: Optional[float] = deserialize.decimal(payload.get("longitude"))
|
||||
self.region: Optional[str] = payload.get("region")
|
||||
self.postal_code: Optional[str] = payload.get("postal_code")
|
||||
self.iso_country: Optional[str] = payload.get("iso_country")
|
||||
self.address_requirements: Optional[str] = payload.get("address_requirements")
|
||||
self.beta: Optional[bool] = payload.get("beta")
|
||||
self.capabilities: Optional[str] = payload.get("capabilities")
|
||||
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"country_code": country_code,
|
||||
}
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.MobileInstance {}>".format(context)
|
||||
|
||||
|
||||
class MobilePage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> MobileInstance:
|
||||
"""
|
||||
Build an instance of MobileInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return MobileInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
country_code=self._solution["country_code"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.MobilePage>"
|
||||
|
||||
|
||||
class MobileList(ListResource):
|
||||
def __init__(self, version: Version, account_sid: str, country_code: str):
|
||||
"""
|
||||
Initialize the MobileList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) requesting the AvailablePhoneNumber resources.
|
||||
:param country_code: The [ISO-3166-1](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code of the country from which to read phone numbers.
|
||||
|
||||
"""
|
||||
super().__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: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[MobileInstance]:
|
||||
"""
|
||||
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 int area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param str contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param bool sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param bool mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param bool voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param bool exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param str near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param int distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param bool fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(
|
||||
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"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[MobileInstance]:
|
||||
"""
|
||||
Asynchronously 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 int area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param str contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param bool sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param bool mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param bool voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param bool exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param str near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param int distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param bool fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(
|
||||
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_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[MobileInstance]:
|
||||
"""
|
||||
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 int area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param str contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param bool sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param bool mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param bool voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param bool exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param str near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param int distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param bool fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return list(
|
||||
self.stream(
|
||||
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,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[MobileInstance]:
|
||||
"""
|
||||
Asynchronously 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 int area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param str contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param bool sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param bool mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param bool voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param bool exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param str near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param int distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param bool fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return [
|
||||
record
|
||||
async for record in await self.stream_async(
|
||||
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: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> MobilePage:
|
||||
"""
|
||||
Retrieve a single page of MobileInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of MobileInstance
|
||||
"""
|
||||
data = 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(method="GET", uri=self._uri, params=data)
|
||||
return MobilePage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> MobilePage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of MobileInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of MobileInstance
|
||||
"""
|
||||
data = 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 = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return MobilePage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> MobilePage:
|
||||
"""
|
||||
Retrieve a specific page of MobileInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of MobileInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return MobilePage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> MobilePage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of MobileInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of MobileInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return MobilePage(self._version, response, self._solution)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.MobileList>"
|
||||
+642
@@ -0,0 +1,642 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, values
|
||||
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.page import Page
|
||||
|
||||
|
||||
class NationalInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar friendly_name: A formatted version of the phone number.
|
||||
:ivar phone_number: The phone number in [E.164](https://www.twilio.com/docs/glossary/what-e164) format, which consists of a + followed by the country code and subscriber number.
|
||||
:ivar lata: The [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) of this phone number. Available for only phone numbers from the US and Canada.
|
||||
:ivar locality: The locality or city of this phone number's location.
|
||||
:ivar rate_center: The [rate center](https://en.wikipedia.org/wiki/Telephone_exchange) of this phone number. Available for only phone numbers from the US and Canada.
|
||||
:ivar latitude: The latitude of this phone number's location. Available for only phone numbers from the US and Canada.
|
||||
:ivar longitude: The longitude of this phone number's location. Available for only phone numbers from the US and Canada.
|
||||
:ivar region: The two-letter state or province abbreviation of this phone number's location. Available for only phone numbers from the US and Canada.
|
||||
:ivar postal_code: The postal or ZIP code of this phone number's location. Available for only phone numbers from the US and Canada.
|
||||
:ivar iso_country: The [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of this phone number.
|
||||
:ivar address_requirements: The type of [Address](https://www.twilio.com/docs/usage/api/address) resource the phone number requires. Can be: `none`, `any`, `local`, or `foreign`. `none` means no address is required. `any` means an address is required, but it can be anywhere in the world. `local` means an address in the phone number's country is required. `foreign` means an address outside of the phone number's country is required.
|
||||
:ivar beta: Whether the phone number is new to the Twilio platform. Can be: `true` or `false`.
|
||||
:ivar capabilities:
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
account_sid: str,
|
||||
country_code: str,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.friendly_name: Optional[str] = payload.get("friendly_name")
|
||||
self.phone_number: Optional[str] = payload.get("phone_number")
|
||||
self.lata: Optional[str] = payload.get("lata")
|
||||
self.locality: Optional[str] = payload.get("locality")
|
||||
self.rate_center: Optional[str] = payload.get("rate_center")
|
||||
self.latitude: Optional[float] = deserialize.decimal(payload.get("latitude"))
|
||||
self.longitude: Optional[float] = deserialize.decimal(payload.get("longitude"))
|
||||
self.region: Optional[str] = payload.get("region")
|
||||
self.postal_code: Optional[str] = payload.get("postal_code")
|
||||
self.iso_country: Optional[str] = payload.get("iso_country")
|
||||
self.address_requirements: Optional[str] = payload.get("address_requirements")
|
||||
self.beta: Optional[bool] = payload.get("beta")
|
||||
self.capabilities: Optional[str] = payload.get("capabilities")
|
||||
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"country_code": country_code,
|
||||
}
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.NationalInstance {}>".format(context)
|
||||
|
||||
|
||||
class NationalPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> NationalInstance:
|
||||
"""
|
||||
Build an instance of NationalInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return NationalInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
country_code=self._solution["country_code"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.NationalPage>"
|
||||
|
||||
|
||||
class NationalList(ListResource):
|
||||
def __init__(self, version: Version, account_sid: str, country_code: str):
|
||||
"""
|
||||
Initialize the NationalList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) requesting the AvailablePhoneNumber resources.
|
||||
:param country_code: The [ISO-3166-1](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code of the country from which to read phone numbers.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"country_code": country_code,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/AvailablePhoneNumbers/{country_code}/National.json".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[NationalInstance]:
|
||||
"""
|
||||
Streams NationalInstance records from the API as a generator stream.
|
||||
This operation lazily loads 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 area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param str contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param bool sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param bool mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param bool voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param bool exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param str near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param int distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param bool fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(
|
||||
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"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[NationalInstance]:
|
||||
"""
|
||||
Asynchronously streams NationalInstance records from the API as a generator stream.
|
||||
This operation lazily loads 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 area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param str contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param bool sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param bool mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param bool voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param bool exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param str near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param int distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param bool fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(
|
||||
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_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[NationalInstance]:
|
||||
"""
|
||||
Lists NationalInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param int area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param str contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param bool sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param bool mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param bool voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param bool exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param str near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param int distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param bool fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return list(
|
||||
self.stream(
|
||||
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,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[NationalInstance]:
|
||||
"""
|
||||
Asynchronously lists NationalInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param int area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param str contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param bool sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param bool mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param bool voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param bool exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param str near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param int distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param bool fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return [
|
||||
record
|
||||
async for record in await self.stream_async(
|
||||
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: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> NationalPage:
|
||||
"""
|
||||
Retrieve a single page of NationalInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of NationalInstance
|
||||
"""
|
||||
data = 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(method="GET", uri=self._uri, params=data)
|
||||
return NationalPage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> NationalPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of NationalInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of NationalInstance
|
||||
"""
|
||||
data = 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 = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return NationalPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> NationalPage:
|
||||
"""
|
||||
Retrieve a specific page of NationalInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of NationalInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return NationalPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> NationalPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of NationalInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of NationalInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return NationalPage(self._version, response, self._solution)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.NationalList>"
|
||||
+642
@@ -0,0 +1,642 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, values
|
||||
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.page import Page
|
||||
|
||||
|
||||
class SharedCostInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar friendly_name: A formatted version of the phone number.
|
||||
:ivar phone_number: The phone number in [E.164](https://www.twilio.com/docs/glossary/what-e164) format, which consists of a + followed by the country code and subscriber number.
|
||||
:ivar lata: The [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) of this phone number. Available for only phone numbers from the US and Canada.
|
||||
:ivar locality: The locality or city of this phone number's location.
|
||||
:ivar rate_center: The [rate center](https://en.wikipedia.org/wiki/Telephone_exchange) of this phone number. Available for only phone numbers from the US and Canada.
|
||||
:ivar latitude: The latitude of this phone number's location. Available for only phone numbers from the US and Canada.
|
||||
:ivar longitude: The longitude of this phone number's location. Available for only phone numbers from the US and Canada.
|
||||
:ivar region: The two-letter state or province abbreviation of this phone number's location. Available for only phone numbers from the US and Canada.
|
||||
:ivar postal_code: The postal or ZIP code of this phone number's location. Available for only phone numbers from the US and Canada.
|
||||
:ivar iso_country: The [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of this phone number.
|
||||
:ivar address_requirements: The type of [Address](https://www.twilio.com/docs/usage/api/address) resource the phone number requires. Can be: `none`, `any`, `local`, or `foreign`. `none` means no address is required. `any` means an address is required, but it can be anywhere in the world. `local` means an address in the phone number's country is required. `foreign` means an address outside of the phone number's country is required.
|
||||
:ivar beta: Whether the phone number is new to the Twilio platform. Can be: `true` or `false`.
|
||||
:ivar capabilities:
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
account_sid: str,
|
||||
country_code: str,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.friendly_name: Optional[str] = payload.get("friendly_name")
|
||||
self.phone_number: Optional[str] = payload.get("phone_number")
|
||||
self.lata: Optional[str] = payload.get("lata")
|
||||
self.locality: Optional[str] = payload.get("locality")
|
||||
self.rate_center: Optional[str] = payload.get("rate_center")
|
||||
self.latitude: Optional[float] = deserialize.decimal(payload.get("latitude"))
|
||||
self.longitude: Optional[float] = deserialize.decimal(payload.get("longitude"))
|
||||
self.region: Optional[str] = payload.get("region")
|
||||
self.postal_code: Optional[str] = payload.get("postal_code")
|
||||
self.iso_country: Optional[str] = payload.get("iso_country")
|
||||
self.address_requirements: Optional[str] = payload.get("address_requirements")
|
||||
self.beta: Optional[bool] = payload.get("beta")
|
||||
self.capabilities: Optional[str] = payload.get("capabilities")
|
||||
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"country_code": country_code,
|
||||
}
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.SharedCostInstance {}>".format(context)
|
||||
|
||||
|
||||
class SharedCostPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> SharedCostInstance:
|
||||
"""
|
||||
Build an instance of SharedCostInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return SharedCostInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
country_code=self._solution["country_code"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.SharedCostPage>"
|
||||
|
||||
|
||||
class SharedCostList(ListResource):
|
||||
def __init__(self, version: Version, account_sid: str, country_code: str):
|
||||
"""
|
||||
Initialize the SharedCostList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) requesting the AvailablePhoneNumber resources.
|
||||
:param country_code: The [ISO-3166-1](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code of the country from which to read phone numbers.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"country_code": country_code,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/AvailablePhoneNumbers/{country_code}/SharedCost.json".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[SharedCostInstance]:
|
||||
"""
|
||||
Streams SharedCostInstance records from the API as a generator stream.
|
||||
This operation lazily loads 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 area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param str contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param bool sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param bool mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param bool voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param bool exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param str near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param int distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param bool fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(
|
||||
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"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[SharedCostInstance]:
|
||||
"""
|
||||
Asynchronously streams SharedCostInstance records from the API as a generator stream.
|
||||
This operation lazily loads 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 area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param str contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param bool sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param bool mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param bool voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param bool exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param str near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param int distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param bool fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(
|
||||
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_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[SharedCostInstance]:
|
||||
"""
|
||||
Lists SharedCostInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param int area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param str contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param bool sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param bool mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param bool voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param bool exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param str near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param int distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param bool fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return list(
|
||||
self.stream(
|
||||
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,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[SharedCostInstance]:
|
||||
"""
|
||||
Asynchronously lists SharedCostInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param int area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param str contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param bool sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param bool mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param bool voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param bool exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param str near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param int distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param bool fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return [
|
||||
record
|
||||
async for record in await self.stream_async(
|
||||
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: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> SharedCostPage:
|
||||
"""
|
||||
Retrieve a single page of SharedCostInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of SharedCostInstance
|
||||
"""
|
||||
data = 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(method="GET", uri=self._uri, params=data)
|
||||
return SharedCostPage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> SharedCostPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of SharedCostInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of SharedCostInstance
|
||||
"""
|
||||
data = 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 = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return SharedCostPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> SharedCostPage:
|
||||
"""
|
||||
Retrieve a specific page of SharedCostInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of SharedCostInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return SharedCostPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> SharedCostPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of SharedCostInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of SharedCostInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return SharedCostPage(self._version, response, self._solution)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.SharedCostList>"
|
||||
+642
@@ -0,0 +1,642 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, values
|
||||
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.page import Page
|
||||
|
||||
|
||||
class TollFreeInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar friendly_name: A formatted version of the phone number.
|
||||
:ivar phone_number: The phone number in [E.164](https://www.twilio.com/docs/glossary/what-e164) format, which consists of a + followed by the country code and subscriber number.
|
||||
:ivar lata: The [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) of this phone number. Available for only phone numbers from the US and Canada.
|
||||
:ivar locality: The locality or city of this phone number's location.
|
||||
:ivar rate_center: The [rate center](https://en.wikipedia.org/wiki/Telephone_exchange) of this phone number. Available for only phone numbers from the US and Canada.
|
||||
:ivar latitude: The latitude of this phone number's location. Available for only phone numbers from the US and Canada.
|
||||
:ivar longitude: The longitude of this phone number's location. Available for only phone numbers from the US and Canada.
|
||||
:ivar region: The two-letter state or province abbreviation of this phone number's location. Available for only phone numbers from the US and Canada.
|
||||
:ivar postal_code: The postal or ZIP code of this phone number's location. Available for only phone numbers from the US and Canada.
|
||||
:ivar iso_country: The [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of this phone number.
|
||||
:ivar address_requirements: The type of [Address](https://www.twilio.com/docs/usage/api/address) resource the phone number requires. Can be: `none`, `any`, `local`, or `foreign`. `none` means no address is required. `any` means an address is required, but it can be anywhere in the world. `local` means an address in the phone number's country is required. `foreign` means an address outside of the phone number's country is required.
|
||||
:ivar beta: Whether the phone number is new to the Twilio platform. Can be: `true` or `false`.
|
||||
:ivar capabilities:
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
account_sid: str,
|
||||
country_code: str,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.friendly_name: Optional[str] = payload.get("friendly_name")
|
||||
self.phone_number: Optional[str] = payload.get("phone_number")
|
||||
self.lata: Optional[str] = payload.get("lata")
|
||||
self.locality: Optional[str] = payload.get("locality")
|
||||
self.rate_center: Optional[str] = payload.get("rate_center")
|
||||
self.latitude: Optional[float] = deserialize.decimal(payload.get("latitude"))
|
||||
self.longitude: Optional[float] = deserialize.decimal(payload.get("longitude"))
|
||||
self.region: Optional[str] = payload.get("region")
|
||||
self.postal_code: Optional[str] = payload.get("postal_code")
|
||||
self.iso_country: Optional[str] = payload.get("iso_country")
|
||||
self.address_requirements: Optional[str] = payload.get("address_requirements")
|
||||
self.beta: Optional[bool] = payload.get("beta")
|
||||
self.capabilities: Optional[str] = payload.get("capabilities")
|
||||
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"country_code": country_code,
|
||||
}
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.TollFreeInstance {}>".format(context)
|
||||
|
||||
|
||||
class TollFreePage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> TollFreeInstance:
|
||||
"""
|
||||
Build an instance of TollFreeInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return TollFreeInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
country_code=self._solution["country_code"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.TollFreePage>"
|
||||
|
||||
|
||||
class TollFreeList(ListResource):
|
||||
def __init__(self, version: Version, account_sid: str, country_code: str):
|
||||
"""
|
||||
Initialize the TollFreeList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) requesting the AvailablePhoneNumber resources.
|
||||
:param country_code: The [ISO-3166-1](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code of the country from which to read phone numbers.
|
||||
|
||||
"""
|
||||
super().__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: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[TollFreeInstance]:
|
||||
"""
|
||||
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 int area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param str contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param bool sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param bool mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param bool voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param bool exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param str near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param int distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param bool fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(
|
||||
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"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[TollFreeInstance]:
|
||||
"""
|
||||
Asynchronously 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 int area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param str contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param bool sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param bool mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param bool voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param bool exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param str near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param int distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param bool fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(
|
||||
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_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[TollFreeInstance]:
|
||||
"""
|
||||
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 int area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param str contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param bool sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param bool mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param bool voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param bool exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param str near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param int distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param bool fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return list(
|
||||
self.stream(
|
||||
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,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[TollFreeInstance]:
|
||||
"""
|
||||
Asynchronously 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 int area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param str contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param bool sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param bool mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param bool voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param bool exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param str near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param int distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param bool fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return [
|
||||
record
|
||||
async for record in await self.stream_async(
|
||||
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: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> TollFreePage:
|
||||
"""
|
||||
Retrieve a single page of TollFreeInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of TollFreeInstance
|
||||
"""
|
||||
data = 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(method="GET", uri=self._uri, params=data)
|
||||
return TollFreePage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> TollFreePage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of TollFreeInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of TollFreeInstance
|
||||
"""
|
||||
data = 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 = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return TollFreePage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> TollFreePage:
|
||||
"""
|
||||
Retrieve a specific page of TollFreeInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of TollFreeInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return TollFreePage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> TollFreePage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of TollFreeInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of TollFreeInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return TollFreePage(self._version, response, self._solution)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.TollFreeList>"
|
||||
+642
@@ -0,0 +1,642 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, values
|
||||
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.page import Page
|
||||
|
||||
|
||||
class VoipInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar friendly_name: A formatted version of the phone number.
|
||||
:ivar phone_number: The phone number in [E.164](https://www.twilio.com/docs/glossary/what-e164) format, which consists of a + followed by the country code and subscriber number.
|
||||
:ivar lata: The [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) of this phone number. Available for only phone numbers from the US and Canada.
|
||||
:ivar locality: The locality or city of this phone number's location.
|
||||
:ivar rate_center: The [rate center](https://en.wikipedia.org/wiki/Telephone_exchange) of this phone number. Available for only phone numbers from the US and Canada.
|
||||
:ivar latitude: The latitude of this phone number's location. Available for only phone numbers from the US and Canada.
|
||||
:ivar longitude: The longitude of this phone number's location. Available for only phone numbers from the US and Canada.
|
||||
:ivar region: The two-letter state or province abbreviation of this phone number's location. Available for only phone numbers from the US and Canada.
|
||||
:ivar postal_code: The postal or ZIP code of this phone number's location. Available for only phone numbers from the US and Canada.
|
||||
:ivar iso_country: The [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of this phone number.
|
||||
:ivar address_requirements: The type of [Address](https://www.twilio.com/docs/usage/api/address) resource the phone number requires. Can be: `none`, `any`, `local`, or `foreign`. `none` means no address is required. `any` means an address is required, but it can be anywhere in the world. `local` means an address in the phone number's country is required. `foreign` means an address outside of the phone number's country is required.
|
||||
:ivar beta: Whether the phone number is new to the Twilio platform. Can be: `true` or `false`.
|
||||
:ivar capabilities:
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
account_sid: str,
|
||||
country_code: str,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.friendly_name: Optional[str] = payload.get("friendly_name")
|
||||
self.phone_number: Optional[str] = payload.get("phone_number")
|
||||
self.lata: Optional[str] = payload.get("lata")
|
||||
self.locality: Optional[str] = payload.get("locality")
|
||||
self.rate_center: Optional[str] = payload.get("rate_center")
|
||||
self.latitude: Optional[float] = deserialize.decimal(payload.get("latitude"))
|
||||
self.longitude: Optional[float] = deserialize.decimal(payload.get("longitude"))
|
||||
self.region: Optional[str] = payload.get("region")
|
||||
self.postal_code: Optional[str] = payload.get("postal_code")
|
||||
self.iso_country: Optional[str] = payload.get("iso_country")
|
||||
self.address_requirements: Optional[str] = payload.get("address_requirements")
|
||||
self.beta: Optional[bool] = payload.get("beta")
|
||||
self.capabilities: Optional[str] = payload.get("capabilities")
|
||||
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"country_code": country_code,
|
||||
}
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.VoipInstance {}>".format(context)
|
||||
|
||||
|
||||
class VoipPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> VoipInstance:
|
||||
"""
|
||||
Build an instance of VoipInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return VoipInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
country_code=self._solution["country_code"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.VoipPage>"
|
||||
|
||||
|
||||
class VoipList(ListResource):
|
||||
def __init__(self, version: Version, account_sid: str, country_code: str):
|
||||
"""
|
||||
Initialize the VoipList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) requesting the AvailablePhoneNumber resources.
|
||||
:param country_code: The [ISO-3166-1](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code of the country from which to read phone numbers.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"country_code": country_code,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/AvailablePhoneNumbers/{country_code}/Voip.json".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[VoipInstance]:
|
||||
"""
|
||||
Streams VoipInstance records from the API as a generator stream.
|
||||
This operation lazily loads 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 area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param str contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param bool sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param bool mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param bool voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param bool exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param str near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param int distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param bool fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(
|
||||
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"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[VoipInstance]:
|
||||
"""
|
||||
Asynchronously streams VoipInstance records from the API as a generator stream.
|
||||
This operation lazily loads 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 area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param str contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param bool sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param bool mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param bool voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param bool exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param str near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param int distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param bool fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(
|
||||
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_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[VoipInstance]:
|
||||
"""
|
||||
Lists VoipInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param int area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param str contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param bool sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param bool mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param bool voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param bool exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param str near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param int distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param bool fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return list(
|
||||
self.stream(
|
||||
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,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[VoipInstance]:
|
||||
"""
|
||||
Asynchronously lists VoipInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param int area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param str contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param bool sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param bool mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param bool voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param bool exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param str near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param int distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param bool fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return [
|
||||
record
|
||||
async for record in await self.stream_async(
|
||||
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: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> VoipPage:
|
||||
"""
|
||||
Retrieve a single page of VoipInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of VoipInstance
|
||||
"""
|
||||
data = 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(method="GET", uri=self._uri, params=data)
|
||||
return VoipPage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> VoipPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of VoipInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of VoipInstance
|
||||
"""
|
||||
data = 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 = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return VoipPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> VoipPage:
|
||||
"""
|
||||
Retrieve a specific page of VoipInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of VoipInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return VoipPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> VoipPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of VoipInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of VoipInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return VoipPage(self._version, response, self._solution)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.VoipList>"
|
||||
@@ -0,0 +1,99 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from typing import Any, Dict, Optional
|
||||
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
|
||||
|
||||
class BalanceInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar account_sid: The unique SID identifier of the Account.
|
||||
:ivar balance: The balance of the Account, in units specified by the unit parameter. Balance changes may not be reflected immediately. Child accounts do not contain balance information
|
||||
:ivar currency: The units of currency for the account balance
|
||||
"""
|
||||
|
||||
def __init__(self, version: Version, payload: Dict[str, Any], account_sid: str):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.balance: Optional[str] = payload.get("balance")
|
||||
self.currency: Optional[str] = payload.get("currency")
|
||||
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
}
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.BalanceInstance {}>".format(context)
|
||||
|
||||
|
||||
class BalanceList(ListResource):
|
||||
def __init__(self, version: Version, account_sid: str):
|
||||
"""
|
||||
Initialize the BalanceList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The unique SID identifier of the Account.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/Balance.json".format(**self._solution)
|
||||
|
||||
def fetch(self) -> BalanceInstance:
|
||||
"""
|
||||
Asynchronously fetch the BalanceInstance
|
||||
|
||||
:returns: The fetched BalanceInstance
|
||||
"""
|
||||
payload = self._version.fetch(method="GET", uri=self._uri)
|
||||
|
||||
return BalanceInstance(
|
||||
self._version, payload, account_sid=self._solution["account_sid"]
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> BalanceInstance:
|
||||
"""
|
||||
Asynchronously fetch the BalanceInstance
|
||||
|
||||
:returns: The fetched BalanceInstance
|
||||
"""
|
||||
payload = await self._version.fetch_async(method="GET", uri=self._uri)
|
||||
|
||||
return BalanceInstance(
|
||||
self._version, payload, account_sid=self._solution["account_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.BalanceList>"
|
||||
File diff suppressed because it is too large
Load Diff
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -0,0 +1,288 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import values
|
||||
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.page import Page
|
||||
|
||||
|
||||
class EventInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar request: Contains a dictionary representing the request of the call.
|
||||
:ivar response: Contains a dictionary representing the call response, including a list of the call events.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self, version: Version, payload: Dict[str, Any], account_sid: str, call_sid: str
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.request: Optional[Dict[str, object]] = payload.get("request")
|
||||
self.response: Optional[Dict[str, object]] = payload.get("response")
|
||||
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"call_sid": call_sid,
|
||||
}
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.EventInstance {}>".format(context)
|
||||
|
||||
|
||||
class EventPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> EventInstance:
|
||||
"""
|
||||
Build an instance of EventInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return EventInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.EventPage>"
|
||||
|
||||
|
||||
class EventList(ListResource):
|
||||
def __init__(self, version: Version, account_sid: str, call_sid: str):
|
||||
"""
|
||||
Initialize the EventList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The unique SID identifier of the Account.
|
||||
:param call_sid: The unique SID identifier of the Call.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"call_sid": call_sid,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/Calls/{call_sid}/Events.json".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[EventInstance]:
|
||||
"""
|
||||
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 limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[EventInstance]:
|
||||
"""
|
||||
Asynchronously 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 limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[EventInstance]:
|
||||
"""
|
||||
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 limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return list(
|
||||
self.stream(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[EventInstance]:
|
||||
"""
|
||||
Asynchronously 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 limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return [
|
||||
record
|
||||
async for record in await self.stream_async(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> EventPage:
|
||||
"""
|
||||
Retrieve a single page of EventInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of EventInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return EventPage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> EventPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of EventInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of EventInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return EventPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> EventPage:
|
||||
"""
|
||||
Retrieve a specific page of EventInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of EventInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return EventPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> EventPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of EventInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of EventInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return EventPage(self._version, response, self._solution)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.EventList>"
|
||||
@@ -0,0 +1,331 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Union
|
||||
from twilio.base import deserialize, serialize, values
|
||||
from twilio.base.instance_context import InstanceContext
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
|
||||
|
||||
class FeedbackInstance(InstanceResource):
|
||||
class Issues(object):
|
||||
AUDIO_LATENCY = "audio-latency"
|
||||
DIGITS_NOT_CAPTURED = "digits-not-captured"
|
||||
DROPPED_CALL = "dropped-call"
|
||||
IMPERFECT_AUDIO = "imperfect-audio"
|
||||
INCORRECT_CALLER_ID = "incorrect-caller-id"
|
||||
ONE_WAY_AUDIO = "one-way-audio"
|
||||
POST_DIAL_DELAY = "post-dial-delay"
|
||||
UNSOLICITED_CALL = "unsolicited-call"
|
||||
|
||||
"""
|
||||
:ivar account_sid: The unique id of the [Account](https://www.twilio.com/docs/iam/api/account) responsible for this resource.
|
||||
:ivar date_created: The date that this resource was created, given in [RFC 2822](https://www.php.net/manual/en/class.datetime.php#datetime.constants.rfc2822) format.
|
||||
:ivar date_updated: The date that this resource was last updated, given in [RFC 2822](https://www.php.net/manual/en/class.datetime.php#datetime.constants.rfc2822) format.
|
||||
:ivar issues: A list of issues experienced during the call. The issues can be: `imperfect-audio`, `dropped-call`, `incorrect-caller-id`, `post-dial-delay`, `digits-not-captured`, `audio-latency`, `unsolicited-call`, or `one-way-audio`.
|
||||
:ivar quality_score: `1` to `5` quality score where `1` represents imperfect experience and `5` represents a perfect call.
|
||||
:ivar sid: A 34 character string that uniquely identifies this resource.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self, version: Version, payload: Dict[str, Any], account_sid: str, call_sid: str
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.date_created: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.issues: Optional[List["FeedbackInstance.Issues"]] = payload.get("issues")
|
||||
self.quality_score: Optional[int] = deserialize.integer(
|
||||
payload.get("quality_score")
|
||||
)
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"call_sid": call_sid,
|
||||
}
|
||||
self._context: Optional[FeedbackContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "FeedbackContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: FeedbackContext for this FeedbackInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = FeedbackContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def fetch(self) -> "FeedbackInstance":
|
||||
"""
|
||||
Fetch the FeedbackInstance
|
||||
|
||||
|
||||
:returns: The fetched FeedbackInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "FeedbackInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the FeedbackInstance
|
||||
|
||||
|
||||
:returns: The fetched FeedbackInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self,
|
||||
quality_score: Union[int, object] = values.unset,
|
||||
issue: Union[List["FeedbackInstance.Issues"], object] = values.unset,
|
||||
) -> "FeedbackInstance":
|
||||
"""
|
||||
Update the FeedbackInstance
|
||||
|
||||
:param quality_score: The call quality expressed as an integer from `1` to `5` where `1` represents very poor call quality and `5` represents a perfect call.
|
||||
:param issue: One or more issues experienced during the call. The issues can be: `imperfect-audio`, `dropped-call`, `incorrect-caller-id`, `post-dial-delay`, `digits-not-captured`, `audio-latency`, `unsolicited-call`, or `one-way-audio`.
|
||||
|
||||
:returns: The updated FeedbackInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
quality_score=quality_score,
|
||||
issue=issue,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
quality_score: Union[int, object] = values.unset,
|
||||
issue: Union[List["FeedbackInstance.Issues"], object] = values.unset,
|
||||
) -> "FeedbackInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the FeedbackInstance
|
||||
|
||||
:param quality_score: The call quality expressed as an integer from `1` to `5` where `1` represents very poor call quality and `5` represents a perfect call.
|
||||
:param issue: One or more issues experienced during the call. The issues can be: `imperfect-audio`, `dropped-call`, `incorrect-caller-id`, `post-dial-delay`, `digits-not-captured`, `audio-latency`, `unsolicited-call`, or `one-way-audio`.
|
||||
|
||||
:returns: The updated FeedbackInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
quality_score=quality_score,
|
||||
issue=issue,
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.FeedbackInstance {}>".format(context)
|
||||
|
||||
|
||||
class FeedbackContext(InstanceContext):
|
||||
def __init__(self, version: Version, account_sid: str, call_sid: str):
|
||||
"""
|
||||
Initialize the FeedbackContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The unique id of the [Account](https://www.twilio.com/docs/iam/api/account) responsible for this resource.
|
||||
:param call_sid: The call sid that uniquely identifies the call
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"call_sid": call_sid,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/Calls/{call_sid}/Feedback.json".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def fetch(self) -> FeedbackInstance:
|
||||
"""
|
||||
Fetch the FeedbackInstance
|
||||
|
||||
|
||||
:returns: The fetched FeedbackInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return FeedbackInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> FeedbackInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the FeedbackInstance
|
||||
|
||||
|
||||
:returns: The fetched FeedbackInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return FeedbackInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self,
|
||||
quality_score: Union[int, object] = values.unset,
|
||||
issue: Union[List["FeedbackInstance.Issues"], object] = values.unset,
|
||||
) -> FeedbackInstance:
|
||||
"""
|
||||
Update the FeedbackInstance
|
||||
|
||||
:param quality_score: The call quality expressed as an integer from `1` to `5` where `1` represents very poor call quality and `5` represents a perfect call.
|
||||
:param issue: One or more issues experienced during the call. The issues can be: `imperfect-audio`, `dropped-call`, `incorrect-caller-id`, `post-dial-delay`, `digits-not-captured`, `audio-latency`, `unsolicited-call`, or `one-way-audio`.
|
||||
|
||||
:returns: The updated FeedbackInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"QualityScore": quality_score,
|
||||
"Issue": serialize.map(issue, lambda e: e),
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return FeedbackInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
quality_score: Union[int, object] = values.unset,
|
||||
issue: Union[List["FeedbackInstance.Issues"], object] = values.unset,
|
||||
) -> FeedbackInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the FeedbackInstance
|
||||
|
||||
:param quality_score: The call quality expressed as an integer from `1` to `5` where `1` represents very poor call quality and `5` represents a perfect call.
|
||||
:param issue: One or more issues experienced during the call. The issues can be: `imperfect-audio`, `dropped-call`, `incorrect-caller-id`, `post-dial-delay`, `digits-not-captured`, `audio-latency`, `unsolicited-call`, or `one-way-audio`.
|
||||
|
||||
:returns: The updated FeedbackInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"QualityScore": quality_score,
|
||||
"Issue": serialize.map(issue, lambda e: e),
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return FeedbackInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.FeedbackContext {}>".format(context)
|
||||
|
||||
|
||||
class FeedbackList(ListResource):
|
||||
def __init__(self, version: Version, account_sid: str, call_sid: str):
|
||||
"""
|
||||
Initialize the FeedbackList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The unique id of the [Account](https://www.twilio.com/docs/iam/api/account) responsible for this resource.
|
||||
:param call_sid: The call sid that uniquely identifies the call
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"call_sid": call_sid,
|
||||
}
|
||||
|
||||
def get(self) -> FeedbackContext:
|
||||
"""
|
||||
Constructs a FeedbackContext
|
||||
|
||||
"""
|
||||
return FeedbackContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
)
|
||||
|
||||
def __call__(self) -> FeedbackContext:
|
||||
"""
|
||||
Constructs a FeedbackContext
|
||||
|
||||
"""
|
||||
return FeedbackContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.FeedbackList>"
|
||||
+374
@@ -0,0 +1,374 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from datetime import date, datetime
|
||||
from typing import Any, Dict, List, Optional, Union
|
||||
from twilio.base import deserialize, serialize, values
|
||||
from twilio.base.instance_context import InstanceContext
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
|
||||
|
||||
class FeedbackSummaryInstance(InstanceResource):
|
||||
class Status(object):
|
||||
QUEUED = "queued"
|
||||
IN_PROGRESS = "in-progress"
|
||||
COMPLETED = "completed"
|
||||
FAILED = "failed"
|
||||
|
||||
"""
|
||||
:ivar account_sid: The unique id of the [Account](https://www.twilio.com/docs/iam/api/account) responsible for this resource.
|
||||
:ivar call_count: The total number of calls.
|
||||
:ivar call_feedback_count: The total number of calls with a feedback entry.
|
||||
:ivar date_created: The date that this resource was created, given in [RFC 2822](https://www.php.net/manual/en/class.datetime.php#datetime.constants.rfc2822) format.
|
||||
:ivar date_updated: The date that this resource was last updated, given in [RFC 2822](https://www.php.net/manual/en/class.datetime.php#datetime.constants.rfc2822) format.
|
||||
:ivar end_date: The last date for which feedback entries are included in this Feedback Summary, formatted as `YYYY-MM-DD` and specified in UTC.
|
||||
:ivar include_subaccounts: Whether the feedback summary includes subaccounts; `true` if it does, otherwise `false`.
|
||||
:ivar issues: A list of issues experienced during the call. The issues can be: `imperfect-audio`, `dropped-call`, `incorrect-caller-id`, `post-dial-delay`, `digits-not-captured`, `audio-latency`, or `one-way-audio`.
|
||||
:ivar quality_score_average: The average QualityScore of the feedback entries.
|
||||
:ivar quality_score_median: The median QualityScore of the feedback entries.
|
||||
:ivar quality_score_standard_deviation: The standard deviation of the quality scores.
|
||||
:ivar sid: A 34 character string that uniquely identifies this resource.
|
||||
:ivar start_date: The first date for which feedback entries are included in this feedback summary, formatted as `YYYY-MM-DD` and specified in UTC.
|
||||
:ivar status:
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
account_sid: str,
|
||||
sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.call_count: Optional[int] = deserialize.integer(payload.get("call_count"))
|
||||
self.call_feedback_count: Optional[int] = deserialize.integer(
|
||||
payload.get("call_feedback_count")
|
||||
)
|
||||
self.date_created: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.end_date: Optional[date] = deserialize.iso8601_date(
|
||||
payload.get("end_date")
|
||||
)
|
||||
self.include_subaccounts: Optional[bool] = payload.get("include_subaccounts")
|
||||
self.issues: Optional[List[object]] = payload.get("issues")
|
||||
self.quality_score_average: Optional[float] = deserialize.decimal(
|
||||
payload.get("quality_score_average")
|
||||
)
|
||||
self.quality_score_median: Optional[float] = deserialize.decimal(
|
||||
payload.get("quality_score_median")
|
||||
)
|
||||
self.quality_score_standard_deviation: Optional[float] = deserialize.decimal(
|
||||
payload.get("quality_score_standard_deviation")
|
||||
)
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.start_date: Optional[date] = deserialize.iso8601_date(
|
||||
payload.get("start_date")
|
||||
)
|
||||
self.status: Optional["FeedbackSummaryInstance.Status"] = payload.get("status")
|
||||
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[FeedbackSummaryContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "FeedbackSummaryContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: FeedbackSummaryContext for this FeedbackSummaryInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = FeedbackSummaryContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the FeedbackSummaryInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the FeedbackSummaryInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
def fetch(self) -> "FeedbackSummaryInstance":
|
||||
"""
|
||||
Fetch the FeedbackSummaryInstance
|
||||
|
||||
|
||||
:returns: The fetched FeedbackSummaryInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "FeedbackSummaryInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the FeedbackSummaryInstance
|
||||
|
||||
|
||||
:returns: The fetched FeedbackSummaryInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.FeedbackSummaryInstance {}>".format(context)
|
||||
|
||||
|
||||
class FeedbackSummaryContext(InstanceContext):
|
||||
def __init__(self, version: Version, account_sid: str, sid: str):
|
||||
"""
|
||||
Initialize the FeedbackSummaryContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The unique id of the [Account](https://www.twilio.com/docs/iam/api/account) responsible for this resource.
|
||||
:param sid: A 34 character string that uniquely identifies this resource.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/Calls/FeedbackSummary/{sid}.json".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the FeedbackSummaryInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._version.delete(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the FeedbackSummaryInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
def fetch(self) -> FeedbackSummaryInstance:
|
||||
"""
|
||||
Fetch the FeedbackSummaryInstance
|
||||
|
||||
|
||||
:returns: The fetched FeedbackSummaryInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return FeedbackSummaryInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> FeedbackSummaryInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the FeedbackSummaryInstance
|
||||
|
||||
|
||||
:returns: The fetched FeedbackSummaryInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return FeedbackSummaryInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.FeedbackSummaryContext {}>".format(context)
|
||||
|
||||
|
||||
class FeedbackSummaryList(ListResource):
|
||||
def __init__(self, version: Version, account_sid: str):
|
||||
"""
|
||||
Initialize the FeedbackSummaryList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The unique id of the [Account](https://www.twilio.com/docs/iam/api/account) responsible for this resource.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/Calls/FeedbackSummary.json".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def create(
|
||||
self,
|
||||
start_date: date,
|
||||
end_date: date,
|
||||
include_subaccounts: Union[bool, object] = values.unset,
|
||||
status_callback: Union[str, object] = values.unset,
|
||||
status_callback_method: Union[str, object] = values.unset,
|
||||
) -> FeedbackSummaryInstance:
|
||||
"""
|
||||
Create the FeedbackSummaryInstance
|
||||
|
||||
:param start_date: Only include feedback given on or after this date. Format is `YYYY-MM-DD` and specified in UTC.
|
||||
:param end_date: Only include feedback given on or before this date. Format is `YYYY-MM-DD` and specified in UTC.
|
||||
:param include_subaccounts: Whether to also include Feedback resources from all subaccounts. `true` includes feedback from all subaccounts and `false`, the default, includes feedback from only the specified account.
|
||||
:param status_callback: The URL that we will request when the feedback summary is complete.
|
||||
:param status_callback_method: The HTTP method (`GET` or `POST`) we use to make the request to the `StatusCallback` URL.
|
||||
|
||||
:returns: The created FeedbackSummaryInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"StartDate": serialize.iso8601_date(start_date),
|
||||
"EndDate": serialize.iso8601_date(end_date),
|
||||
"IncludeSubaccounts": include_subaccounts,
|
||||
"StatusCallback": status_callback,
|
||||
"StatusCallbackMethod": status_callback_method,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return FeedbackSummaryInstance(
|
||||
self._version, payload, account_sid=self._solution["account_sid"]
|
||||
)
|
||||
|
||||
async def create_async(
|
||||
self,
|
||||
start_date: date,
|
||||
end_date: date,
|
||||
include_subaccounts: Union[bool, object] = values.unset,
|
||||
status_callback: Union[str, object] = values.unset,
|
||||
status_callback_method: Union[str, object] = values.unset,
|
||||
) -> FeedbackSummaryInstance:
|
||||
"""
|
||||
Asynchronously create the FeedbackSummaryInstance
|
||||
|
||||
:param start_date: Only include feedback given on or after this date. Format is `YYYY-MM-DD` and specified in UTC.
|
||||
:param end_date: Only include feedback given on or before this date. Format is `YYYY-MM-DD` and specified in UTC.
|
||||
:param include_subaccounts: Whether to also include Feedback resources from all subaccounts. `true` includes feedback from all subaccounts and `false`, the default, includes feedback from only the specified account.
|
||||
:param status_callback: The URL that we will request when the feedback summary is complete.
|
||||
:param status_callback_method: The HTTP method (`GET` or `POST`) we use to make the request to the `StatusCallback` URL.
|
||||
|
||||
:returns: The created FeedbackSummaryInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"StartDate": serialize.iso8601_date(start_date),
|
||||
"EndDate": serialize.iso8601_date(end_date),
|
||||
"IncludeSubaccounts": include_subaccounts,
|
||||
"StatusCallback": status_callback,
|
||||
"StatusCallbackMethod": status_callback_method,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return FeedbackSummaryInstance(
|
||||
self._version, payload, account_sid=self._solution["account_sid"]
|
||||
)
|
||||
|
||||
def get(self, sid: str) -> FeedbackSummaryContext:
|
||||
"""
|
||||
Constructs a FeedbackSummaryContext
|
||||
|
||||
:param sid: A 34 character string that uniquely identifies this resource.
|
||||
"""
|
||||
return FeedbackSummaryContext(
|
||||
self._version, account_sid=self._solution["account_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> FeedbackSummaryContext:
|
||||
"""
|
||||
Constructs a FeedbackSummaryContext
|
||||
|
||||
:param sid: A 34 character string that uniquely identifies this resource.
|
||||
"""
|
||||
return FeedbackSummaryContext(
|
||||
self._version, account_sid=self._solution["account_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.FeedbackSummaryList>"
|
||||
@@ -0,0 +1,547 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from datetime import date, datetime
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, serialize, values
|
||||
from twilio.base.instance_context import InstanceContext
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.page import Page
|
||||
|
||||
|
||||
class NotificationInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Call Notification resource.
|
||||
:ivar api_version: The API version used to create the Call Notification resource.
|
||||
:ivar call_sid: The SID of the [Call](https://www.twilio.com/docs/voice/api/call-resource) the Call Notification resource is associated with.
|
||||
:ivar date_created: The date and time in GMT that the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar date_updated: The date and time in GMT that the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar error_code: A unique error code for the error condition that is described in our [Error Dictionary](https://www.twilio.com/docs/api/errors).
|
||||
:ivar log: An integer log level that corresponds to the type of notification: `0` is ERROR, `1` is WARNING.
|
||||
:ivar message_date: The date the notification was actually generated in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. Message buffering can cause this value to differ from `date_created`.
|
||||
:ivar message_text: The text of the notification.
|
||||
:ivar more_info: The URL for more information about the error condition. This value is a page in our [Error Dictionary](https://www.twilio.com/docs/api/errors).
|
||||
:ivar request_method: The HTTP method used to generate the notification. If the notification was generated during a phone call, this is the HTTP Method used to request the resource on your server. If the notification was generated by your use of our REST API, this is the HTTP method used to call the resource on our servers.
|
||||
:ivar request_url: The URL of the resource that generated the notification. If the notification was generated during a phone call, this is the URL of the resource on your server that caused the notification. If the notification was generated by your use of our REST API, this is the URL of the resource you called.
|
||||
:ivar request_variables: The HTTP GET or POST variables we sent to your server. However, if the notification was generated by our REST API, this contains the HTTP POST or PUT variables you sent to our API.
|
||||
:ivar response_body: The HTTP body returned by your server.
|
||||
:ivar response_headers: The HTTP headers returned by your server.
|
||||
:ivar sid: The unique string that that we created to identify the Call Notification resource.
|
||||
:ivar uri: The URI of the resource, relative to `https://api.twilio.com`.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
account_sid: str,
|
||||
call_sid: str,
|
||||
sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.api_version: Optional[str] = payload.get("api_version")
|
||||
self.call_sid: Optional[str] = payload.get("call_sid")
|
||||
self.date_created: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.error_code: Optional[str] = payload.get("error_code")
|
||||
self.log: Optional[str] = payload.get("log")
|
||||
self.message_date: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("message_date")
|
||||
)
|
||||
self.message_text: Optional[str] = payload.get("message_text")
|
||||
self.more_info: Optional[str] = payload.get("more_info")
|
||||
self.request_method: Optional[str] = payload.get("request_method")
|
||||
self.request_url: Optional[str] = payload.get("request_url")
|
||||
self.request_variables: Optional[str] = payload.get("request_variables")
|
||||
self.response_body: Optional[str] = payload.get("response_body")
|
||||
self.response_headers: Optional[str] = payload.get("response_headers")
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.uri: Optional[str] = payload.get("uri")
|
||||
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"call_sid": call_sid,
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[NotificationContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "NotificationContext":
|
||||
"""
|
||||
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
|
||||
"""
|
||||
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
|
||||
|
||||
def fetch(self) -> "NotificationInstance":
|
||||
"""
|
||||
Fetch the NotificationInstance
|
||||
|
||||
|
||||
:returns: The fetched NotificationInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "NotificationInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the NotificationInstance
|
||||
|
||||
|
||||
:returns: The fetched NotificationInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.NotificationInstance {}>".format(context)
|
||||
|
||||
|
||||
class NotificationContext(InstanceContext):
|
||||
def __init__(self, version: Version, account_sid: str, call_sid: str, sid: str):
|
||||
"""
|
||||
Initialize the NotificationContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Call Notification resource to fetch.
|
||||
:param call_sid: The [Call](https://www.twilio.com/docs/voice/api/call-resource) SID of the Call Notification resource to fetch.
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Call Notification resource to fetch.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"call_sid": call_sid,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = (
|
||||
"/Accounts/{account_sid}/Calls/{call_sid}/Notifications/{sid}.json".format(
|
||||
**self._solution
|
||||
)
|
||||
)
|
||||
|
||||
def fetch(self) -> NotificationInstance:
|
||||
"""
|
||||
Fetch the NotificationInstance
|
||||
|
||||
|
||||
:returns: The fetched NotificationInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return NotificationInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> NotificationInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the NotificationInstance
|
||||
|
||||
|
||||
:returns: The fetched NotificationInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return NotificationInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.NotificationContext {}>".format(context)
|
||||
|
||||
|
||||
class NotificationPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> NotificationInstance:
|
||||
"""
|
||||
Build an instance of NotificationInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return NotificationInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.NotificationPage>"
|
||||
|
||||
|
||||
class NotificationList(ListResource):
|
||||
def __init__(self, version: Version, account_sid: str, call_sid: str):
|
||||
"""
|
||||
Initialize the NotificationList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Call Notification resources to read.
|
||||
:param call_sid: The [Call](https://www.twilio.com/docs/voice/api/call-resource) SID of the Call Notification resources to read.
|
||||
|
||||
"""
|
||||
super().__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: Union[int, object] = values.unset,
|
||||
message_date: Union[date, object] = values.unset,
|
||||
message_date_before: Union[date, object] = values.unset,
|
||||
message_date_after: Union[date, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[NotificationInstance]:
|
||||
"""
|
||||
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 int log: Only read notifications of the specified log level. Can be: `0` to read only ERROR notifications or `1` to read only WARNING notifications. By default, all notifications are read.
|
||||
:param date message_date: Only show notifications for the specified date, formatted as `YYYY-MM-DD`. You can also specify an inequality, such as `<=YYYY-MM-DD` for messages logged at or before midnight on a date, or `>=YYYY-MM-DD` for messages logged at or after midnight on a date.
|
||||
:param date message_date_before: Only show notifications for the specified date, formatted as `YYYY-MM-DD`. You can also specify an inequality, such as `<=YYYY-MM-DD` for messages logged at or before midnight on a date, or `>=YYYY-MM-DD` for messages logged at or after midnight on a date.
|
||||
:param date message_date_after: Only show notifications for the specified date, formatted as `YYYY-MM-DD`. You can also specify an inequality, such as `<=YYYY-MM-DD` for messages logged at or before midnight on a date, or `>=YYYY-MM-DD` for messages logged at or after midnight on a date.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(
|
||||
log=log,
|
||||
message_date=message_date,
|
||||
message_date_before=message_date_before,
|
||||
message_date_after=message_date_after,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
log: Union[int, object] = values.unset,
|
||||
message_date: Union[date, object] = values.unset,
|
||||
message_date_before: Union[date, object] = values.unset,
|
||||
message_date_after: Union[date, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[NotificationInstance]:
|
||||
"""
|
||||
Asynchronously 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 int log: Only read notifications of the specified log level. Can be: `0` to read only ERROR notifications or `1` to read only WARNING notifications. By default, all notifications are read.
|
||||
:param date message_date: Only show notifications for the specified date, formatted as `YYYY-MM-DD`. You can also specify an inequality, such as `<=YYYY-MM-DD` for messages logged at or before midnight on a date, or `>=YYYY-MM-DD` for messages logged at or after midnight on a date.
|
||||
:param date message_date_before: Only show notifications for the specified date, formatted as `YYYY-MM-DD`. You can also specify an inequality, such as `<=YYYY-MM-DD` for messages logged at or before midnight on a date, or `>=YYYY-MM-DD` for messages logged at or after midnight on a date.
|
||||
:param date message_date_after: Only show notifications for the specified date, formatted as `YYYY-MM-DD`. You can also specify an inequality, such as `<=YYYY-MM-DD` for messages logged at or before midnight on a date, or `>=YYYY-MM-DD` for messages logged at or after midnight on a date.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(
|
||||
log=log,
|
||||
message_date=message_date,
|
||||
message_date_before=message_date_before,
|
||||
message_date_after=message_date_after,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
log: Union[int, object] = values.unset,
|
||||
message_date: Union[date, object] = values.unset,
|
||||
message_date_before: Union[date, object] = values.unset,
|
||||
message_date_after: Union[date, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[NotificationInstance]:
|
||||
"""
|
||||
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 int log: Only read notifications of the specified log level. Can be: `0` to read only ERROR notifications or `1` to read only WARNING notifications. By default, all notifications are read.
|
||||
:param date message_date: Only show notifications for the specified date, formatted as `YYYY-MM-DD`. You can also specify an inequality, such as `<=YYYY-MM-DD` for messages logged at or before midnight on a date, or `>=YYYY-MM-DD` for messages logged at or after midnight on a date.
|
||||
:param date message_date_before: Only show notifications for the specified date, formatted as `YYYY-MM-DD`. You can also specify an inequality, such as `<=YYYY-MM-DD` for messages logged at or before midnight on a date, or `>=YYYY-MM-DD` for messages logged at or after midnight on a date.
|
||||
:param date message_date_after: Only show notifications for the specified date, formatted as `YYYY-MM-DD`. You can also specify an inequality, such as `<=YYYY-MM-DD` for messages logged at or before midnight on a date, or `>=YYYY-MM-DD` for messages logged at or after midnight on a date.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return list(
|
||||
self.stream(
|
||||
log=log,
|
||||
message_date=message_date,
|
||||
message_date_before=message_date_before,
|
||||
message_date_after=message_date_after,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
log: Union[int, object] = values.unset,
|
||||
message_date: Union[date, object] = values.unset,
|
||||
message_date_before: Union[date, object] = values.unset,
|
||||
message_date_after: Union[date, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[NotificationInstance]:
|
||||
"""
|
||||
Asynchronously 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 int log: Only read notifications of the specified log level. Can be: `0` to read only ERROR notifications or `1` to read only WARNING notifications. By default, all notifications are read.
|
||||
:param date message_date: Only show notifications for the specified date, formatted as `YYYY-MM-DD`. You can also specify an inequality, such as `<=YYYY-MM-DD` for messages logged at or before midnight on a date, or `>=YYYY-MM-DD` for messages logged at or after midnight on a date.
|
||||
:param date message_date_before: Only show notifications for the specified date, formatted as `YYYY-MM-DD`. You can also specify an inequality, such as `<=YYYY-MM-DD` for messages logged at or before midnight on a date, or `>=YYYY-MM-DD` for messages logged at or after midnight on a date.
|
||||
:param date message_date_after: Only show notifications for the specified date, formatted as `YYYY-MM-DD`. You can also specify an inequality, such as `<=YYYY-MM-DD` for messages logged at or before midnight on a date, or `>=YYYY-MM-DD` for messages logged at or after midnight on a date.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return [
|
||||
record
|
||||
async for record in await self.stream_async(
|
||||
log=log,
|
||||
message_date=message_date,
|
||||
message_date_before=message_date_before,
|
||||
message_date_after=message_date_after,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
log: Union[int, object] = values.unset,
|
||||
message_date: Union[date, object] = values.unset,
|
||||
message_date_before: Union[date, object] = values.unset,
|
||||
message_date_after: Union[date, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> NotificationPage:
|
||||
"""
|
||||
Retrieve a single page of NotificationInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param log: Only read notifications of the specified log level. Can be: `0` to read only ERROR notifications or `1` to read only WARNING notifications. By default, all notifications are read.
|
||||
:param message_date: Only show notifications for the specified date, formatted as `YYYY-MM-DD`. You can also specify an inequality, such as `<=YYYY-MM-DD` for messages logged at or before midnight on a date, or `>=YYYY-MM-DD` for messages logged at or after midnight on a date.
|
||||
:param message_date_before: Only show notifications for the specified date, formatted as `YYYY-MM-DD`. You can also specify an inequality, such as `<=YYYY-MM-DD` for messages logged at or before midnight on a date, or `>=YYYY-MM-DD` for messages logged at or after midnight on a date.
|
||||
:param message_date_after: Only show notifications for the specified date, formatted as `YYYY-MM-DD`. You can also specify an inequality, such as `<=YYYY-MM-DD` for messages logged at or before midnight on a date, or `>=YYYY-MM-DD` for messages logged at or after midnight on a date.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of NotificationInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Log": log,
|
||||
"MessageDate": serialize.iso8601_date(message_date),
|
||||
"MessageDate<": serialize.iso8601_date(message_date_before),
|
||||
"MessageDate>": serialize.iso8601_date(message_date_after),
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return NotificationPage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
log: Union[int, object] = values.unset,
|
||||
message_date: Union[date, object] = values.unset,
|
||||
message_date_before: Union[date, object] = values.unset,
|
||||
message_date_after: Union[date, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> NotificationPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of NotificationInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param log: Only read notifications of the specified log level. Can be: `0` to read only ERROR notifications or `1` to read only WARNING notifications. By default, all notifications are read.
|
||||
:param message_date: Only show notifications for the specified date, formatted as `YYYY-MM-DD`. You can also specify an inequality, such as `<=YYYY-MM-DD` for messages logged at or before midnight on a date, or `>=YYYY-MM-DD` for messages logged at or after midnight on a date.
|
||||
:param message_date_before: Only show notifications for the specified date, formatted as `YYYY-MM-DD`. You can also specify an inequality, such as `<=YYYY-MM-DD` for messages logged at or before midnight on a date, or `>=YYYY-MM-DD` for messages logged at or after midnight on a date.
|
||||
:param message_date_after: Only show notifications for the specified date, formatted as `YYYY-MM-DD`. You can also specify an inequality, such as `<=YYYY-MM-DD` for messages logged at or before midnight on a date, or `>=YYYY-MM-DD` for messages logged at or after midnight on a date.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of NotificationInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Log": log,
|
||||
"MessageDate": serialize.iso8601_date(message_date),
|
||||
"MessageDate<": serialize.iso8601_date(message_date_before),
|
||||
"MessageDate>": serialize.iso8601_date(message_date_after),
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return NotificationPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> NotificationPage:
|
||||
"""
|
||||
Retrieve a specific page of NotificationInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of NotificationInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return NotificationPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> NotificationPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of NotificationInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of NotificationInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return NotificationPage(self._version, response, self._solution)
|
||||
|
||||
def get(self, sid: str) -> NotificationContext:
|
||||
"""
|
||||
Constructs a NotificationContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Call Notification resource to fetch.
|
||||
"""
|
||||
return NotificationContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
sid=sid,
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> NotificationContext:
|
||||
"""
|
||||
Constructs a NotificationContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Call Notification resource to fetch.
|
||||
"""
|
||||
return NotificationContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
sid=sid,
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.NotificationList>"
|
||||
@@ -0,0 +1,484 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, Optional, Union
|
||||
from twilio.base import deserialize, serialize, values
|
||||
from twilio.base.instance_context import InstanceContext
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
|
||||
|
||||
class PaymentInstance(InstanceResource):
|
||||
class BankAccountType(object):
|
||||
CONSUMER_CHECKING = "consumer-checking"
|
||||
CONSUMER_SAVINGS = "consumer-savings"
|
||||
COMMERCIAL_CHECKING = "commercial-checking"
|
||||
|
||||
class Capture(object):
|
||||
PAYMENT_CARD_NUMBER = "payment-card-number"
|
||||
EXPIRATION_DATE = "expiration-date"
|
||||
SECURITY_CODE = "security-code"
|
||||
POSTAL_CODE = "postal-code"
|
||||
BANK_ROUTING_NUMBER = "bank-routing-number"
|
||||
BANK_ACCOUNT_NUMBER = "bank-account-number"
|
||||
|
||||
class PaymentMethod(object):
|
||||
CREDIT_CARD = "credit-card"
|
||||
ACH_DEBIT = "ach-debit"
|
||||
|
||||
class Status(object):
|
||||
COMPLETE = "complete"
|
||||
CANCEL = "cancel"
|
||||
|
||||
class TokenType(object):
|
||||
ONE_TIME = "one-time"
|
||||
REUSABLE = "reusable"
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Payments resource.
|
||||
:ivar call_sid: The SID of the [Call](https://www.twilio.com/docs/voice/api/call-resource) the Payments resource is associated with. This will refer to the call sid that is producing the payment card (credit/ACH) information thru DTMF.
|
||||
:ivar sid: The SID of the Payments resource.
|
||||
:ivar date_created: The date and time in GMT that the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar date_updated: The date and time in GMT that the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar uri: The URI of the resource, relative to `https://api.twilio.com`.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
account_sid: str,
|
||||
call_sid: str,
|
||||
sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.call_sid: Optional[str] = payload.get("call_sid")
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.date_created: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.uri: Optional[str] = payload.get("uri")
|
||||
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"call_sid": call_sid,
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[PaymentContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "PaymentContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: PaymentContext for this PaymentInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = PaymentContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def update(
|
||||
self,
|
||||
idempotency_key: str,
|
||||
status_callback: str,
|
||||
capture: Union["PaymentInstance.Capture", object] = values.unset,
|
||||
status: Union["PaymentInstance.Status", object] = values.unset,
|
||||
) -> "PaymentInstance":
|
||||
"""
|
||||
Update the PaymentInstance
|
||||
|
||||
:param idempotency_key: A unique token that will be used to ensure that multiple API calls with the same information do not result in multiple transactions. This should be a unique string value per API call and can be a randomly generated.
|
||||
:param status_callback: Provide an absolute or relative URL to receive status updates regarding your Pay session. Read more about the [Update](https://www.twilio.com/docs/voice/api/payment-resource#statuscallback-update) and [Complete/Cancel](https://www.twilio.com/docs/voice/api/payment-resource#statuscallback-cancelcomplete) POST requests.
|
||||
:param capture:
|
||||
:param status:
|
||||
|
||||
:returns: The updated PaymentInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
idempotency_key=idempotency_key,
|
||||
status_callback=status_callback,
|
||||
capture=capture,
|
||||
status=status,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
idempotency_key: str,
|
||||
status_callback: str,
|
||||
capture: Union["PaymentInstance.Capture", object] = values.unset,
|
||||
status: Union["PaymentInstance.Status", object] = values.unset,
|
||||
) -> "PaymentInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the PaymentInstance
|
||||
|
||||
:param idempotency_key: A unique token that will be used to ensure that multiple API calls with the same information do not result in multiple transactions. This should be a unique string value per API call and can be a randomly generated.
|
||||
:param status_callback: Provide an absolute or relative URL to receive status updates regarding your Pay session. Read more about the [Update](https://www.twilio.com/docs/voice/api/payment-resource#statuscallback-update) and [Complete/Cancel](https://www.twilio.com/docs/voice/api/payment-resource#statuscallback-cancelcomplete) POST requests.
|
||||
:param capture:
|
||||
:param status:
|
||||
|
||||
:returns: The updated PaymentInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
idempotency_key=idempotency_key,
|
||||
status_callback=status_callback,
|
||||
capture=capture,
|
||||
status=status,
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.PaymentInstance {}>".format(context)
|
||||
|
||||
|
||||
class PaymentContext(InstanceContext):
|
||||
def __init__(self, version: Version, account_sid: str, call_sid: str, sid: str):
|
||||
"""
|
||||
Initialize the PaymentContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that will update the resource.
|
||||
:param call_sid: The SID of the call that will update the resource. This should be the same call sid that was used to create payments resource.
|
||||
:param sid: The SID of Payments session that needs to be updated.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"call_sid": call_sid,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = (
|
||||
"/Accounts/{account_sid}/Calls/{call_sid}/Payments/{sid}.json".format(
|
||||
**self._solution
|
||||
)
|
||||
)
|
||||
|
||||
def update(
|
||||
self,
|
||||
idempotency_key: str,
|
||||
status_callback: str,
|
||||
capture: Union["PaymentInstance.Capture", object] = values.unset,
|
||||
status: Union["PaymentInstance.Status", object] = values.unset,
|
||||
) -> PaymentInstance:
|
||||
"""
|
||||
Update the PaymentInstance
|
||||
|
||||
:param idempotency_key: A unique token that will be used to ensure that multiple API calls with the same information do not result in multiple transactions. This should be a unique string value per API call and can be a randomly generated.
|
||||
:param status_callback: Provide an absolute or relative URL to receive status updates regarding your Pay session. Read more about the [Update](https://www.twilio.com/docs/voice/api/payment-resource#statuscallback-update) and [Complete/Cancel](https://www.twilio.com/docs/voice/api/payment-resource#statuscallback-cancelcomplete) POST requests.
|
||||
:param capture:
|
||||
:param status:
|
||||
|
||||
:returns: The updated PaymentInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"IdempotencyKey": idempotency_key,
|
||||
"StatusCallback": status_callback,
|
||||
"Capture": capture,
|
||||
"Status": status,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return PaymentInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
idempotency_key: str,
|
||||
status_callback: str,
|
||||
capture: Union["PaymentInstance.Capture", object] = values.unset,
|
||||
status: Union["PaymentInstance.Status", object] = values.unset,
|
||||
) -> PaymentInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the PaymentInstance
|
||||
|
||||
:param idempotency_key: A unique token that will be used to ensure that multiple API calls with the same information do not result in multiple transactions. This should be a unique string value per API call and can be a randomly generated.
|
||||
:param status_callback: Provide an absolute or relative URL to receive status updates regarding your Pay session. Read more about the [Update](https://www.twilio.com/docs/voice/api/payment-resource#statuscallback-update) and [Complete/Cancel](https://www.twilio.com/docs/voice/api/payment-resource#statuscallback-cancelcomplete) POST requests.
|
||||
:param capture:
|
||||
:param status:
|
||||
|
||||
:returns: The updated PaymentInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"IdempotencyKey": idempotency_key,
|
||||
"StatusCallback": status_callback,
|
||||
"Capture": capture,
|
||||
"Status": status,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return PaymentInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.PaymentContext {}>".format(context)
|
||||
|
||||
|
||||
class PaymentList(ListResource):
|
||||
def __init__(self, version: Version, account_sid: str, call_sid: str):
|
||||
"""
|
||||
Initialize the PaymentList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that will create the resource.
|
||||
:param call_sid: The SID of the call that will create the resource. Call leg associated with this sid is expected to provide payment information thru DTMF.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"call_sid": call_sid,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/Calls/{call_sid}/Payments.json".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def create(
|
||||
self,
|
||||
idempotency_key: str,
|
||||
status_callback: str,
|
||||
bank_account_type: Union[
|
||||
"PaymentInstance.BankAccountType", object
|
||||
] = values.unset,
|
||||
charge_amount: Union[float, object] = values.unset,
|
||||
currency: Union[str, object] = values.unset,
|
||||
description: Union[str, object] = values.unset,
|
||||
input: Union[str, object] = values.unset,
|
||||
min_postal_code_length: Union[int, object] = values.unset,
|
||||
parameter: Union[object, object] = values.unset,
|
||||
payment_connector: Union[str, object] = values.unset,
|
||||
payment_method: Union["PaymentInstance.PaymentMethod", object] = values.unset,
|
||||
postal_code: Union[bool, object] = values.unset,
|
||||
security_code: Union[bool, object] = values.unset,
|
||||
timeout: Union[int, object] = values.unset,
|
||||
token_type: Union["PaymentInstance.TokenType", object] = values.unset,
|
||||
valid_card_types: Union[str, object] = values.unset,
|
||||
) -> PaymentInstance:
|
||||
"""
|
||||
Create the PaymentInstance
|
||||
|
||||
:param idempotency_key: A unique token that will be used to ensure that multiple API calls with the same information do not result in multiple transactions. This should be a unique string value per API call and can be a randomly generated.
|
||||
:param status_callback: Provide an absolute or relative URL to receive status updates regarding your Pay session. Read more about the [expected StatusCallback values](https://www.twilio.com/docs/voice/api/payment-resource#statuscallback)
|
||||
:param bank_account_type:
|
||||
:param charge_amount: A positive decimal value less than 1,000,000 to charge against the credit card or bank account. Default currency can be overwritten with `currency` field. Leave blank or set to 0 to tokenize.
|
||||
:param currency: The currency of the `charge_amount`, formatted as [ISO 4127](http://www.iso.org/iso/home/standards/currency_codes.htm) format. The default value is `USD` and all values allowed from the Pay Connector are accepted.
|
||||
:param description: The description can be used to provide more details regarding the transaction. This information is submitted along with the payment details to the Payment Connector which are then posted on the transactions.
|
||||
:param input: A list of inputs that should be accepted. Currently only `dtmf` is supported. All digits captured during a pay session are redacted from the logs.
|
||||
:param min_postal_code_length: A positive integer that is used to validate the length of the `PostalCode` inputted by the user. User must enter this many digits.
|
||||
:param parameter: A single-level JSON object used to pass custom parameters to payment processors. (Required for ACH payments). The information that has to be included here depends on the <Pay> Connector. [Read more](https://www.twilio.com/console/voice/pay-connectors).
|
||||
:param payment_connector: This is the unique name corresponding to the Pay Connector installed in the Twilio Add-ons. Learn more about [<Pay> Connectors](https://www.twilio.com/console/voice/pay-connectors). The default value is `Default`.
|
||||
:param payment_method:
|
||||
:param postal_code: Indicates whether the credit card postal code (zip code) is a required piece of payment information that must be provided by the caller. The default is `true`.
|
||||
:param security_code: Indicates whether the credit card security code is a required piece of payment information that must be provided by the caller. The default is `true`.
|
||||
:param timeout: The number of seconds that <Pay> should wait for the caller to press a digit between each subsequent digit, after the first one, before moving on to validate the digits captured. The default is `5`, maximum is `600`.
|
||||
:param token_type:
|
||||
:param valid_card_types: Credit card types separated by space that Pay should accept. The default value is `visa mastercard amex`
|
||||
|
||||
:returns: The created PaymentInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"IdempotencyKey": idempotency_key,
|
||||
"StatusCallback": status_callback,
|
||||
"BankAccountType": bank_account_type,
|
||||
"ChargeAmount": charge_amount,
|
||||
"Currency": currency,
|
||||
"Description": description,
|
||||
"Input": input,
|
||||
"MinPostalCodeLength": min_postal_code_length,
|
||||
"Parameter": serialize.object(parameter),
|
||||
"PaymentConnector": payment_connector,
|
||||
"PaymentMethod": payment_method,
|
||||
"PostalCode": postal_code,
|
||||
"SecurityCode": security_code,
|
||||
"Timeout": timeout,
|
||||
"TokenType": token_type,
|
||||
"ValidCardTypes": valid_card_types,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return PaymentInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
)
|
||||
|
||||
async def create_async(
|
||||
self,
|
||||
idempotency_key: str,
|
||||
status_callback: str,
|
||||
bank_account_type: Union[
|
||||
"PaymentInstance.BankAccountType", object
|
||||
] = values.unset,
|
||||
charge_amount: Union[float, object] = values.unset,
|
||||
currency: Union[str, object] = values.unset,
|
||||
description: Union[str, object] = values.unset,
|
||||
input: Union[str, object] = values.unset,
|
||||
min_postal_code_length: Union[int, object] = values.unset,
|
||||
parameter: Union[object, object] = values.unset,
|
||||
payment_connector: Union[str, object] = values.unset,
|
||||
payment_method: Union["PaymentInstance.PaymentMethod", object] = values.unset,
|
||||
postal_code: Union[bool, object] = values.unset,
|
||||
security_code: Union[bool, object] = values.unset,
|
||||
timeout: Union[int, object] = values.unset,
|
||||
token_type: Union["PaymentInstance.TokenType", object] = values.unset,
|
||||
valid_card_types: Union[str, object] = values.unset,
|
||||
) -> PaymentInstance:
|
||||
"""
|
||||
Asynchronously create the PaymentInstance
|
||||
|
||||
:param idempotency_key: A unique token that will be used to ensure that multiple API calls with the same information do not result in multiple transactions. This should be a unique string value per API call and can be a randomly generated.
|
||||
:param status_callback: Provide an absolute or relative URL to receive status updates regarding your Pay session. Read more about the [expected StatusCallback values](https://www.twilio.com/docs/voice/api/payment-resource#statuscallback)
|
||||
:param bank_account_type:
|
||||
:param charge_amount: A positive decimal value less than 1,000,000 to charge against the credit card or bank account. Default currency can be overwritten with `currency` field. Leave blank or set to 0 to tokenize.
|
||||
:param currency: The currency of the `charge_amount`, formatted as [ISO 4127](http://www.iso.org/iso/home/standards/currency_codes.htm) format. The default value is `USD` and all values allowed from the Pay Connector are accepted.
|
||||
:param description: The description can be used to provide more details regarding the transaction. This information is submitted along with the payment details to the Payment Connector which are then posted on the transactions.
|
||||
:param input: A list of inputs that should be accepted. Currently only `dtmf` is supported. All digits captured during a pay session are redacted from the logs.
|
||||
:param min_postal_code_length: A positive integer that is used to validate the length of the `PostalCode` inputted by the user. User must enter this many digits.
|
||||
:param parameter: A single-level JSON object used to pass custom parameters to payment processors. (Required for ACH payments). The information that has to be included here depends on the <Pay> Connector. [Read more](https://www.twilio.com/console/voice/pay-connectors).
|
||||
:param payment_connector: This is the unique name corresponding to the Pay Connector installed in the Twilio Add-ons. Learn more about [<Pay> Connectors](https://www.twilio.com/console/voice/pay-connectors). The default value is `Default`.
|
||||
:param payment_method:
|
||||
:param postal_code: Indicates whether the credit card postal code (zip code) is a required piece of payment information that must be provided by the caller. The default is `true`.
|
||||
:param security_code: Indicates whether the credit card security code is a required piece of payment information that must be provided by the caller. The default is `true`.
|
||||
:param timeout: The number of seconds that <Pay> should wait for the caller to press a digit between each subsequent digit, after the first one, before moving on to validate the digits captured. The default is `5`, maximum is `600`.
|
||||
:param token_type:
|
||||
:param valid_card_types: Credit card types separated by space that Pay should accept. The default value is `visa mastercard amex`
|
||||
|
||||
:returns: The created PaymentInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"IdempotencyKey": idempotency_key,
|
||||
"StatusCallback": status_callback,
|
||||
"BankAccountType": bank_account_type,
|
||||
"ChargeAmount": charge_amount,
|
||||
"Currency": currency,
|
||||
"Description": description,
|
||||
"Input": input,
|
||||
"MinPostalCodeLength": min_postal_code_length,
|
||||
"Parameter": serialize.object(parameter),
|
||||
"PaymentConnector": payment_connector,
|
||||
"PaymentMethod": payment_method,
|
||||
"PostalCode": postal_code,
|
||||
"SecurityCode": security_code,
|
||||
"Timeout": timeout,
|
||||
"TokenType": token_type,
|
||||
"ValidCardTypes": valid_card_types,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return PaymentInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
)
|
||||
|
||||
def get(self, sid: str) -> PaymentContext:
|
||||
"""
|
||||
Constructs a PaymentContext
|
||||
|
||||
:param sid: The SID of Payments session that needs to be updated.
|
||||
"""
|
||||
return PaymentContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
sid=sid,
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> PaymentContext:
|
||||
"""
|
||||
Constructs a PaymentContext
|
||||
|
||||
:param sid: The SID of Payments session that needs to be updated.
|
||||
"""
|
||||
return PaymentContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
sid=sid,
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.PaymentList>"
|
||||
@@ -0,0 +1,787 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from datetime import date, datetime
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, serialize, values
|
||||
from twilio.base.instance_context import InstanceContext
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.page import Page
|
||||
|
||||
|
||||
class RecordingInstance(InstanceResource):
|
||||
class Source(object):
|
||||
DIALVERB = "DialVerb"
|
||||
CONFERENCE = "Conference"
|
||||
OUTBOUNDAPI = "OutboundAPI"
|
||||
TRUNKING = "Trunking"
|
||||
RECORDVERB = "RecordVerb"
|
||||
STARTCALLRECORDINGAPI = "StartCallRecordingAPI"
|
||||
STARTCONFERENCERECORDINGAPI = "StartConferenceRecordingAPI"
|
||||
|
||||
class Status(object):
|
||||
IN_PROGRESS = "in-progress"
|
||||
PAUSED = "paused"
|
||||
STOPPED = "stopped"
|
||||
PROCESSING = "processing"
|
||||
COMPLETED = "completed"
|
||||
ABSENT = "absent"
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Recording resource.
|
||||
:ivar api_version: The API version used to make the recording.
|
||||
:ivar call_sid: The SID of the [Call](https://www.twilio.com/docs/voice/api/call-resource) the Recording resource is associated with.
|
||||
:ivar conference_sid: The Conference SID that identifies the conference associated with the recording, if a conference recording.
|
||||
:ivar date_created: The date and time in GMT that the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar date_updated: The date and time in GMT that the resource was last updated, specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar start_time: The start time of the recording in GMT and in [RFC 2822](https://www.php.net/manual/en/class.datetime.php#datetime.constants.rfc2822) format.
|
||||
:ivar duration: The length of the recording in seconds.
|
||||
:ivar sid: The unique string that that we created to identify the Recording resource.
|
||||
:ivar price: The one-time cost of creating the recording in the `price_unit` currency.
|
||||
:ivar uri: The URI of the resource, relative to `https://api.twilio.com`.
|
||||
:ivar encryption_details: How to decrypt the recording if it was encrypted using [Call Recording Encryption](https://www.twilio.com/docs/voice/tutorials/voice-recording-encryption) feature.
|
||||
:ivar price_unit: The currency used in the `price` property. Example: `USD`.
|
||||
:ivar status:
|
||||
:ivar channels: The number of channels in the final recording file. Can be: `1`, or `2`. Separating a two leg call into two separate channels of the recording file is supported in [Dial](https://www.twilio.com/docs/voice/twiml/dial#attributes-record) and [Outbound Rest API](https://www.twilio.com/docs/voice/make-calls) record options.
|
||||
:ivar source:
|
||||
:ivar error_code: The error code that describes why the recording is `absent`. The error code is described in our [Error Dictionary](https://www.twilio.com/docs/api/errors). This value is null if the recording `status` is not `absent`.
|
||||
:ivar track: The recorded track. Can be: `inbound`, `outbound`, or `both`.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
account_sid: str,
|
||||
call_sid: str,
|
||||
sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.api_version: Optional[str] = payload.get("api_version")
|
||||
self.call_sid: Optional[str] = payload.get("call_sid")
|
||||
self.conference_sid: Optional[str] = payload.get("conference_sid")
|
||||
self.date_created: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.start_time: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("start_time")
|
||||
)
|
||||
self.duration: Optional[str] = payload.get("duration")
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.price: Optional[float] = deserialize.decimal(payload.get("price"))
|
||||
self.uri: Optional[str] = payload.get("uri")
|
||||
self.encryption_details: Optional[Dict[str, object]] = payload.get(
|
||||
"encryption_details"
|
||||
)
|
||||
self.price_unit: Optional[str] = payload.get("price_unit")
|
||||
self.status: Optional["RecordingInstance.Status"] = payload.get("status")
|
||||
self.channels: Optional[int] = deserialize.integer(payload.get("channels"))
|
||||
self.source: Optional["RecordingInstance.Source"] = payload.get("source")
|
||||
self.error_code: Optional[int] = deserialize.integer(payload.get("error_code"))
|
||||
self.track: Optional[str] = payload.get("track")
|
||||
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"call_sid": call_sid,
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[RecordingContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "RecordingContext":
|
||||
"""
|
||||
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
|
||||
"""
|
||||
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
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the RecordingInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the RecordingInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
def fetch(self) -> "RecordingInstance":
|
||||
"""
|
||||
Fetch the RecordingInstance
|
||||
|
||||
|
||||
:returns: The fetched RecordingInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "RecordingInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the RecordingInstance
|
||||
|
||||
|
||||
:returns: The fetched RecordingInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self,
|
||||
status: "RecordingInstance.Status",
|
||||
pause_behavior: Union[str, object] = values.unset,
|
||||
) -> "RecordingInstance":
|
||||
"""
|
||||
Update the RecordingInstance
|
||||
|
||||
:param status:
|
||||
:param pause_behavior: Whether to record during a pause. Can be: `skip` or `silence` and the default is `silence`. `skip` does not record during the pause period, while `silence` will replace the actual audio of the call with silence during the pause period. This parameter only applies when setting `status` is set to `paused`.
|
||||
|
||||
:returns: The updated RecordingInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
status=status,
|
||||
pause_behavior=pause_behavior,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
status: "RecordingInstance.Status",
|
||||
pause_behavior: Union[str, object] = values.unset,
|
||||
) -> "RecordingInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the RecordingInstance
|
||||
|
||||
:param status:
|
||||
:param pause_behavior: Whether to record during a pause. Can be: `skip` or `silence` and the default is `silence`. `skip` does not record during the pause period, while `silence` will replace the actual audio of the call with silence during the pause period. This parameter only applies when setting `status` is set to `paused`.
|
||||
|
||||
:returns: The updated RecordingInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
status=status,
|
||||
pause_behavior=pause_behavior,
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.RecordingInstance {}>".format(context)
|
||||
|
||||
|
||||
class RecordingContext(InstanceContext):
|
||||
def __init__(self, version: Version, account_sid: str, call_sid: str, sid: str):
|
||||
"""
|
||||
Initialize the RecordingContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Recording resource to update.
|
||||
:param call_sid: The [Call](https://www.twilio.com/docs/voice/api/call-resource) SID of the resource to update.
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Recording resource to update.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"call_sid": call_sid,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = (
|
||||
"/Accounts/{account_sid}/Calls/{call_sid}/Recordings/{sid}.json".format(
|
||||
**self._solution
|
||||
)
|
||||
)
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the RecordingInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._version.delete(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the RecordingInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
def fetch(self) -> RecordingInstance:
|
||||
"""
|
||||
Fetch the RecordingInstance
|
||||
|
||||
|
||||
:returns: The fetched RecordingInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return RecordingInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> RecordingInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the RecordingInstance
|
||||
|
||||
|
||||
:returns: The fetched RecordingInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return RecordingInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self,
|
||||
status: "RecordingInstance.Status",
|
||||
pause_behavior: Union[str, object] = values.unset,
|
||||
) -> RecordingInstance:
|
||||
"""
|
||||
Update the RecordingInstance
|
||||
|
||||
:param status:
|
||||
:param pause_behavior: Whether to record during a pause. Can be: `skip` or `silence` and the default is `silence`. `skip` does not record during the pause period, while `silence` will replace the actual audio of the call with silence during the pause period. This parameter only applies when setting `status` is set to `paused`.
|
||||
|
||||
:returns: The updated RecordingInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Status": status,
|
||||
"PauseBehavior": pause_behavior,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return RecordingInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
status: "RecordingInstance.Status",
|
||||
pause_behavior: Union[str, object] = values.unset,
|
||||
) -> RecordingInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the RecordingInstance
|
||||
|
||||
:param status:
|
||||
:param pause_behavior: Whether to record during a pause. Can be: `skip` or `silence` and the default is `silence`. `skip` does not record during the pause period, while `silence` will replace the actual audio of the call with silence during the pause period. This parameter only applies when setting `status` is set to `paused`.
|
||||
|
||||
:returns: The updated RecordingInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Status": status,
|
||||
"PauseBehavior": pause_behavior,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return RecordingInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.RecordingContext {}>".format(context)
|
||||
|
||||
|
||||
class RecordingPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> RecordingInstance:
|
||||
"""
|
||||
Build an instance of RecordingInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return RecordingInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.RecordingPage>"
|
||||
|
||||
|
||||
class RecordingList(ListResource):
|
||||
def __init__(self, version: Version, account_sid: str, call_sid: str):
|
||||
"""
|
||||
Initialize the RecordingList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Recording resources to read.
|
||||
:param call_sid: The [Call](https://www.twilio.com/docs/voice/api/call-resource) SID of the resources to read.
|
||||
|
||||
"""
|
||||
super().__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 create(
|
||||
self,
|
||||
recording_status_callback_event: Union[List[str], object] = values.unset,
|
||||
recording_status_callback: Union[str, object] = values.unset,
|
||||
recording_status_callback_method: Union[str, object] = values.unset,
|
||||
trim: Union[str, object] = values.unset,
|
||||
recording_channels: Union[str, object] = values.unset,
|
||||
recording_track: Union[str, object] = values.unset,
|
||||
) -> RecordingInstance:
|
||||
"""
|
||||
Create the RecordingInstance
|
||||
|
||||
:param recording_status_callback_event: The recording status events on which we should call the `recording_status_callback` URL. Can be: `in-progress`, `completed` and `absent` and the default is `completed`. Separate multiple event values with a space.
|
||||
:param recording_status_callback: The URL we should call using the `recording_status_callback_method` on each recording event specified in `recording_status_callback_event`. For more information, see [RecordingStatusCallback parameters](https://www.twilio.com/docs/voice/api/recording#recordingstatuscallback).
|
||||
:param recording_status_callback_method: The HTTP method we should use to call `recording_status_callback`. Can be: `GET` or `POST` and the default is `POST`.
|
||||
:param trim: Whether to trim any leading and trailing silence in the recording. Can be: `trim-silence` or `do-not-trim` and the default is `do-not-trim`. `trim-silence` trims the silence from the beginning and end of the recording and `do-not-trim` does not.
|
||||
:param recording_channels: The number of channels used in the recording. Can be: `mono` or `dual` and the default is `mono`. `mono` records all parties of the call into one channel. `dual` records each party of a 2-party call into separate channels.
|
||||
:param recording_track: The audio track to record for the call. Can be: `inbound`, `outbound` or `both`. The default is `both`. `inbound` records the audio that is received by Twilio. `outbound` records the audio that is generated from Twilio. `both` records the audio that is received and generated by Twilio.
|
||||
|
||||
:returns: The created RecordingInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"RecordingStatusCallbackEvent": serialize.map(
|
||||
recording_status_callback_event, lambda e: e
|
||||
),
|
||||
"RecordingStatusCallback": recording_status_callback,
|
||||
"RecordingStatusCallbackMethod": recording_status_callback_method,
|
||||
"Trim": trim,
|
||||
"RecordingChannels": recording_channels,
|
||||
"RecordingTrack": recording_track,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return RecordingInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
)
|
||||
|
||||
async def create_async(
|
||||
self,
|
||||
recording_status_callback_event: Union[List[str], object] = values.unset,
|
||||
recording_status_callback: Union[str, object] = values.unset,
|
||||
recording_status_callback_method: Union[str, object] = values.unset,
|
||||
trim: Union[str, object] = values.unset,
|
||||
recording_channels: Union[str, object] = values.unset,
|
||||
recording_track: Union[str, object] = values.unset,
|
||||
) -> RecordingInstance:
|
||||
"""
|
||||
Asynchronously create the RecordingInstance
|
||||
|
||||
:param recording_status_callback_event: The recording status events on which we should call the `recording_status_callback` URL. Can be: `in-progress`, `completed` and `absent` and the default is `completed`. Separate multiple event values with a space.
|
||||
:param recording_status_callback: The URL we should call using the `recording_status_callback_method` on each recording event specified in `recording_status_callback_event`. For more information, see [RecordingStatusCallback parameters](https://www.twilio.com/docs/voice/api/recording#recordingstatuscallback).
|
||||
:param recording_status_callback_method: The HTTP method we should use to call `recording_status_callback`. Can be: `GET` or `POST` and the default is `POST`.
|
||||
:param trim: Whether to trim any leading and trailing silence in the recording. Can be: `trim-silence` or `do-not-trim` and the default is `do-not-trim`. `trim-silence` trims the silence from the beginning and end of the recording and `do-not-trim` does not.
|
||||
:param recording_channels: The number of channels used in the recording. Can be: `mono` or `dual` and the default is `mono`. `mono` records all parties of the call into one channel. `dual` records each party of a 2-party call into separate channels.
|
||||
:param recording_track: The audio track to record for the call. Can be: `inbound`, `outbound` or `both`. The default is `both`. `inbound` records the audio that is received by Twilio. `outbound` records the audio that is generated from Twilio. `both` records the audio that is received and generated by Twilio.
|
||||
|
||||
:returns: The created RecordingInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"RecordingStatusCallbackEvent": serialize.map(
|
||||
recording_status_callback_event, lambda e: e
|
||||
),
|
||||
"RecordingStatusCallback": recording_status_callback,
|
||||
"RecordingStatusCallbackMethod": recording_status_callback_method,
|
||||
"Trim": trim,
|
||||
"RecordingChannels": recording_channels,
|
||||
"RecordingTrack": recording_track,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return RecordingInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
date_created: Union[date, object] = values.unset,
|
||||
date_created_before: Union[date, object] = values.unset,
|
||||
date_created_after: Union[date, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[RecordingInstance]:
|
||||
"""
|
||||
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: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param date date_created_before: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param date date_created_after: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(
|
||||
date_created=date_created,
|
||||
date_created_before=date_created_before,
|
||||
date_created_after=date_created_after,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
date_created: Union[date, object] = values.unset,
|
||||
date_created_before: Union[date, object] = values.unset,
|
||||
date_created_after: Union[date, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[RecordingInstance]:
|
||||
"""
|
||||
Asynchronously 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: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param date date_created_before: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param date date_created_after: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(
|
||||
date_created=date_created,
|
||||
date_created_before=date_created_before,
|
||||
date_created_after=date_created_after,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
date_created: Union[date, object] = values.unset,
|
||||
date_created_before: Union[date, object] = values.unset,
|
||||
date_created_after: Union[date, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[RecordingInstance]:
|
||||
"""
|
||||
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: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param date date_created_before: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param date date_created_after: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return list(
|
||||
self.stream(
|
||||
date_created=date_created,
|
||||
date_created_before=date_created_before,
|
||||
date_created_after=date_created_after,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
date_created: Union[date, object] = values.unset,
|
||||
date_created_before: Union[date, object] = values.unset,
|
||||
date_created_after: Union[date, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[RecordingInstance]:
|
||||
"""
|
||||
Asynchronously 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: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param date date_created_before: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param date date_created_after: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return [
|
||||
record
|
||||
async for record in await self.stream_async(
|
||||
date_created=date_created,
|
||||
date_created_before=date_created_before,
|
||||
date_created_after=date_created_after,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
date_created: Union[date, object] = values.unset,
|
||||
date_created_before: Union[date, object] = values.unset,
|
||||
date_created_after: Union[date, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> RecordingPage:
|
||||
"""
|
||||
Retrieve a single page of RecordingInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param date_created: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param date_created_before: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param date_created_after: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of RecordingInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"DateCreated": serialize.iso8601_date(date_created),
|
||||
"DateCreated<": serialize.iso8601_date(date_created_before),
|
||||
"DateCreated>": serialize.iso8601_date(date_created_after),
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return RecordingPage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
date_created: Union[date, object] = values.unset,
|
||||
date_created_before: Union[date, object] = values.unset,
|
||||
date_created_after: Union[date, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> RecordingPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of RecordingInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param date_created: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param date_created_before: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param date_created_after: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of RecordingInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"DateCreated": serialize.iso8601_date(date_created),
|
||||
"DateCreated<": serialize.iso8601_date(date_created_before),
|
||||
"DateCreated>": serialize.iso8601_date(date_created_after),
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return RecordingPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> RecordingPage:
|
||||
"""
|
||||
Retrieve a specific page of RecordingInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of RecordingInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return RecordingPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> RecordingPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of RecordingInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of RecordingInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return RecordingPage(self._version, response, self._solution)
|
||||
|
||||
def get(self, sid: str) -> RecordingContext:
|
||||
"""
|
||||
Constructs a RecordingContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Recording resource to update.
|
||||
"""
|
||||
return RecordingContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
sid=sid,
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> RecordingContext:
|
||||
"""
|
||||
Constructs a RecordingContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Recording resource to update.
|
||||
"""
|
||||
return RecordingContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
sid=sid,
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.RecordingList>"
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+152
@@ -0,0 +1,152 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, Optional, Union
|
||||
from twilio.base import deserialize, values
|
||||
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
|
||||
|
||||
class UserDefinedMessageInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created User Defined Message.
|
||||
:ivar call_sid: The SID of the [Call](https://www.twilio.com/docs/voice/api/call-resource) the User Defined Message is associated with.
|
||||
:ivar sid: The SID that uniquely identifies this User Defined Message.
|
||||
:ivar date_created: The date that this User Defined Message was created, given in RFC 2822 format.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self, version: Version, payload: Dict[str, Any], account_sid: str, call_sid: str
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.call_sid: Optional[str] = payload.get("call_sid")
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.date_created: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"call_sid": call_sid,
|
||||
}
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.UserDefinedMessageInstance {}>".format(context)
|
||||
|
||||
|
||||
class UserDefinedMessageList(ListResource):
|
||||
def __init__(self, version: Version, account_sid: str, call_sid: str):
|
||||
"""
|
||||
Initialize the UserDefinedMessageList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created User Defined Message.
|
||||
:param call_sid: The SID of the [Call](https://www.twilio.com/docs/voice/api/call-resource) the User Defined Message is associated with.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"call_sid": call_sid,
|
||||
}
|
||||
self._uri = (
|
||||
"/Accounts/{account_sid}/Calls/{call_sid}/UserDefinedMessages.json".format(
|
||||
**self._solution
|
||||
)
|
||||
)
|
||||
|
||||
def create(
|
||||
self, content: str, idempotency_key: Union[str, object] = values.unset
|
||||
) -> UserDefinedMessageInstance:
|
||||
"""
|
||||
Create the UserDefinedMessageInstance
|
||||
|
||||
:param content: The User Defined Message in the form of URL-encoded JSON string.
|
||||
:param idempotency_key: A unique string value to identify API call. This should be a unique string value per API call and can be a randomly generated.
|
||||
|
||||
:returns: The created UserDefinedMessageInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Content": content,
|
||||
"IdempotencyKey": idempotency_key,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return UserDefinedMessageInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
)
|
||||
|
||||
async def create_async(
|
||||
self, content: str, idempotency_key: Union[str, object] = values.unset
|
||||
) -> UserDefinedMessageInstance:
|
||||
"""
|
||||
Asynchronously create the UserDefinedMessageInstance
|
||||
|
||||
:param content: The User Defined Message in the form of URL-encoded JSON string.
|
||||
:param idempotency_key: A unique string value to identify API call. This should be a unique string value per API call and can be a randomly generated.
|
||||
|
||||
:returns: The created UserDefinedMessageInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Content": content,
|
||||
"IdempotencyKey": idempotency_key,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return UserDefinedMessageInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.UserDefinedMessageList>"
|
||||
+290
@@ -0,0 +1,290 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, Optional, Union
|
||||
from twilio.base import deserialize, values
|
||||
from twilio.base.instance_context import InstanceContext
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
|
||||
|
||||
class UserDefinedMessageSubscriptionInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that subscribed to the User Defined Messages.
|
||||
:ivar call_sid: The SID of the [Call](https://www.twilio.com/docs/voice/api/call-resource) the User Defined Message Subscription is associated with. This refers to the Call SID that is producing the User Defined Messages.
|
||||
:ivar sid: The SID that uniquely identifies this User Defined Message Subscription.
|
||||
:ivar date_created: The date that this User Defined Message Subscription was created, given in RFC 2822 format.
|
||||
:ivar uri: The URI of the User Defined Message Subscription Resource, relative to `https://api.twilio.com`.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
account_sid: str,
|
||||
call_sid: str,
|
||||
sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.call_sid: Optional[str] = payload.get("call_sid")
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.date_created: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.uri: Optional[str] = payload.get("uri")
|
||||
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"call_sid": call_sid,
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[UserDefinedMessageSubscriptionContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "UserDefinedMessageSubscriptionContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: UserDefinedMessageSubscriptionContext for this UserDefinedMessageSubscriptionInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = UserDefinedMessageSubscriptionContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the UserDefinedMessageSubscriptionInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the UserDefinedMessageSubscriptionInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.UserDefinedMessageSubscriptionInstance {}>".format(
|
||||
context
|
||||
)
|
||||
|
||||
|
||||
class UserDefinedMessageSubscriptionContext(InstanceContext):
|
||||
def __init__(self, version: Version, account_sid: str, call_sid: str, sid: str):
|
||||
"""
|
||||
Initialize the UserDefinedMessageSubscriptionContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that subscribed to the User Defined Messages.
|
||||
:param call_sid: The SID of the [Call](https://www.twilio.com/docs/voice/api/call-resource) the User Defined Message Subscription is associated with. This refers to the Call SID that is producing the User Defined Messages.
|
||||
:param sid: The SID that uniquely identifies this User Defined Message Subscription.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"call_sid": call_sid,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/Calls/{call_sid}/UserDefinedMessageSubscriptions/{sid}.json".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the UserDefinedMessageSubscriptionInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._version.delete(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the UserDefinedMessageSubscriptionInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.UserDefinedMessageSubscriptionContext {}>".format(
|
||||
context
|
||||
)
|
||||
|
||||
|
||||
class UserDefinedMessageSubscriptionList(ListResource):
|
||||
def __init__(self, version: Version, account_sid: str, call_sid: str):
|
||||
"""
|
||||
Initialize the UserDefinedMessageSubscriptionList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that subscribed to the User Defined Messages.
|
||||
:param call_sid: The SID of the [Call](https://www.twilio.com/docs/voice/api/call-resource) the User Defined Messages subscription is associated with. This refers to the Call SID that is producing the user defined messages.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"call_sid": call_sid,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/Calls/{call_sid}/UserDefinedMessageSubscriptions.json".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def create(
|
||||
self,
|
||||
callback: str,
|
||||
idempotency_key: Union[str, object] = values.unset,
|
||||
method: Union[str, object] = values.unset,
|
||||
) -> UserDefinedMessageSubscriptionInstance:
|
||||
"""
|
||||
Create the UserDefinedMessageSubscriptionInstance
|
||||
|
||||
:param callback: The URL we should call using the `method` to send user defined events to your application. URLs must contain a valid hostname (underscores are not permitted).
|
||||
:param idempotency_key: A unique string value to identify API call. This should be a unique string value per API call and can be a randomly generated.
|
||||
:param method: The HTTP method Twilio will use when requesting the above `Url`. Either `GET` or `POST`. Default is `POST`.
|
||||
|
||||
:returns: The created UserDefinedMessageSubscriptionInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Callback": callback,
|
||||
"IdempotencyKey": idempotency_key,
|
||||
"Method": method,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return UserDefinedMessageSubscriptionInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
)
|
||||
|
||||
async def create_async(
|
||||
self,
|
||||
callback: str,
|
||||
idempotency_key: Union[str, object] = values.unset,
|
||||
method: Union[str, object] = values.unset,
|
||||
) -> UserDefinedMessageSubscriptionInstance:
|
||||
"""
|
||||
Asynchronously create the UserDefinedMessageSubscriptionInstance
|
||||
|
||||
:param callback: The URL we should call using the `method` to send user defined events to your application. URLs must contain a valid hostname (underscores are not permitted).
|
||||
:param idempotency_key: A unique string value to identify API call. This should be a unique string value per API call and can be a randomly generated.
|
||||
:param method: The HTTP method Twilio will use when requesting the above `Url`. Either `GET` or `POST`. Default is `POST`.
|
||||
|
||||
:returns: The created UserDefinedMessageSubscriptionInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Callback": callback,
|
||||
"IdempotencyKey": idempotency_key,
|
||||
"Method": method,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return UserDefinedMessageSubscriptionInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
)
|
||||
|
||||
def get(self, sid: str) -> UserDefinedMessageSubscriptionContext:
|
||||
"""
|
||||
Constructs a UserDefinedMessageSubscriptionContext
|
||||
|
||||
:param sid: The SID that uniquely identifies this User Defined Message Subscription.
|
||||
"""
|
||||
return UserDefinedMessageSubscriptionContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
sid=sid,
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> UserDefinedMessageSubscriptionContext:
|
||||
"""
|
||||
Constructs a UserDefinedMessageSubscriptionContext
|
||||
|
||||
:param sid: The SID that uniquely identifies this User Defined Message Subscription.
|
||||
"""
|
||||
return UserDefinedMessageSubscriptionContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
sid=sid,
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.UserDefinedMessageSubscriptionList>"
|
||||
+766
@@ -0,0 +1,766 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from datetime import date, datetime
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, serialize, values
|
||||
from twilio.base.instance_context import InstanceContext
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.page import Page
|
||||
from twilio.rest.api.v2010.account.conference.participant import ParticipantList
|
||||
from twilio.rest.api.v2010.account.conference.recording import RecordingList
|
||||
|
||||
|
||||
class ConferenceInstance(InstanceResource):
|
||||
class ReasonConferenceEnded(object):
|
||||
CONFERENCE_ENDED_VIA_API = "conference-ended-via-api"
|
||||
PARTICIPANT_WITH_END_CONFERENCE_ON_EXIT_LEFT = (
|
||||
"participant-with-end-conference-on-exit-left"
|
||||
)
|
||||
PARTICIPANT_WITH_END_CONFERENCE_ON_EXIT_KICKED = (
|
||||
"participant-with-end-conference-on-exit-kicked"
|
||||
)
|
||||
LAST_PARTICIPANT_KICKED = "last-participant-kicked"
|
||||
LAST_PARTICIPANT_LEFT = "last-participant-left"
|
||||
|
||||
class Status(object):
|
||||
INIT = "init"
|
||||
IN_PROGRESS = "in-progress"
|
||||
COMPLETED = "completed"
|
||||
|
||||
class UpdateStatus(object):
|
||||
COMPLETED = "completed"
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created this Conference resource.
|
||||
:ivar date_created: The date and time in GMT that this resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar date_updated: The date and time in GMT that this resource was last updated, specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar api_version: The API version used to create this conference.
|
||||
:ivar friendly_name: A string that you assigned to describe this conference room. Maxiumum length is 128 characters.
|
||||
:ivar region: A string that represents the Twilio Region where the conference audio was mixed. May be `us1`, `ie1`, `de1`, `sg1`, `br1`, `au1`, and `jp1`. Basic conference audio will always be mixed in `us1`. Global Conference audio will be mixed nearest to the majority of participants.
|
||||
:ivar sid: The unique string that that we created to identify this Conference resource.
|
||||
:ivar status:
|
||||
:ivar uri: The URI of this resource, relative to `https://api.twilio.com`.
|
||||
:ivar subresource_uris: A list of related resources identified by their URIs relative to `https://api.twilio.com`.
|
||||
:ivar reason_conference_ended:
|
||||
:ivar call_sid_ending_conference: The call SID that caused the conference to end.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
account_sid: str,
|
||||
sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.date_created: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.api_version: Optional[str] = payload.get("api_version")
|
||||
self.friendly_name: Optional[str] = payload.get("friendly_name")
|
||||
self.region: Optional[str] = payload.get("region")
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.status: Optional["ConferenceInstance.Status"] = payload.get("status")
|
||||
self.uri: Optional[str] = payload.get("uri")
|
||||
self.subresource_uris: Optional[Dict[str, object]] = payload.get(
|
||||
"subresource_uris"
|
||||
)
|
||||
self.reason_conference_ended: Optional[
|
||||
"ConferenceInstance.ReasonConferenceEnded"
|
||||
] = payload.get("reason_conference_ended")
|
||||
self.call_sid_ending_conference: Optional[str] = payload.get(
|
||||
"call_sid_ending_conference"
|
||||
)
|
||||
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[ConferenceContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "ConferenceContext":
|
||||
"""
|
||||
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
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = ConferenceContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def fetch(self) -> "ConferenceInstance":
|
||||
"""
|
||||
Fetch the ConferenceInstance
|
||||
|
||||
|
||||
:returns: The fetched ConferenceInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "ConferenceInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the ConferenceInstance
|
||||
|
||||
|
||||
:returns: The fetched ConferenceInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self,
|
||||
status: Union["ConferenceInstance.UpdateStatus", object] = values.unset,
|
||||
announce_url: Union[str, object] = values.unset,
|
||||
announce_method: Union[str, object] = values.unset,
|
||||
) -> "ConferenceInstance":
|
||||
"""
|
||||
Update the ConferenceInstance
|
||||
|
||||
:param status:
|
||||
:param announce_url: The URL we should call to announce something into the conference. The URL may return an MP3 file, a WAV file, or a TwiML document that contains `<Play>`, `<Say>`, `<Pause>`, or `<Redirect>` verbs.
|
||||
:param announce_method: The HTTP method used to call `announce_url`. Can be: `GET` or `POST` and the default is `POST`
|
||||
|
||||
:returns: The updated ConferenceInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
status=status,
|
||||
announce_url=announce_url,
|
||||
announce_method=announce_method,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
status: Union["ConferenceInstance.UpdateStatus", object] = values.unset,
|
||||
announce_url: Union[str, object] = values.unset,
|
||||
announce_method: Union[str, object] = values.unset,
|
||||
) -> "ConferenceInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the ConferenceInstance
|
||||
|
||||
:param status:
|
||||
:param announce_url: The URL we should call to announce something into the conference. The URL may return an MP3 file, a WAV file, or a TwiML document that contains `<Play>`, `<Say>`, `<Pause>`, or `<Redirect>` verbs.
|
||||
:param announce_method: The HTTP method used to call `announce_url`. Can be: `GET` or `POST` and the default is `POST`
|
||||
|
||||
:returns: The updated ConferenceInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
status=status,
|
||||
announce_url=announce_url,
|
||||
announce_method=announce_method,
|
||||
)
|
||||
|
||||
@property
|
||||
def participants(self) -> ParticipantList:
|
||||
"""
|
||||
Access the participants
|
||||
"""
|
||||
return self._proxy.participants
|
||||
|
||||
@property
|
||||
def recordings(self) -> RecordingList:
|
||||
"""
|
||||
Access the recordings
|
||||
"""
|
||||
return self._proxy.recordings
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.ConferenceInstance {}>".format(context)
|
||||
|
||||
|
||||
class ConferenceContext(InstanceContext):
|
||||
def __init__(self, version: Version, account_sid: str, sid: str):
|
||||
"""
|
||||
Initialize the ConferenceContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Conference resource(s) to update.
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Conference resource to update
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/Conferences/{sid}.json".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
self._participants: Optional[ParticipantList] = None
|
||||
self._recordings: Optional[RecordingList] = None
|
||||
|
||||
def fetch(self) -> ConferenceInstance:
|
||||
"""
|
||||
Fetch the ConferenceInstance
|
||||
|
||||
|
||||
:returns: The fetched ConferenceInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return ConferenceInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> ConferenceInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the ConferenceInstance
|
||||
|
||||
|
||||
:returns: The fetched ConferenceInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return ConferenceInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self,
|
||||
status: Union["ConferenceInstance.UpdateStatus", object] = values.unset,
|
||||
announce_url: Union[str, object] = values.unset,
|
||||
announce_method: Union[str, object] = values.unset,
|
||||
) -> ConferenceInstance:
|
||||
"""
|
||||
Update the ConferenceInstance
|
||||
|
||||
:param status:
|
||||
:param announce_url: The URL we should call to announce something into the conference. The URL may return an MP3 file, a WAV file, or a TwiML document that contains `<Play>`, `<Say>`, `<Pause>`, or `<Redirect>` verbs.
|
||||
:param announce_method: The HTTP method used to call `announce_url`. Can be: `GET` or `POST` and the default is `POST`
|
||||
|
||||
:returns: The updated ConferenceInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Status": status,
|
||||
"AnnounceUrl": announce_url,
|
||||
"AnnounceMethod": announce_method,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return ConferenceInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
status: Union["ConferenceInstance.UpdateStatus", object] = values.unset,
|
||||
announce_url: Union[str, object] = values.unset,
|
||||
announce_method: Union[str, object] = values.unset,
|
||||
) -> ConferenceInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the ConferenceInstance
|
||||
|
||||
:param status:
|
||||
:param announce_url: The URL we should call to announce something into the conference. The URL may return an MP3 file, a WAV file, or a TwiML document that contains `<Play>`, `<Say>`, `<Pause>`, or `<Redirect>` verbs.
|
||||
:param announce_method: The HTTP method used to call `announce_url`. Can be: `GET` or `POST` and the default is `POST`
|
||||
|
||||
:returns: The updated ConferenceInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Status": status,
|
||||
"AnnounceUrl": announce_url,
|
||||
"AnnounceMethod": announce_method,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return ConferenceInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
@property
|
||||
def participants(self) -> ParticipantList:
|
||||
"""
|
||||
Access the participants
|
||||
"""
|
||||
if self._participants is None:
|
||||
self._participants = ParticipantList(
|
||||
self._version,
|
||||
self._solution["account_sid"],
|
||||
self._solution["sid"],
|
||||
)
|
||||
return self._participants
|
||||
|
||||
@property
|
||||
def recordings(self) -> RecordingList:
|
||||
"""
|
||||
Access the recordings
|
||||
"""
|
||||
if self._recordings is None:
|
||||
self._recordings = RecordingList(
|
||||
self._version,
|
||||
self._solution["account_sid"],
|
||||
self._solution["sid"],
|
||||
)
|
||||
return self._recordings
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.ConferenceContext {}>".format(context)
|
||||
|
||||
|
||||
class ConferencePage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> ConferenceInstance:
|
||||
"""
|
||||
Build an instance of ConferenceInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return ConferenceInstance(
|
||||
self._version, payload, account_sid=self._solution["account_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.ConferencePage>"
|
||||
|
||||
|
||||
class ConferenceList(ListResource):
|
||||
def __init__(self, version: Version, account_sid: str):
|
||||
"""
|
||||
Initialize the ConferenceList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Conference resource(s) to read.
|
||||
|
||||
"""
|
||||
super().__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: Union[date, object] = values.unset,
|
||||
date_created_before: Union[date, object] = values.unset,
|
||||
date_created_after: Union[date, object] = values.unset,
|
||||
date_updated: Union[date, object] = values.unset,
|
||||
date_updated_before: Union[date, object] = values.unset,
|
||||
date_updated_after: Union[date, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
status: Union["ConferenceInstance.Status", object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[ConferenceInstance]:
|
||||
"""
|
||||
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: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that started on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that started on or after midnight on a date, use `>=YYYY-MM-DD`.
|
||||
:param date date_created_before: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that started on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that started on or after midnight on a date, use `>=YYYY-MM-DD`.
|
||||
:param date date_created_after: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that started on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that started on or after midnight on a date, use `>=YYYY-MM-DD`.
|
||||
:param date date_updated: The `date_updated` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that were last updated on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that were last updated on or after midnight on a given date, use `>=YYYY-MM-DD`.
|
||||
:param date date_updated_before: The `date_updated` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that were last updated on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that were last updated on or after midnight on a given date, use `>=YYYY-MM-DD`.
|
||||
:param date date_updated_after: The `date_updated` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that were last updated on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that were last updated on or after midnight on a given date, use `>=YYYY-MM-DD`.
|
||||
:param str friendly_name: The string that identifies the Conference resources to read.
|
||||
:param "ConferenceInstance.Status" status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(
|
||||
date_created=date_created,
|
||||
date_created_before=date_created_before,
|
||||
date_created_after=date_created_after,
|
||||
date_updated=date_updated,
|
||||
date_updated_before=date_updated_before,
|
||||
date_updated_after=date_updated_after,
|
||||
friendly_name=friendly_name,
|
||||
status=status,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
date_created: Union[date, object] = values.unset,
|
||||
date_created_before: Union[date, object] = values.unset,
|
||||
date_created_after: Union[date, object] = values.unset,
|
||||
date_updated: Union[date, object] = values.unset,
|
||||
date_updated_before: Union[date, object] = values.unset,
|
||||
date_updated_after: Union[date, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
status: Union["ConferenceInstance.Status", object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[ConferenceInstance]:
|
||||
"""
|
||||
Asynchronously 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: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that started on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that started on or after midnight on a date, use `>=YYYY-MM-DD`.
|
||||
:param date date_created_before: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that started on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that started on or after midnight on a date, use `>=YYYY-MM-DD`.
|
||||
:param date date_created_after: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that started on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that started on or after midnight on a date, use `>=YYYY-MM-DD`.
|
||||
:param date date_updated: The `date_updated` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that were last updated on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that were last updated on or after midnight on a given date, use `>=YYYY-MM-DD`.
|
||||
:param date date_updated_before: The `date_updated` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that were last updated on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that were last updated on or after midnight on a given date, use `>=YYYY-MM-DD`.
|
||||
:param date date_updated_after: The `date_updated` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that were last updated on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that were last updated on or after midnight on a given date, use `>=YYYY-MM-DD`.
|
||||
:param str friendly_name: The string that identifies the Conference resources to read.
|
||||
:param "ConferenceInstance.Status" status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(
|
||||
date_created=date_created,
|
||||
date_created_before=date_created_before,
|
||||
date_created_after=date_created_after,
|
||||
date_updated=date_updated,
|
||||
date_updated_before=date_updated_before,
|
||||
date_updated_after=date_updated_after,
|
||||
friendly_name=friendly_name,
|
||||
status=status,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
date_created: Union[date, object] = values.unset,
|
||||
date_created_before: Union[date, object] = values.unset,
|
||||
date_created_after: Union[date, object] = values.unset,
|
||||
date_updated: Union[date, object] = values.unset,
|
||||
date_updated_before: Union[date, object] = values.unset,
|
||||
date_updated_after: Union[date, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
status: Union["ConferenceInstance.Status", object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[ConferenceInstance]:
|
||||
"""
|
||||
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: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that started on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that started on or after midnight on a date, use `>=YYYY-MM-DD`.
|
||||
:param date date_created_before: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that started on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that started on or after midnight on a date, use `>=YYYY-MM-DD`.
|
||||
:param date date_created_after: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that started on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that started on or after midnight on a date, use `>=YYYY-MM-DD`.
|
||||
:param date date_updated: The `date_updated` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that were last updated on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that were last updated on or after midnight on a given date, use `>=YYYY-MM-DD`.
|
||||
:param date date_updated_before: The `date_updated` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that were last updated on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that were last updated on or after midnight on a given date, use `>=YYYY-MM-DD`.
|
||||
:param date date_updated_after: The `date_updated` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that were last updated on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that were last updated on or after midnight on a given date, use `>=YYYY-MM-DD`.
|
||||
:param str friendly_name: The string that identifies the Conference resources to read.
|
||||
:param "ConferenceInstance.Status" status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return list(
|
||||
self.stream(
|
||||
date_created=date_created,
|
||||
date_created_before=date_created_before,
|
||||
date_created_after=date_created_after,
|
||||
date_updated=date_updated,
|
||||
date_updated_before=date_updated_before,
|
||||
date_updated_after=date_updated_after,
|
||||
friendly_name=friendly_name,
|
||||
status=status,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
date_created: Union[date, object] = values.unset,
|
||||
date_created_before: Union[date, object] = values.unset,
|
||||
date_created_after: Union[date, object] = values.unset,
|
||||
date_updated: Union[date, object] = values.unset,
|
||||
date_updated_before: Union[date, object] = values.unset,
|
||||
date_updated_after: Union[date, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
status: Union["ConferenceInstance.Status", object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[ConferenceInstance]:
|
||||
"""
|
||||
Asynchronously 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: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that started on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that started on or after midnight on a date, use `>=YYYY-MM-DD`.
|
||||
:param date date_created_before: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that started on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that started on or after midnight on a date, use `>=YYYY-MM-DD`.
|
||||
:param date date_created_after: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that started on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that started on or after midnight on a date, use `>=YYYY-MM-DD`.
|
||||
:param date date_updated: The `date_updated` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that were last updated on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that were last updated on or after midnight on a given date, use `>=YYYY-MM-DD`.
|
||||
:param date date_updated_before: The `date_updated` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that were last updated on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that were last updated on or after midnight on a given date, use `>=YYYY-MM-DD`.
|
||||
:param date date_updated_after: The `date_updated` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that were last updated on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that were last updated on or after midnight on a given date, use `>=YYYY-MM-DD`.
|
||||
:param str friendly_name: The string that identifies the Conference resources to read.
|
||||
:param "ConferenceInstance.Status" status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return [
|
||||
record
|
||||
async for record in await self.stream_async(
|
||||
date_created=date_created,
|
||||
date_created_before=date_created_before,
|
||||
date_created_after=date_created_after,
|
||||
date_updated=date_updated,
|
||||
date_updated_before=date_updated_before,
|
||||
date_updated_after=date_updated_after,
|
||||
friendly_name=friendly_name,
|
||||
status=status,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
date_created: Union[date, object] = values.unset,
|
||||
date_created_before: Union[date, object] = values.unset,
|
||||
date_created_after: Union[date, object] = values.unset,
|
||||
date_updated: Union[date, object] = values.unset,
|
||||
date_updated_before: Union[date, object] = values.unset,
|
||||
date_updated_after: Union[date, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
status: Union["ConferenceInstance.Status", object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> ConferencePage:
|
||||
"""
|
||||
Retrieve a single page of ConferenceInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param date_created: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that started on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that started on or after midnight on a date, use `>=YYYY-MM-DD`.
|
||||
:param date_created_before: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that started on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that started on or after midnight on a date, use `>=YYYY-MM-DD`.
|
||||
:param date_created_after: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that started on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that started on or after midnight on a date, use `>=YYYY-MM-DD`.
|
||||
:param date_updated: The `date_updated` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that were last updated on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that were last updated on or after midnight on a given date, use `>=YYYY-MM-DD`.
|
||||
:param date_updated_before: The `date_updated` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that were last updated on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that were last updated on or after midnight on a given date, use `>=YYYY-MM-DD`.
|
||||
:param date_updated_after: The `date_updated` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that were last updated on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that were last updated on or after midnight on a given date, use `>=YYYY-MM-DD`.
|
||||
:param friendly_name: The string that identifies the Conference resources to read.
|
||||
:param status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of ConferenceInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"DateCreated": serialize.iso8601_date(date_created),
|
||||
"DateCreated<": serialize.iso8601_date(date_created_before),
|
||||
"DateCreated>": serialize.iso8601_date(date_created_after),
|
||||
"DateUpdated": serialize.iso8601_date(date_updated),
|
||||
"DateUpdated<": serialize.iso8601_date(date_updated_before),
|
||||
"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(method="GET", uri=self._uri, params=data)
|
||||
return ConferencePage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
date_created: Union[date, object] = values.unset,
|
||||
date_created_before: Union[date, object] = values.unset,
|
||||
date_created_after: Union[date, object] = values.unset,
|
||||
date_updated: Union[date, object] = values.unset,
|
||||
date_updated_before: Union[date, object] = values.unset,
|
||||
date_updated_after: Union[date, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
status: Union["ConferenceInstance.Status", object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> ConferencePage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of ConferenceInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param date_created: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that started on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that started on or after midnight on a date, use `>=YYYY-MM-DD`.
|
||||
:param date_created_before: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that started on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that started on or after midnight on a date, use `>=YYYY-MM-DD`.
|
||||
:param date_created_after: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that started on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that started on or after midnight on a date, use `>=YYYY-MM-DD`.
|
||||
:param date_updated: The `date_updated` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that were last updated on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that were last updated on or after midnight on a given date, use `>=YYYY-MM-DD`.
|
||||
:param date_updated_before: The `date_updated` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that were last updated on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that were last updated on or after midnight on a given date, use `>=YYYY-MM-DD`.
|
||||
:param date_updated_after: The `date_updated` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that were last updated on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that were last updated on or after midnight on a given date, use `>=YYYY-MM-DD`.
|
||||
:param friendly_name: The string that identifies the Conference resources to read.
|
||||
:param status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of ConferenceInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"DateCreated": serialize.iso8601_date(date_created),
|
||||
"DateCreated<": serialize.iso8601_date(date_created_before),
|
||||
"DateCreated>": serialize.iso8601_date(date_created_after),
|
||||
"DateUpdated": serialize.iso8601_date(date_updated),
|
||||
"DateUpdated<": serialize.iso8601_date(date_updated_before),
|
||||
"DateUpdated>": serialize.iso8601_date(date_updated_after),
|
||||
"FriendlyName": friendly_name,
|
||||
"Status": status,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return ConferencePage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> ConferencePage:
|
||||
"""
|
||||
Retrieve a specific page of ConferenceInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of ConferenceInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return ConferencePage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> ConferencePage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of ConferenceInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of ConferenceInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return ConferencePage(self._version, response, self._solution)
|
||||
|
||||
def get(self, sid: str) -> ConferenceContext:
|
||||
"""
|
||||
Constructs a ConferenceContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Conference resource to update
|
||||
"""
|
||||
return ConferenceContext(
|
||||
self._version, account_sid=self._solution["account_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> ConferenceContext:
|
||||
"""
|
||||
Constructs a ConferenceContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Conference resource to update
|
||||
"""
|
||||
return ConferenceContext(
|
||||
self._version, account_sid=self._solution["account_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.ConferenceList>"
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
+1152
File diff suppressed because it is too large
Load Diff
+691
@@ -0,0 +1,691 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from datetime import date, datetime
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, serialize, values
|
||||
from twilio.base.instance_context import InstanceContext
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.page import Page
|
||||
|
||||
|
||||
class RecordingInstance(InstanceResource):
|
||||
class Source(object):
|
||||
DIALVERB = "DialVerb"
|
||||
CONFERENCE = "Conference"
|
||||
OUTBOUNDAPI = "OutboundAPI"
|
||||
TRUNKING = "Trunking"
|
||||
RECORDVERB = "RecordVerb"
|
||||
STARTCALLRECORDINGAPI = "StartCallRecordingAPI"
|
||||
STARTCONFERENCERECORDINGAPI = "StartConferenceRecordingAPI"
|
||||
|
||||
class Status(object):
|
||||
IN_PROGRESS = "in-progress"
|
||||
PAUSED = "paused"
|
||||
STOPPED = "stopped"
|
||||
PROCESSING = "processing"
|
||||
COMPLETED = "completed"
|
||||
ABSENT = "absent"
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Conference Recording resource.
|
||||
:ivar api_version: The API version used to create the recording.
|
||||
:ivar call_sid: The SID of the [Call](https://www.twilio.com/docs/voice/api/call-resource) the Conference Recording resource is associated with.
|
||||
:ivar conference_sid: The Conference SID that identifies the conference associated with the recording.
|
||||
:ivar date_created: The date and time in GMT that the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar date_updated: The date and time in GMT that the resource was last updated, specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar start_time: The start time of the recording in GMT and in [RFC 2822](https://www.php.net/manual/en/class.datetime.php#datetime.constants.rfc2822) format.
|
||||
:ivar duration: The length of the recording in seconds.
|
||||
:ivar sid: The unique string that that we created to identify the Conference Recording resource.
|
||||
:ivar price: The one-time cost of creating the recording in the `price_unit` currency.
|
||||
:ivar price_unit: The currency used in the `price` property. Example: `USD`.
|
||||
:ivar status:
|
||||
:ivar channels: The number of channels in the final recording file. Can be: `1`, or `2`. Separating a two leg call into two separate channels of the recording file is supported in [Dial](https://www.twilio.com/docs/voice/twiml/dial#attributes-record) and [Outbound Rest API](https://www.twilio.com/docs/voice/make-calls) record options.
|
||||
:ivar source:
|
||||
:ivar error_code: The error code that describes why the recording is `absent`. The error code is described in our [Error Dictionary](https://www.twilio.com/docs/api/errors). This value is null if the recording `status` is not `absent`.
|
||||
:ivar encryption_details: How to decrypt the recording if it was encrypted using [Call Recording Encryption](https://www.twilio.com/docs/voice/tutorials/voice-recording-encryption) feature.
|
||||
:ivar uri: The URI of the resource, relative to `https://api.twilio.com`.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
account_sid: str,
|
||||
conference_sid: str,
|
||||
sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.api_version: Optional[str] = payload.get("api_version")
|
||||
self.call_sid: Optional[str] = payload.get("call_sid")
|
||||
self.conference_sid: Optional[str] = payload.get("conference_sid")
|
||||
self.date_created: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.start_time: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("start_time")
|
||||
)
|
||||
self.duration: Optional[str] = payload.get("duration")
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.price: Optional[str] = payload.get("price")
|
||||
self.price_unit: Optional[str] = payload.get("price_unit")
|
||||
self.status: Optional["RecordingInstance.Status"] = payload.get("status")
|
||||
self.channels: Optional[int] = deserialize.integer(payload.get("channels"))
|
||||
self.source: Optional["RecordingInstance.Source"] = payload.get("source")
|
||||
self.error_code: Optional[int] = deserialize.integer(payload.get("error_code"))
|
||||
self.encryption_details: Optional[Dict[str, object]] = payload.get(
|
||||
"encryption_details"
|
||||
)
|
||||
self.uri: Optional[str] = payload.get("uri")
|
||||
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"conference_sid": conference_sid,
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[RecordingContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "RecordingContext":
|
||||
"""
|
||||
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
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = RecordingContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
conference_sid=self._solution["conference_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the RecordingInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the RecordingInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
def fetch(self) -> "RecordingInstance":
|
||||
"""
|
||||
Fetch the RecordingInstance
|
||||
|
||||
|
||||
:returns: The fetched RecordingInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "RecordingInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the RecordingInstance
|
||||
|
||||
|
||||
:returns: The fetched RecordingInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self,
|
||||
status: "RecordingInstance.Status",
|
||||
pause_behavior: Union[str, object] = values.unset,
|
||||
) -> "RecordingInstance":
|
||||
"""
|
||||
Update the RecordingInstance
|
||||
|
||||
:param status:
|
||||
:param pause_behavior: Whether to record during a pause. Can be: `skip` or `silence` and the default is `silence`. `skip` does not record during the pause period, while `silence` will replace the actual audio of the call with silence during the pause period. This parameter only applies when setting `status` is set to `paused`.
|
||||
|
||||
:returns: The updated RecordingInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
status=status,
|
||||
pause_behavior=pause_behavior,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
status: "RecordingInstance.Status",
|
||||
pause_behavior: Union[str, object] = values.unset,
|
||||
) -> "RecordingInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the RecordingInstance
|
||||
|
||||
:param status:
|
||||
:param pause_behavior: Whether to record during a pause. Can be: `skip` or `silence` and the default is `silence`. `skip` does not record during the pause period, while `silence` will replace the actual audio of the call with silence during the pause period. This parameter only applies when setting `status` is set to `paused`.
|
||||
|
||||
:returns: The updated RecordingInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
status=status,
|
||||
pause_behavior=pause_behavior,
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.RecordingInstance {}>".format(context)
|
||||
|
||||
|
||||
class RecordingContext(InstanceContext):
|
||||
def __init__(
|
||||
self, version: Version, account_sid: str, conference_sid: str, sid: str
|
||||
):
|
||||
"""
|
||||
Initialize the RecordingContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Conference Recording resource to update.
|
||||
:param conference_sid: The Conference SID that identifies the conference associated with the recording to update.
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Conference Recording resource to update. Use `Twilio.CURRENT` to reference the current active recording.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"conference_sid": conference_sid,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/Conferences/{conference_sid}/Recordings/{sid}.json".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the RecordingInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._version.delete(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the RecordingInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
def fetch(self) -> RecordingInstance:
|
||||
"""
|
||||
Fetch the RecordingInstance
|
||||
|
||||
|
||||
:returns: The fetched RecordingInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return RecordingInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
conference_sid=self._solution["conference_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> RecordingInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the RecordingInstance
|
||||
|
||||
|
||||
:returns: The fetched RecordingInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return RecordingInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
conference_sid=self._solution["conference_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self,
|
||||
status: "RecordingInstance.Status",
|
||||
pause_behavior: Union[str, object] = values.unset,
|
||||
) -> RecordingInstance:
|
||||
"""
|
||||
Update the RecordingInstance
|
||||
|
||||
:param status:
|
||||
:param pause_behavior: Whether to record during a pause. Can be: `skip` or `silence` and the default is `silence`. `skip` does not record during the pause period, while `silence` will replace the actual audio of the call with silence during the pause period. This parameter only applies when setting `status` is set to `paused`.
|
||||
|
||||
:returns: The updated RecordingInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Status": status,
|
||||
"PauseBehavior": pause_behavior,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return RecordingInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
conference_sid=self._solution["conference_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
status: "RecordingInstance.Status",
|
||||
pause_behavior: Union[str, object] = values.unset,
|
||||
) -> RecordingInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the RecordingInstance
|
||||
|
||||
:param status:
|
||||
:param pause_behavior: Whether to record during a pause. Can be: `skip` or `silence` and the default is `silence`. `skip` does not record during the pause period, while `silence` will replace the actual audio of the call with silence during the pause period. This parameter only applies when setting `status` is set to `paused`.
|
||||
|
||||
:returns: The updated RecordingInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Status": status,
|
||||
"PauseBehavior": pause_behavior,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return RecordingInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
conference_sid=self._solution["conference_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.RecordingContext {}>".format(context)
|
||||
|
||||
|
||||
class RecordingPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> RecordingInstance:
|
||||
"""
|
||||
Build an instance of RecordingInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return RecordingInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
conference_sid=self._solution["conference_sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.RecordingPage>"
|
||||
|
||||
|
||||
class RecordingList(ListResource):
|
||||
def __init__(self, version: Version, account_sid: str, conference_sid: str):
|
||||
"""
|
||||
Initialize the RecordingList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Conference Recording resources to read.
|
||||
:param conference_sid: The Conference SID that identifies the conference associated with the recording to read.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"conference_sid": conference_sid,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/Conferences/{conference_sid}/Recordings.json".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
date_created: Union[date, object] = values.unset,
|
||||
date_created_before: Union[date, object] = values.unset,
|
||||
date_created_after: Union[date, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[RecordingInstance]:
|
||||
"""
|
||||
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: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param date date_created_before: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param date date_created_after: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(
|
||||
date_created=date_created,
|
||||
date_created_before=date_created_before,
|
||||
date_created_after=date_created_after,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
date_created: Union[date, object] = values.unset,
|
||||
date_created_before: Union[date, object] = values.unset,
|
||||
date_created_after: Union[date, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[RecordingInstance]:
|
||||
"""
|
||||
Asynchronously 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: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param date date_created_before: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param date date_created_after: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(
|
||||
date_created=date_created,
|
||||
date_created_before=date_created_before,
|
||||
date_created_after=date_created_after,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
date_created: Union[date, object] = values.unset,
|
||||
date_created_before: Union[date, object] = values.unset,
|
||||
date_created_after: Union[date, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[RecordingInstance]:
|
||||
"""
|
||||
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: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param date date_created_before: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param date date_created_after: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return list(
|
||||
self.stream(
|
||||
date_created=date_created,
|
||||
date_created_before=date_created_before,
|
||||
date_created_after=date_created_after,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
date_created: Union[date, object] = values.unset,
|
||||
date_created_before: Union[date, object] = values.unset,
|
||||
date_created_after: Union[date, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[RecordingInstance]:
|
||||
"""
|
||||
Asynchronously 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: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param date date_created_before: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param date date_created_after: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return [
|
||||
record
|
||||
async for record in await self.stream_async(
|
||||
date_created=date_created,
|
||||
date_created_before=date_created_before,
|
||||
date_created_after=date_created_after,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
date_created: Union[date, object] = values.unset,
|
||||
date_created_before: Union[date, object] = values.unset,
|
||||
date_created_after: Union[date, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> RecordingPage:
|
||||
"""
|
||||
Retrieve a single page of RecordingInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param date_created: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param date_created_before: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param date_created_after: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of RecordingInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"DateCreated": serialize.iso8601_date(date_created),
|
||||
"DateCreated<": serialize.iso8601_date(date_created_before),
|
||||
"DateCreated>": serialize.iso8601_date(date_created_after),
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return RecordingPage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
date_created: Union[date, object] = values.unset,
|
||||
date_created_before: Union[date, object] = values.unset,
|
||||
date_created_after: Union[date, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> RecordingPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of RecordingInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param date_created: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param date_created_before: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param date_created_after: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of RecordingInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"DateCreated": serialize.iso8601_date(date_created),
|
||||
"DateCreated<": serialize.iso8601_date(date_created_before),
|
||||
"DateCreated>": serialize.iso8601_date(date_created_after),
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return RecordingPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> RecordingPage:
|
||||
"""
|
||||
Retrieve a specific page of RecordingInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of RecordingInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return RecordingPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> RecordingPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of RecordingInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of RecordingInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return RecordingPage(self._version, response, self._solution)
|
||||
|
||||
def get(self, sid: str) -> RecordingContext:
|
||||
"""
|
||||
Constructs a RecordingContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Conference Recording resource to update. Use `Twilio.CURRENT` to reference the current active recording.
|
||||
"""
|
||||
return RecordingContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
conference_sid=self._solution["conference_sid"],
|
||||
sid=sid,
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> RecordingContext:
|
||||
"""
|
||||
Constructs a RecordingContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Conference Recording resource to update. Use `Twilio.CURRENT` to reference the current active recording.
|
||||
"""
|
||||
return RecordingContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
conference_sid=self._solution["conference_sid"],
|
||||
sid=sid,
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.RecordingList>"
|
||||
@@ -0,0 +1,663 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import serialize, values
|
||||
from twilio.base.instance_context import InstanceContext
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.page import Page
|
||||
|
||||
|
||||
class ConnectAppInstance(InstanceResource):
|
||||
class Permission(object):
|
||||
GET_ALL = "get-all"
|
||||
POST_ALL = "post-all"
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the ConnectApp resource.
|
||||
:ivar authorize_redirect_url: The URL we redirect the user to after we authenticate the user and obtain authorization to access the Connect App.
|
||||
:ivar company_name: The company name set for the Connect App.
|
||||
:ivar deauthorize_callback_method: The HTTP method we use to call `deauthorize_callback_url`.
|
||||
:ivar deauthorize_callback_url: The URL we call using the `deauthorize_callback_method` to de-authorize the Connect App.
|
||||
:ivar description: The description of the Connect App.
|
||||
:ivar friendly_name: The string that you assigned to describe the resource.
|
||||
:ivar homepage_url: The public URL where users can obtain more information about this Connect App.
|
||||
:ivar permissions: The set of permissions that your ConnectApp requests.
|
||||
:ivar sid: The unique string that that we created to identify the ConnectApp resource.
|
||||
:ivar uri: The URI of the resource, relative to `https://api.twilio.com`.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
account_sid: str,
|
||||
sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.authorize_redirect_url: Optional[str] = payload.get(
|
||||
"authorize_redirect_url"
|
||||
)
|
||||
self.company_name: Optional[str] = payload.get("company_name")
|
||||
self.deauthorize_callback_method: Optional[str] = payload.get(
|
||||
"deauthorize_callback_method"
|
||||
)
|
||||
self.deauthorize_callback_url: Optional[str] = payload.get(
|
||||
"deauthorize_callback_url"
|
||||
)
|
||||
self.description: Optional[str] = payload.get("description")
|
||||
self.friendly_name: Optional[str] = payload.get("friendly_name")
|
||||
self.homepage_url: Optional[str] = payload.get("homepage_url")
|
||||
self.permissions: Optional[List["ConnectAppInstance.Permission"]] = payload.get(
|
||||
"permissions"
|
||||
)
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.uri: Optional[str] = payload.get("uri")
|
||||
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[ConnectAppContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "ConnectAppContext":
|
||||
"""
|
||||
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
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = ConnectAppContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the ConnectAppInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the ConnectAppInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
def fetch(self) -> "ConnectAppInstance":
|
||||
"""
|
||||
Fetch the ConnectAppInstance
|
||||
|
||||
|
||||
:returns: The fetched ConnectAppInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "ConnectAppInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the ConnectAppInstance
|
||||
|
||||
|
||||
:returns: The fetched ConnectAppInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self,
|
||||
authorize_redirect_url: Union[str, object] = values.unset,
|
||||
company_name: Union[str, object] = values.unset,
|
||||
deauthorize_callback_method: Union[str, object] = values.unset,
|
||||
deauthorize_callback_url: Union[str, object] = values.unset,
|
||||
description: Union[str, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
homepage_url: Union[str, object] = values.unset,
|
||||
permissions: Union[
|
||||
List["ConnectAppInstance.Permission"], object
|
||||
] = values.unset,
|
||||
) -> "ConnectAppInstance":
|
||||
"""
|
||||
Update the ConnectAppInstance
|
||||
|
||||
:param authorize_redirect_url: The URL to redirect the user to after we authenticate the user and obtain authorization to access the Connect App.
|
||||
:param company_name: The company name to set for the Connect App.
|
||||
:param deauthorize_callback_method: The HTTP method to use when calling `deauthorize_callback_url`.
|
||||
:param deauthorize_callback_url: The URL to call using the `deauthorize_callback_method` to de-authorize the Connect App.
|
||||
:param description: A description of the Connect App.
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long.
|
||||
:param homepage_url: A public URL where users can obtain more information about this Connect App.
|
||||
:param permissions: A comma-separated list of the permissions you will request from the users of this ConnectApp. Can include: `get-all` and `post-all`.
|
||||
|
||||
:returns: The updated 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,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
authorize_redirect_url: Union[str, object] = values.unset,
|
||||
company_name: Union[str, object] = values.unset,
|
||||
deauthorize_callback_method: Union[str, object] = values.unset,
|
||||
deauthorize_callback_url: Union[str, object] = values.unset,
|
||||
description: Union[str, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
homepage_url: Union[str, object] = values.unset,
|
||||
permissions: Union[
|
||||
List["ConnectAppInstance.Permission"], object
|
||||
] = values.unset,
|
||||
) -> "ConnectAppInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the ConnectAppInstance
|
||||
|
||||
:param authorize_redirect_url: The URL to redirect the user to after we authenticate the user and obtain authorization to access the Connect App.
|
||||
:param company_name: The company name to set for the Connect App.
|
||||
:param deauthorize_callback_method: The HTTP method to use when calling `deauthorize_callback_url`.
|
||||
:param deauthorize_callback_url: The URL to call using the `deauthorize_callback_method` to de-authorize the Connect App.
|
||||
:param description: A description of the Connect App.
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long.
|
||||
:param homepage_url: A public URL where users can obtain more information about this Connect App.
|
||||
:param permissions: A comma-separated list of the permissions you will request from the users of this ConnectApp. Can include: `get-all` and `post-all`.
|
||||
|
||||
:returns: The updated ConnectAppInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
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) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.ConnectAppInstance {}>".format(context)
|
||||
|
||||
|
||||
class ConnectAppContext(InstanceContext):
|
||||
def __init__(self, version: Version, account_sid: str, sid: str):
|
||||
"""
|
||||
Initialize the ConnectAppContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the ConnectApp resources to update.
|
||||
:param sid: The Twilio-provided string that uniquely identifies the ConnectApp resource to update.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/ConnectApps/{sid}.json".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the ConnectAppInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._version.delete(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the ConnectAppInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
def fetch(self) -> ConnectAppInstance:
|
||||
"""
|
||||
Fetch the ConnectAppInstance
|
||||
|
||||
|
||||
:returns: The fetched ConnectAppInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return ConnectAppInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> ConnectAppInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the ConnectAppInstance
|
||||
|
||||
|
||||
:returns: The fetched ConnectAppInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return ConnectAppInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self,
|
||||
authorize_redirect_url: Union[str, object] = values.unset,
|
||||
company_name: Union[str, object] = values.unset,
|
||||
deauthorize_callback_method: Union[str, object] = values.unset,
|
||||
deauthorize_callback_url: Union[str, object] = values.unset,
|
||||
description: Union[str, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
homepage_url: Union[str, object] = values.unset,
|
||||
permissions: Union[
|
||||
List["ConnectAppInstance.Permission"], object
|
||||
] = values.unset,
|
||||
) -> ConnectAppInstance:
|
||||
"""
|
||||
Update the ConnectAppInstance
|
||||
|
||||
:param authorize_redirect_url: The URL to redirect the user to after we authenticate the user and obtain authorization to access the Connect App.
|
||||
:param company_name: The company name to set for the Connect App.
|
||||
:param deauthorize_callback_method: The HTTP method to use when calling `deauthorize_callback_url`.
|
||||
:param deauthorize_callback_url: The URL to call using the `deauthorize_callback_method` to de-authorize the Connect App.
|
||||
:param description: A description of the Connect App.
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long.
|
||||
:param homepage_url: A public URL where users can obtain more information about this Connect App.
|
||||
:param permissions: A comma-separated list of the permissions you will request from the users of this ConnectApp. Can include: `get-all` and `post-all`.
|
||||
|
||||
:returns: The updated 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": serialize.map(permissions, lambda e: e),
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return ConnectAppInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
authorize_redirect_url: Union[str, object] = values.unset,
|
||||
company_name: Union[str, object] = values.unset,
|
||||
deauthorize_callback_method: Union[str, object] = values.unset,
|
||||
deauthorize_callback_url: Union[str, object] = values.unset,
|
||||
description: Union[str, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
homepage_url: Union[str, object] = values.unset,
|
||||
permissions: Union[
|
||||
List["ConnectAppInstance.Permission"], object
|
||||
] = values.unset,
|
||||
) -> ConnectAppInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the ConnectAppInstance
|
||||
|
||||
:param authorize_redirect_url: The URL to redirect the user to after we authenticate the user and obtain authorization to access the Connect App.
|
||||
:param company_name: The company name to set for the Connect App.
|
||||
:param deauthorize_callback_method: The HTTP method to use when calling `deauthorize_callback_url`.
|
||||
:param deauthorize_callback_url: The URL to call using the `deauthorize_callback_method` to de-authorize the Connect App.
|
||||
:param description: A description of the Connect App.
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long.
|
||||
:param homepage_url: A public URL where users can obtain more information about this Connect App.
|
||||
:param permissions: A comma-separated list of the permissions you will request from the users of this ConnectApp. Can include: `get-all` and `post-all`.
|
||||
|
||||
:returns: The updated 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": serialize.map(permissions, lambda e: e),
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return ConnectAppInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.ConnectAppContext {}>".format(context)
|
||||
|
||||
|
||||
class ConnectAppPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> ConnectAppInstance:
|
||||
"""
|
||||
Build an instance of ConnectAppInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return ConnectAppInstance(
|
||||
self._version, payload, account_sid=self._solution["account_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.ConnectAppPage>"
|
||||
|
||||
|
||||
class ConnectAppList(ListResource):
|
||||
def __init__(self, version: Version, account_sid: str):
|
||||
"""
|
||||
Initialize the ConnectAppList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the ConnectApp resources to read.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/ConnectApps.json".format(**self._solution)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[ConnectAppInstance]:
|
||||
"""
|
||||
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 limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[ConnectAppInstance]:
|
||||
"""
|
||||
Asynchronously 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 limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[ConnectAppInstance]:
|
||||
"""
|
||||
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 limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return list(
|
||||
self.stream(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[ConnectAppInstance]:
|
||||
"""
|
||||
Asynchronously 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 limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return [
|
||||
record
|
||||
async for record in await self.stream_async(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> ConnectAppPage:
|
||||
"""
|
||||
Retrieve a single page of ConnectAppInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of ConnectAppInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return ConnectAppPage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> ConnectAppPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of ConnectAppInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of ConnectAppInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return ConnectAppPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> ConnectAppPage:
|
||||
"""
|
||||
Retrieve a specific page of ConnectAppInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of ConnectAppInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return ConnectAppPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> ConnectAppPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of ConnectAppInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of ConnectAppInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return ConnectAppPage(self._version, response, self._solution)
|
||||
|
||||
def get(self, sid: str) -> ConnectAppContext:
|
||||
"""
|
||||
Constructs a ConnectAppContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the ConnectApp resource to update.
|
||||
"""
|
||||
return ConnectAppContext(
|
||||
self._version, account_sid=self._solution["account_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> ConnectAppContext:
|
||||
"""
|
||||
Constructs a ConnectAppContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the ConnectApp resource to update.
|
||||
"""
|
||||
return ConnectAppContext(
|
||||
self._version, account_sid=self._solution["account_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.ConnectAppList>"
|
||||
+1267
File diff suppressed because it is too large
Load Diff
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
+577
@@ -0,0 +1,577 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, values
|
||||
from twilio.base.instance_context import InstanceContext
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.page import Page
|
||||
from twilio.rest.api.v2010.account.incoming_phone_number.assigned_add_on.assigned_add_on_extension import (
|
||||
AssignedAddOnExtensionList,
|
||||
)
|
||||
|
||||
|
||||
class AssignedAddOnInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar sid: The unique string that that we created to identify the resource.
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the resource.
|
||||
:ivar resource_sid: The SID of the Phone Number to which the Add-on is assigned.
|
||||
:ivar friendly_name: The string that you assigned to describe the resource.
|
||||
:ivar description: A short description of the functionality that the Add-on provides.
|
||||
:ivar configuration: A JSON string that represents the current configuration of this Add-on installation.
|
||||
:ivar unique_name: An application-defined string that uniquely identifies the resource. It can be used in place of the resource's `sid` in the URL to address the resource.
|
||||
:ivar date_created: The date and time in GMT that the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar date_updated: The date and time in GMT that the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar uri: The URI of the resource, relative to `https://api.twilio.com`.
|
||||
:ivar subresource_uris: A list of related resources identified by their relative URIs.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
account_sid: str,
|
||||
resource_sid: str,
|
||||
sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.resource_sid: Optional[str] = payload.get("resource_sid")
|
||||
self.friendly_name: Optional[str] = payload.get("friendly_name")
|
||||
self.description: Optional[str] = payload.get("description")
|
||||
self.configuration: Optional[Dict[str, object]] = payload.get("configuration")
|
||||
self.unique_name: Optional[str] = payload.get("unique_name")
|
||||
self.date_created: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.uri: Optional[str] = payload.get("uri")
|
||||
self.subresource_uris: Optional[Dict[str, object]] = payload.get(
|
||||
"subresource_uris"
|
||||
)
|
||||
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"resource_sid": resource_sid,
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[AssignedAddOnContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "AssignedAddOnContext":
|
||||
"""
|
||||
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
|
||||
"""
|
||||
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
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the AssignedAddOnInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the AssignedAddOnInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
def fetch(self) -> "AssignedAddOnInstance":
|
||||
"""
|
||||
Fetch the AssignedAddOnInstance
|
||||
|
||||
|
||||
:returns: The fetched AssignedAddOnInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "AssignedAddOnInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the AssignedAddOnInstance
|
||||
|
||||
|
||||
:returns: The fetched AssignedAddOnInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
@property
|
||||
def extensions(self) -> AssignedAddOnExtensionList:
|
||||
"""
|
||||
Access the extensions
|
||||
"""
|
||||
return self._proxy.extensions
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.AssignedAddOnInstance {}>".format(context)
|
||||
|
||||
|
||||
class AssignedAddOnContext(InstanceContext):
|
||||
def __init__(self, version: Version, account_sid: str, resource_sid: str, sid: str):
|
||||
"""
|
||||
Initialize the AssignedAddOnContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the resource to fetch.
|
||||
:param resource_sid: The SID of the Phone Number to which the Add-on is assigned.
|
||||
:param sid: The Twilio-provided string that uniquely identifies the resource to fetch.
|
||||
"""
|
||||
super().__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
|
||||
)
|
||||
|
||||
self._extensions: Optional[AssignedAddOnExtensionList] = None
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the AssignedAddOnInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._version.delete(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the AssignedAddOnInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
def fetch(self) -> AssignedAddOnInstance:
|
||||
"""
|
||||
Fetch the AssignedAddOnInstance
|
||||
|
||||
|
||||
:returns: The fetched AssignedAddOnInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return AssignedAddOnInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
resource_sid=self._solution["resource_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> AssignedAddOnInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the AssignedAddOnInstance
|
||||
|
||||
|
||||
:returns: The fetched AssignedAddOnInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return AssignedAddOnInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
resource_sid=self._solution["resource_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
@property
|
||||
def extensions(self) -> AssignedAddOnExtensionList:
|
||||
"""
|
||||
Access the extensions
|
||||
"""
|
||||
if self._extensions is None:
|
||||
self._extensions = AssignedAddOnExtensionList(
|
||||
self._version,
|
||||
self._solution["account_sid"],
|
||||
self._solution["resource_sid"],
|
||||
self._solution["sid"],
|
||||
)
|
||||
return self._extensions
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.AssignedAddOnContext {}>".format(context)
|
||||
|
||||
|
||||
class AssignedAddOnPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> AssignedAddOnInstance:
|
||||
"""
|
||||
Build an instance of AssignedAddOnInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return AssignedAddOnInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
resource_sid=self._solution["resource_sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.AssignedAddOnPage>"
|
||||
|
||||
|
||||
class AssignedAddOnList(ListResource):
|
||||
def __init__(self, version: Version, account_sid: str, resource_sid: str):
|
||||
"""
|
||||
Initialize the AssignedAddOnList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the resources to read.
|
||||
:param resource_sid: The SID of the Phone Number to which the Add-on is assigned.
|
||||
|
||||
"""
|
||||
super().__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 create(self, installed_add_on_sid: str) -> AssignedAddOnInstance:
|
||||
"""
|
||||
Create the AssignedAddOnInstance
|
||||
|
||||
:param installed_add_on_sid: The SID that identifies the Add-on installation.
|
||||
|
||||
:returns: The created AssignedAddOnInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"InstalledAddOnSid": installed_add_on_sid,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return AssignedAddOnInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
resource_sid=self._solution["resource_sid"],
|
||||
)
|
||||
|
||||
async def create_async(self, installed_add_on_sid: str) -> AssignedAddOnInstance:
|
||||
"""
|
||||
Asynchronously create the AssignedAddOnInstance
|
||||
|
||||
:param installed_add_on_sid: The SID that identifies the Add-on installation.
|
||||
|
||||
:returns: The created AssignedAddOnInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"InstalledAddOnSid": installed_add_on_sid,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return AssignedAddOnInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
resource_sid=self._solution["resource_sid"],
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[AssignedAddOnInstance]:
|
||||
"""
|
||||
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 limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[AssignedAddOnInstance]:
|
||||
"""
|
||||
Asynchronously 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 limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[AssignedAddOnInstance]:
|
||||
"""
|
||||
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 limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return list(
|
||||
self.stream(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[AssignedAddOnInstance]:
|
||||
"""
|
||||
Asynchronously 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 limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return [
|
||||
record
|
||||
async for record in await self.stream_async(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> AssignedAddOnPage:
|
||||
"""
|
||||
Retrieve a single page of AssignedAddOnInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of AssignedAddOnInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return AssignedAddOnPage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> AssignedAddOnPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of AssignedAddOnInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of AssignedAddOnInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return AssignedAddOnPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> AssignedAddOnPage:
|
||||
"""
|
||||
Retrieve a specific page of AssignedAddOnInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of AssignedAddOnInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return AssignedAddOnPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> AssignedAddOnPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of AssignedAddOnInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of AssignedAddOnInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return AssignedAddOnPage(self._version, response, self._solution)
|
||||
|
||||
def get(self, sid: str) -> AssignedAddOnContext:
|
||||
"""
|
||||
Constructs a AssignedAddOnContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the resource to fetch.
|
||||
"""
|
||||
return AssignedAddOnContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
resource_sid=self._solution["resource_sid"],
|
||||
sid=sid,
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> AssignedAddOnContext:
|
||||
"""
|
||||
Constructs a AssignedAddOnContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the resource to fetch.
|
||||
"""
|
||||
return AssignedAddOnContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
resource_sid=self._solution["resource_sid"],
|
||||
sid=sid,
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.AssignedAddOnList>"
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user