Initial commit: Email alerts application
This commit is contained in:
@@ -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.voice.v1 import V1
|
||||
|
||||
|
||||
class VoiceBase(Domain):
|
||||
def __init__(self, twilio: Client):
|
||||
"""
|
||||
Initialize the Voice Domain
|
||||
|
||||
:returns: Domain for Voice
|
||||
"""
|
||||
super().__init__(twilio, "https://voice.twilio.com")
|
||||
self._v1: Optional[V1] = None
|
||||
|
||||
@property
|
||||
def v1(self) -> V1:
|
||||
"""
|
||||
:returns: Versions v1 of Voice
|
||||
"""
|
||||
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.Voice>"
|
||||
@@ -0,0 +1,65 @@
|
||||
from warnings import warn
|
||||
|
||||
from twilio.rest.voice.VoiceBase import VoiceBase
|
||||
from twilio.rest.voice.v1.archived_call import ArchivedCallList
|
||||
from twilio.rest.voice.v1.byoc_trunk import ByocTrunkList
|
||||
from twilio.rest.voice.v1.connection_policy import ConnectionPolicyList
|
||||
from twilio.rest.voice.v1.dialing_permissions import DialingPermissionsList
|
||||
from twilio.rest.voice.v1.ip_record import IpRecordList
|
||||
from twilio.rest.voice.v1.source_ip_mapping import SourceIpMappingList
|
||||
|
||||
|
||||
class Voice(VoiceBase):
|
||||
@property
|
||||
def archived_calls(self) -> ArchivedCallList:
|
||||
warn(
|
||||
"archived_calls is deprecated. Use v1.archived_calls instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.v1.archived_calls
|
||||
|
||||
@property
|
||||
def byoc_trunks(self) -> ByocTrunkList:
|
||||
warn(
|
||||
"byoc_trunks is deprecated. Use v1.byoc_trunks instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.v1.byoc_trunks
|
||||
|
||||
@property
|
||||
def connection_policies(self) -> ConnectionPolicyList:
|
||||
warn(
|
||||
"connection_policies is deprecated. Use v1.connection_policies instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.v1.connection_policies
|
||||
|
||||
@property
|
||||
def dialing_permissions(self) -> DialingPermissionsList:
|
||||
warn(
|
||||
"dialing_permissions is deprecated. Use v1.dialing_permissions instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.v1.dialing_permissions
|
||||
|
||||
@property
|
||||
def ip_records(self) -> IpRecordList:
|
||||
warn(
|
||||
"ip_records is deprecated. Use v1.ip_records instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.v1.ip_records
|
||||
|
||||
@property
|
||||
def source_ip_mappings(self) -> SourceIpMappingList:
|
||||
warn(
|
||||
"source_ip_mappings is deprecated. Use v1.source_ip_mappings instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.v1.source_ip_mappings
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -0,0 +1,82 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Voice
|
||||
This is the 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.voice.v1.archived_call import ArchivedCallList
|
||||
from twilio.rest.voice.v1.byoc_trunk import ByocTrunkList
|
||||
from twilio.rest.voice.v1.connection_policy import ConnectionPolicyList
|
||||
from twilio.rest.voice.v1.dialing_permissions import DialingPermissionsList
|
||||
from twilio.rest.voice.v1.ip_record import IpRecordList
|
||||
from twilio.rest.voice.v1.source_ip_mapping import SourceIpMappingList
|
||||
|
||||
|
||||
class V1(Version):
|
||||
def __init__(self, domain: Domain):
|
||||
"""
|
||||
Initialize the V1 version of Voice
|
||||
|
||||
:param domain: The Twilio.voice domain
|
||||
"""
|
||||
super().__init__(domain, "v1")
|
||||
self._archived_calls: Optional[ArchivedCallList] = None
|
||||
self._byoc_trunks: Optional[ByocTrunkList] = None
|
||||
self._connection_policies: Optional[ConnectionPolicyList] = None
|
||||
self._dialing_permissions: Optional[DialingPermissionsList] = None
|
||||
self._ip_records: Optional[IpRecordList] = None
|
||||
self._source_ip_mappings: Optional[SourceIpMappingList] = None
|
||||
|
||||
@property
|
||||
def archived_calls(self) -> ArchivedCallList:
|
||||
if self._archived_calls is None:
|
||||
self._archived_calls = ArchivedCallList(self)
|
||||
return self._archived_calls
|
||||
|
||||
@property
|
||||
def byoc_trunks(self) -> ByocTrunkList:
|
||||
if self._byoc_trunks is None:
|
||||
self._byoc_trunks = ByocTrunkList(self)
|
||||
return self._byoc_trunks
|
||||
|
||||
@property
|
||||
def connection_policies(self) -> ConnectionPolicyList:
|
||||
if self._connection_policies is None:
|
||||
self._connection_policies = ConnectionPolicyList(self)
|
||||
return self._connection_policies
|
||||
|
||||
@property
|
||||
def dialing_permissions(self) -> DialingPermissionsList:
|
||||
if self._dialing_permissions is None:
|
||||
self._dialing_permissions = DialingPermissionsList(self)
|
||||
return self._dialing_permissions
|
||||
|
||||
@property
|
||||
def ip_records(self) -> IpRecordList:
|
||||
if self._ip_records is None:
|
||||
self._ip_records = IpRecordList(self)
|
||||
return self._ip_records
|
||||
|
||||
@property
|
||||
def source_ip_mappings(self) -> SourceIpMappingList:
|
||||
if self._source_ip_mappings is None:
|
||||
self._source_ip_mappings = SourceIpMappingList(self)
|
||||
return self._source_ip_mappings
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Voice.V1>"
|
||||
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,109 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Voice
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from datetime import date
|
||||
from twilio.base.instance_context import InstanceContext
|
||||
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
|
||||
|
||||
class ArchivedCallContext(InstanceContext):
|
||||
def __init__(self, version: Version, date: date, sid: str):
|
||||
"""
|
||||
Initialize the ArchivedCallContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param date: The date of the Call in UTC.
|
||||
:param sid: The Twilio-provided Call SID that uniquely identifies the Call resource to delete
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"date": date,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Archives/{date}/Calls/{sid}".format(**self._solution)
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the ArchivedCallInstance
|
||||
|
||||
|
||||
: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 ArchivedCallInstance
|
||||
|
||||
|
||||
: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.Voice.V1.ArchivedCallContext {}>".format(context)
|
||||
|
||||
|
||||
class ArchivedCallList(ListResource):
|
||||
def __init__(self, version: Version):
|
||||
"""
|
||||
Initialize the ArchivedCallList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
def get(self, date: date, sid: str) -> ArchivedCallContext:
|
||||
"""
|
||||
Constructs a ArchivedCallContext
|
||||
|
||||
:param date: The date of the Call in UTC.
|
||||
:param sid: The Twilio-provided Call SID that uniquely identifies the Call resource to delete
|
||||
"""
|
||||
return ArchivedCallContext(self._version, date=date, sid=sid)
|
||||
|
||||
def __call__(self, date: date, sid: str) -> ArchivedCallContext:
|
||||
"""
|
||||
Constructs a ArchivedCallContext
|
||||
|
||||
:param date: The date of the Call in UTC.
|
||||
:param sid: The Twilio-provided Call SID that uniquely identifies the Call resource to delete
|
||||
"""
|
||||
return ArchivedCallContext(self._version, date=date, sid=sid)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Voice.V1.ArchivedCallList>"
|
||||
@@ -0,0 +1,754 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Voice
|
||||
This is the 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 ByocTrunkInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the BYOC Trunk resource.
|
||||
:ivar sid: The unique string that that we created to identify the BYOC Trunk resource.
|
||||
:ivar friendly_name: The string that you assigned to describe the resource.
|
||||
:ivar voice_url: The URL we call using the `voice_method` when the BYOC Trunk receives a call.
|
||||
:ivar voice_method: The HTTP method we use to call `voice_url`. Can be: `GET` or `POST`.
|
||||
:ivar voice_fallback_url: The URL that we call when an error occurs while retrieving or executing the TwiML requested from `voice_url`.
|
||||
:ivar voice_fallback_method: The HTTP method we use to call `voice_fallback_url`. Can be: `GET` or `POST`.
|
||||
:ivar status_callback_url: The URL that we call to pass status parameters (such as call ended) to your application.
|
||||
:ivar status_callback_method: The HTTP method we use to call `status_callback_url`. Either `GET` or `POST`.
|
||||
:ivar cnam_lookup_enabled: Whether Caller ID Name (CNAM) lookup is enabled for the trunk. If enabled, all inbound calls to the BYOC Trunk from the United States and Canada automatically perform a CNAM Lookup and display Caller ID data on your phone. See [CNAM Lookups](https://www.twilio.com/docs/sip-trunking#CNAM) for more information.
|
||||
:ivar connection_policy_sid: The SID of the Connection Policy that Twilio will use when routing traffic to your communications infrastructure.
|
||||
:ivar from_domain_sid: The SID of the SIP Domain that should be used in the `From` header of originating calls sent to your SIP infrastructure. If your SIP infrastructure allows users to \"call back\" an incoming call, configure this with a [SIP Domain](https://www.twilio.com/docs/voice/api/sending-sip) to ensure proper routing. If not configured, the from domain will default to \"sip.twilio.com\".
|
||||
: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 url: The absolute URL of the resource.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self, version: Version, payload: Dict[str, Any], sid: Optional[str] = None
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.friendly_name: Optional[str] = payload.get("friendly_name")
|
||||
self.voice_url: Optional[str] = payload.get("voice_url")
|
||||
self.voice_method: Optional[str] = payload.get("voice_method")
|
||||
self.voice_fallback_url: Optional[str] = payload.get("voice_fallback_url")
|
||||
self.voice_fallback_method: Optional[str] = payload.get("voice_fallback_method")
|
||||
self.status_callback_url: Optional[str] = payload.get("status_callback_url")
|
||||
self.status_callback_method: Optional[str] = payload.get(
|
||||
"status_callback_method"
|
||||
)
|
||||
self.cnam_lookup_enabled: Optional[bool] = payload.get("cnam_lookup_enabled")
|
||||
self.connection_policy_sid: Optional[str] = payload.get("connection_policy_sid")
|
||||
self.from_domain_sid: Optional[str] = payload.get("from_domain_sid")
|
||||
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
|
||||
self._solution = {
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[ByocTrunkContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "ByocTrunkContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: ByocTrunkContext for this ByocTrunkInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = ByocTrunkContext(
|
||||
self._version,
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the ByocTrunkInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the ByocTrunkInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
def fetch(self) -> "ByocTrunkInstance":
|
||||
"""
|
||||
Fetch the ByocTrunkInstance
|
||||
|
||||
|
||||
:returns: The fetched ByocTrunkInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "ByocTrunkInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the ByocTrunkInstance
|
||||
|
||||
|
||||
:returns: The fetched ByocTrunkInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self,
|
||||
friendly_name: 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_url: Union[str, object] = values.unset,
|
||||
status_callback_method: Union[str, object] = values.unset,
|
||||
cnam_lookup_enabled: Union[bool, object] = values.unset,
|
||||
connection_policy_sid: Union[str, object] = values.unset,
|
||||
from_domain_sid: Union[str, object] = values.unset,
|
||||
) -> "ByocTrunkInstance":
|
||||
"""
|
||||
Update the ByocTrunkInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long.
|
||||
:param voice_url: The URL we should call when the BYOC Trunk receives a call.
|
||||
:param voice_method: The HTTP method we should use to call `voice_url`
|
||||
:param voice_fallback_url: The URL that we should call when an error occurs while retrieving or executing the TwiML requested by `voice_url`.
|
||||
:param voice_fallback_method: The HTTP method we should use to call `voice_fallback_url`. Can be: `GET` or `POST`.
|
||||
:param status_callback_url: The URL that we should call to pass status parameters (such as call ended) to your application.
|
||||
:param status_callback_method: The HTTP method we should use to call `status_callback_url`. Can be: `GET` or `POST`.
|
||||
:param cnam_lookup_enabled: Whether Caller ID Name (CNAM) lookup is enabled for the trunk. If enabled, all inbound calls to the BYOC Trunk from the United States and Canada automatically perform a CNAM Lookup and display Caller ID data on your phone. See [CNAM Lookups](https://www.twilio.com/docs/sip-trunking#CNAM) for more information.
|
||||
:param connection_policy_sid: The SID of the Connection Policy that Twilio will use when routing traffic to your communications infrastructure.
|
||||
:param from_domain_sid: The SID of the SIP Domain that should be used in the `From` header of originating calls sent to your SIP infrastructure. If your SIP infrastructure allows users to \\\"call back\\\" an incoming call, configure this with a [SIP Domain](https://www.twilio.com/docs/voice/api/sending-sip) to ensure proper routing. If not configured, the from domain will default to \\\"sip.twilio.com\\\".
|
||||
|
||||
:returns: The updated ByocTrunkInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
friendly_name=friendly_name,
|
||||
voice_url=voice_url,
|
||||
voice_method=voice_method,
|
||||
voice_fallback_url=voice_fallback_url,
|
||||
voice_fallback_method=voice_fallback_method,
|
||||
status_callback_url=status_callback_url,
|
||||
status_callback_method=status_callback_method,
|
||||
cnam_lookup_enabled=cnam_lookup_enabled,
|
||||
connection_policy_sid=connection_policy_sid,
|
||||
from_domain_sid=from_domain_sid,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
friendly_name: 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_url: Union[str, object] = values.unset,
|
||||
status_callback_method: Union[str, object] = values.unset,
|
||||
cnam_lookup_enabled: Union[bool, object] = values.unset,
|
||||
connection_policy_sid: Union[str, object] = values.unset,
|
||||
from_domain_sid: Union[str, object] = values.unset,
|
||||
) -> "ByocTrunkInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the ByocTrunkInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long.
|
||||
:param voice_url: The URL we should call when the BYOC Trunk receives a call.
|
||||
:param voice_method: The HTTP method we should use to call `voice_url`
|
||||
:param voice_fallback_url: The URL that we should call when an error occurs while retrieving or executing the TwiML requested by `voice_url`.
|
||||
:param voice_fallback_method: The HTTP method we should use to call `voice_fallback_url`. Can be: `GET` or `POST`.
|
||||
:param status_callback_url: The URL that we should call to pass status parameters (such as call ended) to your application.
|
||||
:param status_callback_method: The HTTP method we should use to call `status_callback_url`. Can be: `GET` or `POST`.
|
||||
:param cnam_lookup_enabled: Whether Caller ID Name (CNAM) lookup is enabled for the trunk. If enabled, all inbound calls to the BYOC Trunk from the United States and Canada automatically perform a CNAM Lookup and display Caller ID data on your phone. See [CNAM Lookups](https://www.twilio.com/docs/sip-trunking#CNAM) for more information.
|
||||
:param connection_policy_sid: The SID of the Connection Policy that Twilio will use when routing traffic to your communications infrastructure.
|
||||
:param from_domain_sid: The SID of the SIP Domain that should be used in the `From` header of originating calls sent to your SIP infrastructure. If your SIP infrastructure allows users to \\\"call back\\\" an incoming call, configure this with a [SIP Domain](https://www.twilio.com/docs/voice/api/sending-sip) to ensure proper routing. If not configured, the from domain will default to \\\"sip.twilio.com\\\".
|
||||
|
||||
:returns: The updated ByocTrunkInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
friendly_name=friendly_name,
|
||||
voice_url=voice_url,
|
||||
voice_method=voice_method,
|
||||
voice_fallback_url=voice_fallback_url,
|
||||
voice_fallback_method=voice_fallback_method,
|
||||
status_callback_url=status_callback_url,
|
||||
status_callback_method=status_callback_method,
|
||||
cnam_lookup_enabled=cnam_lookup_enabled,
|
||||
connection_policy_sid=connection_policy_sid,
|
||||
from_domain_sid=from_domain_sid,
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Voice.V1.ByocTrunkInstance {}>".format(context)
|
||||
|
||||
|
||||
class ByocTrunkContext(InstanceContext):
|
||||
def __init__(self, version: Version, sid: str):
|
||||
"""
|
||||
Initialize the ByocTrunkContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param sid: The Twilio-provided string that uniquely identifies the BYOC Trunk resource to update.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/ByocTrunks/{sid}".format(**self._solution)
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the ByocTrunkInstance
|
||||
|
||||
|
||||
: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 ByocTrunkInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
def fetch(self) -> ByocTrunkInstance:
|
||||
"""
|
||||
Fetch the ByocTrunkInstance
|
||||
|
||||
|
||||
:returns: The fetched ByocTrunkInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return ByocTrunkInstance(
|
||||
self._version,
|
||||
payload,
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> ByocTrunkInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the ByocTrunkInstance
|
||||
|
||||
|
||||
:returns: The fetched ByocTrunkInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return ByocTrunkInstance(
|
||||
self._version,
|
||||
payload,
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self,
|
||||
friendly_name: 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_url: Union[str, object] = values.unset,
|
||||
status_callback_method: Union[str, object] = values.unset,
|
||||
cnam_lookup_enabled: Union[bool, object] = values.unset,
|
||||
connection_policy_sid: Union[str, object] = values.unset,
|
||||
from_domain_sid: Union[str, object] = values.unset,
|
||||
) -> ByocTrunkInstance:
|
||||
"""
|
||||
Update the ByocTrunkInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long.
|
||||
:param voice_url: The URL we should call when the BYOC Trunk receives a call.
|
||||
:param voice_method: The HTTP method we should use to call `voice_url`
|
||||
:param voice_fallback_url: The URL that we should call when an error occurs while retrieving or executing the TwiML requested by `voice_url`.
|
||||
:param voice_fallback_method: The HTTP method we should use to call `voice_fallback_url`. Can be: `GET` or `POST`.
|
||||
:param status_callback_url: The URL that we should call to pass status parameters (such as call ended) to your application.
|
||||
:param status_callback_method: The HTTP method we should use to call `status_callback_url`. Can be: `GET` or `POST`.
|
||||
:param cnam_lookup_enabled: Whether Caller ID Name (CNAM) lookup is enabled for the trunk. If enabled, all inbound calls to the BYOC Trunk from the United States and Canada automatically perform a CNAM Lookup and display Caller ID data on your phone. See [CNAM Lookups](https://www.twilio.com/docs/sip-trunking#CNAM) for more information.
|
||||
:param connection_policy_sid: The SID of the Connection Policy that Twilio will use when routing traffic to your communications infrastructure.
|
||||
:param from_domain_sid: The SID of the SIP Domain that should be used in the `From` header of originating calls sent to your SIP infrastructure. If your SIP infrastructure allows users to \\\"call back\\\" an incoming call, configure this with a [SIP Domain](https://www.twilio.com/docs/voice/api/sending-sip) to ensure proper routing. If not configured, the from domain will default to \\\"sip.twilio.com\\\".
|
||||
|
||||
:returns: The updated ByocTrunkInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"VoiceUrl": voice_url,
|
||||
"VoiceMethod": voice_method,
|
||||
"VoiceFallbackUrl": voice_fallback_url,
|
||||
"VoiceFallbackMethod": voice_fallback_method,
|
||||
"StatusCallbackUrl": status_callback_url,
|
||||
"StatusCallbackMethod": status_callback_method,
|
||||
"CnamLookupEnabled": cnam_lookup_enabled,
|
||||
"ConnectionPolicySid": connection_policy_sid,
|
||||
"FromDomainSid": from_domain_sid,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return ByocTrunkInstance(self._version, payload, sid=self._solution["sid"])
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
friendly_name: 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_url: Union[str, object] = values.unset,
|
||||
status_callback_method: Union[str, object] = values.unset,
|
||||
cnam_lookup_enabled: Union[bool, object] = values.unset,
|
||||
connection_policy_sid: Union[str, object] = values.unset,
|
||||
from_domain_sid: Union[str, object] = values.unset,
|
||||
) -> ByocTrunkInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the ByocTrunkInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long.
|
||||
:param voice_url: The URL we should call when the BYOC Trunk receives a call.
|
||||
:param voice_method: The HTTP method we should use to call `voice_url`
|
||||
:param voice_fallback_url: The URL that we should call when an error occurs while retrieving or executing the TwiML requested by `voice_url`.
|
||||
:param voice_fallback_method: The HTTP method we should use to call `voice_fallback_url`. Can be: `GET` or `POST`.
|
||||
:param status_callback_url: The URL that we should call to pass status parameters (such as call ended) to your application.
|
||||
:param status_callback_method: The HTTP method we should use to call `status_callback_url`. Can be: `GET` or `POST`.
|
||||
:param cnam_lookup_enabled: Whether Caller ID Name (CNAM) lookup is enabled for the trunk. If enabled, all inbound calls to the BYOC Trunk from the United States and Canada automatically perform a CNAM Lookup and display Caller ID data on your phone. See [CNAM Lookups](https://www.twilio.com/docs/sip-trunking#CNAM) for more information.
|
||||
:param connection_policy_sid: The SID of the Connection Policy that Twilio will use when routing traffic to your communications infrastructure.
|
||||
:param from_domain_sid: The SID of the SIP Domain that should be used in the `From` header of originating calls sent to your SIP infrastructure. If your SIP infrastructure allows users to \\\"call back\\\" an incoming call, configure this with a [SIP Domain](https://www.twilio.com/docs/voice/api/sending-sip) to ensure proper routing. If not configured, the from domain will default to \\\"sip.twilio.com\\\".
|
||||
|
||||
:returns: The updated ByocTrunkInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"VoiceUrl": voice_url,
|
||||
"VoiceMethod": voice_method,
|
||||
"VoiceFallbackUrl": voice_fallback_url,
|
||||
"VoiceFallbackMethod": voice_fallback_method,
|
||||
"StatusCallbackUrl": status_callback_url,
|
||||
"StatusCallbackMethod": status_callback_method,
|
||||
"CnamLookupEnabled": cnam_lookup_enabled,
|
||||
"ConnectionPolicySid": connection_policy_sid,
|
||||
"FromDomainSid": from_domain_sid,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return ByocTrunkInstance(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.Voice.V1.ByocTrunkContext {}>".format(context)
|
||||
|
||||
|
||||
class ByocTrunkPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> ByocTrunkInstance:
|
||||
"""
|
||||
Build an instance of ByocTrunkInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return ByocTrunkInstance(self._version, payload)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Voice.V1.ByocTrunkPage>"
|
||||
|
||||
|
||||
class ByocTrunkList(ListResource):
|
||||
def __init__(self, version: Version):
|
||||
"""
|
||||
Initialize the ByocTrunkList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
self._uri = "/ByocTrunks"
|
||||
|
||||
def create(
|
||||
self,
|
||||
friendly_name: 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_url: Union[str, object] = values.unset,
|
||||
status_callback_method: Union[str, object] = values.unset,
|
||||
cnam_lookup_enabled: Union[bool, object] = values.unset,
|
||||
connection_policy_sid: Union[str, object] = values.unset,
|
||||
from_domain_sid: Union[str, object] = values.unset,
|
||||
) -> ByocTrunkInstance:
|
||||
"""
|
||||
Create the ByocTrunkInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long.
|
||||
:param voice_url: The URL we should call when the BYOC Trunk 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 while retrieving or executing the TwiML from `voice_url`.
|
||||
:param voice_fallback_method: The HTTP method we should use to call `voice_fallback_url`. Can be: `GET` or `POST`.
|
||||
:param status_callback_url: The URL that we should call to pass status parameters (such as call ended) to your application.
|
||||
:param status_callback_method: The HTTP method we should use to call `status_callback_url`. Can be: `GET` or `POST`.
|
||||
:param cnam_lookup_enabled: Whether Caller ID Name (CNAM) lookup is enabled for the trunk. If enabled, all inbound calls to the BYOC Trunk from the United States and Canada automatically perform a CNAM Lookup and display Caller ID data on your phone. See [CNAM Lookups](https://www.twilio.com/docs/sip-trunking#CNAM) for more information.
|
||||
:param connection_policy_sid: The SID of the Connection Policy that Twilio will use when routing traffic to your communications infrastructure.
|
||||
:param from_domain_sid: The SID of the SIP Domain that should be used in the `From` header of originating calls sent to your SIP infrastructure. If your SIP infrastructure allows users to \\\"call back\\\" an incoming call, configure this with a [SIP Domain](https://www.twilio.com/docs/voice/api/sending-sip) to ensure proper routing. If not configured, the from domain will default to \\\"sip.twilio.com\\\".
|
||||
|
||||
:returns: The created ByocTrunkInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"VoiceUrl": voice_url,
|
||||
"VoiceMethod": voice_method,
|
||||
"VoiceFallbackUrl": voice_fallback_url,
|
||||
"VoiceFallbackMethod": voice_fallback_method,
|
||||
"StatusCallbackUrl": status_callback_url,
|
||||
"StatusCallbackMethod": status_callback_method,
|
||||
"CnamLookupEnabled": cnam_lookup_enabled,
|
||||
"ConnectionPolicySid": connection_policy_sid,
|
||||
"FromDomainSid": from_domain_sid,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return ByocTrunkInstance(self._version, payload)
|
||||
|
||||
async def create_async(
|
||||
self,
|
||||
friendly_name: 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_url: Union[str, object] = values.unset,
|
||||
status_callback_method: Union[str, object] = values.unset,
|
||||
cnam_lookup_enabled: Union[bool, object] = values.unset,
|
||||
connection_policy_sid: Union[str, object] = values.unset,
|
||||
from_domain_sid: Union[str, object] = values.unset,
|
||||
) -> ByocTrunkInstance:
|
||||
"""
|
||||
Asynchronously create the ByocTrunkInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long.
|
||||
:param voice_url: The URL we should call when the BYOC Trunk 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 while retrieving or executing the TwiML from `voice_url`.
|
||||
:param voice_fallback_method: The HTTP method we should use to call `voice_fallback_url`. Can be: `GET` or `POST`.
|
||||
:param status_callback_url: The URL that we should call to pass status parameters (such as call ended) to your application.
|
||||
:param status_callback_method: The HTTP method we should use to call `status_callback_url`. Can be: `GET` or `POST`.
|
||||
:param cnam_lookup_enabled: Whether Caller ID Name (CNAM) lookup is enabled for the trunk. If enabled, all inbound calls to the BYOC Trunk from the United States and Canada automatically perform a CNAM Lookup and display Caller ID data on your phone. See [CNAM Lookups](https://www.twilio.com/docs/sip-trunking#CNAM) for more information.
|
||||
:param connection_policy_sid: The SID of the Connection Policy that Twilio will use when routing traffic to your communications infrastructure.
|
||||
:param from_domain_sid: The SID of the SIP Domain that should be used in the `From` header of originating calls sent to your SIP infrastructure. If your SIP infrastructure allows users to \\\"call back\\\" an incoming call, configure this with a [SIP Domain](https://www.twilio.com/docs/voice/api/sending-sip) to ensure proper routing. If not configured, the from domain will default to \\\"sip.twilio.com\\\".
|
||||
|
||||
:returns: The created ByocTrunkInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"VoiceUrl": voice_url,
|
||||
"VoiceMethod": voice_method,
|
||||
"VoiceFallbackUrl": voice_fallback_url,
|
||||
"VoiceFallbackMethod": voice_fallback_method,
|
||||
"StatusCallbackUrl": status_callback_url,
|
||||
"StatusCallbackMethod": status_callback_method,
|
||||
"CnamLookupEnabled": cnam_lookup_enabled,
|
||||
"ConnectionPolicySid": connection_policy_sid,
|
||||
"FromDomainSid": from_domain_sid,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return ByocTrunkInstance(self._version, payload)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[ByocTrunkInstance]:
|
||||
"""
|
||||
Streams ByocTrunkInstance records from the API as a generator stream.
|
||||
This operation lazily loads 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[ByocTrunkInstance]:
|
||||
"""
|
||||
Asynchronously streams ByocTrunkInstance records from the API as a generator stream.
|
||||
This operation lazily loads 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[ByocTrunkInstance]:
|
||||
"""
|
||||
Lists ByocTrunkInstance 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[ByocTrunkInstance]:
|
||||
"""
|
||||
Asynchronously lists ByocTrunkInstance 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,
|
||||
) -> ByocTrunkPage:
|
||||
"""
|
||||
Retrieve a single page of ByocTrunkInstance 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 ByocTrunkInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return ByocTrunkPage(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,
|
||||
) -> ByocTrunkPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of ByocTrunkInstance 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 ByocTrunkInstance
|
||||
"""
|
||||
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 ByocTrunkPage(self._version, response)
|
||||
|
||||
def get_page(self, target_url: str) -> ByocTrunkPage:
|
||||
"""
|
||||
Retrieve a specific page of ByocTrunkInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of ByocTrunkInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return ByocTrunkPage(self._version, response)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> ByocTrunkPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of ByocTrunkInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of ByocTrunkInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return ByocTrunkPage(self._version, response)
|
||||
|
||||
def get(self, sid: str) -> ByocTrunkContext:
|
||||
"""
|
||||
Constructs a ByocTrunkContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the BYOC Trunk resource to update.
|
||||
"""
|
||||
return ByocTrunkContext(self._version, sid=sid)
|
||||
|
||||
def __call__(self, sid: str) -> ByocTrunkContext:
|
||||
"""
|
||||
Constructs a ByocTrunkContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the BYOC Trunk resource to update.
|
||||
"""
|
||||
return ByocTrunkContext(self._version, sid=sid)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Voice.V1.ByocTrunkList>"
|
||||
@@ -0,0 +1,596 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Voice
|
||||
This is the 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.voice.v1.connection_policy.connection_policy_target import (
|
||||
ConnectionPolicyTargetList,
|
||||
)
|
||||
|
||||
|
||||
class ConnectionPolicyInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Connection Policy resource.
|
||||
:ivar sid: The unique string that we created to identify the Connection Policy resource.
|
||||
: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 absolute URL of the resource.
|
||||
:ivar links: The URLs of related resources.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self, version: Version, payload: Dict[str, Any], sid: Optional[str] = None
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.friendly_name: Optional[str] = payload.get("friendly_name")
|
||||
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
self.links: Optional[Dict[str, object]] = payload.get("links")
|
||||
|
||||
self._solution = {
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[ConnectionPolicyContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "ConnectionPolicyContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: ConnectionPolicyContext for this ConnectionPolicyInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = ConnectionPolicyContext(
|
||||
self._version,
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the ConnectionPolicyInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the ConnectionPolicyInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
def fetch(self) -> "ConnectionPolicyInstance":
|
||||
"""
|
||||
Fetch the ConnectionPolicyInstance
|
||||
|
||||
|
||||
:returns: The fetched ConnectionPolicyInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "ConnectionPolicyInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the ConnectionPolicyInstance
|
||||
|
||||
|
||||
:returns: The fetched ConnectionPolicyInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self, friendly_name: Union[str, object] = values.unset
|
||||
) -> "ConnectionPolicyInstance":
|
||||
"""
|
||||
Update the ConnectionPolicyInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long.
|
||||
|
||||
:returns: The updated ConnectionPolicyInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
friendly_name=friendly_name,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self, friendly_name: Union[str, object] = values.unset
|
||||
) -> "ConnectionPolicyInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the ConnectionPolicyInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long.
|
||||
|
||||
:returns: The updated ConnectionPolicyInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
friendly_name=friendly_name,
|
||||
)
|
||||
|
||||
@property
|
||||
def targets(self) -> ConnectionPolicyTargetList:
|
||||
"""
|
||||
Access the targets
|
||||
"""
|
||||
return self._proxy.targets
|
||||
|
||||
def __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.Voice.V1.ConnectionPolicyInstance {}>".format(context)
|
||||
|
||||
|
||||
class ConnectionPolicyContext(InstanceContext):
|
||||
def __init__(self, version: Version, sid: str):
|
||||
"""
|
||||
Initialize the ConnectionPolicyContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param sid: The unique string that we created to identify the Connection Policy resource to update.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/ConnectionPolicies/{sid}".format(**self._solution)
|
||||
|
||||
self._targets: Optional[ConnectionPolicyTargetList] = None
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the ConnectionPolicyInstance
|
||||
|
||||
|
||||
: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 ConnectionPolicyInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
def fetch(self) -> ConnectionPolicyInstance:
|
||||
"""
|
||||
Fetch the ConnectionPolicyInstance
|
||||
|
||||
|
||||
:returns: The fetched ConnectionPolicyInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return ConnectionPolicyInstance(
|
||||
self._version,
|
||||
payload,
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> ConnectionPolicyInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the ConnectionPolicyInstance
|
||||
|
||||
|
||||
:returns: The fetched ConnectionPolicyInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return ConnectionPolicyInstance(
|
||||
self._version,
|
||||
payload,
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self, friendly_name: Union[str, object] = values.unset
|
||||
) -> ConnectionPolicyInstance:
|
||||
"""
|
||||
Update the ConnectionPolicyInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long.
|
||||
|
||||
:returns: The updated ConnectionPolicyInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return ConnectionPolicyInstance(
|
||||
self._version, payload, sid=self._solution["sid"]
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self, friendly_name: Union[str, object] = values.unset
|
||||
) -> ConnectionPolicyInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the ConnectionPolicyInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long.
|
||||
|
||||
:returns: The updated ConnectionPolicyInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return ConnectionPolicyInstance(
|
||||
self._version, payload, sid=self._solution["sid"]
|
||||
)
|
||||
|
||||
@property
|
||||
def targets(self) -> ConnectionPolicyTargetList:
|
||||
"""
|
||||
Access the targets
|
||||
"""
|
||||
if self._targets is None:
|
||||
self._targets = ConnectionPolicyTargetList(
|
||||
self._version,
|
||||
self._solution["sid"],
|
||||
)
|
||||
return self._targets
|
||||
|
||||
def __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.Voice.V1.ConnectionPolicyContext {}>".format(context)
|
||||
|
||||
|
||||
class ConnectionPolicyPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> ConnectionPolicyInstance:
|
||||
"""
|
||||
Build an instance of ConnectionPolicyInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return ConnectionPolicyInstance(self._version, payload)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Voice.V1.ConnectionPolicyPage>"
|
||||
|
||||
|
||||
class ConnectionPolicyList(ListResource):
|
||||
def __init__(self, version: Version):
|
||||
"""
|
||||
Initialize the ConnectionPolicyList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
self._uri = "/ConnectionPolicies"
|
||||
|
||||
def create(
|
||||
self, friendly_name: Union[str, object] = values.unset
|
||||
) -> ConnectionPolicyInstance:
|
||||
"""
|
||||
Create the ConnectionPolicyInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long.
|
||||
|
||||
:returns: The created ConnectionPolicyInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return ConnectionPolicyInstance(self._version, payload)
|
||||
|
||||
async def create_async(
|
||||
self, friendly_name: Union[str, object] = values.unset
|
||||
) -> ConnectionPolicyInstance:
|
||||
"""
|
||||
Asynchronously create the ConnectionPolicyInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long.
|
||||
|
||||
:returns: The created ConnectionPolicyInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return ConnectionPolicyInstance(self._version, payload)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[ConnectionPolicyInstance]:
|
||||
"""
|
||||
Streams ConnectionPolicyInstance records from the API as a generator stream.
|
||||
This operation lazily loads 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[ConnectionPolicyInstance]:
|
||||
"""
|
||||
Asynchronously streams ConnectionPolicyInstance records from the API as a generator stream.
|
||||
This operation lazily loads 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[ConnectionPolicyInstance]:
|
||||
"""
|
||||
Lists ConnectionPolicyInstance 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[ConnectionPolicyInstance]:
|
||||
"""
|
||||
Asynchronously lists ConnectionPolicyInstance 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,
|
||||
) -> ConnectionPolicyPage:
|
||||
"""
|
||||
Retrieve a single page of ConnectionPolicyInstance 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 ConnectionPolicyInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return ConnectionPolicyPage(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,
|
||||
) -> ConnectionPolicyPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of ConnectionPolicyInstance 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 ConnectionPolicyInstance
|
||||
"""
|
||||
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 ConnectionPolicyPage(self._version, response)
|
||||
|
||||
def get_page(self, target_url: str) -> ConnectionPolicyPage:
|
||||
"""
|
||||
Retrieve a specific page of ConnectionPolicyInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of ConnectionPolicyInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return ConnectionPolicyPage(self._version, response)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> ConnectionPolicyPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of ConnectionPolicyInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of ConnectionPolicyInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return ConnectionPolicyPage(self._version, response)
|
||||
|
||||
def get(self, sid: str) -> ConnectionPolicyContext:
|
||||
"""
|
||||
Constructs a ConnectionPolicyContext
|
||||
|
||||
:param sid: The unique string that we created to identify the Connection Policy resource to update.
|
||||
"""
|
||||
return ConnectionPolicyContext(self._version, sid=sid)
|
||||
|
||||
def __call__(self, sid: str) -> ConnectionPolicyContext:
|
||||
"""
|
||||
Constructs a ConnectionPolicyContext
|
||||
|
||||
:param sid: The unique string that we created to identify the Connection Policy resource to update.
|
||||
"""
|
||||
return ConnectionPolicyContext(self._version, sid=sid)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Voice.V1.ConnectionPolicyList>"
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
+703
@@ -0,0 +1,703 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Voice
|
||||
This is the 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 ConnectionPolicyTargetInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Target resource.
|
||||
:ivar connection_policy_sid: The SID of the Connection Policy that owns the Target.
|
||||
:ivar sid: The unique string that we created to identify the Target resource.
|
||||
:ivar friendly_name: The string that you assigned to describe the resource.
|
||||
:ivar target: The SIP address you want Twilio to route your calls to. This must be a `sip:` schema. `sips` is NOT supported.
|
||||
:ivar priority: The relative importance of the target. Can be an integer from 0 to 65535, inclusive, and the default is 10. The lowest number represents the most important target.
|
||||
:ivar weight: The value that determines the relative share of the load the Target should receive compared to other Targets with the same priority. Can be an integer from 1 to 65535, inclusive, and the default is 10. Targets with higher values receive more load than those with lower ones with the same priority.
|
||||
:ivar enabled: Whether the target is enabled. The default is `true`.
|
||||
:ivar date_created: The date and time in GMT when the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar date_updated: The date and time in GMT when the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar url: The absolute URL of the resource.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
connection_policy_sid: str,
|
||||
sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.connection_policy_sid: Optional[str] = payload.get("connection_policy_sid")
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.friendly_name: Optional[str] = payload.get("friendly_name")
|
||||
self.target: Optional[str] = payload.get("target")
|
||||
self.priority: Optional[int] = deserialize.integer(payload.get("priority"))
|
||||
self.weight: Optional[int] = deserialize.integer(payload.get("weight"))
|
||||
self.enabled: Optional[bool] = payload.get("enabled")
|
||||
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 = {
|
||||
"connection_policy_sid": connection_policy_sid,
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[ConnectionPolicyTargetContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "ConnectionPolicyTargetContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: ConnectionPolicyTargetContext for this ConnectionPolicyTargetInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = ConnectionPolicyTargetContext(
|
||||
self._version,
|
||||
connection_policy_sid=self._solution["connection_policy_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the ConnectionPolicyTargetInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the ConnectionPolicyTargetInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
def fetch(self) -> "ConnectionPolicyTargetInstance":
|
||||
"""
|
||||
Fetch the ConnectionPolicyTargetInstance
|
||||
|
||||
|
||||
:returns: The fetched ConnectionPolicyTargetInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "ConnectionPolicyTargetInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the ConnectionPolicyTargetInstance
|
||||
|
||||
|
||||
:returns: The fetched ConnectionPolicyTargetInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
target: Union[str, object] = values.unset,
|
||||
priority: Union[int, object] = values.unset,
|
||||
weight: Union[int, object] = values.unset,
|
||||
enabled: Union[bool, object] = values.unset,
|
||||
) -> "ConnectionPolicyTargetInstance":
|
||||
"""
|
||||
Update the ConnectionPolicyTargetInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long.
|
||||
:param target: The SIP address you want Twilio to route your calls to. This must be a `sip:` schema. `sips` is NOT supported.
|
||||
:param priority: The relative importance of the target. Can be an integer from 0 to 65535, inclusive. The lowest number represents the most important target.
|
||||
:param weight: The value that determines the relative share of the load the Target should receive compared to other Targets with the same priority. Can be an integer from 1 to 65535, inclusive. Targets with higher values receive more load than those with lower ones with the same priority.
|
||||
:param enabled: Whether the Target is enabled.
|
||||
|
||||
:returns: The updated ConnectionPolicyTargetInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
friendly_name=friendly_name,
|
||||
target=target,
|
||||
priority=priority,
|
||||
weight=weight,
|
||||
enabled=enabled,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
target: Union[str, object] = values.unset,
|
||||
priority: Union[int, object] = values.unset,
|
||||
weight: Union[int, object] = values.unset,
|
||||
enabled: Union[bool, object] = values.unset,
|
||||
) -> "ConnectionPolicyTargetInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the ConnectionPolicyTargetInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long.
|
||||
:param target: The SIP address you want Twilio to route your calls to. This must be a `sip:` schema. `sips` is NOT supported.
|
||||
:param priority: The relative importance of the target. Can be an integer from 0 to 65535, inclusive. The lowest number represents the most important target.
|
||||
:param weight: The value that determines the relative share of the load the Target should receive compared to other Targets with the same priority. Can be an integer from 1 to 65535, inclusive. Targets with higher values receive more load than those with lower ones with the same priority.
|
||||
:param enabled: Whether the Target is enabled.
|
||||
|
||||
:returns: The updated ConnectionPolicyTargetInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
friendly_name=friendly_name,
|
||||
target=target,
|
||||
priority=priority,
|
||||
weight=weight,
|
||||
enabled=enabled,
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Voice.V1.ConnectionPolicyTargetInstance {}>".format(context)
|
||||
|
||||
|
||||
class ConnectionPolicyTargetContext(InstanceContext):
|
||||
def __init__(self, version: Version, connection_policy_sid: str, sid: str):
|
||||
"""
|
||||
Initialize the ConnectionPolicyTargetContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param connection_policy_sid: The SID of the Connection Policy that owns the Target.
|
||||
:param sid: The unique string that we created to identify the Target resource to update.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"connection_policy_sid": connection_policy_sid,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/ConnectionPolicies/{connection_policy_sid}/Targets/{sid}".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the ConnectionPolicyTargetInstance
|
||||
|
||||
|
||||
: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 ConnectionPolicyTargetInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
def fetch(self) -> ConnectionPolicyTargetInstance:
|
||||
"""
|
||||
Fetch the ConnectionPolicyTargetInstance
|
||||
|
||||
|
||||
:returns: The fetched ConnectionPolicyTargetInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return ConnectionPolicyTargetInstance(
|
||||
self._version,
|
||||
payload,
|
||||
connection_policy_sid=self._solution["connection_policy_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> ConnectionPolicyTargetInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the ConnectionPolicyTargetInstance
|
||||
|
||||
|
||||
:returns: The fetched ConnectionPolicyTargetInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return ConnectionPolicyTargetInstance(
|
||||
self._version,
|
||||
payload,
|
||||
connection_policy_sid=self._solution["connection_policy_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
target: Union[str, object] = values.unset,
|
||||
priority: Union[int, object] = values.unset,
|
||||
weight: Union[int, object] = values.unset,
|
||||
enabled: Union[bool, object] = values.unset,
|
||||
) -> ConnectionPolicyTargetInstance:
|
||||
"""
|
||||
Update the ConnectionPolicyTargetInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long.
|
||||
:param target: The SIP address you want Twilio to route your calls to. This must be a `sip:` schema. `sips` is NOT supported.
|
||||
:param priority: The relative importance of the target. Can be an integer from 0 to 65535, inclusive. The lowest number represents the most important target.
|
||||
:param weight: The value that determines the relative share of the load the Target should receive compared to other Targets with the same priority. Can be an integer from 1 to 65535, inclusive. Targets with higher values receive more load than those with lower ones with the same priority.
|
||||
:param enabled: Whether the Target is enabled.
|
||||
|
||||
:returns: The updated ConnectionPolicyTargetInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"Target": target,
|
||||
"Priority": priority,
|
||||
"Weight": weight,
|
||||
"Enabled": enabled,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return ConnectionPolicyTargetInstance(
|
||||
self._version,
|
||||
payload,
|
||||
connection_policy_sid=self._solution["connection_policy_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
target: Union[str, object] = values.unset,
|
||||
priority: Union[int, object] = values.unset,
|
||||
weight: Union[int, object] = values.unset,
|
||||
enabled: Union[bool, object] = values.unset,
|
||||
) -> ConnectionPolicyTargetInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the ConnectionPolicyTargetInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long.
|
||||
:param target: The SIP address you want Twilio to route your calls to. This must be a `sip:` schema. `sips` is NOT supported.
|
||||
:param priority: The relative importance of the target. Can be an integer from 0 to 65535, inclusive. The lowest number represents the most important target.
|
||||
:param weight: The value that determines the relative share of the load the Target should receive compared to other Targets with the same priority. Can be an integer from 1 to 65535, inclusive. Targets with higher values receive more load than those with lower ones with the same priority.
|
||||
:param enabled: Whether the Target is enabled.
|
||||
|
||||
:returns: The updated ConnectionPolicyTargetInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"Target": target,
|
||||
"Priority": priority,
|
||||
"Weight": weight,
|
||||
"Enabled": enabled,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return ConnectionPolicyTargetInstance(
|
||||
self._version,
|
||||
payload,
|
||||
connection_policy_sid=self._solution["connection_policy_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.Voice.V1.ConnectionPolicyTargetContext {}>".format(context)
|
||||
|
||||
|
||||
class ConnectionPolicyTargetPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> ConnectionPolicyTargetInstance:
|
||||
"""
|
||||
Build an instance of ConnectionPolicyTargetInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return ConnectionPolicyTargetInstance(
|
||||
self._version,
|
||||
payload,
|
||||
connection_policy_sid=self._solution["connection_policy_sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Voice.V1.ConnectionPolicyTargetPage>"
|
||||
|
||||
|
||||
class ConnectionPolicyTargetList(ListResource):
|
||||
def __init__(self, version: Version, connection_policy_sid: str):
|
||||
"""
|
||||
Initialize the ConnectionPolicyTargetList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param connection_policy_sid: The SID of the Connection Policy from which to read the Targets.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"connection_policy_sid": connection_policy_sid,
|
||||
}
|
||||
self._uri = "/ConnectionPolicies/{connection_policy_sid}/Targets".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def create(
|
||||
self,
|
||||
target: str,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
priority: Union[int, object] = values.unset,
|
||||
weight: Union[int, object] = values.unset,
|
||||
enabled: Union[bool, object] = values.unset,
|
||||
) -> ConnectionPolicyTargetInstance:
|
||||
"""
|
||||
Create the ConnectionPolicyTargetInstance
|
||||
|
||||
:param target: The SIP address you want Twilio to route your calls to. This must be a `sip:` schema. `sips` is NOT supported.
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long.
|
||||
:param priority: The relative importance of the target. Can be an integer from 0 to 65535, inclusive, and the default is 10. The lowest number represents the most important target.
|
||||
:param weight: The value that determines the relative share of the load the Target should receive compared to other Targets with the same priority. Can be an integer from 1 to 65535, inclusive, and the default is 10. Targets with higher values receive more load than those with lower ones with the same priority.
|
||||
:param enabled: Whether the Target is enabled. The default is `true`.
|
||||
|
||||
:returns: The created ConnectionPolicyTargetInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Target": target,
|
||||
"FriendlyName": friendly_name,
|
||||
"Priority": priority,
|
||||
"Weight": weight,
|
||||
"Enabled": enabled,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return ConnectionPolicyTargetInstance(
|
||||
self._version,
|
||||
payload,
|
||||
connection_policy_sid=self._solution["connection_policy_sid"],
|
||||
)
|
||||
|
||||
async def create_async(
|
||||
self,
|
||||
target: str,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
priority: Union[int, object] = values.unset,
|
||||
weight: Union[int, object] = values.unset,
|
||||
enabled: Union[bool, object] = values.unset,
|
||||
) -> ConnectionPolicyTargetInstance:
|
||||
"""
|
||||
Asynchronously create the ConnectionPolicyTargetInstance
|
||||
|
||||
:param target: The SIP address you want Twilio to route your calls to. This must be a `sip:` schema. `sips` is NOT supported.
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long.
|
||||
:param priority: The relative importance of the target. Can be an integer from 0 to 65535, inclusive, and the default is 10. The lowest number represents the most important target.
|
||||
:param weight: The value that determines the relative share of the load the Target should receive compared to other Targets with the same priority. Can be an integer from 1 to 65535, inclusive, and the default is 10. Targets with higher values receive more load than those with lower ones with the same priority.
|
||||
:param enabled: Whether the Target is enabled. The default is `true`.
|
||||
|
||||
:returns: The created ConnectionPolicyTargetInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Target": target,
|
||||
"FriendlyName": friendly_name,
|
||||
"Priority": priority,
|
||||
"Weight": weight,
|
||||
"Enabled": enabled,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return ConnectionPolicyTargetInstance(
|
||||
self._version,
|
||||
payload,
|
||||
connection_policy_sid=self._solution["connection_policy_sid"],
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[ConnectionPolicyTargetInstance]:
|
||||
"""
|
||||
Streams ConnectionPolicyTargetInstance records from the API as a generator stream.
|
||||
This operation lazily loads 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[ConnectionPolicyTargetInstance]:
|
||||
"""
|
||||
Asynchronously streams ConnectionPolicyTargetInstance records from the API as a generator stream.
|
||||
This operation lazily loads 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[ConnectionPolicyTargetInstance]:
|
||||
"""
|
||||
Lists ConnectionPolicyTargetInstance 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[ConnectionPolicyTargetInstance]:
|
||||
"""
|
||||
Asynchronously lists ConnectionPolicyTargetInstance 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,
|
||||
) -> ConnectionPolicyTargetPage:
|
||||
"""
|
||||
Retrieve a single page of ConnectionPolicyTargetInstance 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 ConnectionPolicyTargetInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return ConnectionPolicyTargetPage(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,
|
||||
) -> ConnectionPolicyTargetPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of ConnectionPolicyTargetInstance 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 ConnectionPolicyTargetInstance
|
||||
"""
|
||||
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 ConnectionPolicyTargetPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> ConnectionPolicyTargetPage:
|
||||
"""
|
||||
Retrieve a specific page of ConnectionPolicyTargetInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of ConnectionPolicyTargetInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return ConnectionPolicyTargetPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> ConnectionPolicyTargetPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of ConnectionPolicyTargetInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of ConnectionPolicyTargetInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return ConnectionPolicyTargetPage(self._version, response, self._solution)
|
||||
|
||||
def get(self, sid: str) -> ConnectionPolicyTargetContext:
|
||||
"""
|
||||
Constructs a ConnectionPolicyTargetContext
|
||||
|
||||
:param sid: The unique string that we created to identify the Target resource to update.
|
||||
"""
|
||||
return ConnectionPolicyTargetContext(
|
||||
self._version,
|
||||
connection_policy_sid=self._solution["connection_policy_sid"],
|
||||
sid=sid,
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> ConnectionPolicyTargetContext:
|
||||
"""
|
||||
Constructs a ConnectionPolicyTargetContext
|
||||
|
||||
:param sid: The unique string that we created to identify the Target resource to update.
|
||||
"""
|
||||
return ConnectionPolicyTargetContext(
|
||||
self._version,
|
||||
connection_policy_sid=self._solution["connection_policy_sid"],
|
||||
sid=sid,
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Voice.V1.ConnectionPolicyTargetList>"
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Voice
|
||||
This is the 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.voice.v1.dialing_permissions.bulk_country_update import (
|
||||
BulkCountryUpdateList,
|
||||
)
|
||||
from twilio.rest.voice.v1.dialing_permissions.country import CountryList
|
||||
from twilio.rest.voice.v1.dialing_permissions.settings import SettingsList
|
||||
|
||||
|
||||
class DialingPermissionsList(ListResource):
|
||||
def __init__(self, version: Version):
|
||||
"""
|
||||
Initialize the DialingPermissionsList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
self._uri = "/DialingPermissions"
|
||||
|
||||
self._bulk_country_updates: Optional[BulkCountryUpdateList] = None
|
||||
self._countries: Optional[CountryList] = None
|
||||
self._settings: Optional[SettingsList] = None
|
||||
|
||||
@property
|
||||
def bulk_country_updates(self) -> BulkCountryUpdateList:
|
||||
"""
|
||||
Access the bulk_country_updates
|
||||
"""
|
||||
if self._bulk_country_updates is None:
|
||||
self._bulk_country_updates = BulkCountryUpdateList(self._version)
|
||||
return self._bulk_country_updates
|
||||
|
||||
@property
|
||||
def countries(self) -> CountryList:
|
||||
"""
|
||||
Access the countries
|
||||
"""
|
||||
if self._countries is None:
|
||||
self._countries = CountryList(self._version)
|
||||
return self._countries
|
||||
|
||||
@property
|
||||
def settings(self) -> SettingsList:
|
||||
"""
|
||||
Access the settings
|
||||
"""
|
||||
if self._settings is None:
|
||||
self._settings = SettingsList(self._version)
|
||||
return self._settings
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Voice.V1.DialingPermissionsList>"
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
+111
@@ -0,0 +1,111 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Voice
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from typing import Any, Dict, Optional
|
||||
from twilio.base import deserialize, values
|
||||
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
|
||||
|
||||
class BulkCountryUpdateInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar update_count: The number of countries updated
|
||||
:ivar update_request: A bulk update request to change voice dialing country permissions stored as a URL-encoded, JSON array of update objects. For example : `[ { \"iso_code\": \"GB\", \"low_risk_numbers_enabled\": \"true\", \"high_risk_special_numbers_enabled\":\"true\", \"high_risk_tollfraud_numbers_enabled\": \"false\" } ]`
|
||||
"""
|
||||
|
||||
def __init__(self, version: Version, payload: Dict[str, Any]):
|
||||
super().__init__(version)
|
||||
|
||||
self.update_count: Optional[int] = deserialize.integer(
|
||||
payload.get("update_count")
|
||||
)
|
||||
self.update_request: Optional[str] = payload.get("update_request")
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
|
||||
return "<Twilio.Voice.V1.BulkCountryUpdateInstance>"
|
||||
|
||||
|
||||
class BulkCountryUpdateList(ListResource):
|
||||
def __init__(self, version: Version):
|
||||
"""
|
||||
Initialize the BulkCountryUpdateList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
self._uri = "/DialingPermissions/BulkCountryUpdates"
|
||||
|
||||
def create(self, update_request: str) -> BulkCountryUpdateInstance:
|
||||
"""
|
||||
Create the BulkCountryUpdateInstance
|
||||
|
||||
:param update_request: URL encoded JSON array of update objects. example : `[ { \\\"iso_code\\\": \\\"GB\\\", \\\"low_risk_numbers_enabled\\\": \\\"true\\\", \\\"high_risk_special_numbers_enabled\\\":\\\"true\\\", \\\"high_risk_tollfraud_numbers_enabled\\\": \\\"false\\\" } ]`
|
||||
|
||||
:returns: The created BulkCountryUpdateInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"UpdateRequest": update_request,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return BulkCountryUpdateInstance(self._version, payload)
|
||||
|
||||
async def create_async(self, update_request: str) -> BulkCountryUpdateInstance:
|
||||
"""
|
||||
Asynchronously create the BulkCountryUpdateInstance
|
||||
|
||||
:param update_request: URL encoded JSON array of update objects. example : `[ { \\\"iso_code\\\": \\\"GB\\\", \\\"low_risk_numbers_enabled\\\": \\\"true\\\", \\\"high_risk_special_numbers_enabled\\\":\\\"true\\\", \\\"high_risk_tollfraud_numbers_enabled\\\": \\\"false\\\" } ]`
|
||||
|
||||
:returns: The created BulkCountryUpdateInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"UpdateRequest": update_request,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return BulkCountryUpdateInstance(self._version, payload)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Voice.V1.BulkCountryUpdateList>"
|
||||
+543
@@ -0,0 +1,543 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Voice
|
||||
This is the 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.voice.v1.dialing_permissions.country.highrisk_special_prefix import (
|
||||
HighriskSpecialPrefixList,
|
||||
)
|
||||
|
||||
|
||||
class CountryInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar iso_code: The [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2).
|
||||
:ivar name: The name of the country.
|
||||
:ivar continent: The name of the continent in which the country is located.
|
||||
:ivar country_codes: The E.164 assigned [country codes(s)](https://www.itu.int/itudoc/itu-t/ob-lists/icc/e164_763.html)
|
||||
:ivar low_risk_numbers_enabled: Whether dialing to low-risk numbers is enabled.
|
||||
:ivar high_risk_special_numbers_enabled: Whether dialing to high-risk special services numbers is enabled. These prefixes include number ranges allocated by the country and include premium numbers, special services, shared cost, and others
|
||||
:ivar high_risk_tollfraud_numbers_enabled: Whether dialing to high-risk [toll fraud](https://www.twilio.com/blog/how-to-protect-your-account-from-toll-fraud-with-voice-dialing-geo-permissions-html) numbers is enabled. These prefixes include narrow number ranges that have a high-risk of international revenue sharing fraud (IRSF) attacks, also known as [toll fraud](https://www.twilio.com/blog/how-to-protect-your-account-from-toll-fraud-with-voice-dialing-geo-permissions-html). These prefixes are collected from anti-fraud databases and verified by analyzing calls on our network. These prefixes are not available for download and are updated frequently
|
||||
:ivar url: The absolute URL of this resource.
|
||||
:ivar links: A list of URLs related to this resource.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self, version: Version, payload: Dict[str, Any], iso_code: Optional[str] = None
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.iso_code: Optional[str] = payload.get("iso_code")
|
||||
self.name: Optional[str] = payload.get("name")
|
||||
self.continent: Optional[str] = payload.get("continent")
|
||||
self.country_codes: Optional[List[str]] = payload.get("country_codes")
|
||||
self.low_risk_numbers_enabled: Optional[bool] = payload.get(
|
||||
"low_risk_numbers_enabled"
|
||||
)
|
||||
self.high_risk_special_numbers_enabled: Optional[bool] = payload.get(
|
||||
"high_risk_special_numbers_enabled"
|
||||
)
|
||||
self.high_risk_tollfraud_numbers_enabled: Optional[bool] = payload.get(
|
||||
"high_risk_tollfraud_numbers_enabled"
|
||||
)
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
self.links: Optional[Dict[str, object]] = payload.get("links")
|
||||
|
||||
self._solution = {
|
||||
"iso_code": iso_code or self.iso_code,
|
||||
}
|
||||
self._context: Optional[CountryContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "CountryContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: CountryContext for this CountryInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = CountryContext(
|
||||
self._version,
|
||||
iso_code=self._solution["iso_code"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def fetch(self) -> "CountryInstance":
|
||||
"""
|
||||
Fetch the CountryInstance
|
||||
|
||||
|
||||
:returns: The fetched CountryInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "CountryInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the CountryInstance
|
||||
|
||||
|
||||
:returns: The fetched CountryInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
@property
|
||||
def highrisk_special_prefixes(self) -> HighriskSpecialPrefixList:
|
||||
"""
|
||||
Access the highrisk_special_prefixes
|
||||
"""
|
||||
return self._proxy.highrisk_special_prefixes
|
||||
|
||||
def __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.Voice.V1.CountryInstance {}>".format(context)
|
||||
|
||||
|
||||
class CountryContext(InstanceContext):
|
||||
def __init__(self, version: Version, iso_code: str):
|
||||
"""
|
||||
Initialize the CountryContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param iso_code: The [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the DialingPermissions Country resource to fetch
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"iso_code": iso_code,
|
||||
}
|
||||
self._uri = "/DialingPermissions/Countries/{iso_code}".format(**self._solution)
|
||||
|
||||
self._highrisk_special_prefixes: Optional[HighriskSpecialPrefixList] = None
|
||||
|
||||
def fetch(self) -> CountryInstance:
|
||||
"""
|
||||
Fetch the CountryInstance
|
||||
|
||||
|
||||
:returns: The fetched CountryInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return CountryInstance(
|
||||
self._version,
|
||||
payload,
|
||||
iso_code=self._solution["iso_code"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> CountryInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the CountryInstance
|
||||
|
||||
|
||||
:returns: The fetched CountryInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return CountryInstance(
|
||||
self._version,
|
||||
payload,
|
||||
iso_code=self._solution["iso_code"],
|
||||
)
|
||||
|
||||
@property
|
||||
def highrisk_special_prefixes(self) -> HighriskSpecialPrefixList:
|
||||
"""
|
||||
Access the highrisk_special_prefixes
|
||||
"""
|
||||
if self._highrisk_special_prefixes is None:
|
||||
self._highrisk_special_prefixes = HighriskSpecialPrefixList(
|
||||
self._version,
|
||||
self._solution["iso_code"],
|
||||
)
|
||||
return self._highrisk_special_prefixes
|
||||
|
||||
def __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.Voice.V1.CountryContext {}>".format(context)
|
||||
|
||||
|
||||
class CountryPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> CountryInstance:
|
||||
"""
|
||||
Build an instance of CountryInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return CountryInstance(self._version, payload)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Voice.V1.CountryPage>"
|
||||
|
||||
|
||||
class CountryList(ListResource):
|
||||
def __init__(self, version: Version):
|
||||
"""
|
||||
Initialize the CountryList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
self._uri = "/DialingPermissions/Countries"
|
||||
|
||||
def stream(
|
||||
self,
|
||||
iso_code: Union[str, object] = values.unset,
|
||||
continent: Union[str, object] = values.unset,
|
||||
country_code: Union[str, object] = values.unset,
|
||||
low_risk_numbers_enabled: Union[bool, object] = values.unset,
|
||||
high_risk_special_numbers_enabled: Union[bool, object] = values.unset,
|
||||
high_risk_tollfraud_numbers_enabled: Union[bool, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[CountryInstance]:
|
||||
"""
|
||||
Streams CountryInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param str iso_code: Filter to retrieve the country permissions by specifying the [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)
|
||||
:param str continent: Filter to retrieve the country permissions by specifying the continent
|
||||
:param str country_code: Filter the results by specified [country codes](https://www.itu.int/itudoc/itu-t/ob-lists/icc/e164_763.html)
|
||||
:param bool low_risk_numbers_enabled: Filter to retrieve the country permissions with dialing to low-risk numbers enabled. Can be: `true` or `false`.
|
||||
:param bool high_risk_special_numbers_enabled: Filter to retrieve the country permissions with dialing to high-risk special service numbers enabled. Can be: `true` or `false`
|
||||
:param bool high_risk_tollfraud_numbers_enabled: Filter to retrieve the country permissions with dialing to high-risk [toll fraud](https://www.twilio.com/blog/how-to-protect-your-account-from-toll-fraud-with-voice-dialing-geo-permissions-html) numbers enabled. Can be: `true` or `false`.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page 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(
|
||||
iso_code=iso_code,
|
||||
continent=continent,
|
||||
country_code=country_code,
|
||||
low_risk_numbers_enabled=low_risk_numbers_enabled,
|
||||
high_risk_special_numbers_enabled=high_risk_special_numbers_enabled,
|
||||
high_risk_tollfraud_numbers_enabled=high_risk_tollfraud_numbers_enabled,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
iso_code: Union[str, object] = values.unset,
|
||||
continent: Union[str, object] = values.unset,
|
||||
country_code: Union[str, object] = values.unset,
|
||||
low_risk_numbers_enabled: Union[bool, object] = values.unset,
|
||||
high_risk_special_numbers_enabled: Union[bool, object] = values.unset,
|
||||
high_risk_tollfraud_numbers_enabled: Union[bool, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[CountryInstance]:
|
||||
"""
|
||||
Asynchronously streams CountryInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param str iso_code: Filter to retrieve the country permissions by specifying the [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)
|
||||
:param str continent: Filter to retrieve the country permissions by specifying the continent
|
||||
:param str country_code: Filter the results by specified [country codes](https://www.itu.int/itudoc/itu-t/ob-lists/icc/e164_763.html)
|
||||
:param bool low_risk_numbers_enabled: Filter to retrieve the country permissions with dialing to low-risk numbers enabled. Can be: `true` or `false`.
|
||||
:param bool high_risk_special_numbers_enabled: Filter to retrieve the country permissions with dialing to high-risk special service numbers enabled. Can be: `true` or `false`
|
||||
:param bool high_risk_tollfraud_numbers_enabled: Filter to retrieve the country permissions with dialing to high-risk [toll fraud](https://www.twilio.com/blog/how-to-protect-your-account-from-toll-fraud-with-voice-dialing-geo-permissions-html) numbers enabled. Can be: `true` or `false`.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page 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(
|
||||
iso_code=iso_code,
|
||||
continent=continent,
|
||||
country_code=country_code,
|
||||
low_risk_numbers_enabled=low_risk_numbers_enabled,
|
||||
high_risk_special_numbers_enabled=high_risk_special_numbers_enabled,
|
||||
high_risk_tollfraud_numbers_enabled=high_risk_tollfraud_numbers_enabled,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
iso_code: Union[str, object] = values.unset,
|
||||
continent: Union[str, object] = values.unset,
|
||||
country_code: Union[str, object] = values.unset,
|
||||
low_risk_numbers_enabled: Union[bool, object] = values.unset,
|
||||
high_risk_special_numbers_enabled: Union[bool, object] = values.unset,
|
||||
high_risk_tollfraud_numbers_enabled: Union[bool, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[CountryInstance]:
|
||||
"""
|
||||
Lists CountryInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param str iso_code: Filter to retrieve the country permissions by specifying the [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)
|
||||
:param str continent: Filter to retrieve the country permissions by specifying the continent
|
||||
:param str country_code: Filter the results by specified [country codes](https://www.itu.int/itudoc/itu-t/ob-lists/icc/e164_763.html)
|
||||
:param bool low_risk_numbers_enabled: Filter to retrieve the country permissions with dialing to low-risk numbers enabled. Can be: `true` or `false`.
|
||||
:param bool high_risk_special_numbers_enabled: Filter to retrieve the country permissions with dialing to high-risk special service numbers enabled. Can be: `true` or `false`
|
||||
:param bool high_risk_tollfraud_numbers_enabled: Filter to retrieve the country permissions with dialing to high-risk [toll fraud](https://www.twilio.com/blog/how-to-protect-your-account-from-toll-fraud-with-voice-dialing-geo-permissions-html) numbers enabled. Can be: `true` or `false`.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to 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(
|
||||
iso_code=iso_code,
|
||||
continent=continent,
|
||||
country_code=country_code,
|
||||
low_risk_numbers_enabled=low_risk_numbers_enabled,
|
||||
high_risk_special_numbers_enabled=high_risk_special_numbers_enabled,
|
||||
high_risk_tollfraud_numbers_enabled=high_risk_tollfraud_numbers_enabled,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
iso_code: Union[str, object] = values.unset,
|
||||
continent: Union[str, object] = values.unset,
|
||||
country_code: Union[str, object] = values.unset,
|
||||
low_risk_numbers_enabled: Union[bool, object] = values.unset,
|
||||
high_risk_special_numbers_enabled: Union[bool, object] = values.unset,
|
||||
high_risk_tollfraud_numbers_enabled: Union[bool, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[CountryInstance]:
|
||||
"""
|
||||
Asynchronously lists CountryInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param str iso_code: Filter to retrieve the country permissions by specifying the [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)
|
||||
:param str continent: Filter to retrieve the country permissions by specifying the continent
|
||||
:param str country_code: Filter the results by specified [country codes](https://www.itu.int/itudoc/itu-t/ob-lists/icc/e164_763.html)
|
||||
:param bool low_risk_numbers_enabled: Filter to retrieve the country permissions with dialing to low-risk numbers enabled. Can be: `true` or `false`.
|
||||
:param bool high_risk_special_numbers_enabled: Filter to retrieve the country permissions with dialing to high-risk special service numbers enabled. Can be: `true` or `false`
|
||||
:param bool high_risk_tollfraud_numbers_enabled: Filter to retrieve the country permissions with dialing to high-risk [toll fraud](https://www.twilio.com/blog/how-to-protect-your-account-from-toll-fraud-with-voice-dialing-geo-permissions-html) numbers enabled. Can be: `true` or `false`.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to 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(
|
||||
iso_code=iso_code,
|
||||
continent=continent,
|
||||
country_code=country_code,
|
||||
low_risk_numbers_enabled=low_risk_numbers_enabled,
|
||||
high_risk_special_numbers_enabled=high_risk_special_numbers_enabled,
|
||||
high_risk_tollfraud_numbers_enabled=high_risk_tollfraud_numbers_enabled,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
iso_code: Union[str, object] = values.unset,
|
||||
continent: Union[str, object] = values.unset,
|
||||
country_code: Union[str, object] = values.unset,
|
||||
low_risk_numbers_enabled: Union[bool, object] = values.unset,
|
||||
high_risk_special_numbers_enabled: Union[bool, object] = values.unset,
|
||||
high_risk_tollfraud_numbers_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,
|
||||
) -> CountryPage:
|
||||
"""
|
||||
Retrieve a single page of CountryInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param iso_code: Filter to retrieve the country permissions by specifying the [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)
|
||||
:param continent: Filter to retrieve the country permissions by specifying the continent
|
||||
:param country_code: Filter the results by specified [country codes](https://www.itu.int/itudoc/itu-t/ob-lists/icc/e164_763.html)
|
||||
:param low_risk_numbers_enabled: Filter to retrieve the country permissions with dialing to low-risk numbers enabled. Can be: `true` or `false`.
|
||||
:param high_risk_special_numbers_enabled: Filter to retrieve the country permissions with dialing to high-risk special service numbers enabled. Can be: `true` or `false`
|
||||
:param high_risk_tollfraud_numbers_enabled: Filter to retrieve the country permissions with dialing to high-risk [toll fraud](https://www.twilio.com/blog/how-to-protect-your-account-from-toll-fraud-with-voice-dialing-geo-permissions-html) numbers enabled. Can be: `true` or `false`.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of CountryInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"IsoCode": iso_code,
|
||||
"Continent": continent,
|
||||
"CountryCode": country_code,
|
||||
"LowRiskNumbersEnabled": low_risk_numbers_enabled,
|
||||
"HighRiskSpecialNumbersEnabled": high_risk_special_numbers_enabled,
|
||||
"HighRiskTollfraudNumbersEnabled": high_risk_tollfraud_numbers_enabled,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return CountryPage(self._version, response)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
iso_code: Union[str, object] = values.unset,
|
||||
continent: Union[str, object] = values.unset,
|
||||
country_code: Union[str, object] = values.unset,
|
||||
low_risk_numbers_enabled: Union[bool, object] = values.unset,
|
||||
high_risk_special_numbers_enabled: Union[bool, object] = values.unset,
|
||||
high_risk_tollfraud_numbers_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,
|
||||
) -> CountryPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of CountryInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param iso_code: Filter to retrieve the country permissions by specifying the [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)
|
||||
:param continent: Filter to retrieve the country permissions by specifying the continent
|
||||
:param country_code: Filter the results by specified [country codes](https://www.itu.int/itudoc/itu-t/ob-lists/icc/e164_763.html)
|
||||
:param low_risk_numbers_enabled: Filter to retrieve the country permissions with dialing to low-risk numbers enabled. Can be: `true` or `false`.
|
||||
:param high_risk_special_numbers_enabled: Filter to retrieve the country permissions with dialing to high-risk special service numbers enabled. Can be: `true` or `false`
|
||||
:param high_risk_tollfraud_numbers_enabled: Filter to retrieve the country permissions with dialing to high-risk [toll fraud](https://www.twilio.com/blog/how-to-protect-your-account-from-toll-fraud-with-voice-dialing-geo-permissions-html) numbers enabled. Can be: `true` or `false`.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of CountryInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"IsoCode": iso_code,
|
||||
"Continent": continent,
|
||||
"CountryCode": country_code,
|
||||
"LowRiskNumbersEnabled": low_risk_numbers_enabled,
|
||||
"HighRiskSpecialNumbersEnabled": high_risk_special_numbers_enabled,
|
||||
"HighRiskTollfraudNumbersEnabled": high_risk_tollfraud_numbers_enabled,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return CountryPage(self._version, response)
|
||||
|
||||
def get_page(self, target_url: str) -> CountryPage:
|
||||
"""
|
||||
Retrieve a specific page of CountryInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of CountryInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return CountryPage(self._version, response)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> CountryPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of CountryInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of CountryInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return CountryPage(self._version, response)
|
||||
|
||||
def get(self, iso_code: str) -> CountryContext:
|
||||
"""
|
||||
Constructs a CountryContext
|
||||
|
||||
:param iso_code: The [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the DialingPermissions Country resource to fetch
|
||||
"""
|
||||
return CountryContext(self._version, iso_code=iso_code)
|
||||
|
||||
def __call__(self, iso_code: str) -> CountryContext:
|
||||
"""
|
||||
Constructs a CountryContext
|
||||
|
||||
:param iso_code: The [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the DialingPermissions Country resource to fetch
|
||||
"""
|
||||
return CountryContext(self._version, iso_code=iso_code)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Voice.V1.CountryList>"
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
+280
@@ -0,0 +1,280 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Voice
|
||||
This is the 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 HighriskSpecialPrefixInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar prefix: A prefix is a contiguous number range for a block of E.164 numbers that includes the E.164 assigned country code. For example, a North American Numbering Plan prefix like `+1510720` written like `+1(510) 720` matches all numbers inclusive from `+1(510) 720-0000` to `+1(510) 720-9999`.
|
||||
"""
|
||||
|
||||
def __init__(self, version: Version, payload: Dict[str, Any], iso_code: str):
|
||||
super().__init__(version)
|
||||
|
||||
self.prefix: Optional[str] = payload.get("prefix")
|
||||
|
||||
self._solution = {
|
||||
"iso_code": iso_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.Voice.V1.HighriskSpecialPrefixInstance {}>".format(context)
|
||||
|
||||
|
||||
class HighriskSpecialPrefixPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> HighriskSpecialPrefixInstance:
|
||||
"""
|
||||
Build an instance of HighriskSpecialPrefixInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return HighriskSpecialPrefixInstance(
|
||||
self._version, payload, iso_code=self._solution["iso_code"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Voice.V1.HighriskSpecialPrefixPage>"
|
||||
|
||||
|
||||
class HighriskSpecialPrefixList(ListResource):
|
||||
def __init__(self, version: Version, iso_code: str):
|
||||
"""
|
||||
Initialize the HighriskSpecialPrefixList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param iso_code: The [ISO 3166-1 country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) to identify the country permissions from which high-risk special service number prefixes are fetched
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"iso_code": iso_code,
|
||||
}
|
||||
self._uri = (
|
||||
"/DialingPermissions/Countries/{iso_code}/HighRiskSpecialPrefixes".format(
|
||||
**self._solution
|
||||
)
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[HighriskSpecialPrefixInstance]:
|
||||
"""
|
||||
Streams HighriskSpecialPrefixInstance records from the API as a generator stream.
|
||||
This operation lazily loads 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[HighriskSpecialPrefixInstance]:
|
||||
"""
|
||||
Asynchronously streams HighriskSpecialPrefixInstance records from the API as a generator stream.
|
||||
This operation lazily loads 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[HighriskSpecialPrefixInstance]:
|
||||
"""
|
||||
Lists HighriskSpecialPrefixInstance 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[HighriskSpecialPrefixInstance]:
|
||||
"""
|
||||
Asynchronously lists HighriskSpecialPrefixInstance 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,
|
||||
) -> HighriskSpecialPrefixPage:
|
||||
"""
|
||||
Retrieve a single page of HighriskSpecialPrefixInstance 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 HighriskSpecialPrefixInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return HighriskSpecialPrefixPage(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,
|
||||
) -> HighriskSpecialPrefixPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of HighriskSpecialPrefixInstance 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 HighriskSpecialPrefixInstance
|
||||
"""
|
||||
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 HighriskSpecialPrefixPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> HighriskSpecialPrefixPage:
|
||||
"""
|
||||
Retrieve a specific page of HighriskSpecialPrefixInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of HighriskSpecialPrefixInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return HighriskSpecialPrefixPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> HighriskSpecialPrefixPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of HighriskSpecialPrefixInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of HighriskSpecialPrefixInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return HighriskSpecialPrefixPage(self._version, response, self._solution)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Voice.V1.HighriskSpecialPrefixList>"
|
||||
+246
@@ -0,0 +1,246 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Voice
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from typing import Any, Dict, Optional, Union
|
||||
from twilio.base import values
|
||||
from twilio.base.instance_context import InstanceContext
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
|
||||
|
||||
class SettingsInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar dialing_permissions_inheritance: `true` if the sub-account will inherit voice dialing permissions from the Master Project; otherwise `false`.
|
||||
:ivar url: The absolute URL of this resource.
|
||||
"""
|
||||
|
||||
def __init__(self, version: Version, payload: Dict[str, Any]):
|
||||
super().__init__(version)
|
||||
|
||||
self.dialing_permissions_inheritance: Optional[bool] = payload.get(
|
||||
"dialing_permissions_inheritance"
|
||||
)
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
|
||||
self._context: Optional[SettingsContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "SettingsContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: SettingsContext for this SettingsInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = SettingsContext(
|
||||
self._version,
|
||||
)
|
||||
return self._context
|
||||
|
||||
def fetch(self) -> "SettingsInstance":
|
||||
"""
|
||||
Fetch the SettingsInstance
|
||||
|
||||
|
||||
:returns: The fetched SettingsInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "SettingsInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the SettingsInstance
|
||||
|
||||
|
||||
:returns: The fetched SettingsInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self, dialing_permissions_inheritance: Union[bool, object] = values.unset
|
||||
) -> "SettingsInstance":
|
||||
"""
|
||||
Update the SettingsInstance
|
||||
|
||||
:param dialing_permissions_inheritance: `true` for the sub-account to inherit voice dialing permissions from the Master Project; otherwise `false`.
|
||||
|
||||
:returns: The updated SettingsInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
dialing_permissions_inheritance=dialing_permissions_inheritance,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self, dialing_permissions_inheritance: Union[bool, object] = values.unset
|
||||
) -> "SettingsInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the SettingsInstance
|
||||
|
||||
:param dialing_permissions_inheritance: `true` for the sub-account to inherit voice dialing permissions from the Master Project; otherwise `false`.
|
||||
|
||||
:returns: The updated SettingsInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
dialing_permissions_inheritance=dialing_permissions_inheritance,
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
|
||||
return "<Twilio.Voice.V1.SettingsInstance>"
|
||||
|
||||
|
||||
class SettingsContext(InstanceContext):
|
||||
def __init__(self, version: Version):
|
||||
"""
|
||||
Initialize the SettingsContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
self._uri = "/Settings"
|
||||
|
||||
def fetch(self) -> SettingsInstance:
|
||||
"""
|
||||
Fetch the SettingsInstance
|
||||
|
||||
|
||||
:returns: The fetched SettingsInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return SettingsInstance(
|
||||
self._version,
|
||||
payload,
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> SettingsInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the SettingsInstance
|
||||
|
||||
|
||||
:returns: The fetched SettingsInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return SettingsInstance(
|
||||
self._version,
|
||||
payload,
|
||||
)
|
||||
|
||||
def update(
|
||||
self, dialing_permissions_inheritance: Union[bool, object] = values.unset
|
||||
) -> SettingsInstance:
|
||||
"""
|
||||
Update the SettingsInstance
|
||||
|
||||
:param dialing_permissions_inheritance: `true` for the sub-account to inherit voice dialing permissions from the Master Project; otherwise `false`.
|
||||
|
||||
:returns: The updated SettingsInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"DialingPermissionsInheritance": dialing_permissions_inheritance,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return SettingsInstance(self._version, payload)
|
||||
|
||||
async def update_async(
|
||||
self, dialing_permissions_inheritance: Union[bool, object] = values.unset
|
||||
) -> SettingsInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the SettingsInstance
|
||||
|
||||
:param dialing_permissions_inheritance: `true` for the sub-account to inherit voice dialing permissions from the Master Project; otherwise `false`.
|
||||
|
||||
:returns: The updated SettingsInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"DialingPermissionsInheritance": dialing_permissions_inheritance,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return SettingsInstance(self._version, payload)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
|
||||
return "<Twilio.Voice.V1.SettingsContext>"
|
||||
|
||||
|
||||
class SettingsList(ListResource):
|
||||
def __init__(self, version: Version):
|
||||
"""
|
||||
Initialize the SettingsList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
def get(self) -> SettingsContext:
|
||||
"""
|
||||
Constructs a SettingsContext
|
||||
|
||||
"""
|
||||
return SettingsContext(self._version)
|
||||
|
||||
def __call__(self) -> SettingsContext:
|
||||
"""
|
||||
Constructs a SettingsContext
|
||||
|
||||
"""
|
||||
return SettingsContext(self._version)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Voice.V1.SettingsList>"
|
||||
@@ -0,0 +1,586 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Voice
|
||||
This is the 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 IpRecordInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the IP Record resource.
|
||||
:ivar sid: The unique string that we created to identify the IP Record resource.
|
||||
:ivar friendly_name: The string that you assigned to describe the resource.
|
||||
:ivar ip_address: An IP address in dotted decimal notation, IPv4 only.
|
||||
:ivar cidr_prefix_length: An integer representing the length of the [CIDR](https://tools.ietf.org/html/rfc4632) prefix to use with this IP address. By default the entire IP address is used, which for IPv4 is value 32.
|
||||
: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 url: The absolute URL of the resource.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self, version: Version, payload: Dict[str, Any], sid: Optional[str] = None
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.friendly_name: Optional[str] = payload.get("friendly_name")
|
||||
self.ip_address: Optional[str] = payload.get("ip_address")
|
||||
self.cidr_prefix_length: Optional[int] = deserialize.integer(
|
||||
payload.get("cidr_prefix_length")
|
||||
)
|
||||
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[IpRecordContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "IpRecordContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: IpRecordContext for this IpRecordInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = IpRecordContext(
|
||||
self._version,
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the IpRecordInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the IpRecordInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
def fetch(self) -> "IpRecordInstance":
|
||||
"""
|
||||
Fetch the IpRecordInstance
|
||||
|
||||
|
||||
:returns: The fetched IpRecordInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "IpRecordInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the IpRecordInstance
|
||||
|
||||
|
||||
:returns: The fetched IpRecordInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self, friendly_name: Union[str, object] = values.unset
|
||||
) -> "IpRecordInstance":
|
||||
"""
|
||||
Update the IpRecordInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long.
|
||||
|
||||
:returns: The updated IpRecordInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
friendly_name=friendly_name,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self, friendly_name: Union[str, object] = values.unset
|
||||
) -> "IpRecordInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the IpRecordInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long.
|
||||
|
||||
:returns: The updated IpRecordInstance
|
||||
"""
|
||||
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.Voice.V1.IpRecordInstance {}>".format(context)
|
||||
|
||||
|
||||
class IpRecordContext(InstanceContext):
|
||||
def __init__(self, version: Version, sid: str):
|
||||
"""
|
||||
Initialize the IpRecordContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param sid: The Twilio-provided string that uniquely identifies the IP Record resource to update.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/IpRecords/{sid}".format(**self._solution)
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the IpRecordInstance
|
||||
|
||||
|
||||
: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 IpRecordInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
def fetch(self) -> IpRecordInstance:
|
||||
"""
|
||||
Fetch the IpRecordInstance
|
||||
|
||||
|
||||
:returns: The fetched IpRecordInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return IpRecordInstance(
|
||||
self._version,
|
||||
payload,
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> IpRecordInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the IpRecordInstance
|
||||
|
||||
|
||||
:returns: The fetched IpRecordInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return IpRecordInstance(
|
||||
self._version,
|
||||
payload,
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self, friendly_name: Union[str, object] = values.unset
|
||||
) -> IpRecordInstance:
|
||||
"""
|
||||
Update the IpRecordInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long.
|
||||
|
||||
:returns: The updated IpRecordInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return IpRecordInstance(self._version, payload, sid=self._solution["sid"])
|
||||
|
||||
async def update_async(
|
||||
self, friendly_name: Union[str, object] = values.unset
|
||||
) -> IpRecordInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the IpRecordInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long.
|
||||
|
||||
:returns: The updated IpRecordInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return IpRecordInstance(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.Voice.V1.IpRecordContext {}>".format(context)
|
||||
|
||||
|
||||
class IpRecordPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> IpRecordInstance:
|
||||
"""
|
||||
Build an instance of IpRecordInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return IpRecordInstance(self._version, payload)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Voice.V1.IpRecordPage>"
|
||||
|
||||
|
||||
class IpRecordList(ListResource):
|
||||
def __init__(self, version: Version):
|
||||
"""
|
||||
Initialize the IpRecordList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
self._uri = "/IpRecords"
|
||||
|
||||
def create(
|
||||
self,
|
||||
ip_address: str,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
cidr_prefix_length: Union[int, object] = values.unset,
|
||||
) -> IpRecordInstance:
|
||||
"""
|
||||
Create the IpRecordInstance
|
||||
|
||||
:param ip_address: An IP address in dotted decimal notation, IPv4 only.
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long.
|
||||
:param cidr_prefix_length: An integer representing the length of the [CIDR](https://tools.ietf.org/html/rfc4632) prefix to use with this IP address. By default the entire IP address is used, which for IPv4 is value 32.
|
||||
|
||||
:returns: The created IpRecordInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"IpAddress": ip_address,
|
||||
"FriendlyName": friendly_name,
|
||||
"CidrPrefixLength": cidr_prefix_length,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return IpRecordInstance(self._version, payload)
|
||||
|
||||
async def create_async(
|
||||
self,
|
||||
ip_address: str,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
cidr_prefix_length: Union[int, object] = values.unset,
|
||||
) -> IpRecordInstance:
|
||||
"""
|
||||
Asynchronously create the IpRecordInstance
|
||||
|
||||
:param ip_address: An IP address in dotted decimal notation, IPv4 only.
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long.
|
||||
:param cidr_prefix_length: An integer representing the length of the [CIDR](https://tools.ietf.org/html/rfc4632) prefix to use with this IP address. By default the entire IP address is used, which for IPv4 is value 32.
|
||||
|
||||
:returns: The created IpRecordInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"IpAddress": ip_address,
|
||||
"FriendlyName": friendly_name,
|
||||
"CidrPrefixLength": cidr_prefix_length,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return IpRecordInstance(self._version, payload)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[IpRecordInstance]:
|
||||
"""
|
||||
Streams IpRecordInstance records from the API as a generator stream.
|
||||
This operation lazily loads 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[IpRecordInstance]:
|
||||
"""
|
||||
Asynchronously streams IpRecordInstance records from the API as a generator stream.
|
||||
This operation lazily loads 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[IpRecordInstance]:
|
||||
"""
|
||||
Lists IpRecordInstance 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[IpRecordInstance]:
|
||||
"""
|
||||
Asynchronously lists IpRecordInstance 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,
|
||||
) -> IpRecordPage:
|
||||
"""
|
||||
Retrieve a single page of IpRecordInstance 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 IpRecordInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return IpRecordPage(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,
|
||||
) -> IpRecordPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of IpRecordInstance 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 IpRecordInstance
|
||||
"""
|
||||
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 IpRecordPage(self._version, response)
|
||||
|
||||
def get_page(self, target_url: str) -> IpRecordPage:
|
||||
"""
|
||||
Retrieve a specific page of IpRecordInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of IpRecordInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return IpRecordPage(self._version, response)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> IpRecordPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of IpRecordInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of IpRecordInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return IpRecordPage(self._version, response)
|
||||
|
||||
def get(self, sid: str) -> IpRecordContext:
|
||||
"""
|
||||
Constructs a IpRecordContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the IP Record resource to update.
|
||||
"""
|
||||
return IpRecordContext(self._version, sid=sid)
|
||||
|
||||
def __call__(self, sid: str) -> IpRecordContext:
|
||||
"""
|
||||
Constructs a IpRecordContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the IP Record resource to update.
|
||||
"""
|
||||
return IpRecordContext(self._version, sid=sid)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Voice.V1.IpRecordList>"
|
||||
@@ -0,0 +1,566 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Voice
|
||||
This is the 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 SourceIpMappingInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar sid: The unique string that we created to identify the IP Record resource.
|
||||
:ivar ip_record_sid: The Twilio-provided string that uniquely identifies the IP Record resource to map from.
|
||||
:ivar sip_domain_sid: The SID of the SIP Domain that the IP Record is mapped to.
|
||||
: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 url: The absolute URL of the resource.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self, version: Version, payload: Dict[str, Any], sid: Optional[str] = None
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.ip_record_sid: Optional[str] = payload.get("ip_record_sid")
|
||||
self.sip_domain_sid: Optional[str] = payload.get("sip_domain_sid")
|
||||
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
|
||||
self._solution = {
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[SourceIpMappingContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "SourceIpMappingContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: SourceIpMappingContext for this SourceIpMappingInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = SourceIpMappingContext(
|
||||
self._version,
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the SourceIpMappingInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the SourceIpMappingInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
def fetch(self) -> "SourceIpMappingInstance":
|
||||
"""
|
||||
Fetch the SourceIpMappingInstance
|
||||
|
||||
|
||||
:returns: The fetched SourceIpMappingInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "SourceIpMappingInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the SourceIpMappingInstance
|
||||
|
||||
|
||||
:returns: The fetched SourceIpMappingInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(self, sip_domain_sid: str) -> "SourceIpMappingInstance":
|
||||
"""
|
||||
Update the SourceIpMappingInstance
|
||||
|
||||
:param sip_domain_sid: The SID of the SIP Domain that the IP Record should be mapped to.
|
||||
|
||||
:returns: The updated SourceIpMappingInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
sip_domain_sid=sip_domain_sid,
|
||||
)
|
||||
|
||||
async def update_async(self, sip_domain_sid: str) -> "SourceIpMappingInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the SourceIpMappingInstance
|
||||
|
||||
:param sip_domain_sid: The SID of the SIP Domain that the IP Record should be mapped to.
|
||||
|
||||
:returns: The updated SourceIpMappingInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
sip_domain_sid=sip_domain_sid,
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Voice.V1.SourceIpMappingInstance {}>".format(context)
|
||||
|
||||
|
||||
class SourceIpMappingContext(InstanceContext):
|
||||
def __init__(self, version: Version, sid: str):
|
||||
"""
|
||||
Initialize the SourceIpMappingContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param sid: The Twilio-provided string that uniquely identifies the IP Record resource to update.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/SourceIpMappings/{sid}".format(**self._solution)
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the SourceIpMappingInstance
|
||||
|
||||
|
||||
: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 SourceIpMappingInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
def fetch(self) -> SourceIpMappingInstance:
|
||||
"""
|
||||
Fetch the SourceIpMappingInstance
|
||||
|
||||
|
||||
:returns: The fetched SourceIpMappingInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return SourceIpMappingInstance(
|
||||
self._version,
|
||||
payload,
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> SourceIpMappingInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the SourceIpMappingInstance
|
||||
|
||||
|
||||
:returns: The fetched SourceIpMappingInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return SourceIpMappingInstance(
|
||||
self._version,
|
||||
payload,
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def update(self, sip_domain_sid: str) -> SourceIpMappingInstance:
|
||||
"""
|
||||
Update the SourceIpMappingInstance
|
||||
|
||||
:param sip_domain_sid: The SID of the SIP Domain that the IP Record should be mapped to.
|
||||
|
||||
:returns: The updated SourceIpMappingInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"SipDomainSid": sip_domain_sid,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return SourceIpMappingInstance(
|
||||
self._version, payload, sid=self._solution["sid"]
|
||||
)
|
||||
|
||||
async def update_async(self, sip_domain_sid: str) -> SourceIpMappingInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the SourceIpMappingInstance
|
||||
|
||||
:param sip_domain_sid: The SID of the SIP Domain that the IP Record should be mapped to.
|
||||
|
||||
:returns: The updated SourceIpMappingInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"SipDomainSid": sip_domain_sid,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return SourceIpMappingInstance(
|
||||
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.Voice.V1.SourceIpMappingContext {}>".format(context)
|
||||
|
||||
|
||||
class SourceIpMappingPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> SourceIpMappingInstance:
|
||||
"""
|
||||
Build an instance of SourceIpMappingInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return SourceIpMappingInstance(self._version, payload)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Voice.V1.SourceIpMappingPage>"
|
||||
|
||||
|
||||
class SourceIpMappingList(ListResource):
|
||||
def __init__(self, version: Version):
|
||||
"""
|
||||
Initialize the SourceIpMappingList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
self._uri = "/SourceIpMappings"
|
||||
|
||||
def create(
|
||||
self, ip_record_sid: str, sip_domain_sid: str
|
||||
) -> SourceIpMappingInstance:
|
||||
"""
|
||||
Create the SourceIpMappingInstance
|
||||
|
||||
:param ip_record_sid: The Twilio-provided string that uniquely identifies the IP Record resource to map from.
|
||||
:param sip_domain_sid: The SID of the SIP Domain that the IP Record should be mapped to.
|
||||
|
||||
:returns: The created SourceIpMappingInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"IpRecordSid": ip_record_sid,
|
||||
"SipDomainSid": sip_domain_sid,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return SourceIpMappingInstance(self._version, payload)
|
||||
|
||||
async def create_async(
|
||||
self, ip_record_sid: str, sip_domain_sid: str
|
||||
) -> SourceIpMappingInstance:
|
||||
"""
|
||||
Asynchronously create the SourceIpMappingInstance
|
||||
|
||||
:param ip_record_sid: The Twilio-provided string that uniquely identifies the IP Record resource to map from.
|
||||
:param sip_domain_sid: The SID of the SIP Domain that the IP Record should be mapped to.
|
||||
|
||||
:returns: The created SourceIpMappingInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"IpRecordSid": ip_record_sid,
|
||||
"SipDomainSid": sip_domain_sid,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return SourceIpMappingInstance(self._version, payload)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[SourceIpMappingInstance]:
|
||||
"""
|
||||
Streams SourceIpMappingInstance records from the API as a generator stream.
|
||||
This operation lazily loads 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[SourceIpMappingInstance]:
|
||||
"""
|
||||
Asynchronously streams SourceIpMappingInstance records from the API as a generator stream.
|
||||
This operation lazily loads 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[SourceIpMappingInstance]:
|
||||
"""
|
||||
Lists SourceIpMappingInstance 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[SourceIpMappingInstance]:
|
||||
"""
|
||||
Asynchronously lists SourceIpMappingInstance 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,
|
||||
) -> SourceIpMappingPage:
|
||||
"""
|
||||
Retrieve a single page of SourceIpMappingInstance 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 SourceIpMappingInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return SourceIpMappingPage(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,
|
||||
) -> SourceIpMappingPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of SourceIpMappingInstance 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 SourceIpMappingInstance
|
||||
"""
|
||||
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 SourceIpMappingPage(self._version, response)
|
||||
|
||||
def get_page(self, target_url: str) -> SourceIpMappingPage:
|
||||
"""
|
||||
Retrieve a specific page of SourceIpMappingInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of SourceIpMappingInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return SourceIpMappingPage(self._version, response)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> SourceIpMappingPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of SourceIpMappingInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of SourceIpMappingInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return SourceIpMappingPage(self._version, response)
|
||||
|
||||
def get(self, sid: str) -> SourceIpMappingContext:
|
||||
"""
|
||||
Constructs a SourceIpMappingContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the IP Record resource to update.
|
||||
"""
|
||||
return SourceIpMappingContext(self._version, sid=sid)
|
||||
|
||||
def __call__(self, sid: str) -> SourceIpMappingContext:
|
||||
"""
|
||||
Constructs a SourceIpMappingContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the IP Record resource to update.
|
||||
"""
|
||||
return SourceIpMappingContext(self._version, sid=sid)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Voice.V1.SourceIpMappingList>"
|
||||
Reference in New Issue
Block a user