Initial commit: Email alerts application
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
from typing import Optional
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.domain import Domain
|
||||
from twilio.rest.api.v2010.account import AccountList
|
||||
from twilio.rest.api.v2010.account import AccountContext
|
||||
|
||||
|
||||
class V2010(Version):
|
||||
def __init__(self, domain: Domain):
|
||||
"""
|
||||
Initialize the V2010 version of Api
|
||||
|
||||
:param domain: The Twilio.api domain
|
||||
"""
|
||||
super().__init__(domain, "2010-04-01")
|
||||
self._accounts: Optional[AccountList] = None
|
||||
self._account: Optional[AccountContext] = None
|
||||
|
||||
@property
|
||||
def accounts(self) -> AccountList:
|
||||
if self._accounts is None:
|
||||
self._accounts = AccountList(self)
|
||||
return self._accounts
|
||||
|
||||
@property
|
||||
def account(self) -> AccountContext:
|
||||
if self._account is None:
|
||||
self._account = AccountContext(self, self.domain.twilio.account_sid)
|
||||
return self._account
|
||||
|
||||
@account.setter
|
||||
def account(self, value: AccountContext) -> None:
|
||||
"""
|
||||
Setter to override account
|
||||
:param value: value to use as account
|
||||
"""
|
||||
self._account = value
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010>"
|
||||
BIN
Binary file not shown.
File diff suppressed because it is too large
Load Diff
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -0,0 +1,862 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, values
|
||||
from twilio.base.instance_context import InstanceContext
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.page import Page
|
||||
from twilio.rest.api.v2010.account.address.dependent_phone_number import (
|
||||
DependentPhoneNumberList,
|
||||
)
|
||||
|
||||
|
||||
class AddressInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that is responsible for the Address resource.
|
||||
:ivar city: The city in which the address is located.
|
||||
:ivar customer_name: The name associated with the address.This property has a maximum length of 16 4-byte characters, or 21 3-byte characters.
|
||||
:ivar date_created: The date and time in GMT that the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar date_updated: The date and time in GMT that the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar friendly_name: The string that you assigned to describe the resource.
|
||||
:ivar iso_country: The ISO country code of the address.
|
||||
:ivar postal_code: The postal code of the address.
|
||||
:ivar region: The state or region of the address.
|
||||
:ivar sid: The unique string that that we created to identify the Address resource.
|
||||
:ivar street: The number and street address of the address.
|
||||
:ivar uri: The URI of the resource, relative to `https://api.twilio.com`.
|
||||
:ivar emergency_enabled: Whether emergency calling has been enabled on this number.
|
||||
:ivar validated: Whether the address has been validated to comply with local regulation. In countries that require valid addresses, an invalid address will not be accepted. `true` indicates the Address has been validated. `false` indicate the country doesn't require validation or the Address is not valid.
|
||||
:ivar verified: Whether the address has been verified to comply with regulation. In countries that require valid addresses, an invalid address will not be accepted. `true` indicates the Address has been verified. `false` indicate the country doesn't require verified or the Address is not valid.
|
||||
:ivar street_secondary: The additional number and street address of the address.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
account_sid: str,
|
||||
sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.city: Optional[str] = payload.get("city")
|
||||
self.customer_name: Optional[str] = payload.get("customer_name")
|
||||
self.date_created: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.friendly_name: Optional[str] = payload.get("friendly_name")
|
||||
self.iso_country: Optional[str] = payload.get("iso_country")
|
||||
self.postal_code: Optional[str] = payload.get("postal_code")
|
||||
self.region: Optional[str] = payload.get("region")
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.street: Optional[str] = payload.get("street")
|
||||
self.uri: Optional[str] = payload.get("uri")
|
||||
self.emergency_enabled: Optional[bool] = payload.get("emergency_enabled")
|
||||
self.validated: Optional[bool] = payload.get("validated")
|
||||
self.verified: Optional[bool] = payload.get("verified")
|
||||
self.street_secondary: Optional[str] = payload.get("street_secondary")
|
||||
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[AddressContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "AddressContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: AddressContext for this AddressInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = AddressContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the AddressInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the AddressInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
def fetch(self) -> "AddressInstance":
|
||||
"""
|
||||
Fetch the AddressInstance
|
||||
|
||||
|
||||
:returns: The fetched AddressInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "AddressInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the AddressInstance
|
||||
|
||||
|
||||
:returns: The fetched AddressInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
customer_name: Union[str, object] = values.unset,
|
||||
street: Union[str, object] = values.unset,
|
||||
city: Union[str, object] = values.unset,
|
||||
region: Union[str, object] = values.unset,
|
||||
postal_code: Union[str, object] = values.unset,
|
||||
emergency_enabled: Union[bool, object] = values.unset,
|
||||
auto_correct_address: Union[bool, object] = values.unset,
|
||||
street_secondary: Union[str, object] = values.unset,
|
||||
) -> "AddressInstance":
|
||||
"""
|
||||
Update the AddressInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the address. It can be up to 64 characters long.
|
||||
:param customer_name: The name to associate with the address.
|
||||
:param street: The number and street address of the address.
|
||||
:param city: The city of the address.
|
||||
:param region: The state or region of the address.
|
||||
:param postal_code: The postal code of the address.
|
||||
:param emergency_enabled: Whether to enable emergency calling on the address. Can be: `true` or `false`.
|
||||
:param auto_correct_address: Whether we should automatically correct the address. Can be: `true` or `false` and the default is `true`. If empty or `true`, we will correct the address you provide if necessary. If `false`, we won't alter the address you provide.
|
||||
:param street_secondary: The additional number and street address of the address.
|
||||
|
||||
:returns: The updated AddressInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
friendly_name=friendly_name,
|
||||
customer_name=customer_name,
|
||||
street=street,
|
||||
city=city,
|
||||
region=region,
|
||||
postal_code=postal_code,
|
||||
emergency_enabled=emergency_enabled,
|
||||
auto_correct_address=auto_correct_address,
|
||||
street_secondary=street_secondary,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
customer_name: Union[str, object] = values.unset,
|
||||
street: Union[str, object] = values.unset,
|
||||
city: Union[str, object] = values.unset,
|
||||
region: Union[str, object] = values.unset,
|
||||
postal_code: Union[str, object] = values.unset,
|
||||
emergency_enabled: Union[bool, object] = values.unset,
|
||||
auto_correct_address: Union[bool, object] = values.unset,
|
||||
street_secondary: Union[str, object] = values.unset,
|
||||
) -> "AddressInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the AddressInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the address. It can be up to 64 characters long.
|
||||
:param customer_name: The name to associate with the address.
|
||||
:param street: The number and street address of the address.
|
||||
:param city: The city of the address.
|
||||
:param region: The state or region of the address.
|
||||
:param postal_code: The postal code of the address.
|
||||
:param emergency_enabled: Whether to enable emergency calling on the address. Can be: `true` or `false`.
|
||||
:param auto_correct_address: Whether we should automatically correct the address. Can be: `true` or `false` and the default is `true`. If empty or `true`, we will correct the address you provide if necessary. If `false`, we won't alter the address you provide.
|
||||
:param street_secondary: The additional number and street address of the address.
|
||||
|
||||
:returns: The updated AddressInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
friendly_name=friendly_name,
|
||||
customer_name=customer_name,
|
||||
street=street,
|
||||
city=city,
|
||||
region=region,
|
||||
postal_code=postal_code,
|
||||
emergency_enabled=emergency_enabled,
|
||||
auto_correct_address=auto_correct_address,
|
||||
street_secondary=street_secondary,
|
||||
)
|
||||
|
||||
@property
|
||||
def dependent_phone_numbers(self) -> DependentPhoneNumberList:
|
||||
"""
|
||||
Access the dependent_phone_numbers
|
||||
"""
|
||||
return self._proxy.dependent_phone_numbers
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.AddressInstance {}>".format(context)
|
||||
|
||||
|
||||
class AddressContext(InstanceContext):
|
||||
def __init__(self, version: Version, account_sid: str, sid: str):
|
||||
"""
|
||||
Initialize the AddressContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that is responsible for the Address resource to update.
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Address resource to update.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/Addresses/{sid}.json".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
self._dependent_phone_numbers: Optional[DependentPhoneNumberList] = None
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the AddressInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._version.delete(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the AddressInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
def fetch(self) -> AddressInstance:
|
||||
"""
|
||||
Fetch the AddressInstance
|
||||
|
||||
|
||||
:returns: The fetched AddressInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return AddressInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> AddressInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the AddressInstance
|
||||
|
||||
|
||||
:returns: The fetched AddressInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return AddressInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
customer_name: Union[str, object] = values.unset,
|
||||
street: Union[str, object] = values.unset,
|
||||
city: Union[str, object] = values.unset,
|
||||
region: Union[str, object] = values.unset,
|
||||
postal_code: Union[str, object] = values.unset,
|
||||
emergency_enabled: Union[bool, object] = values.unset,
|
||||
auto_correct_address: Union[bool, object] = values.unset,
|
||||
street_secondary: Union[str, object] = values.unset,
|
||||
) -> AddressInstance:
|
||||
"""
|
||||
Update the AddressInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the address. It can be up to 64 characters long.
|
||||
:param customer_name: The name to associate with the address.
|
||||
:param street: The number and street address of the address.
|
||||
:param city: The city of the address.
|
||||
:param region: The state or region of the address.
|
||||
:param postal_code: The postal code of the address.
|
||||
:param emergency_enabled: Whether to enable emergency calling on the address. Can be: `true` or `false`.
|
||||
:param auto_correct_address: Whether we should automatically correct the address. Can be: `true` or `false` and the default is `true`. If empty or `true`, we will correct the address you provide if necessary. If `false`, we won't alter the address you provide.
|
||||
:param street_secondary: The additional number and street address of the address.
|
||||
|
||||
:returns: The updated AddressInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"CustomerName": customer_name,
|
||||
"Street": street,
|
||||
"City": city,
|
||||
"Region": region,
|
||||
"PostalCode": postal_code,
|
||||
"EmergencyEnabled": emergency_enabled,
|
||||
"AutoCorrectAddress": auto_correct_address,
|
||||
"StreetSecondary": street_secondary,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return AddressInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
customer_name: Union[str, object] = values.unset,
|
||||
street: Union[str, object] = values.unset,
|
||||
city: Union[str, object] = values.unset,
|
||||
region: Union[str, object] = values.unset,
|
||||
postal_code: Union[str, object] = values.unset,
|
||||
emergency_enabled: Union[bool, object] = values.unset,
|
||||
auto_correct_address: Union[bool, object] = values.unset,
|
||||
street_secondary: Union[str, object] = values.unset,
|
||||
) -> AddressInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the AddressInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the address. It can be up to 64 characters long.
|
||||
:param customer_name: The name to associate with the address.
|
||||
:param street: The number and street address of the address.
|
||||
:param city: The city of the address.
|
||||
:param region: The state or region of the address.
|
||||
:param postal_code: The postal code of the address.
|
||||
:param emergency_enabled: Whether to enable emergency calling on the address. Can be: `true` or `false`.
|
||||
:param auto_correct_address: Whether we should automatically correct the address. Can be: `true` or `false` and the default is `true`. If empty or `true`, we will correct the address you provide if necessary. If `false`, we won't alter the address you provide.
|
||||
:param street_secondary: The additional number and street address of the address.
|
||||
|
||||
:returns: The updated AddressInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"CustomerName": customer_name,
|
||||
"Street": street,
|
||||
"City": city,
|
||||
"Region": region,
|
||||
"PostalCode": postal_code,
|
||||
"EmergencyEnabled": emergency_enabled,
|
||||
"AutoCorrectAddress": auto_correct_address,
|
||||
"StreetSecondary": street_secondary,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return AddressInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
@property
|
||||
def dependent_phone_numbers(self) -> DependentPhoneNumberList:
|
||||
"""
|
||||
Access the dependent_phone_numbers
|
||||
"""
|
||||
if self._dependent_phone_numbers is None:
|
||||
self._dependent_phone_numbers = DependentPhoneNumberList(
|
||||
self._version,
|
||||
self._solution["account_sid"],
|
||||
self._solution["sid"],
|
||||
)
|
||||
return self._dependent_phone_numbers
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.AddressContext {}>".format(context)
|
||||
|
||||
|
||||
class AddressPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> AddressInstance:
|
||||
"""
|
||||
Build an instance of AddressInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return AddressInstance(
|
||||
self._version, payload, account_sid=self._solution["account_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.AddressPage>"
|
||||
|
||||
|
||||
class AddressList(ListResource):
|
||||
def __init__(self, version: Version, account_sid: str):
|
||||
"""
|
||||
Initialize the AddressList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that is responsible for the Address resource to read.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/Addresses.json".format(**self._solution)
|
||||
|
||||
def create(
|
||||
self,
|
||||
customer_name: str,
|
||||
street: str,
|
||||
city: str,
|
||||
region: str,
|
||||
postal_code: str,
|
||||
iso_country: str,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
emergency_enabled: Union[bool, object] = values.unset,
|
||||
auto_correct_address: Union[bool, object] = values.unset,
|
||||
street_secondary: Union[str, object] = values.unset,
|
||||
) -> AddressInstance:
|
||||
"""
|
||||
Create the AddressInstance
|
||||
|
||||
:param customer_name: The name to associate with the new address.
|
||||
:param street: The number and street address of the new address.
|
||||
:param city: The city of the new address.
|
||||
:param region: The state or region of the new address.
|
||||
:param postal_code: The postal code of the new address.
|
||||
:param iso_country: The ISO country code of the new address.
|
||||
:param friendly_name: A descriptive string that you create to describe the new address. It can be up to 64 characters long.
|
||||
:param emergency_enabled: Whether to enable emergency calling on the new address. Can be: `true` or `false`.
|
||||
:param auto_correct_address: Whether we should automatically correct the address. Can be: `true` or `false` and the default is `true`. If empty or `true`, we will correct the address you provide if necessary. If `false`, we won't alter the address you provide.
|
||||
:param street_secondary: The additional number and street address of the address.
|
||||
|
||||
:returns: The created AddressInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"CustomerName": customer_name,
|
||||
"Street": street,
|
||||
"City": city,
|
||||
"Region": region,
|
||||
"PostalCode": postal_code,
|
||||
"IsoCountry": iso_country,
|
||||
"FriendlyName": friendly_name,
|
||||
"EmergencyEnabled": emergency_enabled,
|
||||
"AutoCorrectAddress": auto_correct_address,
|
||||
"StreetSecondary": street_secondary,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return AddressInstance(
|
||||
self._version, payload, account_sid=self._solution["account_sid"]
|
||||
)
|
||||
|
||||
async def create_async(
|
||||
self,
|
||||
customer_name: str,
|
||||
street: str,
|
||||
city: str,
|
||||
region: str,
|
||||
postal_code: str,
|
||||
iso_country: str,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
emergency_enabled: Union[bool, object] = values.unset,
|
||||
auto_correct_address: Union[bool, object] = values.unset,
|
||||
street_secondary: Union[str, object] = values.unset,
|
||||
) -> AddressInstance:
|
||||
"""
|
||||
Asynchronously create the AddressInstance
|
||||
|
||||
:param customer_name: The name to associate with the new address.
|
||||
:param street: The number and street address of the new address.
|
||||
:param city: The city of the new address.
|
||||
:param region: The state or region of the new address.
|
||||
:param postal_code: The postal code of the new address.
|
||||
:param iso_country: The ISO country code of the new address.
|
||||
:param friendly_name: A descriptive string that you create to describe the new address. It can be up to 64 characters long.
|
||||
:param emergency_enabled: Whether to enable emergency calling on the new address. Can be: `true` or `false`.
|
||||
:param auto_correct_address: Whether we should automatically correct the address. Can be: `true` or `false` and the default is `true`. If empty or `true`, we will correct the address you provide if necessary. If `false`, we won't alter the address you provide.
|
||||
:param street_secondary: The additional number and street address of the address.
|
||||
|
||||
:returns: The created AddressInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"CustomerName": customer_name,
|
||||
"Street": street,
|
||||
"City": city,
|
||||
"Region": region,
|
||||
"PostalCode": postal_code,
|
||||
"IsoCountry": iso_country,
|
||||
"FriendlyName": friendly_name,
|
||||
"EmergencyEnabled": emergency_enabled,
|
||||
"AutoCorrectAddress": auto_correct_address,
|
||||
"StreetSecondary": street_secondary,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return AddressInstance(
|
||||
self._version, payload, account_sid=self._solution["account_sid"]
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
customer_name: Union[str, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
iso_country: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[AddressInstance]:
|
||||
"""
|
||||
Streams AddressInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param str customer_name: The `customer_name` of the Address resources to read.
|
||||
:param str friendly_name: The string that identifies the Address resources to read.
|
||||
:param str iso_country: The ISO country code of the Address resources to read.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(
|
||||
customer_name=customer_name,
|
||||
friendly_name=friendly_name,
|
||||
iso_country=iso_country,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
customer_name: Union[str, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
iso_country: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[AddressInstance]:
|
||||
"""
|
||||
Asynchronously streams AddressInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param str customer_name: The `customer_name` of the Address resources to read.
|
||||
:param str friendly_name: The string that identifies the Address resources to read.
|
||||
:param str iso_country: The ISO country code of the Address resources to read.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(
|
||||
customer_name=customer_name,
|
||||
friendly_name=friendly_name,
|
||||
iso_country=iso_country,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
customer_name: Union[str, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
iso_country: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[AddressInstance]:
|
||||
"""
|
||||
Lists AddressInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param str customer_name: The `customer_name` of the Address resources to read.
|
||||
:param str friendly_name: The string that identifies the Address resources to read.
|
||||
:param str iso_country: The ISO country code of the Address resources to read.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return list(
|
||||
self.stream(
|
||||
customer_name=customer_name,
|
||||
friendly_name=friendly_name,
|
||||
iso_country=iso_country,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
customer_name: Union[str, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
iso_country: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[AddressInstance]:
|
||||
"""
|
||||
Asynchronously lists AddressInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param str customer_name: The `customer_name` of the Address resources to read.
|
||||
:param str friendly_name: The string that identifies the Address resources to read.
|
||||
:param str iso_country: The ISO country code of the Address resources to read.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return [
|
||||
record
|
||||
async for record in await self.stream_async(
|
||||
customer_name=customer_name,
|
||||
friendly_name=friendly_name,
|
||||
iso_country=iso_country,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
customer_name: Union[str, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
iso_country: Union[str, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> AddressPage:
|
||||
"""
|
||||
Retrieve a single page of AddressInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param customer_name: The `customer_name` of the Address resources to read.
|
||||
:param friendly_name: The string that identifies the Address resources to read.
|
||||
:param iso_country: The ISO country code of the Address resources to read.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of AddressInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"CustomerName": customer_name,
|
||||
"FriendlyName": friendly_name,
|
||||
"IsoCountry": iso_country,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return AddressPage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
customer_name: Union[str, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
iso_country: Union[str, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> AddressPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of AddressInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param customer_name: The `customer_name` of the Address resources to read.
|
||||
:param friendly_name: The string that identifies the Address resources to read.
|
||||
:param iso_country: The ISO country code of the Address resources to read.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of AddressInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"CustomerName": customer_name,
|
||||
"FriendlyName": friendly_name,
|
||||
"IsoCountry": iso_country,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return AddressPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> AddressPage:
|
||||
"""
|
||||
Retrieve a specific page of AddressInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of AddressInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return AddressPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> AddressPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of AddressInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of AddressInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return AddressPage(self._version, response, self._solution)
|
||||
|
||||
def get(self, sid: str) -> AddressContext:
|
||||
"""
|
||||
Constructs a AddressContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Address resource to update.
|
||||
"""
|
||||
return AddressContext(
|
||||
self._version, account_sid=self._solution["account_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> AddressContext:
|
||||
"""
|
||||
Constructs a AddressContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Address resource to update.
|
||||
"""
|
||||
return AddressContext(
|
||||
self._version, account_sid=self._solution["account_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.AddressList>"
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
+362
@@ -0,0 +1,362 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, values
|
||||
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.page import Page
|
||||
|
||||
|
||||
class DependentPhoneNumberInstance(InstanceResource):
|
||||
class AddressRequirement(object):
|
||||
NONE = "none"
|
||||
ANY = "any"
|
||||
LOCAL = "local"
|
||||
FOREIGN = "foreign"
|
||||
|
||||
class EmergencyStatus(object):
|
||||
ACTIVE = "Active"
|
||||
INACTIVE = "Inactive"
|
||||
|
||||
"""
|
||||
:ivar sid: The unique string that that we created to identify the DependentPhoneNumber resource.
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the DependentPhoneNumber resource.
|
||||
:ivar friendly_name: The string that you assigned to describe the resource.
|
||||
:ivar phone_number: The phone number in [E.164](https://www.twilio.com/docs/glossary/what-e164) format, which consists of a + followed by the country code and subscriber number.
|
||||
:ivar voice_url: The URL we call when the phone number receives a call. The `voice_url` will not be used if a `voice_application_sid` or a `trunk_sid` is set.
|
||||
:ivar voice_method: The HTTP method we use to call `voice_url`. Can be: `GET` or `POST`.
|
||||
:ivar voice_fallback_method: The HTTP method we use to call `voice_fallback_url`. Can be: `GET` or `POST`.
|
||||
:ivar voice_fallback_url: The URL that we call when an error occurs retrieving or executing the TwiML requested by `url`.
|
||||
:ivar voice_caller_id_lookup: Whether we look up the caller's caller-ID name from the CNAM database. Can be: `true` or `false`. Caller ID lookups can cost $0.01 each.
|
||||
:ivar date_created: The date and time in GMT that the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar date_updated: The date and time in GMT that the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar sms_fallback_method: The HTTP method we use to call `sms_fallback_url`. Can be: `GET` or `POST`.
|
||||
:ivar sms_fallback_url: The URL that we call when an error occurs while retrieving or executing the TwiML from `sms_url`.
|
||||
:ivar sms_method: The HTTP method we use to call `sms_url`. Can be: `GET` or `POST`.
|
||||
:ivar sms_url: The URL we call when the phone number receives an incoming SMS message.
|
||||
:ivar address_requirements:
|
||||
:ivar capabilities: The set of Boolean properties that indicates whether a phone number can receive calls or messages. Capabilities are `Voice`, `SMS`, and `MMS` and each capability can be: `true` or `false`.
|
||||
:ivar status_callback: The URL we call using the `status_callback_method` to send status information to your application.
|
||||
:ivar status_callback_method: The HTTP method we use to call `status_callback`. Can be: `GET` or `POST`.
|
||||
:ivar api_version: The API version used to start a new TwiML session.
|
||||
:ivar sms_application_sid: The SID of the application that handles SMS messages sent to the phone number. If an `sms_application_sid` is present, we ignore all `sms_*_url` values and use those of the application.
|
||||
:ivar voice_application_sid: The SID of the application that handles calls to the phone number. If a `voice_application_sid` is present, we ignore all of the voice urls and use those set on the application. Setting a `voice_application_sid` will automatically delete your `trunk_sid` and vice versa.
|
||||
:ivar trunk_sid: The SID of the Trunk that handles calls to the phone number. If a `trunk_sid` is present, we ignore all of the voice urls and voice applications and use those set on the Trunk. Setting a `trunk_sid` will automatically delete your `voice_application_sid` and vice versa.
|
||||
:ivar emergency_status:
|
||||
:ivar emergency_address_sid: The SID of the emergency address configuration that we use for emergency calling from the phone number.
|
||||
:ivar uri: The URI of the resource, relative to `https://api.twilio.com`.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
account_sid: str,
|
||||
address_sid: str,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.friendly_name: Optional[str] = payload.get("friendly_name")
|
||||
self.phone_number: Optional[str] = payload.get("phone_number")
|
||||
self.voice_url: Optional[str] = payload.get("voice_url")
|
||||
self.voice_method: Optional[str] = payload.get("voice_method")
|
||||
self.voice_fallback_method: Optional[str] = payload.get("voice_fallback_method")
|
||||
self.voice_fallback_url: Optional[str] = payload.get("voice_fallback_url")
|
||||
self.voice_caller_id_lookup: Optional[bool] = payload.get(
|
||||
"voice_caller_id_lookup"
|
||||
)
|
||||
self.date_created: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.sms_fallback_method: Optional[str] = payload.get("sms_fallback_method")
|
||||
self.sms_fallback_url: Optional[str] = payload.get("sms_fallback_url")
|
||||
self.sms_method: Optional[str] = payload.get("sms_method")
|
||||
self.sms_url: Optional[str] = payload.get("sms_url")
|
||||
self.address_requirements: Optional[
|
||||
"DependentPhoneNumberInstance.AddressRequirement"
|
||||
] = payload.get("address_requirements")
|
||||
self.capabilities: Optional[Dict[str, object]] = payload.get("capabilities")
|
||||
self.status_callback: Optional[str] = payload.get("status_callback")
|
||||
self.status_callback_method: Optional[str] = payload.get(
|
||||
"status_callback_method"
|
||||
)
|
||||
self.api_version: Optional[str] = payload.get("api_version")
|
||||
self.sms_application_sid: Optional[str] = payload.get("sms_application_sid")
|
||||
self.voice_application_sid: Optional[str] = payload.get("voice_application_sid")
|
||||
self.trunk_sid: Optional[str] = payload.get("trunk_sid")
|
||||
self.emergency_status: Optional[
|
||||
"DependentPhoneNumberInstance.EmergencyStatus"
|
||||
] = payload.get("emergency_status")
|
||||
self.emergency_address_sid: Optional[str] = payload.get("emergency_address_sid")
|
||||
self.uri: Optional[str] = payload.get("uri")
|
||||
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"address_sid": address_sid,
|
||||
}
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.DependentPhoneNumberInstance {}>".format(context)
|
||||
|
||||
|
||||
class DependentPhoneNumberPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> DependentPhoneNumberInstance:
|
||||
"""
|
||||
Build an instance of DependentPhoneNumberInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return DependentPhoneNumberInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
address_sid=self._solution["address_sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.DependentPhoneNumberPage>"
|
||||
|
||||
|
||||
class DependentPhoneNumberList(ListResource):
|
||||
def __init__(self, version: Version, account_sid: str, address_sid: str):
|
||||
"""
|
||||
Initialize the DependentPhoneNumberList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the DependentPhoneNumber resources to read.
|
||||
:param address_sid: The SID of the Address resource associated with the phone number.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"address_sid": address_sid,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/Addresses/{address_sid}/DependentPhoneNumbers.json".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[DependentPhoneNumberInstance]:
|
||||
"""
|
||||
Streams DependentPhoneNumberInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[DependentPhoneNumberInstance]:
|
||||
"""
|
||||
Asynchronously streams DependentPhoneNumberInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[DependentPhoneNumberInstance]:
|
||||
"""
|
||||
Lists DependentPhoneNumberInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return list(
|
||||
self.stream(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[DependentPhoneNumberInstance]:
|
||||
"""
|
||||
Asynchronously lists DependentPhoneNumberInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return [
|
||||
record
|
||||
async for record in await self.stream_async(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> DependentPhoneNumberPage:
|
||||
"""
|
||||
Retrieve a single page of DependentPhoneNumberInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of DependentPhoneNumberInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return DependentPhoneNumberPage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> DependentPhoneNumberPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of DependentPhoneNumberInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of DependentPhoneNumberInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return DependentPhoneNumberPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> DependentPhoneNumberPage:
|
||||
"""
|
||||
Retrieve a specific page of DependentPhoneNumberInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of DependentPhoneNumberInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return DependentPhoneNumberPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> DependentPhoneNumberPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of DependentPhoneNumberInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of DependentPhoneNumberInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return DependentPhoneNumberPage(self._version, response, self._solution)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.DependentPhoneNumberList>"
|
||||
@@ -0,0 +1,935 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, values
|
||||
from twilio.base.instance_context import InstanceContext
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.page import Page
|
||||
|
||||
|
||||
class ApplicationInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Application resource.
|
||||
:ivar api_version: The API version used to start a new TwiML session.
|
||||
:ivar date_created: The date and time in GMT that the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar date_updated: The date and time in GMT that the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar friendly_name: The string that you assigned to describe the resource.
|
||||
:ivar message_status_callback: The URL we call using a POST method to send message status information to your application.
|
||||
:ivar sid: The unique string that that we created to identify the Application resource.
|
||||
:ivar sms_fallback_method: The HTTP method we use to call `sms_fallback_url`. Can be: `GET` or `POST`.
|
||||
:ivar sms_fallback_url: The URL that we call when an error occurs while retrieving or executing the TwiML from `sms_url`.
|
||||
:ivar sms_method: The HTTP method we use to call `sms_url`. Can be: `GET` or `POST`.
|
||||
:ivar sms_status_callback: The URL we call using a POST method to send status information to your application about SMS messages that refer to the application.
|
||||
:ivar sms_url: The URL we call when the phone number receives an incoming SMS message.
|
||||
:ivar status_callback: The URL we call using the `status_callback_method` to send status information to your application.
|
||||
:ivar status_callback_method: The HTTP method we use to call `status_callback`. Can be: `GET` or `POST`.
|
||||
:ivar uri: The URI of the resource, relative to `https://api.twilio.com`.
|
||||
:ivar voice_caller_id_lookup: Whether we look up the caller's caller-ID name from the CNAM database (additional charges apply). Can be: `true` or `false`.
|
||||
:ivar voice_fallback_method: The HTTP method we use to call `voice_fallback_url`. Can be: `GET` or `POST`.
|
||||
:ivar voice_fallback_url: The URL that we call when an error occurs retrieving or executing the TwiML requested by `url`.
|
||||
:ivar voice_method: The HTTP method we use to call `voice_url`. Can be: `GET` or `POST`.
|
||||
:ivar voice_url: The URL we call when the phone number assigned to this application receives a call.
|
||||
:ivar public_application_connect_enabled: Whether to allow other Twilio accounts to dial this applicaton using Dial verb. Can be: `true` or `false`.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
account_sid: str,
|
||||
sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.api_version: Optional[str] = payload.get("api_version")
|
||||
self.date_created: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.friendly_name: Optional[str] = payload.get("friendly_name")
|
||||
self.message_status_callback: Optional[str] = payload.get(
|
||||
"message_status_callback"
|
||||
)
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.sms_fallback_method: Optional[str] = payload.get("sms_fallback_method")
|
||||
self.sms_fallback_url: Optional[str] = payload.get("sms_fallback_url")
|
||||
self.sms_method: Optional[str] = payload.get("sms_method")
|
||||
self.sms_status_callback: Optional[str] = payload.get("sms_status_callback")
|
||||
self.sms_url: Optional[str] = payload.get("sms_url")
|
||||
self.status_callback: Optional[str] = payload.get("status_callback")
|
||||
self.status_callback_method: Optional[str] = payload.get(
|
||||
"status_callback_method"
|
||||
)
|
||||
self.uri: Optional[str] = payload.get("uri")
|
||||
self.voice_caller_id_lookup: Optional[bool] = payload.get(
|
||||
"voice_caller_id_lookup"
|
||||
)
|
||||
self.voice_fallback_method: Optional[str] = payload.get("voice_fallback_method")
|
||||
self.voice_fallback_url: Optional[str] = payload.get("voice_fallback_url")
|
||||
self.voice_method: Optional[str] = payload.get("voice_method")
|
||||
self.voice_url: Optional[str] = payload.get("voice_url")
|
||||
self.public_application_connect_enabled: Optional[bool] = payload.get(
|
||||
"public_application_connect_enabled"
|
||||
)
|
||||
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[ApplicationContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "ApplicationContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: ApplicationContext for this ApplicationInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = ApplicationContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the ApplicationInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the ApplicationInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
def fetch(self) -> "ApplicationInstance":
|
||||
"""
|
||||
Fetch the ApplicationInstance
|
||||
|
||||
|
||||
:returns: The fetched ApplicationInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "ApplicationInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the ApplicationInstance
|
||||
|
||||
|
||||
:returns: The fetched ApplicationInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
api_version: Union[str, object] = values.unset,
|
||||
voice_url: Union[str, object] = values.unset,
|
||||
voice_method: Union[str, object] = values.unset,
|
||||
voice_fallback_url: Union[str, object] = values.unset,
|
||||
voice_fallback_method: Union[str, object] = values.unset,
|
||||
status_callback: Union[str, object] = values.unset,
|
||||
status_callback_method: Union[str, object] = values.unset,
|
||||
voice_caller_id_lookup: Union[bool, object] = values.unset,
|
||||
sms_url: Union[str, object] = values.unset,
|
||||
sms_method: Union[str, object] = values.unset,
|
||||
sms_fallback_url: Union[str, object] = values.unset,
|
||||
sms_fallback_method: Union[str, object] = values.unset,
|
||||
sms_status_callback: Union[str, object] = values.unset,
|
||||
message_status_callback: Union[str, object] = values.unset,
|
||||
public_application_connect_enabled: Union[bool, object] = values.unset,
|
||||
) -> "ApplicationInstance":
|
||||
"""
|
||||
Update the ApplicationInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long.
|
||||
:param api_version: The API version to use to start a new TwiML session. Can be: `2010-04-01` or `2008-08-01`. The default value is your account's default API version.
|
||||
:param voice_url: The URL we should call when the phone number assigned to this application receives a call.
|
||||
:param voice_method: The HTTP method we should use to call `voice_url`. Can be: `GET` or `POST`.
|
||||
:param voice_fallback_url: The URL that we should call when an error occurs retrieving or executing the TwiML requested by `url`.
|
||||
:param voice_fallback_method: The HTTP method we should use to call `voice_fallback_url`. Can be: `GET` or `POST`.
|
||||
:param status_callback: The URL we should call using the `status_callback_method` to send status information to your application.
|
||||
:param status_callback_method: The HTTP method we should use to call `status_callback`. Can be: `GET` or `POST`.
|
||||
:param voice_caller_id_lookup: Whether we should look up the caller's caller-ID name from the CNAM database (additional charges apply). Can be: `true` or `false`.
|
||||
:param sms_url: The URL we should call when the phone number receives an incoming SMS message.
|
||||
:param sms_method: The HTTP method we should use to call `sms_url`. Can be: `GET` or `POST`.
|
||||
:param sms_fallback_url: The URL that we should call when an error occurs while retrieving or executing the TwiML from `sms_url`.
|
||||
:param sms_fallback_method: The HTTP method we should use to call `sms_fallback_url`. Can be: `GET` or `POST`.
|
||||
:param sms_status_callback: Same as message_status_callback: The URL we should call using a POST method to send status information about SMS messages sent by the application. Deprecated, included for backwards compatibility.
|
||||
:param message_status_callback: The URL we should call using a POST method to send message status information to your application.
|
||||
:param public_application_connect_enabled: Whether to allow other Twilio accounts to dial this applicaton using Dial verb. Can be: `true` or `false`.
|
||||
|
||||
:returns: The updated ApplicationInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
friendly_name=friendly_name,
|
||||
api_version=api_version,
|
||||
voice_url=voice_url,
|
||||
voice_method=voice_method,
|
||||
voice_fallback_url=voice_fallback_url,
|
||||
voice_fallback_method=voice_fallback_method,
|
||||
status_callback=status_callback,
|
||||
status_callback_method=status_callback_method,
|
||||
voice_caller_id_lookup=voice_caller_id_lookup,
|
||||
sms_url=sms_url,
|
||||
sms_method=sms_method,
|
||||
sms_fallback_url=sms_fallback_url,
|
||||
sms_fallback_method=sms_fallback_method,
|
||||
sms_status_callback=sms_status_callback,
|
||||
message_status_callback=message_status_callback,
|
||||
public_application_connect_enabled=public_application_connect_enabled,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
api_version: Union[str, object] = values.unset,
|
||||
voice_url: Union[str, object] = values.unset,
|
||||
voice_method: Union[str, object] = values.unset,
|
||||
voice_fallback_url: Union[str, object] = values.unset,
|
||||
voice_fallback_method: Union[str, object] = values.unset,
|
||||
status_callback: Union[str, object] = values.unset,
|
||||
status_callback_method: Union[str, object] = values.unset,
|
||||
voice_caller_id_lookup: Union[bool, object] = values.unset,
|
||||
sms_url: Union[str, object] = values.unset,
|
||||
sms_method: Union[str, object] = values.unset,
|
||||
sms_fallback_url: Union[str, object] = values.unset,
|
||||
sms_fallback_method: Union[str, object] = values.unset,
|
||||
sms_status_callback: Union[str, object] = values.unset,
|
||||
message_status_callback: Union[str, object] = values.unset,
|
||||
public_application_connect_enabled: Union[bool, object] = values.unset,
|
||||
) -> "ApplicationInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the ApplicationInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long.
|
||||
:param api_version: The API version to use to start a new TwiML session. Can be: `2010-04-01` or `2008-08-01`. The default value is your account's default API version.
|
||||
:param voice_url: The URL we should call when the phone number assigned to this application receives a call.
|
||||
:param voice_method: The HTTP method we should use to call `voice_url`. Can be: `GET` or `POST`.
|
||||
:param voice_fallback_url: The URL that we should call when an error occurs retrieving or executing the TwiML requested by `url`.
|
||||
:param voice_fallback_method: The HTTP method we should use to call `voice_fallback_url`. Can be: `GET` or `POST`.
|
||||
:param status_callback: The URL we should call using the `status_callback_method` to send status information to your application.
|
||||
:param status_callback_method: The HTTP method we should use to call `status_callback`. Can be: `GET` or `POST`.
|
||||
:param voice_caller_id_lookup: Whether we should look up the caller's caller-ID name from the CNAM database (additional charges apply). Can be: `true` or `false`.
|
||||
:param sms_url: The URL we should call when the phone number receives an incoming SMS message.
|
||||
:param sms_method: The HTTP method we should use to call `sms_url`. Can be: `GET` or `POST`.
|
||||
:param sms_fallback_url: The URL that we should call when an error occurs while retrieving or executing the TwiML from `sms_url`.
|
||||
:param sms_fallback_method: The HTTP method we should use to call `sms_fallback_url`. Can be: `GET` or `POST`.
|
||||
:param sms_status_callback: Same as message_status_callback: The URL we should call using a POST method to send status information about SMS messages sent by the application. Deprecated, included for backwards compatibility.
|
||||
:param message_status_callback: The URL we should call using a POST method to send message status information to your application.
|
||||
:param public_application_connect_enabled: Whether to allow other Twilio accounts to dial this applicaton using Dial verb. Can be: `true` or `false`.
|
||||
|
||||
:returns: The updated ApplicationInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
friendly_name=friendly_name,
|
||||
api_version=api_version,
|
||||
voice_url=voice_url,
|
||||
voice_method=voice_method,
|
||||
voice_fallback_url=voice_fallback_url,
|
||||
voice_fallback_method=voice_fallback_method,
|
||||
status_callback=status_callback,
|
||||
status_callback_method=status_callback_method,
|
||||
voice_caller_id_lookup=voice_caller_id_lookup,
|
||||
sms_url=sms_url,
|
||||
sms_method=sms_method,
|
||||
sms_fallback_url=sms_fallback_url,
|
||||
sms_fallback_method=sms_fallback_method,
|
||||
sms_status_callback=sms_status_callback,
|
||||
message_status_callback=message_status_callback,
|
||||
public_application_connect_enabled=public_application_connect_enabled,
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.ApplicationInstance {}>".format(context)
|
||||
|
||||
|
||||
class ApplicationContext(InstanceContext):
|
||||
def __init__(self, version: Version, account_sid: str, sid: str):
|
||||
"""
|
||||
Initialize the ApplicationContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Application resources to update.
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Application resource to update.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/Applications/{sid}.json".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the ApplicationInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._version.delete(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the ApplicationInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
def fetch(self) -> ApplicationInstance:
|
||||
"""
|
||||
Fetch the ApplicationInstance
|
||||
|
||||
|
||||
:returns: The fetched ApplicationInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return ApplicationInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> ApplicationInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the ApplicationInstance
|
||||
|
||||
|
||||
:returns: The fetched ApplicationInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return ApplicationInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
api_version: Union[str, object] = values.unset,
|
||||
voice_url: Union[str, object] = values.unset,
|
||||
voice_method: Union[str, object] = values.unset,
|
||||
voice_fallback_url: Union[str, object] = values.unset,
|
||||
voice_fallback_method: Union[str, object] = values.unset,
|
||||
status_callback: Union[str, object] = values.unset,
|
||||
status_callback_method: Union[str, object] = values.unset,
|
||||
voice_caller_id_lookup: Union[bool, object] = values.unset,
|
||||
sms_url: Union[str, object] = values.unset,
|
||||
sms_method: Union[str, object] = values.unset,
|
||||
sms_fallback_url: Union[str, object] = values.unset,
|
||||
sms_fallback_method: Union[str, object] = values.unset,
|
||||
sms_status_callback: Union[str, object] = values.unset,
|
||||
message_status_callback: Union[str, object] = values.unset,
|
||||
public_application_connect_enabled: Union[bool, object] = values.unset,
|
||||
) -> ApplicationInstance:
|
||||
"""
|
||||
Update the ApplicationInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long.
|
||||
:param api_version: The API version to use to start a new TwiML session. Can be: `2010-04-01` or `2008-08-01`. The default value is your account's default API version.
|
||||
:param voice_url: The URL we should call when the phone number assigned to this application receives a call.
|
||||
:param voice_method: The HTTP method we should use to call `voice_url`. Can be: `GET` or `POST`.
|
||||
:param voice_fallback_url: The URL that we should call when an error occurs retrieving or executing the TwiML requested by `url`.
|
||||
:param voice_fallback_method: The HTTP method we should use to call `voice_fallback_url`. Can be: `GET` or `POST`.
|
||||
:param status_callback: The URL we should call using the `status_callback_method` to send status information to your application.
|
||||
:param status_callback_method: The HTTP method we should use to call `status_callback`. Can be: `GET` or `POST`.
|
||||
:param voice_caller_id_lookup: Whether we should look up the caller's caller-ID name from the CNAM database (additional charges apply). Can be: `true` or `false`.
|
||||
:param sms_url: The URL we should call when the phone number receives an incoming SMS message.
|
||||
:param sms_method: The HTTP method we should use to call `sms_url`. Can be: `GET` or `POST`.
|
||||
:param sms_fallback_url: The URL that we should call when an error occurs while retrieving or executing the TwiML from `sms_url`.
|
||||
:param sms_fallback_method: The HTTP method we should use to call `sms_fallback_url`. Can be: `GET` or `POST`.
|
||||
:param sms_status_callback: Same as message_status_callback: The URL we should call using a POST method to send status information about SMS messages sent by the application. Deprecated, included for backwards compatibility.
|
||||
:param message_status_callback: The URL we should call using a POST method to send message status information to your application.
|
||||
:param public_application_connect_enabled: Whether to allow other Twilio accounts to dial this applicaton using Dial verb. Can be: `true` or `false`.
|
||||
|
||||
:returns: The updated ApplicationInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"ApiVersion": api_version,
|
||||
"VoiceUrl": voice_url,
|
||||
"VoiceMethod": voice_method,
|
||||
"VoiceFallbackUrl": voice_fallback_url,
|
||||
"VoiceFallbackMethod": voice_fallback_method,
|
||||
"StatusCallback": status_callback,
|
||||
"StatusCallbackMethod": status_callback_method,
|
||||
"VoiceCallerIdLookup": voice_caller_id_lookup,
|
||||
"SmsUrl": sms_url,
|
||||
"SmsMethod": sms_method,
|
||||
"SmsFallbackUrl": sms_fallback_url,
|
||||
"SmsFallbackMethod": sms_fallback_method,
|
||||
"SmsStatusCallback": sms_status_callback,
|
||||
"MessageStatusCallback": message_status_callback,
|
||||
"PublicApplicationConnectEnabled": public_application_connect_enabled,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return ApplicationInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
api_version: Union[str, object] = values.unset,
|
||||
voice_url: Union[str, object] = values.unset,
|
||||
voice_method: Union[str, object] = values.unset,
|
||||
voice_fallback_url: Union[str, object] = values.unset,
|
||||
voice_fallback_method: Union[str, object] = values.unset,
|
||||
status_callback: Union[str, object] = values.unset,
|
||||
status_callback_method: Union[str, object] = values.unset,
|
||||
voice_caller_id_lookup: Union[bool, object] = values.unset,
|
||||
sms_url: Union[str, object] = values.unset,
|
||||
sms_method: Union[str, object] = values.unset,
|
||||
sms_fallback_url: Union[str, object] = values.unset,
|
||||
sms_fallback_method: Union[str, object] = values.unset,
|
||||
sms_status_callback: Union[str, object] = values.unset,
|
||||
message_status_callback: Union[str, object] = values.unset,
|
||||
public_application_connect_enabled: Union[bool, object] = values.unset,
|
||||
) -> ApplicationInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the ApplicationInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long.
|
||||
:param api_version: The API version to use to start a new TwiML session. Can be: `2010-04-01` or `2008-08-01`. The default value is your account's default API version.
|
||||
:param voice_url: The URL we should call when the phone number assigned to this application receives a call.
|
||||
:param voice_method: The HTTP method we should use to call `voice_url`. Can be: `GET` or `POST`.
|
||||
:param voice_fallback_url: The URL that we should call when an error occurs retrieving or executing the TwiML requested by `url`.
|
||||
:param voice_fallback_method: The HTTP method we should use to call `voice_fallback_url`. Can be: `GET` or `POST`.
|
||||
:param status_callback: The URL we should call using the `status_callback_method` to send status information to your application.
|
||||
:param status_callback_method: The HTTP method we should use to call `status_callback`. Can be: `GET` or `POST`.
|
||||
:param voice_caller_id_lookup: Whether we should look up the caller's caller-ID name from the CNAM database (additional charges apply). Can be: `true` or `false`.
|
||||
:param sms_url: The URL we should call when the phone number receives an incoming SMS message.
|
||||
:param sms_method: The HTTP method we should use to call `sms_url`. Can be: `GET` or `POST`.
|
||||
:param sms_fallback_url: The URL that we should call when an error occurs while retrieving or executing the TwiML from `sms_url`.
|
||||
:param sms_fallback_method: The HTTP method we should use to call `sms_fallback_url`. Can be: `GET` or `POST`.
|
||||
:param sms_status_callback: Same as message_status_callback: The URL we should call using a POST method to send status information about SMS messages sent by the application. Deprecated, included for backwards compatibility.
|
||||
:param message_status_callback: The URL we should call using a POST method to send message status information to your application.
|
||||
:param public_application_connect_enabled: Whether to allow other Twilio accounts to dial this applicaton using Dial verb. Can be: `true` or `false`.
|
||||
|
||||
:returns: The updated ApplicationInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"ApiVersion": api_version,
|
||||
"VoiceUrl": voice_url,
|
||||
"VoiceMethod": voice_method,
|
||||
"VoiceFallbackUrl": voice_fallback_url,
|
||||
"VoiceFallbackMethod": voice_fallback_method,
|
||||
"StatusCallback": status_callback,
|
||||
"StatusCallbackMethod": status_callback_method,
|
||||
"VoiceCallerIdLookup": voice_caller_id_lookup,
|
||||
"SmsUrl": sms_url,
|
||||
"SmsMethod": sms_method,
|
||||
"SmsFallbackUrl": sms_fallback_url,
|
||||
"SmsFallbackMethod": sms_fallback_method,
|
||||
"SmsStatusCallback": sms_status_callback,
|
||||
"MessageStatusCallback": message_status_callback,
|
||||
"PublicApplicationConnectEnabled": public_application_connect_enabled,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return ApplicationInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.ApplicationContext {}>".format(context)
|
||||
|
||||
|
||||
class ApplicationPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> ApplicationInstance:
|
||||
"""
|
||||
Build an instance of ApplicationInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return ApplicationInstance(
|
||||
self._version, payload, account_sid=self._solution["account_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.ApplicationPage>"
|
||||
|
||||
|
||||
class ApplicationList(ListResource):
|
||||
def __init__(self, version: Version, account_sid: str):
|
||||
"""
|
||||
Initialize the ApplicationList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Application resources to read.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/Applications.json".format(**self._solution)
|
||||
|
||||
def create(
|
||||
self,
|
||||
api_version: Union[str, object] = values.unset,
|
||||
voice_url: Union[str, object] = values.unset,
|
||||
voice_method: Union[str, object] = values.unset,
|
||||
voice_fallback_url: Union[str, object] = values.unset,
|
||||
voice_fallback_method: Union[str, object] = values.unset,
|
||||
status_callback: Union[str, object] = values.unset,
|
||||
status_callback_method: Union[str, object] = values.unset,
|
||||
voice_caller_id_lookup: Union[bool, object] = values.unset,
|
||||
sms_url: Union[str, object] = values.unset,
|
||||
sms_method: Union[str, object] = values.unset,
|
||||
sms_fallback_url: Union[str, object] = values.unset,
|
||||
sms_fallback_method: Union[str, object] = values.unset,
|
||||
sms_status_callback: Union[str, object] = values.unset,
|
||||
message_status_callback: Union[str, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
public_application_connect_enabled: Union[bool, object] = values.unset,
|
||||
) -> ApplicationInstance:
|
||||
"""
|
||||
Create the ApplicationInstance
|
||||
|
||||
:param api_version: The API version to use to start a new TwiML session. Can be: `2010-04-01` or `2008-08-01`. The default value is the account's default API version.
|
||||
:param voice_url: The URL we should call when the phone number assigned to this application receives a call.
|
||||
:param voice_method: The HTTP method we should use to call `voice_url`. Can be: `GET` or `POST`.
|
||||
:param voice_fallback_url: The URL that we should call when an error occurs retrieving or executing the TwiML requested by `url`.
|
||||
:param voice_fallback_method: The HTTP method we should use to call `voice_fallback_url`. Can be: `GET` or `POST`.
|
||||
:param status_callback: The URL we should call using the `status_callback_method` to send status information to your application.
|
||||
:param status_callback_method: The HTTP method we should use to call `status_callback`. Can be: `GET` or `POST`.
|
||||
:param voice_caller_id_lookup: Whether we should look up the caller's caller-ID name from the CNAM database (additional charges apply). Can be: `true` or `false`.
|
||||
:param sms_url: The URL we should call when the phone number receives an incoming SMS message.
|
||||
:param sms_method: The HTTP method we should use to call `sms_url`. Can be: `GET` or `POST`.
|
||||
:param sms_fallback_url: The URL that we should call when an error occurs while retrieving or executing the TwiML from `sms_url`.
|
||||
:param sms_fallback_method: The HTTP method we should use to call `sms_fallback_url`. Can be: `GET` or `POST`.
|
||||
:param sms_status_callback: The URL we should call using a POST method to send status information about SMS messages sent by the application.
|
||||
:param message_status_callback: The URL we should call using a POST method to send message status information to your application.
|
||||
:param friendly_name: A descriptive string that you create to describe the new application. It can be up to 64 characters long.
|
||||
:param public_application_connect_enabled: Whether to allow other Twilio accounts to dial this applicaton using Dial verb. Can be: `true` or `false`.
|
||||
|
||||
:returns: The created ApplicationInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"ApiVersion": api_version,
|
||||
"VoiceUrl": voice_url,
|
||||
"VoiceMethod": voice_method,
|
||||
"VoiceFallbackUrl": voice_fallback_url,
|
||||
"VoiceFallbackMethod": voice_fallback_method,
|
||||
"StatusCallback": status_callback,
|
||||
"StatusCallbackMethod": status_callback_method,
|
||||
"VoiceCallerIdLookup": voice_caller_id_lookup,
|
||||
"SmsUrl": sms_url,
|
||||
"SmsMethod": sms_method,
|
||||
"SmsFallbackUrl": sms_fallback_url,
|
||||
"SmsFallbackMethod": sms_fallback_method,
|
||||
"SmsStatusCallback": sms_status_callback,
|
||||
"MessageStatusCallback": message_status_callback,
|
||||
"FriendlyName": friendly_name,
|
||||
"PublicApplicationConnectEnabled": public_application_connect_enabled,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return ApplicationInstance(
|
||||
self._version, payload, account_sid=self._solution["account_sid"]
|
||||
)
|
||||
|
||||
async def create_async(
|
||||
self,
|
||||
api_version: Union[str, object] = values.unset,
|
||||
voice_url: Union[str, object] = values.unset,
|
||||
voice_method: Union[str, object] = values.unset,
|
||||
voice_fallback_url: Union[str, object] = values.unset,
|
||||
voice_fallback_method: Union[str, object] = values.unset,
|
||||
status_callback: Union[str, object] = values.unset,
|
||||
status_callback_method: Union[str, object] = values.unset,
|
||||
voice_caller_id_lookup: Union[bool, object] = values.unset,
|
||||
sms_url: Union[str, object] = values.unset,
|
||||
sms_method: Union[str, object] = values.unset,
|
||||
sms_fallback_url: Union[str, object] = values.unset,
|
||||
sms_fallback_method: Union[str, object] = values.unset,
|
||||
sms_status_callback: Union[str, object] = values.unset,
|
||||
message_status_callback: Union[str, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
public_application_connect_enabled: Union[bool, object] = values.unset,
|
||||
) -> ApplicationInstance:
|
||||
"""
|
||||
Asynchronously create the ApplicationInstance
|
||||
|
||||
:param api_version: The API version to use to start a new TwiML session. Can be: `2010-04-01` or `2008-08-01`. The default value is the account's default API version.
|
||||
:param voice_url: The URL we should call when the phone number assigned to this application receives a call.
|
||||
:param voice_method: The HTTP method we should use to call `voice_url`. Can be: `GET` or `POST`.
|
||||
:param voice_fallback_url: The URL that we should call when an error occurs retrieving or executing the TwiML requested by `url`.
|
||||
:param voice_fallback_method: The HTTP method we should use to call `voice_fallback_url`. Can be: `GET` or `POST`.
|
||||
:param status_callback: The URL we should call using the `status_callback_method` to send status information to your application.
|
||||
:param status_callback_method: The HTTP method we should use to call `status_callback`. Can be: `GET` or `POST`.
|
||||
:param voice_caller_id_lookup: Whether we should look up the caller's caller-ID name from the CNAM database (additional charges apply). Can be: `true` or `false`.
|
||||
:param sms_url: The URL we should call when the phone number receives an incoming SMS message.
|
||||
:param sms_method: The HTTP method we should use to call `sms_url`. Can be: `GET` or `POST`.
|
||||
:param sms_fallback_url: The URL that we should call when an error occurs while retrieving or executing the TwiML from `sms_url`.
|
||||
:param sms_fallback_method: The HTTP method we should use to call `sms_fallback_url`. Can be: `GET` or `POST`.
|
||||
:param sms_status_callback: The URL we should call using a POST method to send status information about SMS messages sent by the application.
|
||||
:param message_status_callback: The URL we should call using a POST method to send message status information to your application.
|
||||
:param friendly_name: A descriptive string that you create to describe the new application. It can be up to 64 characters long.
|
||||
:param public_application_connect_enabled: Whether to allow other Twilio accounts to dial this applicaton using Dial verb. Can be: `true` or `false`.
|
||||
|
||||
:returns: The created ApplicationInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"ApiVersion": api_version,
|
||||
"VoiceUrl": voice_url,
|
||||
"VoiceMethod": voice_method,
|
||||
"VoiceFallbackUrl": voice_fallback_url,
|
||||
"VoiceFallbackMethod": voice_fallback_method,
|
||||
"StatusCallback": status_callback,
|
||||
"StatusCallbackMethod": status_callback_method,
|
||||
"VoiceCallerIdLookup": voice_caller_id_lookup,
|
||||
"SmsUrl": sms_url,
|
||||
"SmsMethod": sms_method,
|
||||
"SmsFallbackUrl": sms_fallback_url,
|
||||
"SmsFallbackMethod": sms_fallback_method,
|
||||
"SmsStatusCallback": sms_status_callback,
|
||||
"MessageStatusCallback": message_status_callback,
|
||||
"FriendlyName": friendly_name,
|
||||
"PublicApplicationConnectEnabled": public_application_connect_enabled,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return ApplicationInstance(
|
||||
self._version, payload, account_sid=self._solution["account_sid"]
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[ApplicationInstance]:
|
||||
"""
|
||||
Streams ApplicationInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param str friendly_name: The string that identifies the Application resources to read.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(friendly_name=friendly_name, page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[ApplicationInstance]:
|
||||
"""
|
||||
Asynchronously streams ApplicationInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param str friendly_name: The string that identifies the Application resources to read.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(
|
||||
friendly_name=friendly_name, page_size=limits["page_size"]
|
||||
)
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[ApplicationInstance]:
|
||||
"""
|
||||
Lists ApplicationInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param str friendly_name: The string that identifies the Application resources to read.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return list(
|
||||
self.stream(
|
||||
friendly_name=friendly_name,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[ApplicationInstance]:
|
||||
"""
|
||||
Asynchronously lists ApplicationInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param str friendly_name: The string that identifies the Application resources to read.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return [
|
||||
record
|
||||
async for record in await self.stream_async(
|
||||
friendly_name=friendly_name,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> ApplicationPage:
|
||||
"""
|
||||
Retrieve a single page of ApplicationInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param friendly_name: The string that identifies the Application resources to read.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of ApplicationInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return ApplicationPage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> ApplicationPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of ApplicationInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param friendly_name: The string that identifies the Application resources to read.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of ApplicationInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return ApplicationPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> ApplicationPage:
|
||||
"""
|
||||
Retrieve a specific page of ApplicationInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of ApplicationInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return ApplicationPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> ApplicationPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of ApplicationInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of ApplicationInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return ApplicationPage(self._version, response, self._solution)
|
||||
|
||||
def get(self, sid: str) -> ApplicationContext:
|
||||
"""
|
||||
Constructs a ApplicationContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Application resource to update.
|
||||
"""
|
||||
return ApplicationContext(
|
||||
self._version, account_sid=self._solution["account_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> ApplicationContext:
|
||||
"""
|
||||
Constructs a ApplicationContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Application resource to update.
|
||||
"""
|
||||
return ApplicationContext(
|
||||
self._version, account_sid=self._solution["account_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.ApplicationList>"
|
||||
+450
@@ -0,0 +1,450 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, values
|
||||
from twilio.base.instance_context import InstanceContext
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.page import Page
|
||||
|
||||
|
||||
class AuthorizedConnectAppInstance(InstanceResource):
|
||||
class Permission(object):
|
||||
GET_ALL = "get-all"
|
||||
POST_ALL = "post-all"
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the AuthorizedConnectApp resource.
|
||||
:ivar connect_app_company_name: The company name set for the Connect App.
|
||||
:ivar connect_app_description: A detailed description of the Connect App.
|
||||
:ivar connect_app_friendly_name: The name of the Connect App.
|
||||
:ivar connect_app_homepage_url: The public URL for the Connect App.
|
||||
:ivar connect_app_sid: The SID that we assigned to the Connect App.
|
||||
:ivar date_created: The date and time in GMT that the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar date_updated: The date and time in GMT that the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar permissions: The set of permissions that you authorized for the Connect App. Can be: `get-all` or `post-all`.
|
||||
:ivar uri: The URI of the resource, relative to `https://api.twilio.com`.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
account_sid: str,
|
||||
connect_app_sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.connect_app_company_name: Optional[str] = payload.get(
|
||||
"connect_app_company_name"
|
||||
)
|
||||
self.connect_app_description: Optional[str] = payload.get(
|
||||
"connect_app_description"
|
||||
)
|
||||
self.connect_app_friendly_name: Optional[str] = payload.get(
|
||||
"connect_app_friendly_name"
|
||||
)
|
||||
self.connect_app_homepage_url: Optional[str] = payload.get(
|
||||
"connect_app_homepage_url"
|
||||
)
|
||||
self.connect_app_sid: Optional[str] = payload.get("connect_app_sid")
|
||||
self.date_created: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.permissions: Optional[
|
||||
List["AuthorizedConnectAppInstance.Permission"]
|
||||
] = payload.get("permissions")
|
||||
self.uri: Optional[str] = payload.get("uri")
|
||||
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"connect_app_sid": connect_app_sid or self.connect_app_sid,
|
||||
}
|
||||
self._context: Optional[AuthorizedConnectAppContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "AuthorizedConnectAppContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: AuthorizedConnectAppContext for this AuthorizedConnectAppInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = AuthorizedConnectAppContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
connect_app_sid=self._solution["connect_app_sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def fetch(self) -> "AuthorizedConnectAppInstance":
|
||||
"""
|
||||
Fetch the AuthorizedConnectAppInstance
|
||||
|
||||
|
||||
:returns: The fetched AuthorizedConnectAppInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "AuthorizedConnectAppInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the AuthorizedConnectAppInstance
|
||||
|
||||
|
||||
:returns: The fetched AuthorizedConnectAppInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.AuthorizedConnectAppInstance {}>".format(context)
|
||||
|
||||
|
||||
class AuthorizedConnectAppContext(InstanceContext):
|
||||
def __init__(self, version: Version, account_sid: str, connect_app_sid: str):
|
||||
"""
|
||||
Initialize the AuthorizedConnectAppContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the AuthorizedConnectApp resource to fetch.
|
||||
:param connect_app_sid: The SID of the Connect App to fetch.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"connect_app_sid": connect_app_sid,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/AuthorizedConnectApps/{connect_app_sid}.json".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def fetch(self) -> AuthorizedConnectAppInstance:
|
||||
"""
|
||||
Fetch the AuthorizedConnectAppInstance
|
||||
|
||||
|
||||
:returns: The fetched AuthorizedConnectAppInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return AuthorizedConnectAppInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
connect_app_sid=self._solution["connect_app_sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> AuthorizedConnectAppInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the AuthorizedConnectAppInstance
|
||||
|
||||
|
||||
:returns: The fetched AuthorizedConnectAppInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return AuthorizedConnectAppInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
connect_app_sid=self._solution["connect_app_sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.AuthorizedConnectAppContext {}>".format(context)
|
||||
|
||||
|
||||
class AuthorizedConnectAppPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> AuthorizedConnectAppInstance:
|
||||
"""
|
||||
Build an instance of AuthorizedConnectAppInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return AuthorizedConnectAppInstance(
|
||||
self._version, payload, account_sid=self._solution["account_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.AuthorizedConnectAppPage>"
|
||||
|
||||
|
||||
class AuthorizedConnectAppList(ListResource):
|
||||
def __init__(self, version: Version, account_sid: str):
|
||||
"""
|
||||
Initialize the AuthorizedConnectAppList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the AuthorizedConnectApp resources to read.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/AuthorizedConnectApps.json".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[AuthorizedConnectAppInstance]:
|
||||
"""
|
||||
Streams AuthorizedConnectAppInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[AuthorizedConnectAppInstance]:
|
||||
"""
|
||||
Asynchronously streams AuthorizedConnectAppInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[AuthorizedConnectAppInstance]:
|
||||
"""
|
||||
Lists AuthorizedConnectAppInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return list(
|
||||
self.stream(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[AuthorizedConnectAppInstance]:
|
||||
"""
|
||||
Asynchronously lists AuthorizedConnectAppInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return [
|
||||
record
|
||||
async for record in await self.stream_async(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> AuthorizedConnectAppPage:
|
||||
"""
|
||||
Retrieve a single page of AuthorizedConnectAppInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of AuthorizedConnectAppInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return AuthorizedConnectAppPage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> AuthorizedConnectAppPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of AuthorizedConnectAppInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of AuthorizedConnectAppInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return AuthorizedConnectAppPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> AuthorizedConnectAppPage:
|
||||
"""
|
||||
Retrieve a specific page of AuthorizedConnectAppInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of AuthorizedConnectAppInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return AuthorizedConnectAppPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> AuthorizedConnectAppPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of AuthorizedConnectAppInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of AuthorizedConnectAppInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return AuthorizedConnectAppPage(self._version, response, self._solution)
|
||||
|
||||
def get(self, connect_app_sid: str) -> AuthorizedConnectAppContext:
|
||||
"""
|
||||
Constructs a AuthorizedConnectAppContext
|
||||
|
||||
:param connect_app_sid: The SID of the Connect App to fetch.
|
||||
"""
|
||||
return AuthorizedConnectAppContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
connect_app_sid=connect_app_sid,
|
||||
)
|
||||
|
||||
def __call__(self, connect_app_sid: str) -> AuthorizedConnectAppContext:
|
||||
"""
|
||||
Constructs a AuthorizedConnectAppContext
|
||||
|
||||
:param connect_app_sid: The SID of the Connect App to fetch.
|
||||
"""
|
||||
return AuthorizedConnectAppContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
connect_app_sid=connect_app_sid,
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.AuthorizedConnectAppList>"
|
||||
+597
@@ -0,0 +1,597 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import values
|
||||
from twilio.base.instance_context import InstanceContext
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.page import Page
|
||||
from twilio.rest.api.v2010.account.available_phone_number_country.local import LocalList
|
||||
from twilio.rest.api.v2010.account.available_phone_number_country.machine_to_machine import (
|
||||
MachineToMachineList,
|
||||
)
|
||||
from twilio.rest.api.v2010.account.available_phone_number_country.mobile import (
|
||||
MobileList,
|
||||
)
|
||||
from twilio.rest.api.v2010.account.available_phone_number_country.national import (
|
||||
NationalList,
|
||||
)
|
||||
from twilio.rest.api.v2010.account.available_phone_number_country.shared_cost import (
|
||||
SharedCostList,
|
||||
)
|
||||
from twilio.rest.api.v2010.account.available_phone_number_country.toll_free import (
|
||||
TollFreeList,
|
||||
)
|
||||
from twilio.rest.api.v2010.account.available_phone_number_country.voip import VoipList
|
||||
|
||||
|
||||
class AvailablePhoneNumberCountryInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar country_code: The [ISO-3166-1](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code of the country.
|
||||
:ivar country: The name of the country.
|
||||
:ivar uri: The URI of the Country resource, relative to `https://api.twilio.com`.
|
||||
:ivar beta: Whether all phone numbers available in the country are new to the Twilio platform. `true` if they are and `false` if all numbers are not in the Twilio Phone Number Beta program.
|
||||
:ivar subresource_uris: A list of related AvailablePhoneNumber resources identified by their URIs relative to `https://api.twilio.com`.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
account_sid: str,
|
||||
country_code: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.country_code: Optional[str] = payload.get("country_code")
|
||||
self.country: Optional[str] = payload.get("country")
|
||||
self.uri: Optional[str] = payload.get("uri")
|
||||
self.beta: Optional[bool] = payload.get("beta")
|
||||
self.subresource_uris: Optional[Dict[str, object]] = payload.get(
|
||||
"subresource_uris"
|
||||
)
|
||||
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"country_code": country_code or self.country_code,
|
||||
}
|
||||
self._context: Optional[AvailablePhoneNumberCountryContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "AvailablePhoneNumberCountryContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: AvailablePhoneNumberCountryContext for this AvailablePhoneNumberCountryInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = AvailablePhoneNumberCountryContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
country_code=self._solution["country_code"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def fetch(self) -> "AvailablePhoneNumberCountryInstance":
|
||||
"""
|
||||
Fetch the AvailablePhoneNumberCountryInstance
|
||||
|
||||
|
||||
:returns: The fetched AvailablePhoneNumberCountryInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "AvailablePhoneNumberCountryInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the AvailablePhoneNumberCountryInstance
|
||||
|
||||
|
||||
:returns: The fetched AvailablePhoneNumberCountryInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
@property
|
||||
def local(self) -> LocalList:
|
||||
"""
|
||||
Access the local
|
||||
"""
|
||||
return self._proxy.local
|
||||
|
||||
@property
|
||||
def machine_to_machine(self) -> MachineToMachineList:
|
||||
"""
|
||||
Access the machine_to_machine
|
||||
"""
|
||||
return self._proxy.machine_to_machine
|
||||
|
||||
@property
|
||||
def mobile(self) -> MobileList:
|
||||
"""
|
||||
Access the mobile
|
||||
"""
|
||||
return self._proxy.mobile
|
||||
|
||||
@property
|
||||
def national(self) -> NationalList:
|
||||
"""
|
||||
Access the national
|
||||
"""
|
||||
return self._proxy.national
|
||||
|
||||
@property
|
||||
def shared_cost(self) -> SharedCostList:
|
||||
"""
|
||||
Access the shared_cost
|
||||
"""
|
||||
return self._proxy.shared_cost
|
||||
|
||||
@property
|
||||
def toll_free(self) -> TollFreeList:
|
||||
"""
|
||||
Access the toll_free
|
||||
"""
|
||||
return self._proxy.toll_free
|
||||
|
||||
@property
|
||||
def voip(self) -> VoipList:
|
||||
"""
|
||||
Access the voip
|
||||
"""
|
||||
return self._proxy.voip
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.AvailablePhoneNumberCountryInstance {}>".format(
|
||||
context
|
||||
)
|
||||
|
||||
|
||||
class AvailablePhoneNumberCountryContext(InstanceContext):
|
||||
def __init__(self, version: Version, account_sid: str, country_code: str):
|
||||
"""
|
||||
Initialize the AvailablePhoneNumberCountryContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) requesting the available phone number Country resource.
|
||||
:param country_code: The [ISO-3166-1](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code of the country to fetch available phone number information about.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"country_code": country_code,
|
||||
}
|
||||
self._uri = (
|
||||
"/Accounts/{account_sid}/AvailablePhoneNumbers/{country_code}.json".format(
|
||||
**self._solution
|
||||
)
|
||||
)
|
||||
|
||||
self._local: Optional[LocalList] = None
|
||||
self._machine_to_machine: Optional[MachineToMachineList] = None
|
||||
self._mobile: Optional[MobileList] = None
|
||||
self._national: Optional[NationalList] = None
|
||||
self._shared_cost: Optional[SharedCostList] = None
|
||||
self._toll_free: Optional[TollFreeList] = None
|
||||
self._voip: Optional[VoipList] = None
|
||||
|
||||
def fetch(self) -> AvailablePhoneNumberCountryInstance:
|
||||
"""
|
||||
Fetch the AvailablePhoneNumberCountryInstance
|
||||
|
||||
|
||||
:returns: The fetched AvailablePhoneNumberCountryInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return AvailablePhoneNumberCountryInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
country_code=self._solution["country_code"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> AvailablePhoneNumberCountryInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the AvailablePhoneNumberCountryInstance
|
||||
|
||||
|
||||
:returns: The fetched AvailablePhoneNumberCountryInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return AvailablePhoneNumberCountryInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
country_code=self._solution["country_code"],
|
||||
)
|
||||
|
||||
@property
|
||||
def local(self) -> LocalList:
|
||||
"""
|
||||
Access the local
|
||||
"""
|
||||
if self._local is None:
|
||||
self._local = LocalList(
|
||||
self._version,
|
||||
self._solution["account_sid"],
|
||||
self._solution["country_code"],
|
||||
)
|
||||
return self._local
|
||||
|
||||
@property
|
||||
def machine_to_machine(self) -> MachineToMachineList:
|
||||
"""
|
||||
Access the machine_to_machine
|
||||
"""
|
||||
if self._machine_to_machine is None:
|
||||
self._machine_to_machine = MachineToMachineList(
|
||||
self._version,
|
||||
self._solution["account_sid"],
|
||||
self._solution["country_code"],
|
||||
)
|
||||
return self._machine_to_machine
|
||||
|
||||
@property
|
||||
def mobile(self) -> MobileList:
|
||||
"""
|
||||
Access the mobile
|
||||
"""
|
||||
if self._mobile is None:
|
||||
self._mobile = MobileList(
|
||||
self._version,
|
||||
self._solution["account_sid"],
|
||||
self._solution["country_code"],
|
||||
)
|
||||
return self._mobile
|
||||
|
||||
@property
|
||||
def national(self) -> NationalList:
|
||||
"""
|
||||
Access the national
|
||||
"""
|
||||
if self._national is None:
|
||||
self._national = NationalList(
|
||||
self._version,
|
||||
self._solution["account_sid"],
|
||||
self._solution["country_code"],
|
||||
)
|
||||
return self._national
|
||||
|
||||
@property
|
||||
def shared_cost(self) -> SharedCostList:
|
||||
"""
|
||||
Access the shared_cost
|
||||
"""
|
||||
if self._shared_cost is None:
|
||||
self._shared_cost = SharedCostList(
|
||||
self._version,
|
||||
self._solution["account_sid"],
|
||||
self._solution["country_code"],
|
||||
)
|
||||
return self._shared_cost
|
||||
|
||||
@property
|
||||
def toll_free(self) -> TollFreeList:
|
||||
"""
|
||||
Access the toll_free
|
||||
"""
|
||||
if self._toll_free is None:
|
||||
self._toll_free = TollFreeList(
|
||||
self._version,
|
||||
self._solution["account_sid"],
|
||||
self._solution["country_code"],
|
||||
)
|
||||
return self._toll_free
|
||||
|
||||
@property
|
||||
def voip(self) -> VoipList:
|
||||
"""
|
||||
Access the voip
|
||||
"""
|
||||
if self._voip is None:
|
||||
self._voip = VoipList(
|
||||
self._version,
|
||||
self._solution["account_sid"],
|
||||
self._solution["country_code"],
|
||||
)
|
||||
return self._voip
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.AvailablePhoneNumberCountryContext {}>".format(
|
||||
context
|
||||
)
|
||||
|
||||
|
||||
class AvailablePhoneNumberCountryPage(Page):
|
||||
def get_instance(
|
||||
self, payload: Dict[str, Any]
|
||||
) -> AvailablePhoneNumberCountryInstance:
|
||||
"""
|
||||
Build an instance of AvailablePhoneNumberCountryInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return AvailablePhoneNumberCountryInstance(
|
||||
self._version, payload, account_sid=self._solution["account_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.AvailablePhoneNumberCountryPage>"
|
||||
|
||||
|
||||
class AvailablePhoneNumberCountryList(ListResource):
|
||||
def __init__(self, version: Version, account_sid: str):
|
||||
"""
|
||||
Initialize the AvailablePhoneNumberCountryList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) requesting the available phone number Country resources.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/AvailablePhoneNumbers.json".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[AvailablePhoneNumberCountryInstance]:
|
||||
"""
|
||||
Streams AvailablePhoneNumberCountryInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[AvailablePhoneNumberCountryInstance]:
|
||||
"""
|
||||
Asynchronously streams AvailablePhoneNumberCountryInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[AvailablePhoneNumberCountryInstance]:
|
||||
"""
|
||||
Lists AvailablePhoneNumberCountryInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return list(
|
||||
self.stream(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[AvailablePhoneNumberCountryInstance]:
|
||||
"""
|
||||
Asynchronously lists AvailablePhoneNumberCountryInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return [
|
||||
record
|
||||
async for record in await self.stream_async(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> AvailablePhoneNumberCountryPage:
|
||||
"""
|
||||
Retrieve a single page of AvailablePhoneNumberCountryInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of AvailablePhoneNumberCountryInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return AvailablePhoneNumberCountryPage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> AvailablePhoneNumberCountryPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of AvailablePhoneNumberCountryInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of AvailablePhoneNumberCountryInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return AvailablePhoneNumberCountryPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> AvailablePhoneNumberCountryPage:
|
||||
"""
|
||||
Retrieve a specific page of AvailablePhoneNumberCountryInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of AvailablePhoneNumberCountryInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return AvailablePhoneNumberCountryPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> AvailablePhoneNumberCountryPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of AvailablePhoneNumberCountryInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of AvailablePhoneNumberCountryInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return AvailablePhoneNumberCountryPage(self._version, response, self._solution)
|
||||
|
||||
def get(self, country_code: str) -> AvailablePhoneNumberCountryContext:
|
||||
"""
|
||||
Constructs a AvailablePhoneNumberCountryContext
|
||||
|
||||
:param country_code: The [ISO-3166-1](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code of the country to fetch available phone number information about.
|
||||
"""
|
||||
return AvailablePhoneNumberCountryContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
country_code=country_code,
|
||||
)
|
||||
|
||||
def __call__(self, country_code: str) -> AvailablePhoneNumberCountryContext:
|
||||
"""
|
||||
Constructs a AvailablePhoneNumberCountryContext
|
||||
|
||||
:param country_code: The [ISO-3166-1](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code of the country to fetch available phone number information about.
|
||||
"""
|
||||
return AvailablePhoneNumberCountryContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
country_code=country_code,
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.AvailablePhoneNumberCountryList>"
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
+642
@@ -0,0 +1,642 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, values
|
||||
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.page import Page
|
||||
|
||||
|
||||
class LocalInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar friendly_name: A formatted version of the phone number.
|
||||
:ivar phone_number: The phone number in [E.164](https://www.twilio.com/docs/glossary/what-e164) format, which consists of a + followed by the country code and subscriber number.
|
||||
:ivar lata: The [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) of this phone number. Available for only phone numbers from the US and Canada.
|
||||
:ivar locality: The locality or city of this phone number's location.
|
||||
:ivar rate_center: The [rate center](https://en.wikipedia.org/wiki/Telephone_exchange) of this phone number. Available for only phone numbers from the US and Canada.
|
||||
:ivar latitude: The latitude of this phone number's location. Available for only phone numbers from the US and Canada.
|
||||
:ivar longitude: The longitude of this phone number's location. Available for only phone numbers from the US and Canada.
|
||||
:ivar region: The two-letter state or province abbreviation of this phone number's location. Available for only phone numbers from the US and Canada.
|
||||
:ivar postal_code: The postal or ZIP code of this phone number's location. Available for only phone numbers from the US and Canada.
|
||||
:ivar iso_country: The [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of this phone number.
|
||||
:ivar address_requirements: The type of [Address](https://www.twilio.com/docs/usage/api/address) resource the phone number requires. Can be: `none`, `any`, `local`, or `foreign`. `none` means no address is required. `any` means an address is required, but it can be anywhere in the world. `local` means an address in the phone number's country is required. `foreign` means an address outside of the phone number's country is required.
|
||||
:ivar beta: Whether the phone number is new to the Twilio platform. Can be: `true` or `false`.
|
||||
:ivar capabilities:
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
account_sid: str,
|
||||
country_code: str,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.friendly_name: Optional[str] = payload.get("friendly_name")
|
||||
self.phone_number: Optional[str] = payload.get("phone_number")
|
||||
self.lata: Optional[str] = payload.get("lata")
|
||||
self.locality: Optional[str] = payload.get("locality")
|
||||
self.rate_center: Optional[str] = payload.get("rate_center")
|
||||
self.latitude: Optional[float] = deserialize.decimal(payload.get("latitude"))
|
||||
self.longitude: Optional[float] = deserialize.decimal(payload.get("longitude"))
|
||||
self.region: Optional[str] = payload.get("region")
|
||||
self.postal_code: Optional[str] = payload.get("postal_code")
|
||||
self.iso_country: Optional[str] = payload.get("iso_country")
|
||||
self.address_requirements: Optional[str] = payload.get("address_requirements")
|
||||
self.beta: Optional[bool] = payload.get("beta")
|
||||
self.capabilities: Optional[str] = payload.get("capabilities")
|
||||
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"country_code": country_code,
|
||||
}
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.LocalInstance {}>".format(context)
|
||||
|
||||
|
||||
class LocalPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> LocalInstance:
|
||||
"""
|
||||
Build an instance of LocalInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return LocalInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
country_code=self._solution["country_code"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.LocalPage>"
|
||||
|
||||
|
||||
class LocalList(ListResource):
|
||||
def __init__(self, version: Version, account_sid: str, country_code: str):
|
||||
"""
|
||||
Initialize the LocalList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) requesting the AvailablePhoneNumber resources.
|
||||
:param country_code: The [ISO-3166-1](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code of the country from which to read phone numbers.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"country_code": country_code,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/AvailablePhoneNumbers/{country_code}/Local.json".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[LocalInstance]:
|
||||
"""
|
||||
Streams LocalInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param int area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param str contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumberlocal-resource?code-sample=code-find-phone-numbers-by-number-pattern) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumberlocal-resource?code-sample=code-find-phone-numbers-by-character-pattern). If specified, this value must have at least two characters.
|
||||
:param bool sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param bool mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param bool voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param bool exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param str near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param int distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param bool fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(
|
||||
area_code=area_code,
|
||||
contains=contains,
|
||||
sms_enabled=sms_enabled,
|
||||
mms_enabled=mms_enabled,
|
||||
voice_enabled=voice_enabled,
|
||||
exclude_all_address_required=exclude_all_address_required,
|
||||
exclude_local_address_required=exclude_local_address_required,
|
||||
exclude_foreign_address_required=exclude_foreign_address_required,
|
||||
beta=beta,
|
||||
near_number=near_number,
|
||||
near_lat_long=near_lat_long,
|
||||
distance=distance,
|
||||
in_postal_code=in_postal_code,
|
||||
in_region=in_region,
|
||||
in_rate_center=in_rate_center,
|
||||
in_lata=in_lata,
|
||||
in_locality=in_locality,
|
||||
fax_enabled=fax_enabled,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[LocalInstance]:
|
||||
"""
|
||||
Asynchronously streams LocalInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param int area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param str contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumberlocal-resource?code-sample=code-find-phone-numbers-by-number-pattern) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumberlocal-resource?code-sample=code-find-phone-numbers-by-character-pattern). If specified, this value must have at least two characters.
|
||||
:param bool sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param bool mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param bool voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param bool exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param str near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param int distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param bool fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(
|
||||
area_code=area_code,
|
||||
contains=contains,
|
||||
sms_enabled=sms_enabled,
|
||||
mms_enabled=mms_enabled,
|
||||
voice_enabled=voice_enabled,
|
||||
exclude_all_address_required=exclude_all_address_required,
|
||||
exclude_local_address_required=exclude_local_address_required,
|
||||
exclude_foreign_address_required=exclude_foreign_address_required,
|
||||
beta=beta,
|
||||
near_number=near_number,
|
||||
near_lat_long=near_lat_long,
|
||||
distance=distance,
|
||||
in_postal_code=in_postal_code,
|
||||
in_region=in_region,
|
||||
in_rate_center=in_rate_center,
|
||||
in_lata=in_lata,
|
||||
in_locality=in_locality,
|
||||
fax_enabled=fax_enabled,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[LocalInstance]:
|
||||
"""
|
||||
Lists LocalInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param int area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param str contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumberlocal-resource?code-sample=code-find-phone-numbers-by-number-pattern) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumberlocal-resource?code-sample=code-find-phone-numbers-by-character-pattern). If specified, this value must have at least two characters.
|
||||
:param bool sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param bool mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param bool voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param bool exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param str near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param int distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param bool fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return list(
|
||||
self.stream(
|
||||
area_code=area_code,
|
||||
contains=contains,
|
||||
sms_enabled=sms_enabled,
|
||||
mms_enabled=mms_enabled,
|
||||
voice_enabled=voice_enabled,
|
||||
exclude_all_address_required=exclude_all_address_required,
|
||||
exclude_local_address_required=exclude_local_address_required,
|
||||
exclude_foreign_address_required=exclude_foreign_address_required,
|
||||
beta=beta,
|
||||
near_number=near_number,
|
||||
near_lat_long=near_lat_long,
|
||||
distance=distance,
|
||||
in_postal_code=in_postal_code,
|
||||
in_region=in_region,
|
||||
in_rate_center=in_rate_center,
|
||||
in_lata=in_lata,
|
||||
in_locality=in_locality,
|
||||
fax_enabled=fax_enabled,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[LocalInstance]:
|
||||
"""
|
||||
Asynchronously lists LocalInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param int area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param str contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumberlocal-resource?code-sample=code-find-phone-numbers-by-number-pattern) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumberlocal-resource?code-sample=code-find-phone-numbers-by-character-pattern). If specified, this value must have at least two characters.
|
||||
:param bool sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param bool mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param bool voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param bool exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param str near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param int distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param bool fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return [
|
||||
record
|
||||
async for record in await self.stream_async(
|
||||
area_code=area_code,
|
||||
contains=contains,
|
||||
sms_enabled=sms_enabled,
|
||||
mms_enabled=mms_enabled,
|
||||
voice_enabled=voice_enabled,
|
||||
exclude_all_address_required=exclude_all_address_required,
|
||||
exclude_local_address_required=exclude_local_address_required,
|
||||
exclude_foreign_address_required=exclude_foreign_address_required,
|
||||
beta=beta,
|
||||
near_number=near_number,
|
||||
near_lat_long=near_lat_long,
|
||||
distance=distance,
|
||||
in_postal_code=in_postal_code,
|
||||
in_region=in_region,
|
||||
in_rate_center=in_rate_center,
|
||||
in_lata=in_lata,
|
||||
in_locality=in_locality,
|
||||
fax_enabled=fax_enabled,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> LocalPage:
|
||||
"""
|
||||
Retrieve a single page of LocalInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumberlocal-resource?code-sample=code-find-phone-numbers-by-number-pattern) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumberlocal-resource?code-sample=code-find-phone-numbers-by-character-pattern). If specified, this value must have at least two characters.
|
||||
:param sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of LocalInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"AreaCode": area_code,
|
||||
"Contains": contains,
|
||||
"SmsEnabled": sms_enabled,
|
||||
"MmsEnabled": mms_enabled,
|
||||
"VoiceEnabled": voice_enabled,
|
||||
"ExcludeAllAddressRequired": exclude_all_address_required,
|
||||
"ExcludeLocalAddressRequired": exclude_local_address_required,
|
||||
"ExcludeForeignAddressRequired": exclude_foreign_address_required,
|
||||
"Beta": beta,
|
||||
"NearNumber": near_number,
|
||||
"NearLatLong": near_lat_long,
|
||||
"Distance": distance,
|
||||
"InPostalCode": in_postal_code,
|
||||
"InRegion": in_region,
|
||||
"InRateCenter": in_rate_center,
|
||||
"InLata": in_lata,
|
||||
"InLocality": in_locality,
|
||||
"FaxEnabled": fax_enabled,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return LocalPage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> LocalPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of LocalInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumberlocal-resource?code-sample=code-find-phone-numbers-by-number-pattern) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumberlocal-resource?code-sample=code-find-phone-numbers-by-character-pattern). If specified, this value must have at least two characters.
|
||||
:param sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of LocalInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"AreaCode": area_code,
|
||||
"Contains": contains,
|
||||
"SmsEnabled": sms_enabled,
|
||||
"MmsEnabled": mms_enabled,
|
||||
"VoiceEnabled": voice_enabled,
|
||||
"ExcludeAllAddressRequired": exclude_all_address_required,
|
||||
"ExcludeLocalAddressRequired": exclude_local_address_required,
|
||||
"ExcludeForeignAddressRequired": exclude_foreign_address_required,
|
||||
"Beta": beta,
|
||||
"NearNumber": near_number,
|
||||
"NearLatLong": near_lat_long,
|
||||
"Distance": distance,
|
||||
"InPostalCode": in_postal_code,
|
||||
"InRegion": in_region,
|
||||
"InRateCenter": in_rate_center,
|
||||
"InLata": in_lata,
|
||||
"InLocality": in_locality,
|
||||
"FaxEnabled": fax_enabled,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return LocalPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> LocalPage:
|
||||
"""
|
||||
Retrieve a specific page of LocalInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of LocalInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return LocalPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> LocalPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of LocalInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of LocalInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return LocalPage(self._version, response, self._solution)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.LocalList>"
|
||||
+642
@@ -0,0 +1,642 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, values
|
||||
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.page import Page
|
||||
|
||||
|
||||
class MachineToMachineInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar friendly_name: A formatted version of the phone number.
|
||||
:ivar phone_number: The phone number in [E.164](https://www.twilio.com/docs/glossary/what-e164) format, which consists of a + followed by the country code and subscriber number.
|
||||
:ivar lata: The [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) of this phone number. Available for only phone numbers from the US and Canada.
|
||||
:ivar locality: The locality or city of this phone number's location.
|
||||
:ivar rate_center: The [rate center](https://en.wikipedia.org/wiki/Telephone_exchange) of this phone number. Available for only phone numbers from the US and Canada.
|
||||
:ivar latitude: The latitude of this phone number's location. Available for only phone numbers from the US and Canada.
|
||||
:ivar longitude: The longitude of this phone number's location. Available for only phone numbers from the US and Canada.
|
||||
:ivar region: The two-letter state or province abbreviation of this phone number's location. Available for only phone numbers from the US and Canada.
|
||||
:ivar postal_code: The postal or ZIP code of this phone number's location. Available for only phone numbers from the US and Canada.
|
||||
:ivar iso_country: The [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of this phone number.
|
||||
:ivar address_requirements: The type of [Address](https://www.twilio.com/docs/usage/api/address) resource the phone number requires. Can be: `none`, `any`, `local`, or `foreign`. `none` means no address is required. `any` means an address is required, but it can be anywhere in the world. `local` means an address in the phone number's country is required. `foreign` means an address outside of the phone number's country is required.
|
||||
:ivar beta: Whether the phone number is new to the Twilio platform. Can be: `true` or `false`.
|
||||
:ivar capabilities:
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
account_sid: str,
|
||||
country_code: str,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.friendly_name: Optional[str] = payload.get("friendly_name")
|
||||
self.phone_number: Optional[str] = payload.get("phone_number")
|
||||
self.lata: Optional[str] = payload.get("lata")
|
||||
self.locality: Optional[str] = payload.get("locality")
|
||||
self.rate_center: Optional[str] = payload.get("rate_center")
|
||||
self.latitude: Optional[float] = deserialize.decimal(payload.get("latitude"))
|
||||
self.longitude: Optional[float] = deserialize.decimal(payload.get("longitude"))
|
||||
self.region: Optional[str] = payload.get("region")
|
||||
self.postal_code: Optional[str] = payload.get("postal_code")
|
||||
self.iso_country: Optional[str] = payload.get("iso_country")
|
||||
self.address_requirements: Optional[str] = payload.get("address_requirements")
|
||||
self.beta: Optional[bool] = payload.get("beta")
|
||||
self.capabilities: Optional[str] = payload.get("capabilities")
|
||||
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"country_code": country_code,
|
||||
}
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.MachineToMachineInstance {}>".format(context)
|
||||
|
||||
|
||||
class MachineToMachinePage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> MachineToMachineInstance:
|
||||
"""
|
||||
Build an instance of MachineToMachineInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return MachineToMachineInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
country_code=self._solution["country_code"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.MachineToMachinePage>"
|
||||
|
||||
|
||||
class MachineToMachineList(ListResource):
|
||||
def __init__(self, version: Version, account_sid: str, country_code: str):
|
||||
"""
|
||||
Initialize the MachineToMachineList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) requesting the AvailablePhoneNumber resources.
|
||||
:param country_code: The [ISO-3166-1](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code of the country from which to read phone numbers.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"country_code": country_code,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/AvailablePhoneNumbers/{country_code}/MachineToMachine.json".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[MachineToMachineInstance]:
|
||||
"""
|
||||
Streams MachineToMachineInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param int area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param str contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param bool sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param bool mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param bool voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param bool exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param str near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param int distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param bool fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(
|
||||
area_code=area_code,
|
||||
contains=contains,
|
||||
sms_enabled=sms_enabled,
|
||||
mms_enabled=mms_enabled,
|
||||
voice_enabled=voice_enabled,
|
||||
exclude_all_address_required=exclude_all_address_required,
|
||||
exclude_local_address_required=exclude_local_address_required,
|
||||
exclude_foreign_address_required=exclude_foreign_address_required,
|
||||
beta=beta,
|
||||
near_number=near_number,
|
||||
near_lat_long=near_lat_long,
|
||||
distance=distance,
|
||||
in_postal_code=in_postal_code,
|
||||
in_region=in_region,
|
||||
in_rate_center=in_rate_center,
|
||||
in_lata=in_lata,
|
||||
in_locality=in_locality,
|
||||
fax_enabled=fax_enabled,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[MachineToMachineInstance]:
|
||||
"""
|
||||
Asynchronously streams MachineToMachineInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param int area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param str contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param bool sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param bool mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param bool voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param bool exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param str near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param int distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param bool fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(
|
||||
area_code=area_code,
|
||||
contains=contains,
|
||||
sms_enabled=sms_enabled,
|
||||
mms_enabled=mms_enabled,
|
||||
voice_enabled=voice_enabled,
|
||||
exclude_all_address_required=exclude_all_address_required,
|
||||
exclude_local_address_required=exclude_local_address_required,
|
||||
exclude_foreign_address_required=exclude_foreign_address_required,
|
||||
beta=beta,
|
||||
near_number=near_number,
|
||||
near_lat_long=near_lat_long,
|
||||
distance=distance,
|
||||
in_postal_code=in_postal_code,
|
||||
in_region=in_region,
|
||||
in_rate_center=in_rate_center,
|
||||
in_lata=in_lata,
|
||||
in_locality=in_locality,
|
||||
fax_enabled=fax_enabled,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[MachineToMachineInstance]:
|
||||
"""
|
||||
Lists MachineToMachineInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param int area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param str contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param bool sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param bool mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param bool voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param bool exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param str near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param int distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param bool fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return list(
|
||||
self.stream(
|
||||
area_code=area_code,
|
||||
contains=contains,
|
||||
sms_enabled=sms_enabled,
|
||||
mms_enabled=mms_enabled,
|
||||
voice_enabled=voice_enabled,
|
||||
exclude_all_address_required=exclude_all_address_required,
|
||||
exclude_local_address_required=exclude_local_address_required,
|
||||
exclude_foreign_address_required=exclude_foreign_address_required,
|
||||
beta=beta,
|
||||
near_number=near_number,
|
||||
near_lat_long=near_lat_long,
|
||||
distance=distance,
|
||||
in_postal_code=in_postal_code,
|
||||
in_region=in_region,
|
||||
in_rate_center=in_rate_center,
|
||||
in_lata=in_lata,
|
||||
in_locality=in_locality,
|
||||
fax_enabled=fax_enabled,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[MachineToMachineInstance]:
|
||||
"""
|
||||
Asynchronously lists MachineToMachineInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param int area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param str contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param bool sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param bool mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param bool voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param bool exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param str near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param int distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param bool fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return [
|
||||
record
|
||||
async for record in await self.stream_async(
|
||||
area_code=area_code,
|
||||
contains=contains,
|
||||
sms_enabled=sms_enabled,
|
||||
mms_enabled=mms_enabled,
|
||||
voice_enabled=voice_enabled,
|
||||
exclude_all_address_required=exclude_all_address_required,
|
||||
exclude_local_address_required=exclude_local_address_required,
|
||||
exclude_foreign_address_required=exclude_foreign_address_required,
|
||||
beta=beta,
|
||||
near_number=near_number,
|
||||
near_lat_long=near_lat_long,
|
||||
distance=distance,
|
||||
in_postal_code=in_postal_code,
|
||||
in_region=in_region,
|
||||
in_rate_center=in_rate_center,
|
||||
in_lata=in_lata,
|
||||
in_locality=in_locality,
|
||||
fax_enabled=fax_enabled,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> MachineToMachinePage:
|
||||
"""
|
||||
Retrieve a single page of MachineToMachineInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of MachineToMachineInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"AreaCode": area_code,
|
||||
"Contains": contains,
|
||||
"SmsEnabled": sms_enabled,
|
||||
"MmsEnabled": mms_enabled,
|
||||
"VoiceEnabled": voice_enabled,
|
||||
"ExcludeAllAddressRequired": exclude_all_address_required,
|
||||
"ExcludeLocalAddressRequired": exclude_local_address_required,
|
||||
"ExcludeForeignAddressRequired": exclude_foreign_address_required,
|
||||
"Beta": beta,
|
||||
"NearNumber": near_number,
|
||||
"NearLatLong": near_lat_long,
|
||||
"Distance": distance,
|
||||
"InPostalCode": in_postal_code,
|
||||
"InRegion": in_region,
|
||||
"InRateCenter": in_rate_center,
|
||||
"InLata": in_lata,
|
||||
"InLocality": in_locality,
|
||||
"FaxEnabled": fax_enabled,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return MachineToMachinePage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> MachineToMachinePage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of MachineToMachineInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of MachineToMachineInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"AreaCode": area_code,
|
||||
"Contains": contains,
|
||||
"SmsEnabled": sms_enabled,
|
||||
"MmsEnabled": mms_enabled,
|
||||
"VoiceEnabled": voice_enabled,
|
||||
"ExcludeAllAddressRequired": exclude_all_address_required,
|
||||
"ExcludeLocalAddressRequired": exclude_local_address_required,
|
||||
"ExcludeForeignAddressRequired": exclude_foreign_address_required,
|
||||
"Beta": beta,
|
||||
"NearNumber": near_number,
|
||||
"NearLatLong": near_lat_long,
|
||||
"Distance": distance,
|
||||
"InPostalCode": in_postal_code,
|
||||
"InRegion": in_region,
|
||||
"InRateCenter": in_rate_center,
|
||||
"InLata": in_lata,
|
||||
"InLocality": in_locality,
|
||||
"FaxEnabled": fax_enabled,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return MachineToMachinePage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> MachineToMachinePage:
|
||||
"""
|
||||
Retrieve a specific page of MachineToMachineInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of MachineToMachineInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return MachineToMachinePage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> MachineToMachinePage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of MachineToMachineInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of MachineToMachineInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return MachineToMachinePage(self._version, response, self._solution)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.MachineToMachineList>"
|
||||
+642
@@ -0,0 +1,642 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, values
|
||||
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.page import Page
|
||||
|
||||
|
||||
class MobileInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar friendly_name: A formatted version of the phone number.
|
||||
:ivar phone_number: The phone number in [E.164](https://www.twilio.com/docs/glossary/what-e164) format, which consists of a + followed by the country code and subscriber number.
|
||||
:ivar lata: The [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) of this phone number. Available for only phone numbers from the US and Canada.
|
||||
:ivar locality: The locality or city of this phone number's location.
|
||||
:ivar rate_center: The [rate center](https://en.wikipedia.org/wiki/Telephone_exchange) of this phone number. Available for only phone numbers from the US and Canada.
|
||||
:ivar latitude: The latitude of this phone number's location. Available for only phone numbers from the US and Canada.
|
||||
:ivar longitude: The longitude of this phone number's location. Available for only phone numbers from the US and Canada.
|
||||
:ivar region: The two-letter state or province abbreviation of this phone number's location. Available for only phone numbers from the US and Canada.
|
||||
:ivar postal_code: The postal or ZIP code of this phone number's location. Available for only phone numbers from the US and Canada.
|
||||
:ivar iso_country: The [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of this phone number.
|
||||
:ivar address_requirements: The type of [Address](https://www.twilio.com/docs/usage/api/address) resource the phone number requires. Can be: `none`, `any`, `local`, or `foreign`. `none` means no address is required. `any` means an address is required, but it can be anywhere in the world. `local` means an address in the phone number's country is required. `foreign` means an address outside of the phone number's country is required.
|
||||
:ivar beta: Whether the phone number is new to the Twilio platform. Can be: `true` or `false`.
|
||||
:ivar capabilities:
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
account_sid: str,
|
||||
country_code: str,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.friendly_name: Optional[str] = payload.get("friendly_name")
|
||||
self.phone_number: Optional[str] = payload.get("phone_number")
|
||||
self.lata: Optional[str] = payload.get("lata")
|
||||
self.locality: Optional[str] = payload.get("locality")
|
||||
self.rate_center: Optional[str] = payload.get("rate_center")
|
||||
self.latitude: Optional[float] = deserialize.decimal(payload.get("latitude"))
|
||||
self.longitude: Optional[float] = deserialize.decimal(payload.get("longitude"))
|
||||
self.region: Optional[str] = payload.get("region")
|
||||
self.postal_code: Optional[str] = payload.get("postal_code")
|
||||
self.iso_country: Optional[str] = payload.get("iso_country")
|
||||
self.address_requirements: Optional[str] = payload.get("address_requirements")
|
||||
self.beta: Optional[bool] = payload.get("beta")
|
||||
self.capabilities: Optional[str] = payload.get("capabilities")
|
||||
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"country_code": country_code,
|
||||
}
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.MobileInstance {}>".format(context)
|
||||
|
||||
|
||||
class MobilePage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> MobileInstance:
|
||||
"""
|
||||
Build an instance of MobileInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return MobileInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
country_code=self._solution["country_code"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.MobilePage>"
|
||||
|
||||
|
||||
class MobileList(ListResource):
|
||||
def __init__(self, version: Version, account_sid: str, country_code: str):
|
||||
"""
|
||||
Initialize the MobileList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) requesting the AvailablePhoneNumber resources.
|
||||
:param country_code: The [ISO-3166-1](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code of the country from which to read phone numbers.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"country_code": country_code,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/AvailablePhoneNumbers/{country_code}/Mobile.json".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[MobileInstance]:
|
||||
"""
|
||||
Streams MobileInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param int area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param str contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param bool sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param bool mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param bool voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param bool exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param str near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param int distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param bool fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(
|
||||
area_code=area_code,
|
||||
contains=contains,
|
||||
sms_enabled=sms_enabled,
|
||||
mms_enabled=mms_enabled,
|
||||
voice_enabled=voice_enabled,
|
||||
exclude_all_address_required=exclude_all_address_required,
|
||||
exclude_local_address_required=exclude_local_address_required,
|
||||
exclude_foreign_address_required=exclude_foreign_address_required,
|
||||
beta=beta,
|
||||
near_number=near_number,
|
||||
near_lat_long=near_lat_long,
|
||||
distance=distance,
|
||||
in_postal_code=in_postal_code,
|
||||
in_region=in_region,
|
||||
in_rate_center=in_rate_center,
|
||||
in_lata=in_lata,
|
||||
in_locality=in_locality,
|
||||
fax_enabled=fax_enabled,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[MobileInstance]:
|
||||
"""
|
||||
Asynchronously streams MobileInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param int area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param str contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param bool sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param bool mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param bool voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param bool exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param str near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param int distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param bool fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(
|
||||
area_code=area_code,
|
||||
contains=contains,
|
||||
sms_enabled=sms_enabled,
|
||||
mms_enabled=mms_enabled,
|
||||
voice_enabled=voice_enabled,
|
||||
exclude_all_address_required=exclude_all_address_required,
|
||||
exclude_local_address_required=exclude_local_address_required,
|
||||
exclude_foreign_address_required=exclude_foreign_address_required,
|
||||
beta=beta,
|
||||
near_number=near_number,
|
||||
near_lat_long=near_lat_long,
|
||||
distance=distance,
|
||||
in_postal_code=in_postal_code,
|
||||
in_region=in_region,
|
||||
in_rate_center=in_rate_center,
|
||||
in_lata=in_lata,
|
||||
in_locality=in_locality,
|
||||
fax_enabled=fax_enabled,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[MobileInstance]:
|
||||
"""
|
||||
Lists MobileInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param int area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param str contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param bool sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param bool mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param bool voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param bool exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param str near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param int distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param bool fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return list(
|
||||
self.stream(
|
||||
area_code=area_code,
|
||||
contains=contains,
|
||||
sms_enabled=sms_enabled,
|
||||
mms_enabled=mms_enabled,
|
||||
voice_enabled=voice_enabled,
|
||||
exclude_all_address_required=exclude_all_address_required,
|
||||
exclude_local_address_required=exclude_local_address_required,
|
||||
exclude_foreign_address_required=exclude_foreign_address_required,
|
||||
beta=beta,
|
||||
near_number=near_number,
|
||||
near_lat_long=near_lat_long,
|
||||
distance=distance,
|
||||
in_postal_code=in_postal_code,
|
||||
in_region=in_region,
|
||||
in_rate_center=in_rate_center,
|
||||
in_lata=in_lata,
|
||||
in_locality=in_locality,
|
||||
fax_enabled=fax_enabled,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[MobileInstance]:
|
||||
"""
|
||||
Asynchronously lists MobileInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param int area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param str contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param bool sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param bool mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param bool voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param bool exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param str near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param int distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param bool fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return [
|
||||
record
|
||||
async for record in await self.stream_async(
|
||||
area_code=area_code,
|
||||
contains=contains,
|
||||
sms_enabled=sms_enabled,
|
||||
mms_enabled=mms_enabled,
|
||||
voice_enabled=voice_enabled,
|
||||
exclude_all_address_required=exclude_all_address_required,
|
||||
exclude_local_address_required=exclude_local_address_required,
|
||||
exclude_foreign_address_required=exclude_foreign_address_required,
|
||||
beta=beta,
|
||||
near_number=near_number,
|
||||
near_lat_long=near_lat_long,
|
||||
distance=distance,
|
||||
in_postal_code=in_postal_code,
|
||||
in_region=in_region,
|
||||
in_rate_center=in_rate_center,
|
||||
in_lata=in_lata,
|
||||
in_locality=in_locality,
|
||||
fax_enabled=fax_enabled,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> MobilePage:
|
||||
"""
|
||||
Retrieve a single page of MobileInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of MobileInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"AreaCode": area_code,
|
||||
"Contains": contains,
|
||||
"SmsEnabled": sms_enabled,
|
||||
"MmsEnabled": mms_enabled,
|
||||
"VoiceEnabled": voice_enabled,
|
||||
"ExcludeAllAddressRequired": exclude_all_address_required,
|
||||
"ExcludeLocalAddressRequired": exclude_local_address_required,
|
||||
"ExcludeForeignAddressRequired": exclude_foreign_address_required,
|
||||
"Beta": beta,
|
||||
"NearNumber": near_number,
|
||||
"NearLatLong": near_lat_long,
|
||||
"Distance": distance,
|
||||
"InPostalCode": in_postal_code,
|
||||
"InRegion": in_region,
|
||||
"InRateCenter": in_rate_center,
|
||||
"InLata": in_lata,
|
||||
"InLocality": in_locality,
|
||||
"FaxEnabled": fax_enabled,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return MobilePage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> MobilePage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of MobileInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of MobileInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"AreaCode": area_code,
|
||||
"Contains": contains,
|
||||
"SmsEnabled": sms_enabled,
|
||||
"MmsEnabled": mms_enabled,
|
||||
"VoiceEnabled": voice_enabled,
|
||||
"ExcludeAllAddressRequired": exclude_all_address_required,
|
||||
"ExcludeLocalAddressRequired": exclude_local_address_required,
|
||||
"ExcludeForeignAddressRequired": exclude_foreign_address_required,
|
||||
"Beta": beta,
|
||||
"NearNumber": near_number,
|
||||
"NearLatLong": near_lat_long,
|
||||
"Distance": distance,
|
||||
"InPostalCode": in_postal_code,
|
||||
"InRegion": in_region,
|
||||
"InRateCenter": in_rate_center,
|
||||
"InLata": in_lata,
|
||||
"InLocality": in_locality,
|
||||
"FaxEnabled": fax_enabled,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return MobilePage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> MobilePage:
|
||||
"""
|
||||
Retrieve a specific page of MobileInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of MobileInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return MobilePage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> MobilePage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of MobileInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of MobileInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return MobilePage(self._version, response, self._solution)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.MobileList>"
|
||||
+642
@@ -0,0 +1,642 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, values
|
||||
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.page import Page
|
||||
|
||||
|
||||
class NationalInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar friendly_name: A formatted version of the phone number.
|
||||
:ivar phone_number: The phone number in [E.164](https://www.twilio.com/docs/glossary/what-e164) format, which consists of a + followed by the country code and subscriber number.
|
||||
:ivar lata: The [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) of this phone number. Available for only phone numbers from the US and Canada.
|
||||
:ivar locality: The locality or city of this phone number's location.
|
||||
:ivar rate_center: The [rate center](https://en.wikipedia.org/wiki/Telephone_exchange) of this phone number. Available for only phone numbers from the US and Canada.
|
||||
:ivar latitude: The latitude of this phone number's location. Available for only phone numbers from the US and Canada.
|
||||
:ivar longitude: The longitude of this phone number's location. Available for only phone numbers from the US and Canada.
|
||||
:ivar region: The two-letter state or province abbreviation of this phone number's location. Available for only phone numbers from the US and Canada.
|
||||
:ivar postal_code: The postal or ZIP code of this phone number's location. Available for only phone numbers from the US and Canada.
|
||||
:ivar iso_country: The [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of this phone number.
|
||||
:ivar address_requirements: The type of [Address](https://www.twilio.com/docs/usage/api/address) resource the phone number requires. Can be: `none`, `any`, `local`, or `foreign`. `none` means no address is required. `any` means an address is required, but it can be anywhere in the world. `local` means an address in the phone number's country is required. `foreign` means an address outside of the phone number's country is required.
|
||||
:ivar beta: Whether the phone number is new to the Twilio platform. Can be: `true` or `false`.
|
||||
:ivar capabilities:
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
account_sid: str,
|
||||
country_code: str,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.friendly_name: Optional[str] = payload.get("friendly_name")
|
||||
self.phone_number: Optional[str] = payload.get("phone_number")
|
||||
self.lata: Optional[str] = payload.get("lata")
|
||||
self.locality: Optional[str] = payload.get("locality")
|
||||
self.rate_center: Optional[str] = payload.get("rate_center")
|
||||
self.latitude: Optional[float] = deserialize.decimal(payload.get("latitude"))
|
||||
self.longitude: Optional[float] = deserialize.decimal(payload.get("longitude"))
|
||||
self.region: Optional[str] = payload.get("region")
|
||||
self.postal_code: Optional[str] = payload.get("postal_code")
|
||||
self.iso_country: Optional[str] = payload.get("iso_country")
|
||||
self.address_requirements: Optional[str] = payload.get("address_requirements")
|
||||
self.beta: Optional[bool] = payload.get("beta")
|
||||
self.capabilities: Optional[str] = payload.get("capabilities")
|
||||
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"country_code": country_code,
|
||||
}
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.NationalInstance {}>".format(context)
|
||||
|
||||
|
||||
class NationalPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> NationalInstance:
|
||||
"""
|
||||
Build an instance of NationalInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return NationalInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
country_code=self._solution["country_code"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.NationalPage>"
|
||||
|
||||
|
||||
class NationalList(ListResource):
|
||||
def __init__(self, version: Version, account_sid: str, country_code: str):
|
||||
"""
|
||||
Initialize the NationalList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) requesting the AvailablePhoneNumber resources.
|
||||
:param country_code: The [ISO-3166-1](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code of the country from which to read phone numbers.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"country_code": country_code,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/AvailablePhoneNumbers/{country_code}/National.json".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[NationalInstance]:
|
||||
"""
|
||||
Streams NationalInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param int area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param str contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param bool sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param bool mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param bool voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param bool exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param str near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param int distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param bool fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(
|
||||
area_code=area_code,
|
||||
contains=contains,
|
||||
sms_enabled=sms_enabled,
|
||||
mms_enabled=mms_enabled,
|
||||
voice_enabled=voice_enabled,
|
||||
exclude_all_address_required=exclude_all_address_required,
|
||||
exclude_local_address_required=exclude_local_address_required,
|
||||
exclude_foreign_address_required=exclude_foreign_address_required,
|
||||
beta=beta,
|
||||
near_number=near_number,
|
||||
near_lat_long=near_lat_long,
|
||||
distance=distance,
|
||||
in_postal_code=in_postal_code,
|
||||
in_region=in_region,
|
||||
in_rate_center=in_rate_center,
|
||||
in_lata=in_lata,
|
||||
in_locality=in_locality,
|
||||
fax_enabled=fax_enabled,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[NationalInstance]:
|
||||
"""
|
||||
Asynchronously streams NationalInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param int area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param str contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param bool sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param bool mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param bool voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param bool exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param str near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param int distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param bool fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(
|
||||
area_code=area_code,
|
||||
contains=contains,
|
||||
sms_enabled=sms_enabled,
|
||||
mms_enabled=mms_enabled,
|
||||
voice_enabled=voice_enabled,
|
||||
exclude_all_address_required=exclude_all_address_required,
|
||||
exclude_local_address_required=exclude_local_address_required,
|
||||
exclude_foreign_address_required=exclude_foreign_address_required,
|
||||
beta=beta,
|
||||
near_number=near_number,
|
||||
near_lat_long=near_lat_long,
|
||||
distance=distance,
|
||||
in_postal_code=in_postal_code,
|
||||
in_region=in_region,
|
||||
in_rate_center=in_rate_center,
|
||||
in_lata=in_lata,
|
||||
in_locality=in_locality,
|
||||
fax_enabled=fax_enabled,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[NationalInstance]:
|
||||
"""
|
||||
Lists NationalInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param int area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param str contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param bool sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param bool mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param bool voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param bool exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param str near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param int distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param bool fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return list(
|
||||
self.stream(
|
||||
area_code=area_code,
|
||||
contains=contains,
|
||||
sms_enabled=sms_enabled,
|
||||
mms_enabled=mms_enabled,
|
||||
voice_enabled=voice_enabled,
|
||||
exclude_all_address_required=exclude_all_address_required,
|
||||
exclude_local_address_required=exclude_local_address_required,
|
||||
exclude_foreign_address_required=exclude_foreign_address_required,
|
||||
beta=beta,
|
||||
near_number=near_number,
|
||||
near_lat_long=near_lat_long,
|
||||
distance=distance,
|
||||
in_postal_code=in_postal_code,
|
||||
in_region=in_region,
|
||||
in_rate_center=in_rate_center,
|
||||
in_lata=in_lata,
|
||||
in_locality=in_locality,
|
||||
fax_enabled=fax_enabled,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[NationalInstance]:
|
||||
"""
|
||||
Asynchronously lists NationalInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param int area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param str contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param bool sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param bool mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param bool voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param bool exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param str near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param int distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param bool fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return [
|
||||
record
|
||||
async for record in await self.stream_async(
|
||||
area_code=area_code,
|
||||
contains=contains,
|
||||
sms_enabled=sms_enabled,
|
||||
mms_enabled=mms_enabled,
|
||||
voice_enabled=voice_enabled,
|
||||
exclude_all_address_required=exclude_all_address_required,
|
||||
exclude_local_address_required=exclude_local_address_required,
|
||||
exclude_foreign_address_required=exclude_foreign_address_required,
|
||||
beta=beta,
|
||||
near_number=near_number,
|
||||
near_lat_long=near_lat_long,
|
||||
distance=distance,
|
||||
in_postal_code=in_postal_code,
|
||||
in_region=in_region,
|
||||
in_rate_center=in_rate_center,
|
||||
in_lata=in_lata,
|
||||
in_locality=in_locality,
|
||||
fax_enabled=fax_enabled,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> NationalPage:
|
||||
"""
|
||||
Retrieve a single page of NationalInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of NationalInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"AreaCode": area_code,
|
||||
"Contains": contains,
|
||||
"SmsEnabled": sms_enabled,
|
||||
"MmsEnabled": mms_enabled,
|
||||
"VoiceEnabled": voice_enabled,
|
||||
"ExcludeAllAddressRequired": exclude_all_address_required,
|
||||
"ExcludeLocalAddressRequired": exclude_local_address_required,
|
||||
"ExcludeForeignAddressRequired": exclude_foreign_address_required,
|
||||
"Beta": beta,
|
||||
"NearNumber": near_number,
|
||||
"NearLatLong": near_lat_long,
|
||||
"Distance": distance,
|
||||
"InPostalCode": in_postal_code,
|
||||
"InRegion": in_region,
|
||||
"InRateCenter": in_rate_center,
|
||||
"InLata": in_lata,
|
||||
"InLocality": in_locality,
|
||||
"FaxEnabled": fax_enabled,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return NationalPage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> NationalPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of NationalInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of NationalInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"AreaCode": area_code,
|
||||
"Contains": contains,
|
||||
"SmsEnabled": sms_enabled,
|
||||
"MmsEnabled": mms_enabled,
|
||||
"VoiceEnabled": voice_enabled,
|
||||
"ExcludeAllAddressRequired": exclude_all_address_required,
|
||||
"ExcludeLocalAddressRequired": exclude_local_address_required,
|
||||
"ExcludeForeignAddressRequired": exclude_foreign_address_required,
|
||||
"Beta": beta,
|
||||
"NearNumber": near_number,
|
||||
"NearLatLong": near_lat_long,
|
||||
"Distance": distance,
|
||||
"InPostalCode": in_postal_code,
|
||||
"InRegion": in_region,
|
||||
"InRateCenter": in_rate_center,
|
||||
"InLata": in_lata,
|
||||
"InLocality": in_locality,
|
||||
"FaxEnabled": fax_enabled,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return NationalPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> NationalPage:
|
||||
"""
|
||||
Retrieve a specific page of NationalInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of NationalInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return NationalPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> NationalPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of NationalInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of NationalInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return NationalPage(self._version, response, self._solution)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.NationalList>"
|
||||
+642
@@ -0,0 +1,642 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, values
|
||||
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.page import Page
|
||||
|
||||
|
||||
class SharedCostInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar friendly_name: A formatted version of the phone number.
|
||||
:ivar phone_number: The phone number in [E.164](https://www.twilio.com/docs/glossary/what-e164) format, which consists of a + followed by the country code and subscriber number.
|
||||
:ivar lata: The [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) of this phone number. Available for only phone numbers from the US and Canada.
|
||||
:ivar locality: The locality or city of this phone number's location.
|
||||
:ivar rate_center: The [rate center](https://en.wikipedia.org/wiki/Telephone_exchange) of this phone number. Available for only phone numbers from the US and Canada.
|
||||
:ivar latitude: The latitude of this phone number's location. Available for only phone numbers from the US and Canada.
|
||||
:ivar longitude: The longitude of this phone number's location. Available for only phone numbers from the US and Canada.
|
||||
:ivar region: The two-letter state or province abbreviation of this phone number's location. Available for only phone numbers from the US and Canada.
|
||||
:ivar postal_code: The postal or ZIP code of this phone number's location. Available for only phone numbers from the US and Canada.
|
||||
:ivar iso_country: The [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of this phone number.
|
||||
:ivar address_requirements: The type of [Address](https://www.twilio.com/docs/usage/api/address) resource the phone number requires. Can be: `none`, `any`, `local`, or `foreign`. `none` means no address is required. `any` means an address is required, but it can be anywhere in the world. `local` means an address in the phone number's country is required. `foreign` means an address outside of the phone number's country is required.
|
||||
:ivar beta: Whether the phone number is new to the Twilio platform. Can be: `true` or `false`.
|
||||
:ivar capabilities:
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
account_sid: str,
|
||||
country_code: str,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.friendly_name: Optional[str] = payload.get("friendly_name")
|
||||
self.phone_number: Optional[str] = payload.get("phone_number")
|
||||
self.lata: Optional[str] = payload.get("lata")
|
||||
self.locality: Optional[str] = payload.get("locality")
|
||||
self.rate_center: Optional[str] = payload.get("rate_center")
|
||||
self.latitude: Optional[float] = deserialize.decimal(payload.get("latitude"))
|
||||
self.longitude: Optional[float] = deserialize.decimal(payload.get("longitude"))
|
||||
self.region: Optional[str] = payload.get("region")
|
||||
self.postal_code: Optional[str] = payload.get("postal_code")
|
||||
self.iso_country: Optional[str] = payload.get("iso_country")
|
||||
self.address_requirements: Optional[str] = payload.get("address_requirements")
|
||||
self.beta: Optional[bool] = payload.get("beta")
|
||||
self.capabilities: Optional[str] = payload.get("capabilities")
|
||||
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"country_code": country_code,
|
||||
}
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.SharedCostInstance {}>".format(context)
|
||||
|
||||
|
||||
class SharedCostPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> SharedCostInstance:
|
||||
"""
|
||||
Build an instance of SharedCostInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return SharedCostInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
country_code=self._solution["country_code"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.SharedCostPage>"
|
||||
|
||||
|
||||
class SharedCostList(ListResource):
|
||||
def __init__(self, version: Version, account_sid: str, country_code: str):
|
||||
"""
|
||||
Initialize the SharedCostList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) requesting the AvailablePhoneNumber resources.
|
||||
:param country_code: The [ISO-3166-1](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code of the country from which to read phone numbers.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"country_code": country_code,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/AvailablePhoneNumbers/{country_code}/SharedCost.json".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[SharedCostInstance]:
|
||||
"""
|
||||
Streams SharedCostInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param int area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param str contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param bool sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param bool mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param bool voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param bool exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param str near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param int distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param bool fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(
|
||||
area_code=area_code,
|
||||
contains=contains,
|
||||
sms_enabled=sms_enabled,
|
||||
mms_enabled=mms_enabled,
|
||||
voice_enabled=voice_enabled,
|
||||
exclude_all_address_required=exclude_all_address_required,
|
||||
exclude_local_address_required=exclude_local_address_required,
|
||||
exclude_foreign_address_required=exclude_foreign_address_required,
|
||||
beta=beta,
|
||||
near_number=near_number,
|
||||
near_lat_long=near_lat_long,
|
||||
distance=distance,
|
||||
in_postal_code=in_postal_code,
|
||||
in_region=in_region,
|
||||
in_rate_center=in_rate_center,
|
||||
in_lata=in_lata,
|
||||
in_locality=in_locality,
|
||||
fax_enabled=fax_enabled,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[SharedCostInstance]:
|
||||
"""
|
||||
Asynchronously streams SharedCostInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param int area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param str contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param bool sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param bool mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param bool voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param bool exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param str near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param int distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param bool fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(
|
||||
area_code=area_code,
|
||||
contains=contains,
|
||||
sms_enabled=sms_enabled,
|
||||
mms_enabled=mms_enabled,
|
||||
voice_enabled=voice_enabled,
|
||||
exclude_all_address_required=exclude_all_address_required,
|
||||
exclude_local_address_required=exclude_local_address_required,
|
||||
exclude_foreign_address_required=exclude_foreign_address_required,
|
||||
beta=beta,
|
||||
near_number=near_number,
|
||||
near_lat_long=near_lat_long,
|
||||
distance=distance,
|
||||
in_postal_code=in_postal_code,
|
||||
in_region=in_region,
|
||||
in_rate_center=in_rate_center,
|
||||
in_lata=in_lata,
|
||||
in_locality=in_locality,
|
||||
fax_enabled=fax_enabled,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[SharedCostInstance]:
|
||||
"""
|
||||
Lists SharedCostInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param int area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param str contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param bool sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param bool mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param bool voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param bool exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param str near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param int distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param bool fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return list(
|
||||
self.stream(
|
||||
area_code=area_code,
|
||||
contains=contains,
|
||||
sms_enabled=sms_enabled,
|
||||
mms_enabled=mms_enabled,
|
||||
voice_enabled=voice_enabled,
|
||||
exclude_all_address_required=exclude_all_address_required,
|
||||
exclude_local_address_required=exclude_local_address_required,
|
||||
exclude_foreign_address_required=exclude_foreign_address_required,
|
||||
beta=beta,
|
||||
near_number=near_number,
|
||||
near_lat_long=near_lat_long,
|
||||
distance=distance,
|
||||
in_postal_code=in_postal_code,
|
||||
in_region=in_region,
|
||||
in_rate_center=in_rate_center,
|
||||
in_lata=in_lata,
|
||||
in_locality=in_locality,
|
||||
fax_enabled=fax_enabled,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[SharedCostInstance]:
|
||||
"""
|
||||
Asynchronously lists SharedCostInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param int area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param str contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param bool sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param bool mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param bool voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param bool exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param str near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param int distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param bool fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return [
|
||||
record
|
||||
async for record in await self.stream_async(
|
||||
area_code=area_code,
|
||||
contains=contains,
|
||||
sms_enabled=sms_enabled,
|
||||
mms_enabled=mms_enabled,
|
||||
voice_enabled=voice_enabled,
|
||||
exclude_all_address_required=exclude_all_address_required,
|
||||
exclude_local_address_required=exclude_local_address_required,
|
||||
exclude_foreign_address_required=exclude_foreign_address_required,
|
||||
beta=beta,
|
||||
near_number=near_number,
|
||||
near_lat_long=near_lat_long,
|
||||
distance=distance,
|
||||
in_postal_code=in_postal_code,
|
||||
in_region=in_region,
|
||||
in_rate_center=in_rate_center,
|
||||
in_lata=in_lata,
|
||||
in_locality=in_locality,
|
||||
fax_enabled=fax_enabled,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> SharedCostPage:
|
||||
"""
|
||||
Retrieve a single page of SharedCostInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of SharedCostInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"AreaCode": area_code,
|
||||
"Contains": contains,
|
||||
"SmsEnabled": sms_enabled,
|
||||
"MmsEnabled": mms_enabled,
|
||||
"VoiceEnabled": voice_enabled,
|
||||
"ExcludeAllAddressRequired": exclude_all_address_required,
|
||||
"ExcludeLocalAddressRequired": exclude_local_address_required,
|
||||
"ExcludeForeignAddressRequired": exclude_foreign_address_required,
|
||||
"Beta": beta,
|
||||
"NearNumber": near_number,
|
||||
"NearLatLong": near_lat_long,
|
||||
"Distance": distance,
|
||||
"InPostalCode": in_postal_code,
|
||||
"InRegion": in_region,
|
||||
"InRateCenter": in_rate_center,
|
||||
"InLata": in_lata,
|
||||
"InLocality": in_locality,
|
||||
"FaxEnabled": fax_enabled,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return SharedCostPage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> SharedCostPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of SharedCostInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of SharedCostInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"AreaCode": area_code,
|
||||
"Contains": contains,
|
||||
"SmsEnabled": sms_enabled,
|
||||
"MmsEnabled": mms_enabled,
|
||||
"VoiceEnabled": voice_enabled,
|
||||
"ExcludeAllAddressRequired": exclude_all_address_required,
|
||||
"ExcludeLocalAddressRequired": exclude_local_address_required,
|
||||
"ExcludeForeignAddressRequired": exclude_foreign_address_required,
|
||||
"Beta": beta,
|
||||
"NearNumber": near_number,
|
||||
"NearLatLong": near_lat_long,
|
||||
"Distance": distance,
|
||||
"InPostalCode": in_postal_code,
|
||||
"InRegion": in_region,
|
||||
"InRateCenter": in_rate_center,
|
||||
"InLata": in_lata,
|
||||
"InLocality": in_locality,
|
||||
"FaxEnabled": fax_enabled,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return SharedCostPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> SharedCostPage:
|
||||
"""
|
||||
Retrieve a specific page of SharedCostInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of SharedCostInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return SharedCostPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> SharedCostPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of SharedCostInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of SharedCostInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return SharedCostPage(self._version, response, self._solution)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.SharedCostList>"
|
||||
+642
@@ -0,0 +1,642 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, values
|
||||
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.page import Page
|
||||
|
||||
|
||||
class TollFreeInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar friendly_name: A formatted version of the phone number.
|
||||
:ivar phone_number: The phone number in [E.164](https://www.twilio.com/docs/glossary/what-e164) format, which consists of a + followed by the country code and subscriber number.
|
||||
:ivar lata: The [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) of this phone number. Available for only phone numbers from the US and Canada.
|
||||
:ivar locality: The locality or city of this phone number's location.
|
||||
:ivar rate_center: The [rate center](https://en.wikipedia.org/wiki/Telephone_exchange) of this phone number. Available for only phone numbers from the US and Canada.
|
||||
:ivar latitude: The latitude of this phone number's location. Available for only phone numbers from the US and Canada.
|
||||
:ivar longitude: The longitude of this phone number's location. Available for only phone numbers from the US and Canada.
|
||||
:ivar region: The two-letter state or province abbreviation of this phone number's location. Available for only phone numbers from the US and Canada.
|
||||
:ivar postal_code: The postal or ZIP code of this phone number's location. Available for only phone numbers from the US and Canada.
|
||||
:ivar iso_country: The [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of this phone number.
|
||||
:ivar address_requirements: The type of [Address](https://www.twilio.com/docs/usage/api/address) resource the phone number requires. Can be: `none`, `any`, `local`, or `foreign`. `none` means no address is required. `any` means an address is required, but it can be anywhere in the world. `local` means an address in the phone number's country is required. `foreign` means an address outside of the phone number's country is required.
|
||||
:ivar beta: Whether the phone number is new to the Twilio platform. Can be: `true` or `false`.
|
||||
:ivar capabilities:
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
account_sid: str,
|
||||
country_code: str,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.friendly_name: Optional[str] = payload.get("friendly_name")
|
||||
self.phone_number: Optional[str] = payload.get("phone_number")
|
||||
self.lata: Optional[str] = payload.get("lata")
|
||||
self.locality: Optional[str] = payload.get("locality")
|
||||
self.rate_center: Optional[str] = payload.get("rate_center")
|
||||
self.latitude: Optional[float] = deserialize.decimal(payload.get("latitude"))
|
||||
self.longitude: Optional[float] = deserialize.decimal(payload.get("longitude"))
|
||||
self.region: Optional[str] = payload.get("region")
|
||||
self.postal_code: Optional[str] = payload.get("postal_code")
|
||||
self.iso_country: Optional[str] = payload.get("iso_country")
|
||||
self.address_requirements: Optional[str] = payload.get("address_requirements")
|
||||
self.beta: Optional[bool] = payload.get("beta")
|
||||
self.capabilities: Optional[str] = payload.get("capabilities")
|
||||
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"country_code": country_code,
|
||||
}
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.TollFreeInstance {}>".format(context)
|
||||
|
||||
|
||||
class TollFreePage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> TollFreeInstance:
|
||||
"""
|
||||
Build an instance of TollFreeInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return TollFreeInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
country_code=self._solution["country_code"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.TollFreePage>"
|
||||
|
||||
|
||||
class TollFreeList(ListResource):
|
||||
def __init__(self, version: Version, account_sid: str, country_code: str):
|
||||
"""
|
||||
Initialize the TollFreeList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) requesting the AvailablePhoneNumber resources.
|
||||
:param country_code: The [ISO-3166-1](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code of the country from which to read phone numbers.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"country_code": country_code,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/AvailablePhoneNumbers/{country_code}/TollFree.json".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[TollFreeInstance]:
|
||||
"""
|
||||
Streams TollFreeInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param int area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param str contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param bool sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param bool mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param bool voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param bool exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param str near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param int distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param bool fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(
|
||||
area_code=area_code,
|
||||
contains=contains,
|
||||
sms_enabled=sms_enabled,
|
||||
mms_enabled=mms_enabled,
|
||||
voice_enabled=voice_enabled,
|
||||
exclude_all_address_required=exclude_all_address_required,
|
||||
exclude_local_address_required=exclude_local_address_required,
|
||||
exclude_foreign_address_required=exclude_foreign_address_required,
|
||||
beta=beta,
|
||||
near_number=near_number,
|
||||
near_lat_long=near_lat_long,
|
||||
distance=distance,
|
||||
in_postal_code=in_postal_code,
|
||||
in_region=in_region,
|
||||
in_rate_center=in_rate_center,
|
||||
in_lata=in_lata,
|
||||
in_locality=in_locality,
|
||||
fax_enabled=fax_enabled,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[TollFreeInstance]:
|
||||
"""
|
||||
Asynchronously streams TollFreeInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param int area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param str contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param bool sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param bool mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param bool voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param bool exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param str near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param int distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param bool fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(
|
||||
area_code=area_code,
|
||||
contains=contains,
|
||||
sms_enabled=sms_enabled,
|
||||
mms_enabled=mms_enabled,
|
||||
voice_enabled=voice_enabled,
|
||||
exclude_all_address_required=exclude_all_address_required,
|
||||
exclude_local_address_required=exclude_local_address_required,
|
||||
exclude_foreign_address_required=exclude_foreign_address_required,
|
||||
beta=beta,
|
||||
near_number=near_number,
|
||||
near_lat_long=near_lat_long,
|
||||
distance=distance,
|
||||
in_postal_code=in_postal_code,
|
||||
in_region=in_region,
|
||||
in_rate_center=in_rate_center,
|
||||
in_lata=in_lata,
|
||||
in_locality=in_locality,
|
||||
fax_enabled=fax_enabled,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[TollFreeInstance]:
|
||||
"""
|
||||
Lists TollFreeInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param int area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param str contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param bool sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param bool mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param bool voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param bool exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param str near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param int distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param bool fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return list(
|
||||
self.stream(
|
||||
area_code=area_code,
|
||||
contains=contains,
|
||||
sms_enabled=sms_enabled,
|
||||
mms_enabled=mms_enabled,
|
||||
voice_enabled=voice_enabled,
|
||||
exclude_all_address_required=exclude_all_address_required,
|
||||
exclude_local_address_required=exclude_local_address_required,
|
||||
exclude_foreign_address_required=exclude_foreign_address_required,
|
||||
beta=beta,
|
||||
near_number=near_number,
|
||||
near_lat_long=near_lat_long,
|
||||
distance=distance,
|
||||
in_postal_code=in_postal_code,
|
||||
in_region=in_region,
|
||||
in_rate_center=in_rate_center,
|
||||
in_lata=in_lata,
|
||||
in_locality=in_locality,
|
||||
fax_enabled=fax_enabled,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[TollFreeInstance]:
|
||||
"""
|
||||
Asynchronously lists TollFreeInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param int area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param str contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param bool sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param bool mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param bool voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param bool exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param str near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param int distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param bool fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return [
|
||||
record
|
||||
async for record in await self.stream_async(
|
||||
area_code=area_code,
|
||||
contains=contains,
|
||||
sms_enabled=sms_enabled,
|
||||
mms_enabled=mms_enabled,
|
||||
voice_enabled=voice_enabled,
|
||||
exclude_all_address_required=exclude_all_address_required,
|
||||
exclude_local_address_required=exclude_local_address_required,
|
||||
exclude_foreign_address_required=exclude_foreign_address_required,
|
||||
beta=beta,
|
||||
near_number=near_number,
|
||||
near_lat_long=near_lat_long,
|
||||
distance=distance,
|
||||
in_postal_code=in_postal_code,
|
||||
in_region=in_region,
|
||||
in_rate_center=in_rate_center,
|
||||
in_lata=in_lata,
|
||||
in_locality=in_locality,
|
||||
fax_enabled=fax_enabled,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> TollFreePage:
|
||||
"""
|
||||
Retrieve a single page of TollFreeInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of TollFreeInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"AreaCode": area_code,
|
||||
"Contains": contains,
|
||||
"SmsEnabled": sms_enabled,
|
||||
"MmsEnabled": mms_enabled,
|
||||
"VoiceEnabled": voice_enabled,
|
||||
"ExcludeAllAddressRequired": exclude_all_address_required,
|
||||
"ExcludeLocalAddressRequired": exclude_local_address_required,
|
||||
"ExcludeForeignAddressRequired": exclude_foreign_address_required,
|
||||
"Beta": beta,
|
||||
"NearNumber": near_number,
|
||||
"NearLatLong": near_lat_long,
|
||||
"Distance": distance,
|
||||
"InPostalCode": in_postal_code,
|
||||
"InRegion": in_region,
|
||||
"InRateCenter": in_rate_center,
|
||||
"InLata": in_lata,
|
||||
"InLocality": in_locality,
|
||||
"FaxEnabled": fax_enabled,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return TollFreePage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> TollFreePage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of TollFreeInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of TollFreeInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"AreaCode": area_code,
|
||||
"Contains": contains,
|
||||
"SmsEnabled": sms_enabled,
|
||||
"MmsEnabled": mms_enabled,
|
||||
"VoiceEnabled": voice_enabled,
|
||||
"ExcludeAllAddressRequired": exclude_all_address_required,
|
||||
"ExcludeLocalAddressRequired": exclude_local_address_required,
|
||||
"ExcludeForeignAddressRequired": exclude_foreign_address_required,
|
||||
"Beta": beta,
|
||||
"NearNumber": near_number,
|
||||
"NearLatLong": near_lat_long,
|
||||
"Distance": distance,
|
||||
"InPostalCode": in_postal_code,
|
||||
"InRegion": in_region,
|
||||
"InRateCenter": in_rate_center,
|
||||
"InLata": in_lata,
|
||||
"InLocality": in_locality,
|
||||
"FaxEnabled": fax_enabled,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return TollFreePage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> TollFreePage:
|
||||
"""
|
||||
Retrieve a specific page of TollFreeInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of TollFreeInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return TollFreePage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> TollFreePage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of TollFreeInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of TollFreeInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return TollFreePage(self._version, response, self._solution)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.TollFreeList>"
|
||||
+642
@@ -0,0 +1,642 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, values
|
||||
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.page import Page
|
||||
|
||||
|
||||
class VoipInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar friendly_name: A formatted version of the phone number.
|
||||
:ivar phone_number: The phone number in [E.164](https://www.twilio.com/docs/glossary/what-e164) format, which consists of a + followed by the country code and subscriber number.
|
||||
:ivar lata: The [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) of this phone number. Available for only phone numbers from the US and Canada.
|
||||
:ivar locality: The locality or city of this phone number's location.
|
||||
:ivar rate_center: The [rate center](https://en.wikipedia.org/wiki/Telephone_exchange) of this phone number. Available for only phone numbers from the US and Canada.
|
||||
:ivar latitude: The latitude of this phone number's location. Available for only phone numbers from the US and Canada.
|
||||
:ivar longitude: The longitude of this phone number's location. Available for only phone numbers from the US and Canada.
|
||||
:ivar region: The two-letter state or province abbreviation of this phone number's location. Available for only phone numbers from the US and Canada.
|
||||
:ivar postal_code: The postal or ZIP code of this phone number's location. Available for only phone numbers from the US and Canada.
|
||||
:ivar iso_country: The [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of this phone number.
|
||||
:ivar address_requirements: The type of [Address](https://www.twilio.com/docs/usage/api/address) resource the phone number requires. Can be: `none`, `any`, `local`, or `foreign`. `none` means no address is required. `any` means an address is required, but it can be anywhere in the world. `local` means an address in the phone number's country is required. `foreign` means an address outside of the phone number's country is required.
|
||||
:ivar beta: Whether the phone number is new to the Twilio platform. Can be: `true` or `false`.
|
||||
:ivar capabilities:
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
account_sid: str,
|
||||
country_code: str,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.friendly_name: Optional[str] = payload.get("friendly_name")
|
||||
self.phone_number: Optional[str] = payload.get("phone_number")
|
||||
self.lata: Optional[str] = payload.get("lata")
|
||||
self.locality: Optional[str] = payload.get("locality")
|
||||
self.rate_center: Optional[str] = payload.get("rate_center")
|
||||
self.latitude: Optional[float] = deserialize.decimal(payload.get("latitude"))
|
||||
self.longitude: Optional[float] = deserialize.decimal(payload.get("longitude"))
|
||||
self.region: Optional[str] = payload.get("region")
|
||||
self.postal_code: Optional[str] = payload.get("postal_code")
|
||||
self.iso_country: Optional[str] = payload.get("iso_country")
|
||||
self.address_requirements: Optional[str] = payload.get("address_requirements")
|
||||
self.beta: Optional[bool] = payload.get("beta")
|
||||
self.capabilities: Optional[str] = payload.get("capabilities")
|
||||
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"country_code": country_code,
|
||||
}
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.VoipInstance {}>".format(context)
|
||||
|
||||
|
||||
class VoipPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> VoipInstance:
|
||||
"""
|
||||
Build an instance of VoipInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return VoipInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
country_code=self._solution["country_code"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.VoipPage>"
|
||||
|
||||
|
||||
class VoipList(ListResource):
|
||||
def __init__(self, version: Version, account_sid: str, country_code: str):
|
||||
"""
|
||||
Initialize the VoipList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) requesting the AvailablePhoneNumber resources.
|
||||
:param country_code: The [ISO-3166-1](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code of the country from which to read phone numbers.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"country_code": country_code,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/AvailablePhoneNumbers/{country_code}/Voip.json".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[VoipInstance]:
|
||||
"""
|
||||
Streams VoipInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param int area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param str contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param bool sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param bool mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param bool voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param bool exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param str near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param int distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param bool fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(
|
||||
area_code=area_code,
|
||||
contains=contains,
|
||||
sms_enabled=sms_enabled,
|
||||
mms_enabled=mms_enabled,
|
||||
voice_enabled=voice_enabled,
|
||||
exclude_all_address_required=exclude_all_address_required,
|
||||
exclude_local_address_required=exclude_local_address_required,
|
||||
exclude_foreign_address_required=exclude_foreign_address_required,
|
||||
beta=beta,
|
||||
near_number=near_number,
|
||||
near_lat_long=near_lat_long,
|
||||
distance=distance,
|
||||
in_postal_code=in_postal_code,
|
||||
in_region=in_region,
|
||||
in_rate_center=in_rate_center,
|
||||
in_lata=in_lata,
|
||||
in_locality=in_locality,
|
||||
fax_enabled=fax_enabled,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[VoipInstance]:
|
||||
"""
|
||||
Asynchronously streams VoipInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param int area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param str contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param bool sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param bool mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param bool voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param bool exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param str near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param int distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param bool fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(
|
||||
area_code=area_code,
|
||||
contains=contains,
|
||||
sms_enabled=sms_enabled,
|
||||
mms_enabled=mms_enabled,
|
||||
voice_enabled=voice_enabled,
|
||||
exclude_all_address_required=exclude_all_address_required,
|
||||
exclude_local_address_required=exclude_local_address_required,
|
||||
exclude_foreign_address_required=exclude_foreign_address_required,
|
||||
beta=beta,
|
||||
near_number=near_number,
|
||||
near_lat_long=near_lat_long,
|
||||
distance=distance,
|
||||
in_postal_code=in_postal_code,
|
||||
in_region=in_region,
|
||||
in_rate_center=in_rate_center,
|
||||
in_lata=in_lata,
|
||||
in_locality=in_locality,
|
||||
fax_enabled=fax_enabled,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[VoipInstance]:
|
||||
"""
|
||||
Lists VoipInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param int area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param str contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param bool sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param bool mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param bool voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param bool exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param str near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param int distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param bool fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return list(
|
||||
self.stream(
|
||||
area_code=area_code,
|
||||
contains=contains,
|
||||
sms_enabled=sms_enabled,
|
||||
mms_enabled=mms_enabled,
|
||||
voice_enabled=voice_enabled,
|
||||
exclude_all_address_required=exclude_all_address_required,
|
||||
exclude_local_address_required=exclude_local_address_required,
|
||||
exclude_foreign_address_required=exclude_foreign_address_required,
|
||||
beta=beta,
|
||||
near_number=near_number,
|
||||
near_lat_long=near_lat_long,
|
||||
distance=distance,
|
||||
in_postal_code=in_postal_code,
|
||||
in_region=in_region,
|
||||
in_rate_center=in_rate_center,
|
||||
in_lata=in_lata,
|
||||
in_locality=in_locality,
|
||||
fax_enabled=fax_enabled,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[VoipInstance]:
|
||||
"""
|
||||
Asynchronously lists VoipInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param int area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param str contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param bool sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param bool mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param bool voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param bool exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param bool beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param str near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param int distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param str in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param bool fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return [
|
||||
record
|
||||
async for record in await self.stream_async(
|
||||
area_code=area_code,
|
||||
contains=contains,
|
||||
sms_enabled=sms_enabled,
|
||||
mms_enabled=mms_enabled,
|
||||
voice_enabled=voice_enabled,
|
||||
exclude_all_address_required=exclude_all_address_required,
|
||||
exclude_local_address_required=exclude_local_address_required,
|
||||
exclude_foreign_address_required=exclude_foreign_address_required,
|
||||
beta=beta,
|
||||
near_number=near_number,
|
||||
near_lat_long=near_lat_long,
|
||||
distance=distance,
|
||||
in_postal_code=in_postal_code,
|
||||
in_region=in_region,
|
||||
in_rate_center=in_rate_center,
|
||||
in_lata=in_lata,
|
||||
in_locality=in_locality,
|
||||
fax_enabled=fax_enabled,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> VoipPage:
|
||||
"""
|
||||
Retrieve a single page of VoipInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of VoipInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"AreaCode": area_code,
|
||||
"Contains": contains,
|
||||
"SmsEnabled": sms_enabled,
|
||||
"MmsEnabled": mms_enabled,
|
||||
"VoiceEnabled": voice_enabled,
|
||||
"ExcludeAllAddressRequired": exclude_all_address_required,
|
||||
"ExcludeLocalAddressRequired": exclude_local_address_required,
|
||||
"ExcludeForeignAddressRequired": exclude_foreign_address_required,
|
||||
"Beta": beta,
|
||||
"NearNumber": near_number,
|
||||
"NearLatLong": near_lat_long,
|
||||
"Distance": distance,
|
||||
"InPostalCode": in_postal_code,
|
||||
"InRegion": in_region,
|
||||
"InRateCenter": in_rate_center,
|
||||
"InLata": in_lata,
|
||||
"InLocality": in_locality,
|
||||
"FaxEnabled": fax_enabled,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return VoipPage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
area_code: Union[int, object] = values.unset,
|
||||
contains: Union[str, object] = values.unset,
|
||||
sms_enabled: Union[bool, object] = values.unset,
|
||||
mms_enabled: Union[bool, object] = values.unset,
|
||||
voice_enabled: Union[bool, object] = values.unset,
|
||||
exclude_all_address_required: Union[bool, object] = values.unset,
|
||||
exclude_local_address_required: Union[bool, object] = values.unset,
|
||||
exclude_foreign_address_required: Union[bool, object] = values.unset,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
near_number: Union[str, object] = values.unset,
|
||||
near_lat_long: Union[str, object] = values.unset,
|
||||
distance: Union[int, object] = values.unset,
|
||||
in_postal_code: Union[str, object] = values.unset,
|
||||
in_region: Union[str, object] = values.unset,
|
||||
in_rate_center: Union[str, object] = values.unset,
|
||||
in_lata: Union[str, object] = values.unset,
|
||||
in_locality: Union[str, object] = values.unset,
|
||||
fax_enabled: Union[bool, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> VoipPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of VoipInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param area_code: The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
|
||||
:param contains: The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
|
||||
:param sms_enabled: Whether the phone numbers can receive text messages. Can be: `true` or `false`.
|
||||
:param mms_enabled: Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
|
||||
:param voice_enabled: Whether the phone numbers can receive calls. Can be: `true` or `false`.
|
||||
:param exclude_all_address_required: Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param exclude_local_address_required: Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param exclude_foreign_address_required: Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
|
||||
:param beta: Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param near_number: Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
|
||||
:param near_lat_long: Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
|
||||
:param distance: The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
|
||||
:param in_postal_code: Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_region: Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_rate_center: Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
|
||||
:param in_lata: Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
|
||||
:param in_locality: Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
|
||||
:param fax_enabled: Whether the phone numbers can receive faxes. Can be: `true` or `false`.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of VoipInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"AreaCode": area_code,
|
||||
"Contains": contains,
|
||||
"SmsEnabled": sms_enabled,
|
||||
"MmsEnabled": mms_enabled,
|
||||
"VoiceEnabled": voice_enabled,
|
||||
"ExcludeAllAddressRequired": exclude_all_address_required,
|
||||
"ExcludeLocalAddressRequired": exclude_local_address_required,
|
||||
"ExcludeForeignAddressRequired": exclude_foreign_address_required,
|
||||
"Beta": beta,
|
||||
"NearNumber": near_number,
|
||||
"NearLatLong": near_lat_long,
|
||||
"Distance": distance,
|
||||
"InPostalCode": in_postal_code,
|
||||
"InRegion": in_region,
|
||||
"InRateCenter": in_rate_center,
|
||||
"InLata": in_lata,
|
||||
"InLocality": in_locality,
|
||||
"FaxEnabled": fax_enabled,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return VoipPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> VoipPage:
|
||||
"""
|
||||
Retrieve a specific page of VoipInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of VoipInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return VoipPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> VoipPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of VoipInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of VoipInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return VoipPage(self._version, response, self._solution)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.VoipList>"
|
||||
@@ -0,0 +1,99 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from typing import Any, Dict, Optional
|
||||
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
|
||||
|
||||
class BalanceInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar account_sid: The unique SID identifier of the Account.
|
||||
:ivar balance: The balance of the Account, in units specified by the unit parameter. Balance changes may not be reflected immediately. Child accounts do not contain balance information
|
||||
:ivar currency: The units of currency for the account balance
|
||||
"""
|
||||
|
||||
def __init__(self, version: Version, payload: Dict[str, Any], account_sid: str):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.balance: Optional[str] = payload.get("balance")
|
||||
self.currency: Optional[str] = payload.get("currency")
|
||||
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
}
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.BalanceInstance {}>".format(context)
|
||||
|
||||
|
||||
class BalanceList(ListResource):
|
||||
def __init__(self, version: Version, account_sid: str):
|
||||
"""
|
||||
Initialize the BalanceList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The unique SID identifier of the Account.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/Balance.json".format(**self._solution)
|
||||
|
||||
def fetch(self) -> BalanceInstance:
|
||||
"""
|
||||
Asynchronously fetch the BalanceInstance
|
||||
|
||||
:returns: The fetched BalanceInstance
|
||||
"""
|
||||
payload = self._version.fetch(method="GET", uri=self._uri)
|
||||
|
||||
return BalanceInstance(
|
||||
self._version, payload, account_sid=self._solution["account_sid"]
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> BalanceInstance:
|
||||
"""
|
||||
Asynchronously fetch the BalanceInstance
|
||||
|
||||
:returns: The fetched BalanceInstance
|
||||
"""
|
||||
payload = await self._version.fetch_async(method="GET", uri=self._uri)
|
||||
|
||||
return BalanceInstance(
|
||||
self._version, payload, account_sid=self._solution["account_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.BalanceList>"
|
||||
File diff suppressed because it is too large
Load Diff
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -0,0 +1,288 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import values
|
||||
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.page import Page
|
||||
|
||||
|
||||
class EventInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar request: Contains a dictionary representing the request of the call.
|
||||
:ivar response: Contains a dictionary representing the call response, including a list of the call events.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self, version: Version, payload: Dict[str, Any], account_sid: str, call_sid: str
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.request: Optional[Dict[str, object]] = payload.get("request")
|
||||
self.response: Optional[Dict[str, object]] = payload.get("response")
|
||||
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"call_sid": call_sid,
|
||||
}
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.EventInstance {}>".format(context)
|
||||
|
||||
|
||||
class EventPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> EventInstance:
|
||||
"""
|
||||
Build an instance of EventInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return EventInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.EventPage>"
|
||||
|
||||
|
||||
class EventList(ListResource):
|
||||
def __init__(self, version: Version, account_sid: str, call_sid: str):
|
||||
"""
|
||||
Initialize the EventList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The unique SID identifier of the Account.
|
||||
:param call_sid: The unique SID identifier of the Call.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"call_sid": call_sid,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/Calls/{call_sid}/Events.json".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[EventInstance]:
|
||||
"""
|
||||
Streams EventInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[EventInstance]:
|
||||
"""
|
||||
Asynchronously streams EventInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[EventInstance]:
|
||||
"""
|
||||
Lists EventInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return list(
|
||||
self.stream(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[EventInstance]:
|
||||
"""
|
||||
Asynchronously lists EventInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return [
|
||||
record
|
||||
async for record in await self.stream_async(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> EventPage:
|
||||
"""
|
||||
Retrieve a single page of EventInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of EventInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return EventPage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> EventPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of EventInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of EventInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return EventPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> EventPage:
|
||||
"""
|
||||
Retrieve a specific page of EventInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of EventInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return EventPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> EventPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of EventInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of EventInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return EventPage(self._version, response, self._solution)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.EventList>"
|
||||
@@ -0,0 +1,331 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Union
|
||||
from twilio.base import deserialize, serialize, values
|
||||
from twilio.base.instance_context import InstanceContext
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
|
||||
|
||||
class FeedbackInstance(InstanceResource):
|
||||
class Issues(object):
|
||||
AUDIO_LATENCY = "audio-latency"
|
||||
DIGITS_NOT_CAPTURED = "digits-not-captured"
|
||||
DROPPED_CALL = "dropped-call"
|
||||
IMPERFECT_AUDIO = "imperfect-audio"
|
||||
INCORRECT_CALLER_ID = "incorrect-caller-id"
|
||||
ONE_WAY_AUDIO = "one-way-audio"
|
||||
POST_DIAL_DELAY = "post-dial-delay"
|
||||
UNSOLICITED_CALL = "unsolicited-call"
|
||||
|
||||
"""
|
||||
:ivar account_sid: The unique id of the [Account](https://www.twilio.com/docs/iam/api/account) responsible for this resource.
|
||||
:ivar date_created: The date that this resource was created, given in [RFC 2822](https://www.php.net/manual/en/class.datetime.php#datetime.constants.rfc2822) format.
|
||||
:ivar date_updated: The date that this resource was last updated, given in [RFC 2822](https://www.php.net/manual/en/class.datetime.php#datetime.constants.rfc2822) format.
|
||||
:ivar issues: A list of issues experienced during the call. The issues can be: `imperfect-audio`, `dropped-call`, `incorrect-caller-id`, `post-dial-delay`, `digits-not-captured`, `audio-latency`, `unsolicited-call`, or `one-way-audio`.
|
||||
:ivar quality_score: `1` to `5` quality score where `1` represents imperfect experience and `5` represents a perfect call.
|
||||
:ivar sid: A 34 character string that uniquely identifies this resource.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self, version: Version, payload: Dict[str, Any], account_sid: str, call_sid: str
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.date_created: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.issues: Optional[List["FeedbackInstance.Issues"]] = payload.get("issues")
|
||||
self.quality_score: Optional[int] = deserialize.integer(
|
||||
payload.get("quality_score")
|
||||
)
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"call_sid": call_sid,
|
||||
}
|
||||
self._context: Optional[FeedbackContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "FeedbackContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: FeedbackContext for this FeedbackInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = FeedbackContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def fetch(self) -> "FeedbackInstance":
|
||||
"""
|
||||
Fetch the FeedbackInstance
|
||||
|
||||
|
||||
:returns: The fetched FeedbackInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "FeedbackInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the FeedbackInstance
|
||||
|
||||
|
||||
:returns: The fetched FeedbackInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self,
|
||||
quality_score: Union[int, object] = values.unset,
|
||||
issue: Union[List["FeedbackInstance.Issues"], object] = values.unset,
|
||||
) -> "FeedbackInstance":
|
||||
"""
|
||||
Update the FeedbackInstance
|
||||
|
||||
:param quality_score: The call quality expressed as an integer from `1` to `5` where `1` represents very poor call quality and `5` represents a perfect call.
|
||||
:param issue: One or more issues experienced during the call. The issues can be: `imperfect-audio`, `dropped-call`, `incorrect-caller-id`, `post-dial-delay`, `digits-not-captured`, `audio-latency`, `unsolicited-call`, or `one-way-audio`.
|
||||
|
||||
:returns: The updated FeedbackInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
quality_score=quality_score,
|
||||
issue=issue,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
quality_score: Union[int, object] = values.unset,
|
||||
issue: Union[List["FeedbackInstance.Issues"], object] = values.unset,
|
||||
) -> "FeedbackInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the FeedbackInstance
|
||||
|
||||
:param quality_score: The call quality expressed as an integer from `1` to `5` where `1` represents very poor call quality and `5` represents a perfect call.
|
||||
:param issue: One or more issues experienced during the call. The issues can be: `imperfect-audio`, `dropped-call`, `incorrect-caller-id`, `post-dial-delay`, `digits-not-captured`, `audio-latency`, `unsolicited-call`, or `one-way-audio`.
|
||||
|
||||
:returns: The updated FeedbackInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
quality_score=quality_score,
|
||||
issue=issue,
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.FeedbackInstance {}>".format(context)
|
||||
|
||||
|
||||
class FeedbackContext(InstanceContext):
|
||||
def __init__(self, version: Version, account_sid: str, call_sid: str):
|
||||
"""
|
||||
Initialize the FeedbackContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The unique id of the [Account](https://www.twilio.com/docs/iam/api/account) responsible for this resource.
|
||||
:param call_sid: The call sid that uniquely identifies the call
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"call_sid": call_sid,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/Calls/{call_sid}/Feedback.json".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def fetch(self) -> FeedbackInstance:
|
||||
"""
|
||||
Fetch the FeedbackInstance
|
||||
|
||||
|
||||
:returns: The fetched FeedbackInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return FeedbackInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> FeedbackInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the FeedbackInstance
|
||||
|
||||
|
||||
:returns: The fetched FeedbackInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return FeedbackInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self,
|
||||
quality_score: Union[int, object] = values.unset,
|
||||
issue: Union[List["FeedbackInstance.Issues"], object] = values.unset,
|
||||
) -> FeedbackInstance:
|
||||
"""
|
||||
Update the FeedbackInstance
|
||||
|
||||
:param quality_score: The call quality expressed as an integer from `1` to `5` where `1` represents very poor call quality and `5` represents a perfect call.
|
||||
:param issue: One or more issues experienced during the call. The issues can be: `imperfect-audio`, `dropped-call`, `incorrect-caller-id`, `post-dial-delay`, `digits-not-captured`, `audio-latency`, `unsolicited-call`, or `one-way-audio`.
|
||||
|
||||
:returns: The updated FeedbackInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"QualityScore": quality_score,
|
||||
"Issue": serialize.map(issue, lambda e: e),
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return FeedbackInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
quality_score: Union[int, object] = values.unset,
|
||||
issue: Union[List["FeedbackInstance.Issues"], object] = values.unset,
|
||||
) -> FeedbackInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the FeedbackInstance
|
||||
|
||||
:param quality_score: The call quality expressed as an integer from `1` to `5` where `1` represents very poor call quality and `5` represents a perfect call.
|
||||
:param issue: One or more issues experienced during the call. The issues can be: `imperfect-audio`, `dropped-call`, `incorrect-caller-id`, `post-dial-delay`, `digits-not-captured`, `audio-latency`, `unsolicited-call`, or `one-way-audio`.
|
||||
|
||||
:returns: The updated FeedbackInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"QualityScore": quality_score,
|
||||
"Issue": serialize.map(issue, lambda e: e),
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return FeedbackInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.FeedbackContext {}>".format(context)
|
||||
|
||||
|
||||
class FeedbackList(ListResource):
|
||||
def __init__(self, version: Version, account_sid: str, call_sid: str):
|
||||
"""
|
||||
Initialize the FeedbackList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The unique id of the [Account](https://www.twilio.com/docs/iam/api/account) responsible for this resource.
|
||||
:param call_sid: The call sid that uniquely identifies the call
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"call_sid": call_sid,
|
||||
}
|
||||
|
||||
def get(self) -> FeedbackContext:
|
||||
"""
|
||||
Constructs a FeedbackContext
|
||||
|
||||
"""
|
||||
return FeedbackContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
)
|
||||
|
||||
def __call__(self) -> FeedbackContext:
|
||||
"""
|
||||
Constructs a FeedbackContext
|
||||
|
||||
"""
|
||||
return FeedbackContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.FeedbackList>"
|
||||
+374
@@ -0,0 +1,374 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from datetime import date, datetime
|
||||
from typing import Any, Dict, List, Optional, Union
|
||||
from twilio.base import deserialize, serialize, values
|
||||
from twilio.base.instance_context import InstanceContext
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
|
||||
|
||||
class FeedbackSummaryInstance(InstanceResource):
|
||||
class Status(object):
|
||||
QUEUED = "queued"
|
||||
IN_PROGRESS = "in-progress"
|
||||
COMPLETED = "completed"
|
||||
FAILED = "failed"
|
||||
|
||||
"""
|
||||
:ivar account_sid: The unique id of the [Account](https://www.twilio.com/docs/iam/api/account) responsible for this resource.
|
||||
:ivar call_count: The total number of calls.
|
||||
:ivar call_feedback_count: The total number of calls with a feedback entry.
|
||||
:ivar date_created: The date that this resource was created, given in [RFC 2822](https://www.php.net/manual/en/class.datetime.php#datetime.constants.rfc2822) format.
|
||||
:ivar date_updated: The date that this resource was last updated, given in [RFC 2822](https://www.php.net/manual/en/class.datetime.php#datetime.constants.rfc2822) format.
|
||||
:ivar end_date: The last date for which feedback entries are included in this Feedback Summary, formatted as `YYYY-MM-DD` and specified in UTC.
|
||||
:ivar include_subaccounts: Whether the feedback summary includes subaccounts; `true` if it does, otherwise `false`.
|
||||
:ivar issues: A list of issues experienced during the call. The issues can be: `imperfect-audio`, `dropped-call`, `incorrect-caller-id`, `post-dial-delay`, `digits-not-captured`, `audio-latency`, or `one-way-audio`.
|
||||
:ivar quality_score_average: The average QualityScore of the feedback entries.
|
||||
:ivar quality_score_median: The median QualityScore of the feedback entries.
|
||||
:ivar quality_score_standard_deviation: The standard deviation of the quality scores.
|
||||
:ivar sid: A 34 character string that uniquely identifies this resource.
|
||||
:ivar start_date: The first date for which feedback entries are included in this feedback summary, formatted as `YYYY-MM-DD` and specified in UTC.
|
||||
:ivar status:
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
account_sid: str,
|
||||
sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.call_count: Optional[int] = deserialize.integer(payload.get("call_count"))
|
||||
self.call_feedback_count: Optional[int] = deserialize.integer(
|
||||
payload.get("call_feedback_count")
|
||||
)
|
||||
self.date_created: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.end_date: Optional[date] = deserialize.iso8601_date(
|
||||
payload.get("end_date")
|
||||
)
|
||||
self.include_subaccounts: Optional[bool] = payload.get("include_subaccounts")
|
||||
self.issues: Optional[List[object]] = payload.get("issues")
|
||||
self.quality_score_average: Optional[float] = deserialize.decimal(
|
||||
payload.get("quality_score_average")
|
||||
)
|
||||
self.quality_score_median: Optional[float] = deserialize.decimal(
|
||||
payload.get("quality_score_median")
|
||||
)
|
||||
self.quality_score_standard_deviation: Optional[float] = deserialize.decimal(
|
||||
payload.get("quality_score_standard_deviation")
|
||||
)
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.start_date: Optional[date] = deserialize.iso8601_date(
|
||||
payload.get("start_date")
|
||||
)
|
||||
self.status: Optional["FeedbackSummaryInstance.Status"] = payload.get("status")
|
||||
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[FeedbackSummaryContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "FeedbackSummaryContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: FeedbackSummaryContext for this FeedbackSummaryInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = FeedbackSummaryContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the FeedbackSummaryInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the FeedbackSummaryInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
def fetch(self) -> "FeedbackSummaryInstance":
|
||||
"""
|
||||
Fetch the FeedbackSummaryInstance
|
||||
|
||||
|
||||
:returns: The fetched FeedbackSummaryInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "FeedbackSummaryInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the FeedbackSummaryInstance
|
||||
|
||||
|
||||
:returns: The fetched FeedbackSummaryInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.FeedbackSummaryInstance {}>".format(context)
|
||||
|
||||
|
||||
class FeedbackSummaryContext(InstanceContext):
|
||||
def __init__(self, version: Version, account_sid: str, sid: str):
|
||||
"""
|
||||
Initialize the FeedbackSummaryContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The unique id of the [Account](https://www.twilio.com/docs/iam/api/account) responsible for this resource.
|
||||
:param sid: A 34 character string that uniquely identifies this resource.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/Calls/FeedbackSummary/{sid}.json".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the FeedbackSummaryInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._version.delete(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the FeedbackSummaryInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
def fetch(self) -> FeedbackSummaryInstance:
|
||||
"""
|
||||
Fetch the FeedbackSummaryInstance
|
||||
|
||||
|
||||
:returns: The fetched FeedbackSummaryInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return FeedbackSummaryInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> FeedbackSummaryInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the FeedbackSummaryInstance
|
||||
|
||||
|
||||
:returns: The fetched FeedbackSummaryInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return FeedbackSummaryInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.FeedbackSummaryContext {}>".format(context)
|
||||
|
||||
|
||||
class FeedbackSummaryList(ListResource):
|
||||
def __init__(self, version: Version, account_sid: str):
|
||||
"""
|
||||
Initialize the FeedbackSummaryList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The unique id of the [Account](https://www.twilio.com/docs/iam/api/account) responsible for this resource.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/Calls/FeedbackSummary.json".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def create(
|
||||
self,
|
||||
start_date: date,
|
||||
end_date: date,
|
||||
include_subaccounts: Union[bool, object] = values.unset,
|
||||
status_callback: Union[str, object] = values.unset,
|
||||
status_callback_method: Union[str, object] = values.unset,
|
||||
) -> FeedbackSummaryInstance:
|
||||
"""
|
||||
Create the FeedbackSummaryInstance
|
||||
|
||||
:param start_date: Only include feedback given on or after this date. Format is `YYYY-MM-DD` and specified in UTC.
|
||||
:param end_date: Only include feedback given on or before this date. Format is `YYYY-MM-DD` and specified in UTC.
|
||||
:param include_subaccounts: Whether to also include Feedback resources from all subaccounts. `true` includes feedback from all subaccounts and `false`, the default, includes feedback from only the specified account.
|
||||
:param status_callback: The URL that we will request when the feedback summary is complete.
|
||||
:param status_callback_method: The HTTP method (`GET` or `POST`) we use to make the request to the `StatusCallback` URL.
|
||||
|
||||
:returns: The created FeedbackSummaryInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"StartDate": serialize.iso8601_date(start_date),
|
||||
"EndDate": serialize.iso8601_date(end_date),
|
||||
"IncludeSubaccounts": include_subaccounts,
|
||||
"StatusCallback": status_callback,
|
||||
"StatusCallbackMethod": status_callback_method,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return FeedbackSummaryInstance(
|
||||
self._version, payload, account_sid=self._solution["account_sid"]
|
||||
)
|
||||
|
||||
async def create_async(
|
||||
self,
|
||||
start_date: date,
|
||||
end_date: date,
|
||||
include_subaccounts: Union[bool, object] = values.unset,
|
||||
status_callback: Union[str, object] = values.unset,
|
||||
status_callback_method: Union[str, object] = values.unset,
|
||||
) -> FeedbackSummaryInstance:
|
||||
"""
|
||||
Asynchronously create the FeedbackSummaryInstance
|
||||
|
||||
:param start_date: Only include feedback given on or after this date. Format is `YYYY-MM-DD` and specified in UTC.
|
||||
:param end_date: Only include feedback given on or before this date. Format is `YYYY-MM-DD` and specified in UTC.
|
||||
:param include_subaccounts: Whether to also include Feedback resources from all subaccounts. `true` includes feedback from all subaccounts and `false`, the default, includes feedback from only the specified account.
|
||||
:param status_callback: The URL that we will request when the feedback summary is complete.
|
||||
:param status_callback_method: The HTTP method (`GET` or `POST`) we use to make the request to the `StatusCallback` URL.
|
||||
|
||||
:returns: The created FeedbackSummaryInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"StartDate": serialize.iso8601_date(start_date),
|
||||
"EndDate": serialize.iso8601_date(end_date),
|
||||
"IncludeSubaccounts": include_subaccounts,
|
||||
"StatusCallback": status_callback,
|
||||
"StatusCallbackMethod": status_callback_method,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return FeedbackSummaryInstance(
|
||||
self._version, payload, account_sid=self._solution["account_sid"]
|
||||
)
|
||||
|
||||
def get(self, sid: str) -> FeedbackSummaryContext:
|
||||
"""
|
||||
Constructs a FeedbackSummaryContext
|
||||
|
||||
:param sid: A 34 character string that uniquely identifies this resource.
|
||||
"""
|
||||
return FeedbackSummaryContext(
|
||||
self._version, account_sid=self._solution["account_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> FeedbackSummaryContext:
|
||||
"""
|
||||
Constructs a FeedbackSummaryContext
|
||||
|
||||
:param sid: A 34 character string that uniquely identifies this resource.
|
||||
"""
|
||||
return FeedbackSummaryContext(
|
||||
self._version, account_sid=self._solution["account_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.FeedbackSummaryList>"
|
||||
@@ -0,0 +1,547 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from datetime import date, datetime
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, serialize, values
|
||||
from twilio.base.instance_context import InstanceContext
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.page import Page
|
||||
|
||||
|
||||
class NotificationInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Call Notification resource.
|
||||
:ivar api_version: The API version used to create the Call Notification resource.
|
||||
:ivar call_sid: The SID of the [Call](https://www.twilio.com/docs/voice/api/call-resource) the Call Notification resource is associated with.
|
||||
:ivar date_created: The date and time in GMT that the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar date_updated: The date and time in GMT that the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar error_code: A unique error code for the error condition that is described in our [Error Dictionary](https://www.twilio.com/docs/api/errors).
|
||||
:ivar log: An integer log level that corresponds to the type of notification: `0` is ERROR, `1` is WARNING.
|
||||
:ivar message_date: The date the notification was actually generated in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. Message buffering can cause this value to differ from `date_created`.
|
||||
:ivar message_text: The text of the notification.
|
||||
:ivar more_info: The URL for more information about the error condition. This value is a page in our [Error Dictionary](https://www.twilio.com/docs/api/errors).
|
||||
:ivar request_method: The HTTP method used to generate the notification. If the notification was generated during a phone call, this is the HTTP Method used to request the resource on your server. If the notification was generated by your use of our REST API, this is the HTTP method used to call the resource on our servers.
|
||||
:ivar request_url: The URL of the resource that generated the notification. If the notification was generated during a phone call, this is the URL of the resource on your server that caused the notification. If the notification was generated by your use of our REST API, this is the URL of the resource you called.
|
||||
:ivar request_variables: The HTTP GET or POST variables we sent to your server. However, if the notification was generated by our REST API, this contains the HTTP POST or PUT variables you sent to our API.
|
||||
:ivar response_body: The HTTP body returned by your server.
|
||||
:ivar response_headers: The HTTP headers returned by your server.
|
||||
:ivar sid: The unique string that that we created to identify the Call Notification resource.
|
||||
:ivar uri: The URI of the resource, relative to `https://api.twilio.com`.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
account_sid: str,
|
||||
call_sid: str,
|
||||
sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.api_version: Optional[str] = payload.get("api_version")
|
||||
self.call_sid: Optional[str] = payload.get("call_sid")
|
||||
self.date_created: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.error_code: Optional[str] = payload.get("error_code")
|
||||
self.log: Optional[str] = payload.get("log")
|
||||
self.message_date: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("message_date")
|
||||
)
|
||||
self.message_text: Optional[str] = payload.get("message_text")
|
||||
self.more_info: Optional[str] = payload.get("more_info")
|
||||
self.request_method: Optional[str] = payload.get("request_method")
|
||||
self.request_url: Optional[str] = payload.get("request_url")
|
||||
self.request_variables: Optional[str] = payload.get("request_variables")
|
||||
self.response_body: Optional[str] = payload.get("response_body")
|
||||
self.response_headers: Optional[str] = payload.get("response_headers")
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.uri: Optional[str] = payload.get("uri")
|
||||
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"call_sid": call_sid,
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[NotificationContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "NotificationContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: NotificationContext for this NotificationInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = NotificationContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def fetch(self) -> "NotificationInstance":
|
||||
"""
|
||||
Fetch the NotificationInstance
|
||||
|
||||
|
||||
:returns: The fetched NotificationInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "NotificationInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the NotificationInstance
|
||||
|
||||
|
||||
:returns: The fetched NotificationInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.NotificationInstance {}>".format(context)
|
||||
|
||||
|
||||
class NotificationContext(InstanceContext):
|
||||
def __init__(self, version: Version, account_sid: str, call_sid: str, sid: str):
|
||||
"""
|
||||
Initialize the NotificationContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Call Notification resource to fetch.
|
||||
:param call_sid: The [Call](https://www.twilio.com/docs/voice/api/call-resource) SID of the Call Notification resource to fetch.
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Call Notification resource to fetch.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"call_sid": call_sid,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = (
|
||||
"/Accounts/{account_sid}/Calls/{call_sid}/Notifications/{sid}.json".format(
|
||||
**self._solution
|
||||
)
|
||||
)
|
||||
|
||||
def fetch(self) -> NotificationInstance:
|
||||
"""
|
||||
Fetch the NotificationInstance
|
||||
|
||||
|
||||
:returns: The fetched NotificationInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return NotificationInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> NotificationInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the NotificationInstance
|
||||
|
||||
|
||||
:returns: The fetched NotificationInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return NotificationInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.NotificationContext {}>".format(context)
|
||||
|
||||
|
||||
class NotificationPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> NotificationInstance:
|
||||
"""
|
||||
Build an instance of NotificationInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return NotificationInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.NotificationPage>"
|
||||
|
||||
|
||||
class NotificationList(ListResource):
|
||||
def __init__(self, version: Version, account_sid: str, call_sid: str):
|
||||
"""
|
||||
Initialize the NotificationList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Call Notification resources to read.
|
||||
:param call_sid: The [Call](https://www.twilio.com/docs/voice/api/call-resource) SID of the Call Notification resources to read.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"call_sid": call_sid,
|
||||
}
|
||||
self._uri = (
|
||||
"/Accounts/{account_sid}/Calls/{call_sid}/Notifications.json".format(
|
||||
**self._solution
|
||||
)
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
log: Union[int, object] = values.unset,
|
||||
message_date: Union[date, object] = values.unset,
|
||||
message_date_before: Union[date, object] = values.unset,
|
||||
message_date_after: Union[date, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[NotificationInstance]:
|
||||
"""
|
||||
Streams NotificationInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param int log: Only read notifications of the specified log level. Can be: `0` to read only ERROR notifications or `1` to read only WARNING notifications. By default, all notifications are read.
|
||||
:param date message_date: Only show notifications for the specified date, formatted as `YYYY-MM-DD`. You can also specify an inequality, such as `<=YYYY-MM-DD` for messages logged at or before midnight on a date, or `>=YYYY-MM-DD` for messages logged at or after midnight on a date.
|
||||
:param date message_date_before: Only show notifications for the specified date, formatted as `YYYY-MM-DD`. You can also specify an inequality, such as `<=YYYY-MM-DD` for messages logged at or before midnight on a date, or `>=YYYY-MM-DD` for messages logged at or after midnight on a date.
|
||||
:param date message_date_after: Only show notifications for the specified date, formatted as `YYYY-MM-DD`. You can also specify an inequality, such as `<=YYYY-MM-DD` for messages logged at or before midnight on a date, or `>=YYYY-MM-DD` for messages logged at or after midnight on a date.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(
|
||||
log=log,
|
||||
message_date=message_date,
|
||||
message_date_before=message_date_before,
|
||||
message_date_after=message_date_after,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
log: Union[int, object] = values.unset,
|
||||
message_date: Union[date, object] = values.unset,
|
||||
message_date_before: Union[date, object] = values.unset,
|
||||
message_date_after: Union[date, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[NotificationInstance]:
|
||||
"""
|
||||
Asynchronously streams NotificationInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param int log: Only read notifications of the specified log level. Can be: `0` to read only ERROR notifications or `1` to read only WARNING notifications. By default, all notifications are read.
|
||||
:param date message_date: Only show notifications for the specified date, formatted as `YYYY-MM-DD`. You can also specify an inequality, such as `<=YYYY-MM-DD` for messages logged at or before midnight on a date, or `>=YYYY-MM-DD` for messages logged at or after midnight on a date.
|
||||
:param date message_date_before: Only show notifications for the specified date, formatted as `YYYY-MM-DD`. You can also specify an inequality, such as `<=YYYY-MM-DD` for messages logged at or before midnight on a date, or `>=YYYY-MM-DD` for messages logged at or after midnight on a date.
|
||||
:param date message_date_after: Only show notifications for the specified date, formatted as `YYYY-MM-DD`. You can also specify an inequality, such as `<=YYYY-MM-DD` for messages logged at or before midnight on a date, or `>=YYYY-MM-DD` for messages logged at or after midnight on a date.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(
|
||||
log=log,
|
||||
message_date=message_date,
|
||||
message_date_before=message_date_before,
|
||||
message_date_after=message_date_after,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
log: Union[int, object] = values.unset,
|
||||
message_date: Union[date, object] = values.unset,
|
||||
message_date_before: Union[date, object] = values.unset,
|
||||
message_date_after: Union[date, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[NotificationInstance]:
|
||||
"""
|
||||
Lists NotificationInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param int log: Only read notifications of the specified log level. Can be: `0` to read only ERROR notifications or `1` to read only WARNING notifications. By default, all notifications are read.
|
||||
:param date message_date: Only show notifications for the specified date, formatted as `YYYY-MM-DD`. You can also specify an inequality, such as `<=YYYY-MM-DD` for messages logged at or before midnight on a date, or `>=YYYY-MM-DD` for messages logged at or after midnight on a date.
|
||||
:param date message_date_before: Only show notifications for the specified date, formatted as `YYYY-MM-DD`. You can also specify an inequality, such as `<=YYYY-MM-DD` for messages logged at or before midnight on a date, or `>=YYYY-MM-DD` for messages logged at or after midnight on a date.
|
||||
:param date message_date_after: Only show notifications for the specified date, formatted as `YYYY-MM-DD`. You can also specify an inequality, such as `<=YYYY-MM-DD` for messages logged at or before midnight on a date, or `>=YYYY-MM-DD` for messages logged at or after midnight on a date.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return list(
|
||||
self.stream(
|
||||
log=log,
|
||||
message_date=message_date,
|
||||
message_date_before=message_date_before,
|
||||
message_date_after=message_date_after,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
log: Union[int, object] = values.unset,
|
||||
message_date: Union[date, object] = values.unset,
|
||||
message_date_before: Union[date, object] = values.unset,
|
||||
message_date_after: Union[date, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[NotificationInstance]:
|
||||
"""
|
||||
Asynchronously lists NotificationInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param int log: Only read notifications of the specified log level. Can be: `0` to read only ERROR notifications or `1` to read only WARNING notifications. By default, all notifications are read.
|
||||
:param date message_date: Only show notifications for the specified date, formatted as `YYYY-MM-DD`. You can also specify an inequality, such as `<=YYYY-MM-DD` for messages logged at or before midnight on a date, or `>=YYYY-MM-DD` for messages logged at or after midnight on a date.
|
||||
:param date message_date_before: Only show notifications for the specified date, formatted as `YYYY-MM-DD`. You can also specify an inequality, such as `<=YYYY-MM-DD` for messages logged at or before midnight on a date, or `>=YYYY-MM-DD` for messages logged at or after midnight on a date.
|
||||
:param date message_date_after: Only show notifications for the specified date, formatted as `YYYY-MM-DD`. You can also specify an inequality, such as `<=YYYY-MM-DD` for messages logged at or before midnight on a date, or `>=YYYY-MM-DD` for messages logged at or after midnight on a date.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return [
|
||||
record
|
||||
async for record in await self.stream_async(
|
||||
log=log,
|
||||
message_date=message_date,
|
||||
message_date_before=message_date_before,
|
||||
message_date_after=message_date_after,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
log: Union[int, object] = values.unset,
|
||||
message_date: Union[date, object] = values.unset,
|
||||
message_date_before: Union[date, object] = values.unset,
|
||||
message_date_after: Union[date, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> NotificationPage:
|
||||
"""
|
||||
Retrieve a single page of NotificationInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param log: Only read notifications of the specified log level. Can be: `0` to read only ERROR notifications or `1` to read only WARNING notifications. By default, all notifications are read.
|
||||
:param message_date: Only show notifications for the specified date, formatted as `YYYY-MM-DD`. You can also specify an inequality, such as `<=YYYY-MM-DD` for messages logged at or before midnight on a date, or `>=YYYY-MM-DD` for messages logged at or after midnight on a date.
|
||||
:param message_date_before: Only show notifications for the specified date, formatted as `YYYY-MM-DD`. You can also specify an inequality, such as `<=YYYY-MM-DD` for messages logged at or before midnight on a date, or `>=YYYY-MM-DD` for messages logged at or after midnight on a date.
|
||||
:param message_date_after: Only show notifications for the specified date, formatted as `YYYY-MM-DD`. You can also specify an inequality, such as `<=YYYY-MM-DD` for messages logged at or before midnight on a date, or `>=YYYY-MM-DD` for messages logged at or after midnight on a date.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of NotificationInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Log": log,
|
||||
"MessageDate": serialize.iso8601_date(message_date),
|
||||
"MessageDate<": serialize.iso8601_date(message_date_before),
|
||||
"MessageDate>": serialize.iso8601_date(message_date_after),
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return NotificationPage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
log: Union[int, object] = values.unset,
|
||||
message_date: Union[date, object] = values.unset,
|
||||
message_date_before: Union[date, object] = values.unset,
|
||||
message_date_after: Union[date, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> NotificationPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of NotificationInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param log: Only read notifications of the specified log level. Can be: `0` to read only ERROR notifications or `1` to read only WARNING notifications. By default, all notifications are read.
|
||||
:param message_date: Only show notifications for the specified date, formatted as `YYYY-MM-DD`. You can also specify an inequality, such as `<=YYYY-MM-DD` for messages logged at or before midnight on a date, or `>=YYYY-MM-DD` for messages logged at or after midnight on a date.
|
||||
:param message_date_before: Only show notifications for the specified date, formatted as `YYYY-MM-DD`. You can also specify an inequality, such as `<=YYYY-MM-DD` for messages logged at or before midnight on a date, or `>=YYYY-MM-DD` for messages logged at or after midnight on a date.
|
||||
:param message_date_after: Only show notifications for the specified date, formatted as `YYYY-MM-DD`. You can also specify an inequality, such as `<=YYYY-MM-DD` for messages logged at or before midnight on a date, or `>=YYYY-MM-DD` for messages logged at or after midnight on a date.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of NotificationInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Log": log,
|
||||
"MessageDate": serialize.iso8601_date(message_date),
|
||||
"MessageDate<": serialize.iso8601_date(message_date_before),
|
||||
"MessageDate>": serialize.iso8601_date(message_date_after),
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return NotificationPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> NotificationPage:
|
||||
"""
|
||||
Retrieve a specific page of NotificationInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of NotificationInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return NotificationPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> NotificationPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of NotificationInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of NotificationInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return NotificationPage(self._version, response, self._solution)
|
||||
|
||||
def get(self, sid: str) -> NotificationContext:
|
||||
"""
|
||||
Constructs a NotificationContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Call Notification resource to fetch.
|
||||
"""
|
||||
return NotificationContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
sid=sid,
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> NotificationContext:
|
||||
"""
|
||||
Constructs a NotificationContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Call Notification resource to fetch.
|
||||
"""
|
||||
return NotificationContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
sid=sid,
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.NotificationList>"
|
||||
@@ -0,0 +1,484 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, Optional, Union
|
||||
from twilio.base import deserialize, serialize, values
|
||||
from twilio.base.instance_context import InstanceContext
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
|
||||
|
||||
class PaymentInstance(InstanceResource):
|
||||
class BankAccountType(object):
|
||||
CONSUMER_CHECKING = "consumer-checking"
|
||||
CONSUMER_SAVINGS = "consumer-savings"
|
||||
COMMERCIAL_CHECKING = "commercial-checking"
|
||||
|
||||
class Capture(object):
|
||||
PAYMENT_CARD_NUMBER = "payment-card-number"
|
||||
EXPIRATION_DATE = "expiration-date"
|
||||
SECURITY_CODE = "security-code"
|
||||
POSTAL_CODE = "postal-code"
|
||||
BANK_ROUTING_NUMBER = "bank-routing-number"
|
||||
BANK_ACCOUNT_NUMBER = "bank-account-number"
|
||||
|
||||
class PaymentMethod(object):
|
||||
CREDIT_CARD = "credit-card"
|
||||
ACH_DEBIT = "ach-debit"
|
||||
|
||||
class Status(object):
|
||||
COMPLETE = "complete"
|
||||
CANCEL = "cancel"
|
||||
|
||||
class TokenType(object):
|
||||
ONE_TIME = "one-time"
|
||||
REUSABLE = "reusable"
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Payments resource.
|
||||
:ivar call_sid: The SID of the [Call](https://www.twilio.com/docs/voice/api/call-resource) the Payments resource is associated with. This will refer to the call sid that is producing the payment card (credit/ACH) information thru DTMF.
|
||||
:ivar sid: The SID of the Payments resource.
|
||||
:ivar date_created: The date and time in GMT that the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar date_updated: The date and time in GMT that the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar uri: The URI of the resource, relative to `https://api.twilio.com`.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
account_sid: str,
|
||||
call_sid: str,
|
||||
sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.call_sid: Optional[str] = payload.get("call_sid")
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.date_created: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.uri: Optional[str] = payload.get("uri")
|
||||
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"call_sid": call_sid,
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[PaymentContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "PaymentContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: PaymentContext for this PaymentInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = PaymentContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def update(
|
||||
self,
|
||||
idempotency_key: str,
|
||||
status_callback: str,
|
||||
capture: Union["PaymentInstance.Capture", object] = values.unset,
|
||||
status: Union["PaymentInstance.Status", object] = values.unset,
|
||||
) -> "PaymentInstance":
|
||||
"""
|
||||
Update the PaymentInstance
|
||||
|
||||
:param idempotency_key: A unique token that will be used to ensure that multiple API calls with the same information do not result in multiple transactions. This should be a unique string value per API call and can be a randomly generated.
|
||||
:param status_callback: Provide an absolute or relative URL to receive status updates regarding your Pay session. Read more about the [Update](https://www.twilio.com/docs/voice/api/payment-resource#statuscallback-update) and [Complete/Cancel](https://www.twilio.com/docs/voice/api/payment-resource#statuscallback-cancelcomplete) POST requests.
|
||||
:param capture:
|
||||
:param status:
|
||||
|
||||
:returns: The updated PaymentInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
idempotency_key=idempotency_key,
|
||||
status_callback=status_callback,
|
||||
capture=capture,
|
||||
status=status,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
idempotency_key: str,
|
||||
status_callback: str,
|
||||
capture: Union["PaymentInstance.Capture", object] = values.unset,
|
||||
status: Union["PaymentInstance.Status", object] = values.unset,
|
||||
) -> "PaymentInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the PaymentInstance
|
||||
|
||||
:param idempotency_key: A unique token that will be used to ensure that multiple API calls with the same information do not result in multiple transactions. This should be a unique string value per API call and can be a randomly generated.
|
||||
:param status_callback: Provide an absolute or relative URL to receive status updates regarding your Pay session. Read more about the [Update](https://www.twilio.com/docs/voice/api/payment-resource#statuscallback-update) and [Complete/Cancel](https://www.twilio.com/docs/voice/api/payment-resource#statuscallback-cancelcomplete) POST requests.
|
||||
:param capture:
|
||||
:param status:
|
||||
|
||||
:returns: The updated PaymentInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
idempotency_key=idempotency_key,
|
||||
status_callback=status_callback,
|
||||
capture=capture,
|
||||
status=status,
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.PaymentInstance {}>".format(context)
|
||||
|
||||
|
||||
class PaymentContext(InstanceContext):
|
||||
def __init__(self, version: Version, account_sid: str, call_sid: str, sid: str):
|
||||
"""
|
||||
Initialize the PaymentContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that will update the resource.
|
||||
:param call_sid: The SID of the call that will update the resource. This should be the same call sid that was used to create payments resource.
|
||||
:param sid: The SID of Payments session that needs to be updated.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"call_sid": call_sid,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = (
|
||||
"/Accounts/{account_sid}/Calls/{call_sid}/Payments/{sid}.json".format(
|
||||
**self._solution
|
||||
)
|
||||
)
|
||||
|
||||
def update(
|
||||
self,
|
||||
idempotency_key: str,
|
||||
status_callback: str,
|
||||
capture: Union["PaymentInstance.Capture", object] = values.unset,
|
||||
status: Union["PaymentInstance.Status", object] = values.unset,
|
||||
) -> PaymentInstance:
|
||||
"""
|
||||
Update the PaymentInstance
|
||||
|
||||
:param idempotency_key: A unique token that will be used to ensure that multiple API calls with the same information do not result in multiple transactions. This should be a unique string value per API call and can be a randomly generated.
|
||||
:param status_callback: Provide an absolute or relative URL to receive status updates regarding your Pay session. Read more about the [Update](https://www.twilio.com/docs/voice/api/payment-resource#statuscallback-update) and [Complete/Cancel](https://www.twilio.com/docs/voice/api/payment-resource#statuscallback-cancelcomplete) POST requests.
|
||||
:param capture:
|
||||
:param status:
|
||||
|
||||
:returns: The updated PaymentInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"IdempotencyKey": idempotency_key,
|
||||
"StatusCallback": status_callback,
|
||||
"Capture": capture,
|
||||
"Status": status,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return PaymentInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
idempotency_key: str,
|
||||
status_callback: str,
|
||||
capture: Union["PaymentInstance.Capture", object] = values.unset,
|
||||
status: Union["PaymentInstance.Status", object] = values.unset,
|
||||
) -> PaymentInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the PaymentInstance
|
||||
|
||||
:param idempotency_key: A unique token that will be used to ensure that multiple API calls with the same information do not result in multiple transactions. This should be a unique string value per API call and can be a randomly generated.
|
||||
:param status_callback: Provide an absolute or relative URL to receive status updates regarding your Pay session. Read more about the [Update](https://www.twilio.com/docs/voice/api/payment-resource#statuscallback-update) and [Complete/Cancel](https://www.twilio.com/docs/voice/api/payment-resource#statuscallback-cancelcomplete) POST requests.
|
||||
:param capture:
|
||||
:param status:
|
||||
|
||||
:returns: The updated PaymentInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"IdempotencyKey": idempotency_key,
|
||||
"StatusCallback": status_callback,
|
||||
"Capture": capture,
|
||||
"Status": status,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return PaymentInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.PaymentContext {}>".format(context)
|
||||
|
||||
|
||||
class PaymentList(ListResource):
|
||||
def __init__(self, version: Version, account_sid: str, call_sid: str):
|
||||
"""
|
||||
Initialize the PaymentList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that will create the resource.
|
||||
:param call_sid: The SID of the call that will create the resource. Call leg associated with this sid is expected to provide payment information thru DTMF.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"call_sid": call_sid,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/Calls/{call_sid}/Payments.json".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def create(
|
||||
self,
|
||||
idempotency_key: str,
|
||||
status_callback: str,
|
||||
bank_account_type: Union[
|
||||
"PaymentInstance.BankAccountType", object
|
||||
] = values.unset,
|
||||
charge_amount: Union[float, object] = values.unset,
|
||||
currency: Union[str, object] = values.unset,
|
||||
description: Union[str, object] = values.unset,
|
||||
input: Union[str, object] = values.unset,
|
||||
min_postal_code_length: Union[int, object] = values.unset,
|
||||
parameter: Union[object, object] = values.unset,
|
||||
payment_connector: Union[str, object] = values.unset,
|
||||
payment_method: Union["PaymentInstance.PaymentMethod", object] = values.unset,
|
||||
postal_code: Union[bool, object] = values.unset,
|
||||
security_code: Union[bool, object] = values.unset,
|
||||
timeout: Union[int, object] = values.unset,
|
||||
token_type: Union["PaymentInstance.TokenType", object] = values.unset,
|
||||
valid_card_types: Union[str, object] = values.unset,
|
||||
) -> PaymentInstance:
|
||||
"""
|
||||
Create the PaymentInstance
|
||||
|
||||
:param idempotency_key: A unique token that will be used to ensure that multiple API calls with the same information do not result in multiple transactions. This should be a unique string value per API call and can be a randomly generated.
|
||||
:param status_callback: Provide an absolute or relative URL to receive status updates regarding your Pay session. Read more about the [expected StatusCallback values](https://www.twilio.com/docs/voice/api/payment-resource#statuscallback)
|
||||
:param bank_account_type:
|
||||
:param charge_amount: A positive decimal value less than 1,000,000 to charge against the credit card or bank account. Default currency can be overwritten with `currency` field. Leave blank or set to 0 to tokenize.
|
||||
:param currency: The currency of the `charge_amount`, formatted as [ISO 4127](http://www.iso.org/iso/home/standards/currency_codes.htm) format. The default value is `USD` and all values allowed from the Pay Connector are accepted.
|
||||
:param description: The description can be used to provide more details regarding the transaction. This information is submitted along with the payment details to the Payment Connector which are then posted on the transactions.
|
||||
:param input: A list of inputs that should be accepted. Currently only `dtmf` is supported. All digits captured during a pay session are redacted from the logs.
|
||||
:param min_postal_code_length: A positive integer that is used to validate the length of the `PostalCode` inputted by the user. User must enter this many digits.
|
||||
:param parameter: A single-level JSON object used to pass custom parameters to payment processors. (Required for ACH payments). The information that has to be included here depends on the <Pay> Connector. [Read more](https://www.twilio.com/console/voice/pay-connectors).
|
||||
:param payment_connector: This is the unique name corresponding to the Pay Connector installed in the Twilio Add-ons. Learn more about [<Pay> Connectors](https://www.twilio.com/console/voice/pay-connectors). The default value is `Default`.
|
||||
:param payment_method:
|
||||
:param postal_code: Indicates whether the credit card postal code (zip code) is a required piece of payment information that must be provided by the caller. The default is `true`.
|
||||
:param security_code: Indicates whether the credit card security code is a required piece of payment information that must be provided by the caller. The default is `true`.
|
||||
:param timeout: The number of seconds that <Pay> should wait for the caller to press a digit between each subsequent digit, after the first one, before moving on to validate the digits captured. The default is `5`, maximum is `600`.
|
||||
:param token_type:
|
||||
:param valid_card_types: Credit card types separated by space that Pay should accept. The default value is `visa mastercard amex`
|
||||
|
||||
:returns: The created PaymentInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"IdempotencyKey": idempotency_key,
|
||||
"StatusCallback": status_callback,
|
||||
"BankAccountType": bank_account_type,
|
||||
"ChargeAmount": charge_amount,
|
||||
"Currency": currency,
|
||||
"Description": description,
|
||||
"Input": input,
|
||||
"MinPostalCodeLength": min_postal_code_length,
|
||||
"Parameter": serialize.object(parameter),
|
||||
"PaymentConnector": payment_connector,
|
||||
"PaymentMethod": payment_method,
|
||||
"PostalCode": postal_code,
|
||||
"SecurityCode": security_code,
|
||||
"Timeout": timeout,
|
||||
"TokenType": token_type,
|
||||
"ValidCardTypes": valid_card_types,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return PaymentInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
)
|
||||
|
||||
async def create_async(
|
||||
self,
|
||||
idempotency_key: str,
|
||||
status_callback: str,
|
||||
bank_account_type: Union[
|
||||
"PaymentInstance.BankAccountType", object
|
||||
] = values.unset,
|
||||
charge_amount: Union[float, object] = values.unset,
|
||||
currency: Union[str, object] = values.unset,
|
||||
description: Union[str, object] = values.unset,
|
||||
input: Union[str, object] = values.unset,
|
||||
min_postal_code_length: Union[int, object] = values.unset,
|
||||
parameter: Union[object, object] = values.unset,
|
||||
payment_connector: Union[str, object] = values.unset,
|
||||
payment_method: Union["PaymentInstance.PaymentMethod", object] = values.unset,
|
||||
postal_code: Union[bool, object] = values.unset,
|
||||
security_code: Union[bool, object] = values.unset,
|
||||
timeout: Union[int, object] = values.unset,
|
||||
token_type: Union["PaymentInstance.TokenType", object] = values.unset,
|
||||
valid_card_types: Union[str, object] = values.unset,
|
||||
) -> PaymentInstance:
|
||||
"""
|
||||
Asynchronously create the PaymentInstance
|
||||
|
||||
:param idempotency_key: A unique token that will be used to ensure that multiple API calls with the same information do not result in multiple transactions. This should be a unique string value per API call and can be a randomly generated.
|
||||
:param status_callback: Provide an absolute or relative URL to receive status updates regarding your Pay session. Read more about the [expected StatusCallback values](https://www.twilio.com/docs/voice/api/payment-resource#statuscallback)
|
||||
:param bank_account_type:
|
||||
:param charge_amount: A positive decimal value less than 1,000,000 to charge against the credit card or bank account. Default currency can be overwritten with `currency` field. Leave blank or set to 0 to tokenize.
|
||||
:param currency: The currency of the `charge_amount`, formatted as [ISO 4127](http://www.iso.org/iso/home/standards/currency_codes.htm) format. The default value is `USD` and all values allowed from the Pay Connector are accepted.
|
||||
:param description: The description can be used to provide more details regarding the transaction. This information is submitted along with the payment details to the Payment Connector which are then posted on the transactions.
|
||||
:param input: A list of inputs that should be accepted. Currently only `dtmf` is supported. All digits captured during a pay session are redacted from the logs.
|
||||
:param min_postal_code_length: A positive integer that is used to validate the length of the `PostalCode` inputted by the user. User must enter this many digits.
|
||||
:param parameter: A single-level JSON object used to pass custom parameters to payment processors. (Required for ACH payments). The information that has to be included here depends on the <Pay> Connector. [Read more](https://www.twilio.com/console/voice/pay-connectors).
|
||||
:param payment_connector: This is the unique name corresponding to the Pay Connector installed in the Twilio Add-ons. Learn more about [<Pay> Connectors](https://www.twilio.com/console/voice/pay-connectors). The default value is `Default`.
|
||||
:param payment_method:
|
||||
:param postal_code: Indicates whether the credit card postal code (zip code) is a required piece of payment information that must be provided by the caller. The default is `true`.
|
||||
:param security_code: Indicates whether the credit card security code is a required piece of payment information that must be provided by the caller. The default is `true`.
|
||||
:param timeout: The number of seconds that <Pay> should wait for the caller to press a digit between each subsequent digit, after the first one, before moving on to validate the digits captured. The default is `5`, maximum is `600`.
|
||||
:param token_type:
|
||||
:param valid_card_types: Credit card types separated by space that Pay should accept. The default value is `visa mastercard amex`
|
||||
|
||||
:returns: The created PaymentInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"IdempotencyKey": idempotency_key,
|
||||
"StatusCallback": status_callback,
|
||||
"BankAccountType": bank_account_type,
|
||||
"ChargeAmount": charge_amount,
|
||||
"Currency": currency,
|
||||
"Description": description,
|
||||
"Input": input,
|
||||
"MinPostalCodeLength": min_postal_code_length,
|
||||
"Parameter": serialize.object(parameter),
|
||||
"PaymentConnector": payment_connector,
|
||||
"PaymentMethod": payment_method,
|
||||
"PostalCode": postal_code,
|
||||
"SecurityCode": security_code,
|
||||
"Timeout": timeout,
|
||||
"TokenType": token_type,
|
||||
"ValidCardTypes": valid_card_types,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return PaymentInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
)
|
||||
|
||||
def get(self, sid: str) -> PaymentContext:
|
||||
"""
|
||||
Constructs a PaymentContext
|
||||
|
||||
:param sid: The SID of Payments session that needs to be updated.
|
||||
"""
|
||||
return PaymentContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
sid=sid,
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> PaymentContext:
|
||||
"""
|
||||
Constructs a PaymentContext
|
||||
|
||||
:param sid: The SID of Payments session that needs to be updated.
|
||||
"""
|
||||
return PaymentContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
sid=sid,
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.PaymentList>"
|
||||
@@ -0,0 +1,787 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from datetime import date, datetime
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, serialize, values
|
||||
from twilio.base.instance_context import InstanceContext
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.page import Page
|
||||
|
||||
|
||||
class RecordingInstance(InstanceResource):
|
||||
class Source(object):
|
||||
DIALVERB = "DialVerb"
|
||||
CONFERENCE = "Conference"
|
||||
OUTBOUNDAPI = "OutboundAPI"
|
||||
TRUNKING = "Trunking"
|
||||
RECORDVERB = "RecordVerb"
|
||||
STARTCALLRECORDINGAPI = "StartCallRecordingAPI"
|
||||
STARTCONFERENCERECORDINGAPI = "StartConferenceRecordingAPI"
|
||||
|
||||
class Status(object):
|
||||
IN_PROGRESS = "in-progress"
|
||||
PAUSED = "paused"
|
||||
STOPPED = "stopped"
|
||||
PROCESSING = "processing"
|
||||
COMPLETED = "completed"
|
||||
ABSENT = "absent"
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Recording resource.
|
||||
:ivar api_version: The API version used to make the recording.
|
||||
:ivar call_sid: The SID of the [Call](https://www.twilio.com/docs/voice/api/call-resource) the Recording resource is associated with.
|
||||
:ivar conference_sid: The Conference SID that identifies the conference associated with the recording, if a conference recording.
|
||||
:ivar date_created: The date and time in GMT that the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar date_updated: The date and time in GMT that the resource was last updated, specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar start_time: The start time of the recording in GMT and in [RFC 2822](https://www.php.net/manual/en/class.datetime.php#datetime.constants.rfc2822) format.
|
||||
:ivar duration: The length of the recording in seconds.
|
||||
:ivar sid: The unique string that that we created to identify the Recording resource.
|
||||
:ivar price: The one-time cost of creating the recording in the `price_unit` currency.
|
||||
:ivar uri: The URI of the resource, relative to `https://api.twilio.com`.
|
||||
:ivar encryption_details: How to decrypt the recording if it was encrypted using [Call Recording Encryption](https://www.twilio.com/docs/voice/tutorials/voice-recording-encryption) feature.
|
||||
:ivar price_unit: The currency used in the `price` property. Example: `USD`.
|
||||
:ivar status:
|
||||
:ivar channels: The number of channels in the final recording file. Can be: `1`, or `2`. Separating a two leg call into two separate channels of the recording file is supported in [Dial](https://www.twilio.com/docs/voice/twiml/dial#attributes-record) and [Outbound Rest API](https://www.twilio.com/docs/voice/make-calls) record options.
|
||||
:ivar source:
|
||||
:ivar error_code: The error code that describes why the recording is `absent`. The error code is described in our [Error Dictionary](https://www.twilio.com/docs/api/errors). This value is null if the recording `status` is not `absent`.
|
||||
:ivar track: The recorded track. Can be: `inbound`, `outbound`, or `both`.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
account_sid: str,
|
||||
call_sid: str,
|
||||
sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.api_version: Optional[str] = payload.get("api_version")
|
||||
self.call_sid: Optional[str] = payload.get("call_sid")
|
||||
self.conference_sid: Optional[str] = payload.get("conference_sid")
|
||||
self.date_created: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.start_time: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("start_time")
|
||||
)
|
||||
self.duration: Optional[str] = payload.get("duration")
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.price: Optional[float] = deserialize.decimal(payload.get("price"))
|
||||
self.uri: Optional[str] = payload.get("uri")
|
||||
self.encryption_details: Optional[Dict[str, object]] = payload.get(
|
||||
"encryption_details"
|
||||
)
|
||||
self.price_unit: Optional[str] = payload.get("price_unit")
|
||||
self.status: Optional["RecordingInstance.Status"] = payload.get("status")
|
||||
self.channels: Optional[int] = deserialize.integer(payload.get("channels"))
|
||||
self.source: Optional["RecordingInstance.Source"] = payload.get("source")
|
||||
self.error_code: Optional[int] = deserialize.integer(payload.get("error_code"))
|
||||
self.track: Optional[str] = payload.get("track")
|
||||
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"call_sid": call_sid,
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[RecordingContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "RecordingContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: RecordingContext for this RecordingInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = RecordingContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the RecordingInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the RecordingInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
def fetch(self) -> "RecordingInstance":
|
||||
"""
|
||||
Fetch the RecordingInstance
|
||||
|
||||
|
||||
:returns: The fetched RecordingInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "RecordingInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the RecordingInstance
|
||||
|
||||
|
||||
:returns: The fetched RecordingInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self,
|
||||
status: "RecordingInstance.Status",
|
||||
pause_behavior: Union[str, object] = values.unset,
|
||||
) -> "RecordingInstance":
|
||||
"""
|
||||
Update the RecordingInstance
|
||||
|
||||
:param status:
|
||||
:param pause_behavior: Whether to record during a pause. Can be: `skip` or `silence` and the default is `silence`. `skip` does not record during the pause period, while `silence` will replace the actual audio of the call with silence during the pause period. This parameter only applies when setting `status` is set to `paused`.
|
||||
|
||||
:returns: The updated RecordingInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
status=status,
|
||||
pause_behavior=pause_behavior,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
status: "RecordingInstance.Status",
|
||||
pause_behavior: Union[str, object] = values.unset,
|
||||
) -> "RecordingInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the RecordingInstance
|
||||
|
||||
:param status:
|
||||
:param pause_behavior: Whether to record during a pause. Can be: `skip` or `silence` and the default is `silence`. `skip` does not record during the pause period, while `silence` will replace the actual audio of the call with silence during the pause period. This parameter only applies when setting `status` is set to `paused`.
|
||||
|
||||
:returns: The updated RecordingInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
status=status,
|
||||
pause_behavior=pause_behavior,
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.RecordingInstance {}>".format(context)
|
||||
|
||||
|
||||
class RecordingContext(InstanceContext):
|
||||
def __init__(self, version: Version, account_sid: str, call_sid: str, sid: str):
|
||||
"""
|
||||
Initialize the RecordingContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Recording resource to update.
|
||||
:param call_sid: The [Call](https://www.twilio.com/docs/voice/api/call-resource) SID of the resource to update.
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Recording resource to update.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"call_sid": call_sid,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = (
|
||||
"/Accounts/{account_sid}/Calls/{call_sid}/Recordings/{sid}.json".format(
|
||||
**self._solution
|
||||
)
|
||||
)
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the RecordingInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._version.delete(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the RecordingInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
def fetch(self) -> RecordingInstance:
|
||||
"""
|
||||
Fetch the RecordingInstance
|
||||
|
||||
|
||||
:returns: The fetched RecordingInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return RecordingInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> RecordingInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the RecordingInstance
|
||||
|
||||
|
||||
:returns: The fetched RecordingInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return RecordingInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self,
|
||||
status: "RecordingInstance.Status",
|
||||
pause_behavior: Union[str, object] = values.unset,
|
||||
) -> RecordingInstance:
|
||||
"""
|
||||
Update the RecordingInstance
|
||||
|
||||
:param status:
|
||||
:param pause_behavior: Whether to record during a pause. Can be: `skip` or `silence` and the default is `silence`. `skip` does not record during the pause period, while `silence` will replace the actual audio of the call with silence during the pause period. This parameter only applies when setting `status` is set to `paused`.
|
||||
|
||||
:returns: The updated RecordingInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Status": status,
|
||||
"PauseBehavior": pause_behavior,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return RecordingInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
status: "RecordingInstance.Status",
|
||||
pause_behavior: Union[str, object] = values.unset,
|
||||
) -> RecordingInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the RecordingInstance
|
||||
|
||||
:param status:
|
||||
:param pause_behavior: Whether to record during a pause. Can be: `skip` or `silence` and the default is `silence`. `skip` does not record during the pause period, while `silence` will replace the actual audio of the call with silence during the pause period. This parameter only applies when setting `status` is set to `paused`.
|
||||
|
||||
:returns: The updated RecordingInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Status": status,
|
||||
"PauseBehavior": pause_behavior,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return RecordingInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.RecordingContext {}>".format(context)
|
||||
|
||||
|
||||
class RecordingPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> RecordingInstance:
|
||||
"""
|
||||
Build an instance of RecordingInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return RecordingInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.RecordingPage>"
|
||||
|
||||
|
||||
class RecordingList(ListResource):
|
||||
def __init__(self, version: Version, account_sid: str, call_sid: str):
|
||||
"""
|
||||
Initialize the RecordingList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Recording resources to read.
|
||||
:param call_sid: The [Call](https://www.twilio.com/docs/voice/api/call-resource) SID of the resources to read.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"call_sid": call_sid,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/Calls/{call_sid}/Recordings.json".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def create(
|
||||
self,
|
||||
recording_status_callback_event: Union[List[str], object] = values.unset,
|
||||
recording_status_callback: Union[str, object] = values.unset,
|
||||
recording_status_callback_method: Union[str, object] = values.unset,
|
||||
trim: Union[str, object] = values.unset,
|
||||
recording_channels: Union[str, object] = values.unset,
|
||||
recording_track: Union[str, object] = values.unset,
|
||||
) -> RecordingInstance:
|
||||
"""
|
||||
Create the RecordingInstance
|
||||
|
||||
:param recording_status_callback_event: The recording status events on which we should call the `recording_status_callback` URL. Can be: `in-progress`, `completed` and `absent` and the default is `completed`. Separate multiple event values with a space.
|
||||
:param recording_status_callback: The URL we should call using the `recording_status_callback_method` on each recording event specified in `recording_status_callback_event`. For more information, see [RecordingStatusCallback parameters](https://www.twilio.com/docs/voice/api/recording#recordingstatuscallback).
|
||||
:param recording_status_callback_method: The HTTP method we should use to call `recording_status_callback`. Can be: `GET` or `POST` and the default is `POST`.
|
||||
:param trim: Whether to trim any leading and trailing silence in the recording. Can be: `trim-silence` or `do-not-trim` and the default is `do-not-trim`. `trim-silence` trims the silence from the beginning and end of the recording and `do-not-trim` does not.
|
||||
:param recording_channels: The number of channels used in the recording. Can be: `mono` or `dual` and the default is `mono`. `mono` records all parties of the call into one channel. `dual` records each party of a 2-party call into separate channels.
|
||||
:param recording_track: The audio track to record for the call. Can be: `inbound`, `outbound` or `both`. The default is `both`. `inbound` records the audio that is received by Twilio. `outbound` records the audio that is generated from Twilio. `both` records the audio that is received and generated by Twilio.
|
||||
|
||||
:returns: The created RecordingInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"RecordingStatusCallbackEvent": serialize.map(
|
||||
recording_status_callback_event, lambda e: e
|
||||
),
|
||||
"RecordingStatusCallback": recording_status_callback,
|
||||
"RecordingStatusCallbackMethod": recording_status_callback_method,
|
||||
"Trim": trim,
|
||||
"RecordingChannels": recording_channels,
|
||||
"RecordingTrack": recording_track,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return RecordingInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
)
|
||||
|
||||
async def create_async(
|
||||
self,
|
||||
recording_status_callback_event: Union[List[str], object] = values.unset,
|
||||
recording_status_callback: Union[str, object] = values.unset,
|
||||
recording_status_callback_method: Union[str, object] = values.unset,
|
||||
trim: Union[str, object] = values.unset,
|
||||
recording_channels: Union[str, object] = values.unset,
|
||||
recording_track: Union[str, object] = values.unset,
|
||||
) -> RecordingInstance:
|
||||
"""
|
||||
Asynchronously create the RecordingInstance
|
||||
|
||||
:param recording_status_callback_event: The recording status events on which we should call the `recording_status_callback` URL. Can be: `in-progress`, `completed` and `absent` and the default is `completed`. Separate multiple event values with a space.
|
||||
:param recording_status_callback: The URL we should call using the `recording_status_callback_method` on each recording event specified in `recording_status_callback_event`. For more information, see [RecordingStatusCallback parameters](https://www.twilio.com/docs/voice/api/recording#recordingstatuscallback).
|
||||
:param recording_status_callback_method: The HTTP method we should use to call `recording_status_callback`. Can be: `GET` or `POST` and the default is `POST`.
|
||||
:param trim: Whether to trim any leading and trailing silence in the recording. Can be: `trim-silence` or `do-not-trim` and the default is `do-not-trim`. `trim-silence` trims the silence from the beginning and end of the recording and `do-not-trim` does not.
|
||||
:param recording_channels: The number of channels used in the recording. Can be: `mono` or `dual` and the default is `mono`. `mono` records all parties of the call into one channel. `dual` records each party of a 2-party call into separate channels.
|
||||
:param recording_track: The audio track to record for the call. Can be: `inbound`, `outbound` or `both`. The default is `both`. `inbound` records the audio that is received by Twilio. `outbound` records the audio that is generated from Twilio. `both` records the audio that is received and generated by Twilio.
|
||||
|
||||
:returns: The created RecordingInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"RecordingStatusCallbackEvent": serialize.map(
|
||||
recording_status_callback_event, lambda e: e
|
||||
),
|
||||
"RecordingStatusCallback": recording_status_callback,
|
||||
"RecordingStatusCallbackMethod": recording_status_callback_method,
|
||||
"Trim": trim,
|
||||
"RecordingChannels": recording_channels,
|
||||
"RecordingTrack": recording_track,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return RecordingInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
date_created: Union[date, object] = values.unset,
|
||||
date_created_before: Union[date, object] = values.unset,
|
||||
date_created_after: Union[date, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[RecordingInstance]:
|
||||
"""
|
||||
Streams RecordingInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param date date_created: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param date date_created_before: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param date date_created_after: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(
|
||||
date_created=date_created,
|
||||
date_created_before=date_created_before,
|
||||
date_created_after=date_created_after,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
date_created: Union[date, object] = values.unset,
|
||||
date_created_before: Union[date, object] = values.unset,
|
||||
date_created_after: Union[date, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[RecordingInstance]:
|
||||
"""
|
||||
Asynchronously streams RecordingInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param date date_created: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param date date_created_before: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param date date_created_after: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(
|
||||
date_created=date_created,
|
||||
date_created_before=date_created_before,
|
||||
date_created_after=date_created_after,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
date_created: Union[date, object] = values.unset,
|
||||
date_created_before: Union[date, object] = values.unset,
|
||||
date_created_after: Union[date, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[RecordingInstance]:
|
||||
"""
|
||||
Lists RecordingInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param date date_created: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param date date_created_before: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param date date_created_after: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return list(
|
||||
self.stream(
|
||||
date_created=date_created,
|
||||
date_created_before=date_created_before,
|
||||
date_created_after=date_created_after,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
date_created: Union[date, object] = values.unset,
|
||||
date_created_before: Union[date, object] = values.unset,
|
||||
date_created_after: Union[date, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[RecordingInstance]:
|
||||
"""
|
||||
Asynchronously lists RecordingInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param date date_created: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param date date_created_before: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param date date_created_after: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return [
|
||||
record
|
||||
async for record in await self.stream_async(
|
||||
date_created=date_created,
|
||||
date_created_before=date_created_before,
|
||||
date_created_after=date_created_after,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
date_created: Union[date, object] = values.unset,
|
||||
date_created_before: Union[date, object] = values.unset,
|
||||
date_created_after: Union[date, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> RecordingPage:
|
||||
"""
|
||||
Retrieve a single page of RecordingInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param date_created: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param date_created_before: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param date_created_after: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of RecordingInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"DateCreated": serialize.iso8601_date(date_created),
|
||||
"DateCreated<": serialize.iso8601_date(date_created_before),
|
||||
"DateCreated>": serialize.iso8601_date(date_created_after),
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return RecordingPage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
date_created: Union[date, object] = values.unset,
|
||||
date_created_before: Union[date, object] = values.unset,
|
||||
date_created_after: Union[date, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> RecordingPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of RecordingInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param date_created: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param date_created_before: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param date_created_after: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of RecordingInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"DateCreated": serialize.iso8601_date(date_created),
|
||||
"DateCreated<": serialize.iso8601_date(date_created_before),
|
||||
"DateCreated>": serialize.iso8601_date(date_created_after),
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return RecordingPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> RecordingPage:
|
||||
"""
|
||||
Retrieve a specific page of RecordingInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of RecordingInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return RecordingPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> RecordingPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of RecordingInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of RecordingInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return RecordingPage(self._version, response, self._solution)
|
||||
|
||||
def get(self, sid: str) -> RecordingContext:
|
||||
"""
|
||||
Constructs a RecordingContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Recording resource to update.
|
||||
"""
|
||||
return RecordingContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
sid=sid,
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> RecordingContext:
|
||||
"""
|
||||
Constructs a RecordingContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Recording resource to update.
|
||||
"""
|
||||
return RecordingContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
sid=sid,
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.RecordingList>"
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+152
@@ -0,0 +1,152 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, Optional, Union
|
||||
from twilio.base import deserialize, values
|
||||
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
|
||||
|
||||
class UserDefinedMessageInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created User Defined Message.
|
||||
:ivar call_sid: The SID of the [Call](https://www.twilio.com/docs/voice/api/call-resource) the User Defined Message is associated with.
|
||||
:ivar sid: The SID that uniquely identifies this User Defined Message.
|
||||
:ivar date_created: The date that this User Defined Message was created, given in RFC 2822 format.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self, version: Version, payload: Dict[str, Any], account_sid: str, call_sid: str
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.call_sid: Optional[str] = payload.get("call_sid")
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.date_created: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"call_sid": call_sid,
|
||||
}
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.UserDefinedMessageInstance {}>".format(context)
|
||||
|
||||
|
||||
class UserDefinedMessageList(ListResource):
|
||||
def __init__(self, version: Version, account_sid: str, call_sid: str):
|
||||
"""
|
||||
Initialize the UserDefinedMessageList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created User Defined Message.
|
||||
:param call_sid: The SID of the [Call](https://www.twilio.com/docs/voice/api/call-resource) the User Defined Message is associated with.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"call_sid": call_sid,
|
||||
}
|
||||
self._uri = (
|
||||
"/Accounts/{account_sid}/Calls/{call_sid}/UserDefinedMessages.json".format(
|
||||
**self._solution
|
||||
)
|
||||
)
|
||||
|
||||
def create(
|
||||
self, content: str, idempotency_key: Union[str, object] = values.unset
|
||||
) -> UserDefinedMessageInstance:
|
||||
"""
|
||||
Create the UserDefinedMessageInstance
|
||||
|
||||
:param content: The User Defined Message in the form of URL-encoded JSON string.
|
||||
:param idempotency_key: A unique string value to identify API call. This should be a unique string value per API call and can be a randomly generated.
|
||||
|
||||
:returns: The created UserDefinedMessageInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Content": content,
|
||||
"IdempotencyKey": idempotency_key,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return UserDefinedMessageInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
)
|
||||
|
||||
async def create_async(
|
||||
self, content: str, idempotency_key: Union[str, object] = values.unset
|
||||
) -> UserDefinedMessageInstance:
|
||||
"""
|
||||
Asynchronously create the UserDefinedMessageInstance
|
||||
|
||||
:param content: The User Defined Message in the form of URL-encoded JSON string.
|
||||
:param idempotency_key: A unique string value to identify API call. This should be a unique string value per API call and can be a randomly generated.
|
||||
|
||||
:returns: The created UserDefinedMessageInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Content": content,
|
||||
"IdempotencyKey": idempotency_key,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return UserDefinedMessageInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.UserDefinedMessageList>"
|
||||
+290
@@ -0,0 +1,290 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, Optional, Union
|
||||
from twilio.base import deserialize, values
|
||||
from twilio.base.instance_context import InstanceContext
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
|
||||
|
||||
class UserDefinedMessageSubscriptionInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that subscribed to the User Defined Messages.
|
||||
:ivar call_sid: The SID of the [Call](https://www.twilio.com/docs/voice/api/call-resource) the User Defined Message Subscription is associated with. This refers to the Call SID that is producing the User Defined Messages.
|
||||
:ivar sid: The SID that uniquely identifies this User Defined Message Subscription.
|
||||
:ivar date_created: The date that this User Defined Message Subscription was created, given in RFC 2822 format.
|
||||
:ivar uri: The URI of the User Defined Message Subscription Resource, relative to `https://api.twilio.com`.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
account_sid: str,
|
||||
call_sid: str,
|
||||
sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.call_sid: Optional[str] = payload.get("call_sid")
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.date_created: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.uri: Optional[str] = payload.get("uri")
|
||||
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"call_sid": call_sid,
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[UserDefinedMessageSubscriptionContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "UserDefinedMessageSubscriptionContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: UserDefinedMessageSubscriptionContext for this UserDefinedMessageSubscriptionInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = UserDefinedMessageSubscriptionContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the UserDefinedMessageSubscriptionInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the UserDefinedMessageSubscriptionInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.UserDefinedMessageSubscriptionInstance {}>".format(
|
||||
context
|
||||
)
|
||||
|
||||
|
||||
class UserDefinedMessageSubscriptionContext(InstanceContext):
|
||||
def __init__(self, version: Version, account_sid: str, call_sid: str, sid: str):
|
||||
"""
|
||||
Initialize the UserDefinedMessageSubscriptionContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that subscribed to the User Defined Messages.
|
||||
:param call_sid: The SID of the [Call](https://www.twilio.com/docs/voice/api/call-resource) the User Defined Message Subscription is associated with. This refers to the Call SID that is producing the User Defined Messages.
|
||||
:param sid: The SID that uniquely identifies this User Defined Message Subscription.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"call_sid": call_sid,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/Calls/{call_sid}/UserDefinedMessageSubscriptions/{sid}.json".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the UserDefinedMessageSubscriptionInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._version.delete(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the UserDefinedMessageSubscriptionInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.UserDefinedMessageSubscriptionContext {}>".format(
|
||||
context
|
||||
)
|
||||
|
||||
|
||||
class UserDefinedMessageSubscriptionList(ListResource):
|
||||
def __init__(self, version: Version, account_sid: str, call_sid: str):
|
||||
"""
|
||||
Initialize the UserDefinedMessageSubscriptionList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that subscribed to the User Defined Messages.
|
||||
:param call_sid: The SID of the [Call](https://www.twilio.com/docs/voice/api/call-resource) the User Defined Messages subscription is associated with. This refers to the Call SID that is producing the user defined messages.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"call_sid": call_sid,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/Calls/{call_sid}/UserDefinedMessageSubscriptions.json".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def create(
|
||||
self,
|
||||
callback: str,
|
||||
idempotency_key: Union[str, object] = values.unset,
|
||||
method: Union[str, object] = values.unset,
|
||||
) -> UserDefinedMessageSubscriptionInstance:
|
||||
"""
|
||||
Create the UserDefinedMessageSubscriptionInstance
|
||||
|
||||
:param callback: The URL we should call using the `method` to send user defined events to your application. URLs must contain a valid hostname (underscores are not permitted).
|
||||
:param idempotency_key: A unique string value to identify API call. This should be a unique string value per API call and can be a randomly generated.
|
||||
:param method: The HTTP method Twilio will use when requesting the above `Url`. Either `GET` or `POST`. Default is `POST`.
|
||||
|
||||
:returns: The created UserDefinedMessageSubscriptionInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Callback": callback,
|
||||
"IdempotencyKey": idempotency_key,
|
||||
"Method": method,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return UserDefinedMessageSubscriptionInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
)
|
||||
|
||||
async def create_async(
|
||||
self,
|
||||
callback: str,
|
||||
idempotency_key: Union[str, object] = values.unset,
|
||||
method: Union[str, object] = values.unset,
|
||||
) -> UserDefinedMessageSubscriptionInstance:
|
||||
"""
|
||||
Asynchronously create the UserDefinedMessageSubscriptionInstance
|
||||
|
||||
:param callback: The URL we should call using the `method` to send user defined events to your application. URLs must contain a valid hostname (underscores are not permitted).
|
||||
:param idempotency_key: A unique string value to identify API call. This should be a unique string value per API call and can be a randomly generated.
|
||||
:param method: The HTTP method Twilio will use when requesting the above `Url`. Either `GET` or `POST`. Default is `POST`.
|
||||
|
||||
:returns: The created UserDefinedMessageSubscriptionInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Callback": callback,
|
||||
"IdempotencyKey": idempotency_key,
|
||||
"Method": method,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return UserDefinedMessageSubscriptionInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
)
|
||||
|
||||
def get(self, sid: str) -> UserDefinedMessageSubscriptionContext:
|
||||
"""
|
||||
Constructs a UserDefinedMessageSubscriptionContext
|
||||
|
||||
:param sid: The SID that uniquely identifies this User Defined Message Subscription.
|
||||
"""
|
||||
return UserDefinedMessageSubscriptionContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
sid=sid,
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> UserDefinedMessageSubscriptionContext:
|
||||
"""
|
||||
Constructs a UserDefinedMessageSubscriptionContext
|
||||
|
||||
:param sid: The SID that uniquely identifies this User Defined Message Subscription.
|
||||
"""
|
||||
return UserDefinedMessageSubscriptionContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
sid=sid,
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.UserDefinedMessageSubscriptionList>"
|
||||
+766
@@ -0,0 +1,766 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from datetime import date, datetime
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, serialize, values
|
||||
from twilio.base.instance_context import InstanceContext
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.page import Page
|
||||
from twilio.rest.api.v2010.account.conference.participant import ParticipantList
|
||||
from twilio.rest.api.v2010.account.conference.recording import RecordingList
|
||||
|
||||
|
||||
class ConferenceInstance(InstanceResource):
|
||||
class ReasonConferenceEnded(object):
|
||||
CONFERENCE_ENDED_VIA_API = "conference-ended-via-api"
|
||||
PARTICIPANT_WITH_END_CONFERENCE_ON_EXIT_LEFT = (
|
||||
"participant-with-end-conference-on-exit-left"
|
||||
)
|
||||
PARTICIPANT_WITH_END_CONFERENCE_ON_EXIT_KICKED = (
|
||||
"participant-with-end-conference-on-exit-kicked"
|
||||
)
|
||||
LAST_PARTICIPANT_KICKED = "last-participant-kicked"
|
||||
LAST_PARTICIPANT_LEFT = "last-participant-left"
|
||||
|
||||
class Status(object):
|
||||
INIT = "init"
|
||||
IN_PROGRESS = "in-progress"
|
||||
COMPLETED = "completed"
|
||||
|
||||
class UpdateStatus(object):
|
||||
COMPLETED = "completed"
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created this Conference resource.
|
||||
:ivar date_created: The date and time in GMT that this resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar date_updated: The date and time in GMT that this resource was last updated, specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar api_version: The API version used to create this conference.
|
||||
:ivar friendly_name: A string that you assigned to describe this conference room. Maxiumum length is 128 characters.
|
||||
:ivar region: A string that represents the Twilio Region where the conference audio was mixed. May be `us1`, `ie1`, `de1`, `sg1`, `br1`, `au1`, and `jp1`. Basic conference audio will always be mixed in `us1`. Global Conference audio will be mixed nearest to the majority of participants.
|
||||
:ivar sid: The unique string that that we created to identify this Conference resource.
|
||||
:ivar status:
|
||||
:ivar uri: The URI of this resource, relative to `https://api.twilio.com`.
|
||||
:ivar subresource_uris: A list of related resources identified by their URIs relative to `https://api.twilio.com`.
|
||||
:ivar reason_conference_ended:
|
||||
:ivar call_sid_ending_conference: The call SID that caused the conference to end.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
account_sid: str,
|
||||
sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.date_created: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.api_version: Optional[str] = payload.get("api_version")
|
||||
self.friendly_name: Optional[str] = payload.get("friendly_name")
|
||||
self.region: Optional[str] = payload.get("region")
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.status: Optional["ConferenceInstance.Status"] = payload.get("status")
|
||||
self.uri: Optional[str] = payload.get("uri")
|
||||
self.subresource_uris: Optional[Dict[str, object]] = payload.get(
|
||||
"subresource_uris"
|
||||
)
|
||||
self.reason_conference_ended: Optional[
|
||||
"ConferenceInstance.ReasonConferenceEnded"
|
||||
] = payload.get("reason_conference_ended")
|
||||
self.call_sid_ending_conference: Optional[str] = payload.get(
|
||||
"call_sid_ending_conference"
|
||||
)
|
||||
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[ConferenceContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "ConferenceContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: ConferenceContext for this ConferenceInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = ConferenceContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def fetch(self) -> "ConferenceInstance":
|
||||
"""
|
||||
Fetch the ConferenceInstance
|
||||
|
||||
|
||||
:returns: The fetched ConferenceInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "ConferenceInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the ConferenceInstance
|
||||
|
||||
|
||||
:returns: The fetched ConferenceInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self,
|
||||
status: Union["ConferenceInstance.UpdateStatus", object] = values.unset,
|
||||
announce_url: Union[str, object] = values.unset,
|
||||
announce_method: Union[str, object] = values.unset,
|
||||
) -> "ConferenceInstance":
|
||||
"""
|
||||
Update the ConferenceInstance
|
||||
|
||||
:param status:
|
||||
:param announce_url: The URL we should call to announce something into the conference. The URL may return an MP3 file, a WAV file, or a TwiML document that contains `<Play>`, `<Say>`, `<Pause>`, or `<Redirect>` verbs.
|
||||
:param announce_method: The HTTP method used to call `announce_url`. Can be: `GET` or `POST` and the default is `POST`
|
||||
|
||||
:returns: The updated ConferenceInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
status=status,
|
||||
announce_url=announce_url,
|
||||
announce_method=announce_method,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
status: Union["ConferenceInstance.UpdateStatus", object] = values.unset,
|
||||
announce_url: Union[str, object] = values.unset,
|
||||
announce_method: Union[str, object] = values.unset,
|
||||
) -> "ConferenceInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the ConferenceInstance
|
||||
|
||||
:param status:
|
||||
:param announce_url: The URL we should call to announce something into the conference. The URL may return an MP3 file, a WAV file, or a TwiML document that contains `<Play>`, `<Say>`, `<Pause>`, or `<Redirect>` verbs.
|
||||
:param announce_method: The HTTP method used to call `announce_url`. Can be: `GET` or `POST` and the default is `POST`
|
||||
|
||||
:returns: The updated ConferenceInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
status=status,
|
||||
announce_url=announce_url,
|
||||
announce_method=announce_method,
|
||||
)
|
||||
|
||||
@property
|
||||
def participants(self) -> ParticipantList:
|
||||
"""
|
||||
Access the participants
|
||||
"""
|
||||
return self._proxy.participants
|
||||
|
||||
@property
|
||||
def recordings(self) -> RecordingList:
|
||||
"""
|
||||
Access the recordings
|
||||
"""
|
||||
return self._proxy.recordings
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.ConferenceInstance {}>".format(context)
|
||||
|
||||
|
||||
class ConferenceContext(InstanceContext):
|
||||
def __init__(self, version: Version, account_sid: str, sid: str):
|
||||
"""
|
||||
Initialize the ConferenceContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Conference resource(s) to update.
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Conference resource to update
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/Conferences/{sid}.json".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
self._participants: Optional[ParticipantList] = None
|
||||
self._recordings: Optional[RecordingList] = None
|
||||
|
||||
def fetch(self) -> ConferenceInstance:
|
||||
"""
|
||||
Fetch the ConferenceInstance
|
||||
|
||||
|
||||
:returns: The fetched ConferenceInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return ConferenceInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> ConferenceInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the ConferenceInstance
|
||||
|
||||
|
||||
:returns: The fetched ConferenceInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return ConferenceInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self,
|
||||
status: Union["ConferenceInstance.UpdateStatus", object] = values.unset,
|
||||
announce_url: Union[str, object] = values.unset,
|
||||
announce_method: Union[str, object] = values.unset,
|
||||
) -> ConferenceInstance:
|
||||
"""
|
||||
Update the ConferenceInstance
|
||||
|
||||
:param status:
|
||||
:param announce_url: The URL we should call to announce something into the conference. The URL may return an MP3 file, a WAV file, or a TwiML document that contains `<Play>`, `<Say>`, `<Pause>`, or `<Redirect>` verbs.
|
||||
:param announce_method: The HTTP method used to call `announce_url`. Can be: `GET` or `POST` and the default is `POST`
|
||||
|
||||
:returns: The updated ConferenceInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Status": status,
|
||||
"AnnounceUrl": announce_url,
|
||||
"AnnounceMethod": announce_method,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return ConferenceInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
status: Union["ConferenceInstance.UpdateStatus", object] = values.unset,
|
||||
announce_url: Union[str, object] = values.unset,
|
||||
announce_method: Union[str, object] = values.unset,
|
||||
) -> ConferenceInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the ConferenceInstance
|
||||
|
||||
:param status:
|
||||
:param announce_url: The URL we should call to announce something into the conference. The URL may return an MP3 file, a WAV file, or a TwiML document that contains `<Play>`, `<Say>`, `<Pause>`, or `<Redirect>` verbs.
|
||||
:param announce_method: The HTTP method used to call `announce_url`. Can be: `GET` or `POST` and the default is `POST`
|
||||
|
||||
:returns: The updated ConferenceInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Status": status,
|
||||
"AnnounceUrl": announce_url,
|
||||
"AnnounceMethod": announce_method,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return ConferenceInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
@property
|
||||
def participants(self) -> ParticipantList:
|
||||
"""
|
||||
Access the participants
|
||||
"""
|
||||
if self._participants is None:
|
||||
self._participants = ParticipantList(
|
||||
self._version,
|
||||
self._solution["account_sid"],
|
||||
self._solution["sid"],
|
||||
)
|
||||
return self._participants
|
||||
|
||||
@property
|
||||
def recordings(self) -> RecordingList:
|
||||
"""
|
||||
Access the recordings
|
||||
"""
|
||||
if self._recordings is None:
|
||||
self._recordings = RecordingList(
|
||||
self._version,
|
||||
self._solution["account_sid"],
|
||||
self._solution["sid"],
|
||||
)
|
||||
return self._recordings
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.ConferenceContext {}>".format(context)
|
||||
|
||||
|
||||
class ConferencePage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> ConferenceInstance:
|
||||
"""
|
||||
Build an instance of ConferenceInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return ConferenceInstance(
|
||||
self._version, payload, account_sid=self._solution["account_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.ConferencePage>"
|
||||
|
||||
|
||||
class ConferenceList(ListResource):
|
||||
def __init__(self, version: Version, account_sid: str):
|
||||
"""
|
||||
Initialize the ConferenceList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Conference resource(s) to read.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/Conferences.json".format(**self._solution)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
date_created: Union[date, object] = values.unset,
|
||||
date_created_before: Union[date, object] = values.unset,
|
||||
date_created_after: Union[date, object] = values.unset,
|
||||
date_updated: Union[date, object] = values.unset,
|
||||
date_updated_before: Union[date, object] = values.unset,
|
||||
date_updated_after: Union[date, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
status: Union["ConferenceInstance.Status", object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[ConferenceInstance]:
|
||||
"""
|
||||
Streams ConferenceInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param date date_created: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that started on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that started on or after midnight on a date, use `>=YYYY-MM-DD`.
|
||||
:param date date_created_before: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that started on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that started on or after midnight on a date, use `>=YYYY-MM-DD`.
|
||||
:param date date_created_after: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that started on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that started on or after midnight on a date, use `>=YYYY-MM-DD`.
|
||||
:param date date_updated: The `date_updated` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that were last updated on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that were last updated on or after midnight on a given date, use `>=YYYY-MM-DD`.
|
||||
:param date date_updated_before: The `date_updated` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that were last updated on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that were last updated on or after midnight on a given date, use `>=YYYY-MM-DD`.
|
||||
:param date date_updated_after: The `date_updated` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that were last updated on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that were last updated on or after midnight on a given date, use `>=YYYY-MM-DD`.
|
||||
:param str friendly_name: The string that identifies the Conference resources to read.
|
||||
:param "ConferenceInstance.Status" status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(
|
||||
date_created=date_created,
|
||||
date_created_before=date_created_before,
|
||||
date_created_after=date_created_after,
|
||||
date_updated=date_updated,
|
||||
date_updated_before=date_updated_before,
|
||||
date_updated_after=date_updated_after,
|
||||
friendly_name=friendly_name,
|
||||
status=status,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
date_created: Union[date, object] = values.unset,
|
||||
date_created_before: Union[date, object] = values.unset,
|
||||
date_created_after: Union[date, object] = values.unset,
|
||||
date_updated: Union[date, object] = values.unset,
|
||||
date_updated_before: Union[date, object] = values.unset,
|
||||
date_updated_after: Union[date, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
status: Union["ConferenceInstance.Status", object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[ConferenceInstance]:
|
||||
"""
|
||||
Asynchronously streams ConferenceInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param date date_created: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that started on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that started on or after midnight on a date, use `>=YYYY-MM-DD`.
|
||||
:param date date_created_before: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that started on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that started on or after midnight on a date, use `>=YYYY-MM-DD`.
|
||||
:param date date_created_after: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that started on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that started on or after midnight on a date, use `>=YYYY-MM-DD`.
|
||||
:param date date_updated: The `date_updated` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that were last updated on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that were last updated on or after midnight on a given date, use `>=YYYY-MM-DD`.
|
||||
:param date date_updated_before: The `date_updated` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that were last updated on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that were last updated on or after midnight on a given date, use `>=YYYY-MM-DD`.
|
||||
:param date date_updated_after: The `date_updated` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that were last updated on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that were last updated on or after midnight on a given date, use `>=YYYY-MM-DD`.
|
||||
:param str friendly_name: The string that identifies the Conference resources to read.
|
||||
:param "ConferenceInstance.Status" status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(
|
||||
date_created=date_created,
|
||||
date_created_before=date_created_before,
|
||||
date_created_after=date_created_after,
|
||||
date_updated=date_updated,
|
||||
date_updated_before=date_updated_before,
|
||||
date_updated_after=date_updated_after,
|
||||
friendly_name=friendly_name,
|
||||
status=status,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
date_created: Union[date, object] = values.unset,
|
||||
date_created_before: Union[date, object] = values.unset,
|
||||
date_created_after: Union[date, object] = values.unset,
|
||||
date_updated: Union[date, object] = values.unset,
|
||||
date_updated_before: Union[date, object] = values.unset,
|
||||
date_updated_after: Union[date, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
status: Union["ConferenceInstance.Status", object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[ConferenceInstance]:
|
||||
"""
|
||||
Lists ConferenceInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param date date_created: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that started on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that started on or after midnight on a date, use `>=YYYY-MM-DD`.
|
||||
:param date date_created_before: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that started on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that started on or after midnight on a date, use `>=YYYY-MM-DD`.
|
||||
:param date date_created_after: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that started on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that started on or after midnight on a date, use `>=YYYY-MM-DD`.
|
||||
:param date date_updated: The `date_updated` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that were last updated on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that were last updated on or after midnight on a given date, use `>=YYYY-MM-DD`.
|
||||
:param date date_updated_before: The `date_updated` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that were last updated on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that were last updated on or after midnight on a given date, use `>=YYYY-MM-DD`.
|
||||
:param date date_updated_after: The `date_updated` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that were last updated on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that were last updated on or after midnight on a given date, use `>=YYYY-MM-DD`.
|
||||
:param str friendly_name: The string that identifies the Conference resources to read.
|
||||
:param "ConferenceInstance.Status" status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return list(
|
||||
self.stream(
|
||||
date_created=date_created,
|
||||
date_created_before=date_created_before,
|
||||
date_created_after=date_created_after,
|
||||
date_updated=date_updated,
|
||||
date_updated_before=date_updated_before,
|
||||
date_updated_after=date_updated_after,
|
||||
friendly_name=friendly_name,
|
||||
status=status,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
date_created: Union[date, object] = values.unset,
|
||||
date_created_before: Union[date, object] = values.unset,
|
||||
date_created_after: Union[date, object] = values.unset,
|
||||
date_updated: Union[date, object] = values.unset,
|
||||
date_updated_before: Union[date, object] = values.unset,
|
||||
date_updated_after: Union[date, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
status: Union["ConferenceInstance.Status", object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[ConferenceInstance]:
|
||||
"""
|
||||
Asynchronously lists ConferenceInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param date date_created: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that started on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that started on or after midnight on a date, use `>=YYYY-MM-DD`.
|
||||
:param date date_created_before: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that started on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that started on or after midnight on a date, use `>=YYYY-MM-DD`.
|
||||
:param date date_created_after: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that started on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that started on or after midnight on a date, use `>=YYYY-MM-DD`.
|
||||
:param date date_updated: The `date_updated` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that were last updated on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that were last updated on or after midnight on a given date, use `>=YYYY-MM-DD`.
|
||||
:param date date_updated_before: The `date_updated` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that were last updated on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that were last updated on or after midnight on a given date, use `>=YYYY-MM-DD`.
|
||||
:param date date_updated_after: The `date_updated` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that were last updated on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that were last updated on or after midnight on a given date, use `>=YYYY-MM-DD`.
|
||||
:param str friendly_name: The string that identifies the Conference resources to read.
|
||||
:param "ConferenceInstance.Status" status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return [
|
||||
record
|
||||
async for record in await self.stream_async(
|
||||
date_created=date_created,
|
||||
date_created_before=date_created_before,
|
||||
date_created_after=date_created_after,
|
||||
date_updated=date_updated,
|
||||
date_updated_before=date_updated_before,
|
||||
date_updated_after=date_updated_after,
|
||||
friendly_name=friendly_name,
|
||||
status=status,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
date_created: Union[date, object] = values.unset,
|
||||
date_created_before: Union[date, object] = values.unset,
|
||||
date_created_after: Union[date, object] = values.unset,
|
||||
date_updated: Union[date, object] = values.unset,
|
||||
date_updated_before: Union[date, object] = values.unset,
|
||||
date_updated_after: Union[date, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
status: Union["ConferenceInstance.Status", object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> ConferencePage:
|
||||
"""
|
||||
Retrieve a single page of ConferenceInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param date_created: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that started on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that started on or after midnight on a date, use `>=YYYY-MM-DD`.
|
||||
:param date_created_before: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that started on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that started on or after midnight on a date, use `>=YYYY-MM-DD`.
|
||||
:param date_created_after: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that started on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that started on or after midnight on a date, use `>=YYYY-MM-DD`.
|
||||
:param date_updated: The `date_updated` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that were last updated on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that were last updated on or after midnight on a given date, use `>=YYYY-MM-DD`.
|
||||
:param date_updated_before: The `date_updated` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that were last updated on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that were last updated on or after midnight on a given date, use `>=YYYY-MM-DD`.
|
||||
:param date_updated_after: The `date_updated` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that were last updated on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that were last updated on or after midnight on a given date, use `>=YYYY-MM-DD`.
|
||||
:param friendly_name: The string that identifies the Conference resources to read.
|
||||
:param status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of ConferenceInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"DateCreated": serialize.iso8601_date(date_created),
|
||||
"DateCreated<": serialize.iso8601_date(date_created_before),
|
||||
"DateCreated>": serialize.iso8601_date(date_created_after),
|
||||
"DateUpdated": serialize.iso8601_date(date_updated),
|
||||
"DateUpdated<": serialize.iso8601_date(date_updated_before),
|
||||
"DateUpdated>": serialize.iso8601_date(date_updated_after),
|
||||
"FriendlyName": friendly_name,
|
||||
"Status": status,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return ConferencePage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
date_created: Union[date, object] = values.unset,
|
||||
date_created_before: Union[date, object] = values.unset,
|
||||
date_created_after: Union[date, object] = values.unset,
|
||||
date_updated: Union[date, object] = values.unset,
|
||||
date_updated_before: Union[date, object] = values.unset,
|
||||
date_updated_after: Union[date, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
status: Union["ConferenceInstance.Status", object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> ConferencePage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of ConferenceInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param date_created: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that started on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that started on or after midnight on a date, use `>=YYYY-MM-DD`.
|
||||
:param date_created_before: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that started on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that started on or after midnight on a date, use `>=YYYY-MM-DD`.
|
||||
:param date_created_after: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that started on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that started on or after midnight on a date, use `>=YYYY-MM-DD`.
|
||||
:param date_updated: The `date_updated` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that were last updated on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that were last updated on or after midnight on a given date, use `>=YYYY-MM-DD`.
|
||||
:param date_updated_before: The `date_updated` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that were last updated on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that were last updated on or after midnight on a given date, use `>=YYYY-MM-DD`.
|
||||
:param date_updated_after: The `date_updated` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that were last updated on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that were last updated on or after midnight on a given date, use `>=YYYY-MM-DD`.
|
||||
:param friendly_name: The string that identifies the Conference resources to read.
|
||||
:param status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of ConferenceInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"DateCreated": serialize.iso8601_date(date_created),
|
||||
"DateCreated<": serialize.iso8601_date(date_created_before),
|
||||
"DateCreated>": serialize.iso8601_date(date_created_after),
|
||||
"DateUpdated": serialize.iso8601_date(date_updated),
|
||||
"DateUpdated<": serialize.iso8601_date(date_updated_before),
|
||||
"DateUpdated>": serialize.iso8601_date(date_updated_after),
|
||||
"FriendlyName": friendly_name,
|
||||
"Status": status,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return ConferencePage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> ConferencePage:
|
||||
"""
|
||||
Retrieve a specific page of ConferenceInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of ConferenceInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return ConferencePage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> ConferencePage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of ConferenceInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of ConferenceInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return ConferencePage(self._version, response, self._solution)
|
||||
|
||||
def get(self, sid: str) -> ConferenceContext:
|
||||
"""
|
||||
Constructs a ConferenceContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Conference resource to update
|
||||
"""
|
||||
return ConferenceContext(
|
||||
self._version, account_sid=self._solution["account_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> ConferenceContext:
|
||||
"""
|
||||
Constructs a ConferenceContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Conference resource to update
|
||||
"""
|
||||
return ConferenceContext(
|
||||
self._version, account_sid=self._solution["account_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.ConferenceList>"
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
+1152
File diff suppressed because it is too large
Load Diff
+691
@@ -0,0 +1,691 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from datetime import date, datetime
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, serialize, values
|
||||
from twilio.base.instance_context import InstanceContext
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.page import Page
|
||||
|
||||
|
||||
class RecordingInstance(InstanceResource):
|
||||
class Source(object):
|
||||
DIALVERB = "DialVerb"
|
||||
CONFERENCE = "Conference"
|
||||
OUTBOUNDAPI = "OutboundAPI"
|
||||
TRUNKING = "Trunking"
|
||||
RECORDVERB = "RecordVerb"
|
||||
STARTCALLRECORDINGAPI = "StartCallRecordingAPI"
|
||||
STARTCONFERENCERECORDINGAPI = "StartConferenceRecordingAPI"
|
||||
|
||||
class Status(object):
|
||||
IN_PROGRESS = "in-progress"
|
||||
PAUSED = "paused"
|
||||
STOPPED = "stopped"
|
||||
PROCESSING = "processing"
|
||||
COMPLETED = "completed"
|
||||
ABSENT = "absent"
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Conference Recording resource.
|
||||
:ivar api_version: The API version used to create the recording.
|
||||
:ivar call_sid: The SID of the [Call](https://www.twilio.com/docs/voice/api/call-resource) the Conference Recording resource is associated with.
|
||||
:ivar conference_sid: The Conference SID that identifies the conference associated with the recording.
|
||||
:ivar date_created: The date and time in GMT that the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar date_updated: The date and time in GMT that the resource was last updated, specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar start_time: The start time of the recording in GMT and in [RFC 2822](https://www.php.net/manual/en/class.datetime.php#datetime.constants.rfc2822) format.
|
||||
:ivar duration: The length of the recording in seconds.
|
||||
:ivar sid: The unique string that that we created to identify the Conference Recording resource.
|
||||
:ivar price: The one-time cost of creating the recording in the `price_unit` currency.
|
||||
:ivar price_unit: The currency used in the `price` property. Example: `USD`.
|
||||
:ivar status:
|
||||
:ivar channels: The number of channels in the final recording file. Can be: `1`, or `2`. Separating a two leg call into two separate channels of the recording file is supported in [Dial](https://www.twilio.com/docs/voice/twiml/dial#attributes-record) and [Outbound Rest API](https://www.twilio.com/docs/voice/make-calls) record options.
|
||||
:ivar source:
|
||||
:ivar error_code: The error code that describes why the recording is `absent`. The error code is described in our [Error Dictionary](https://www.twilio.com/docs/api/errors). This value is null if the recording `status` is not `absent`.
|
||||
:ivar encryption_details: How to decrypt the recording if it was encrypted using [Call Recording Encryption](https://www.twilio.com/docs/voice/tutorials/voice-recording-encryption) feature.
|
||||
:ivar uri: The URI of the resource, relative to `https://api.twilio.com`.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
account_sid: str,
|
||||
conference_sid: str,
|
||||
sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.api_version: Optional[str] = payload.get("api_version")
|
||||
self.call_sid: Optional[str] = payload.get("call_sid")
|
||||
self.conference_sid: Optional[str] = payload.get("conference_sid")
|
||||
self.date_created: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.start_time: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("start_time")
|
||||
)
|
||||
self.duration: Optional[str] = payload.get("duration")
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.price: Optional[str] = payload.get("price")
|
||||
self.price_unit: Optional[str] = payload.get("price_unit")
|
||||
self.status: Optional["RecordingInstance.Status"] = payload.get("status")
|
||||
self.channels: Optional[int] = deserialize.integer(payload.get("channels"))
|
||||
self.source: Optional["RecordingInstance.Source"] = payload.get("source")
|
||||
self.error_code: Optional[int] = deserialize.integer(payload.get("error_code"))
|
||||
self.encryption_details: Optional[Dict[str, object]] = payload.get(
|
||||
"encryption_details"
|
||||
)
|
||||
self.uri: Optional[str] = payload.get("uri")
|
||||
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"conference_sid": conference_sid,
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[RecordingContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "RecordingContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: RecordingContext for this RecordingInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = RecordingContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
conference_sid=self._solution["conference_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the RecordingInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the RecordingInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
def fetch(self) -> "RecordingInstance":
|
||||
"""
|
||||
Fetch the RecordingInstance
|
||||
|
||||
|
||||
:returns: The fetched RecordingInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "RecordingInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the RecordingInstance
|
||||
|
||||
|
||||
:returns: The fetched RecordingInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self,
|
||||
status: "RecordingInstance.Status",
|
||||
pause_behavior: Union[str, object] = values.unset,
|
||||
) -> "RecordingInstance":
|
||||
"""
|
||||
Update the RecordingInstance
|
||||
|
||||
:param status:
|
||||
:param pause_behavior: Whether to record during a pause. Can be: `skip` or `silence` and the default is `silence`. `skip` does not record during the pause period, while `silence` will replace the actual audio of the call with silence during the pause period. This parameter only applies when setting `status` is set to `paused`.
|
||||
|
||||
:returns: The updated RecordingInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
status=status,
|
||||
pause_behavior=pause_behavior,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
status: "RecordingInstance.Status",
|
||||
pause_behavior: Union[str, object] = values.unset,
|
||||
) -> "RecordingInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the RecordingInstance
|
||||
|
||||
:param status:
|
||||
:param pause_behavior: Whether to record during a pause. Can be: `skip` or `silence` and the default is `silence`. `skip` does not record during the pause period, while `silence` will replace the actual audio of the call with silence during the pause period. This parameter only applies when setting `status` is set to `paused`.
|
||||
|
||||
:returns: The updated RecordingInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
status=status,
|
||||
pause_behavior=pause_behavior,
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.RecordingInstance {}>".format(context)
|
||||
|
||||
|
||||
class RecordingContext(InstanceContext):
|
||||
def __init__(
|
||||
self, version: Version, account_sid: str, conference_sid: str, sid: str
|
||||
):
|
||||
"""
|
||||
Initialize the RecordingContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Conference Recording resource to update.
|
||||
:param conference_sid: The Conference SID that identifies the conference associated with the recording to update.
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Conference Recording resource to update. Use `Twilio.CURRENT` to reference the current active recording.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"conference_sid": conference_sid,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/Conferences/{conference_sid}/Recordings/{sid}.json".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the RecordingInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._version.delete(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the RecordingInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
def fetch(self) -> RecordingInstance:
|
||||
"""
|
||||
Fetch the RecordingInstance
|
||||
|
||||
|
||||
:returns: The fetched RecordingInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return RecordingInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
conference_sid=self._solution["conference_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> RecordingInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the RecordingInstance
|
||||
|
||||
|
||||
:returns: The fetched RecordingInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return RecordingInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
conference_sid=self._solution["conference_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self,
|
||||
status: "RecordingInstance.Status",
|
||||
pause_behavior: Union[str, object] = values.unset,
|
||||
) -> RecordingInstance:
|
||||
"""
|
||||
Update the RecordingInstance
|
||||
|
||||
:param status:
|
||||
:param pause_behavior: Whether to record during a pause. Can be: `skip` or `silence` and the default is `silence`. `skip` does not record during the pause period, while `silence` will replace the actual audio of the call with silence during the pause period. This parameter only applies when setting `status` is set to `paused`.
|
||||
|
||||
:returns: The updated RecordingInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Status": status,
|
||||
"PauseBehavior": pause_behavior,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return RecordingInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
conference_sid=self._solution["conference_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
status: "RecordingInstance.Status",
|
||||
pause_behavior: Union[str, object] = values.unset,
|
||||
) -> RecordingInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the RecordingInstance
|
||||
|
||||
:param status:
|
||||
:param pause_behavior: Whether to record during a pause. Can be: `skip` or `silence` and the default is `silence`. `skip` does not record during the pause period, while `silence` will replace the actual audio of the call with silence during the pause period. This parameter only applies when setting `status` is set to `paused`.
|
||||
|
||||
:returns: The updated RecordingInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Status": status,
|
||||
"PauseBehavior": pause_behavior,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return RecordingInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
conference_sid=self._solution["conference_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.RecordingContext {}>".format(context)
|
||||
|
||||
|
||||
class RecordingPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> RecordingInstance:
|
||||
"""
|
||||
Build an instance of RecordingInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return RecordingInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
conference_sid=self._solution["conference_sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.RecordingPage>"
|
||||
|
||||
|
||||
class RecordingList(ListResource):
|
||||
def __init__(self, version: Version, account_sid: str, conference_sid: str):
|
||||
"""
|
||||
Initialize the RecordingList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Conference Recording resources to read.
|
||||
:param conference_sid: The Conference SID that identifies the conference associated with the recording to read.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"conference_sid": conference_sid,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/Conferences/{conference_sid}/Recordings.json".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
date_created: Union[date, object] = values.unset,
|
||||
date_created_before: Union[date, object] = values.unset,
|
||||
date_created_after: Union[date, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[RecordingInstance]:
|
||||
"""
|
||||
Streams RecordingInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param date date_created: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param date date_created_before: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param date date_created_after: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(
|
||||
date_created=date_created,
|
||||
date_created_before=date_created_before,
|
||||
date_created_after=date_created_after,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
date_created: Union[date, object] = values.unset,
|
||||
date_created_before: Union[date, object] = values.unset,
|
||||
date_created_after: Union[date, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[RecordingInstance]:
|
||||
"""
|
||||
Asynchronously streams RecordingInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param date date_created: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param date date_created_before: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param date date_created_after: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(
|
||||
date_created=date_created,
|
||||
date_created_before=date_created_before,
|
||||
date_created_after=date_created_after,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
date_created: Union[date, object] = values.unset,
|
||||
date_created_before: Union[date, object] = values.unset,
|
||||
date_created_after: Union[date, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[RecordingInstance]:
|
||||
"""
|
||||
Lists RecordingInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param date date_created: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param date date_created_before: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param date date_created_after: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return list(
|
||||
self.stream(
|
||||
date_created=date_created,
|
||||
date_created_before=date_created_before,
|
||||
date_created_after=date_created_after,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
date_created: Union[date, object] = values.unset,
|
||||
date_created_before: Union[date, object] = values.unset,
|
||||
date_created_after: Union[date, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[RecordingInstance]:
|
||||
"""
|
||||
Asynchronously lists RecordingInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param date date_created: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param date date_created_before: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param date date_created_after: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return [
|
||||
record
|
||||
async for record in await self.stream_async(
|
||||
date_created=date_created,
|
||||
date_created_before=date_created_before,
|
||||
date_created_after=date_created_after,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
date_created: Union[date, object] = values.unset,
|
||||
date_created_before: Union[date, object] = values.unset,
|
||||
date_created_after: Union[date, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> RecordingPage:
|
||||
"""
|
||||
Retrieve a single page of RecordingInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param date_created: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param date_created_before: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param date_created_after: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of RecordingInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"DateCreated": serialize.iso8601_date(date_created),
|
||||
"DateCreated<": serialize.iso8601_date(date_created_before),
|
||||
"DateCreated>": serialize.iso8601_date(date_created_after),
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return RecordingPage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
date_created: Union[date, object] = values.unset,
|
||||
date_created_before: Union[date, object] = values.unset,
|
||||
date_created_after: Union[date, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> RecordingPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of RecordingInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param date_created: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param date_created_before: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param date_created_after: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. You can also specify inequality: `DateCreated<=YYYY-MM-DD` will return recordings generated at or before midnight on a given date, and `DateCreated>=YYYY-MM-DD` returns recordings generated at or after midnight on a date.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of RecordingInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"DateCreated": serialize.iso8601_date(date_created),
|
||||
"DateCreated<": serialize.iso8601_date(date_created_before),
|
||||
"DateCreated>": serialize.iso8601_date(date_created_after),
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return RecordingPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> RecordingPage:
|
||||
"""
|
||||
Retrieve a specific page of RecordingInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of RecordingInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return RecordingPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> RecordingPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of RecordingInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of RecordingInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return RecordingPage(self._version, response, self._solution)
|
||||
|
||||
def get(self, sid: str) -> RecordingContext:
|
||||
"""
|
||||
Constructs a RecordingContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Conference Recording resource to update. Use `Twilio.CURRENT` to reference the current active recording.
|
||||
"""
|
||||
return RecordingContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
conference_sid=self._solution["conference_sid"],
|
||||
sid=sid,
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> RecordingContext:
|
||||
"""
|
||||
Constructs a RecordingContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Conference Recording resource to update. Use `Twilio.CURRENT` to reference the current active recording.
|
||||
"""
|
||||
return RecordingContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
conference_sid=self._solution["conference_sid"],
|
||||
sid=sid,
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.RecordingList>"
|
||||
@@ -0,0 +1,663 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import serialize, values
|
||||
from twilio.base.instance_context import InstanceContext
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.page import Page
|
||||
|
||||
|
||||
class ConnectAppInstance(InstanceResource):
|
||||
class Permission(object):
|
||||
GET_ALL = "get-all"
|
||||
POST_ALL = "post-all"
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the ConnectApp resource.
|
||||
:ivar authorize_redirect_url: The URL we redirect the user to after we authenticate the user and obtain authorization to access the Connect App.
|
||||
:ivar company_name: The company name set for the Connect App.
|
||||
:ivar deauthorize_callback_method: The HTTP method we use to call `deauthorize_callback_url`.
|
||||
:ivar deauthorize_callback_url: The URL we call using the `deauthorize_callback_method` to de-authorize the Connect App.
|
||||
:ivar description: The description of the Connect App.
|
||||
:ivar friendly_name: The string that you assigned to describe the resource.
|
||||
:ivar homepage_url: The public URL where users can obtain more information about this Connect App.
|
||||
:ivar permissions: The set of permissions that your ConnectApp requests.
|
||||
:ivar sid: The unique string that that we created to identify the ConnectApp resource.
|
||||
:ivar uri: The URI of the resource, relative to `https://api.twilio.com`.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
account_sid: str,
|
||||
sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.authorize_redirect_url: Optional[str] = payload.get(
|
||||
"authorize_redirect_url"
|
||||
)
|
||||
self.company_name: Optional[str] = payload.get("company_name")
|
||||
self.deauthorize_callback_method: Optional[str] = payload.get(
|
||||
"deauthorize_callback_method"
|
||||
)
|
||||
self.deauthorize_callback_url: Optional[str] = payload.get(
|
||||
"deauthorize_callback_url"
|
||||
)
|
||||
self.description: Optional[str] = payload.get("description")
|
||||
self.friendly_name: Optional[str] = payload.get("friendly_name")
|
||||
self.homepage_url: Optional[str] = payload.get("homepage_url")
|
||||
self.permissions: Optional[List["ConnectAppInstance.Permission"]] = payload.get(
|
||||
"permissions"
|
||||
)
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.uri: Optional[str] = payload.get("uri")
|
||||
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[ConnectAppContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "ConnectAppContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: ConnectAppContext for this ConnectAppInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = ConnectAppContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the ConnectAppInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the ConnectAppInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
def fetch(self) -> "ConnectAppInstance":
|
||||
"""
|
||||
Fetch the ConnectAppInstance
|
||||
|
||||
|
||||
:returns: The fetched ConnectAppInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "ConnectAppInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the ConnectAppInstance
|
||||
|
||||
|
||||
:returns: The fetched ConnectAppInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self,
|
||||
authorize_redirect_url: Union[str, object] = values.unset,
|
||||
company_name: Union[str, object] = values.unset,
|
||||
deauthorize_callback_method: Union[str, object] = values.unset,
|
||||
deauthorize_callback_url: Union[str, object] = values.unset,
|
||||
description: Union[str, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
homepage_url: Union[str, object] = values.unset,
|
||||
permissions: Union[
|
||||
List["ConnectAppInstance.Permission"], object
|
||||
] = values.unset,
|
||||
) -> "ConnectAppInstance":
|
||||
"""
|
||||
Update the ConnectAppInstance
|
||||
|
||||
:param authorize_redirect_url: The URL to redirect the user to after we authenticate the user and obtain authorization to access the Connect App.
|
||||
:param company_name: The company name to set for the Connect App.
|
||||
:param deauthorize_callback_method: The HTTP method to use when calling `deauthorize_callback_url`.
|
||||
:param deauthorize_callback_url: The URL to call using the `deauthorize_callback_method` to de-authorize the Connect App.
|
||||
:param description: A description of the Connect App.
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long.
|
||||
:param homepage_url: A public URL where users can obtain more information about this Connect App.
|
||||
:param permissions: A comma-separated list of the permissions you will request from the users of this ConnectApp. Can include: `get-all` and `post-all`.
|
||||
|
||||
:returns: The updated ConnectAppInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
authorize_redirect_url=authorize_redirect_url,
|
||||
company_name=company_name,
|
||||
deauthorize_callback_method=deauthorize_callback_method,
|
||||
deauthorize_callback_url=deauthorize_callback_url,
|
||||
description=description,
|
||||
friendly_name=friendly_name,
|
||||
homepage_url=homepage_url,
|
||||
permissions=permissions,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
authorize_redirect_url: Union[str, object] = values.unset,
|
||||
company_name: Union[str, object] = values.unset,
|
||||
deauthorize_callback_method: Union[str, object] = values.unset,
|
||||
deauthorize_callback_url: Union[str, object] = values.unset,
|
||||
description: Union[str, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
homepage_url: Union[str, object] = values.unset,
|
||||
permissions: Union[
|
||||
List["ConnectAppInstance.Permission"], object
|
||||
] = values.unset,
|
||||
) -> "ConnectAppInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the ConnectAppInstance
|
||||
|
||||
:param authorize_redirect_url: The URL to redirect the user to after we authenticate the user and obtain authorization to access the Connect App.
|
||||
:param company_name: The company name to set for the Connect App.
|
||||
:param deauthorize_callback_method: The HTTP method to use when calling `deauthorize_callback_url`.
|
||||
:param deauthorize_callback_url: The URL to call using the `deauthorize_callback_method` to de-authorize the Connect App.
|
||||
:param description: A description of the Connect App.
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long.
|
||||
:param homepage_url: A public URL where users can obtain more information about this Connect App.
|
||||
:param permissions: A comma-separated list of the permissions you will request from the users of this ConnectApp. Can include: `get-all` and `post-all`.
|
||||
|
||||
:returns: The updated ConnectAppInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
authorize_redirect_url=authorize_redirect_url,
|
||||
company_name=company_name,
|
||||
deauthorize_callback_method=deauthorize_callback_method,
|
||||
deauthorize_callback_url=deauthorize_callback_url,
|
||||
description=description,
|
||||
friendly_name=friendly_name,
|
||||
homepage_url=homepage_url,
|
||||
permissions=permissions,
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.ConnectAppInstance {}>".format(context)
|
||||
|
||||
|
||||
class ConnectAppContext(InstanceContext):
|
||||
def __init__(self, version: Version, account_sid: str, sid: str):
|
||||
"""
|
||||
Initialize the ConnectAppContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the ConnectApp resources to update.
|
||||
:param sid: The Twilio-provided string that uniquely identifies the ConnectApp resource to update.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/ConnectApps/{sid}.json".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the ConnectAppInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._version.delete(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the ConnectAppInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
def fetch(self) -> ConnectAppInstance:
|
||||
"""
|
||||
Fetch the ConnectAppInstance
|
||||
|
||||
|
||||
:returns: The fetched ConnectAppInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return ConnectAppInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> ConnectAppInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the ConnectAppInstance
|
||||
|
||||
|
||||
:returns: The fetched ConnectAppInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return ConnectAppInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self,
|
||||
authorize_redirect_url: Union[str, object] = values.unset,
|
||||
company_name: Union[str, object] = values.unset,
|
||||
deauthorize_callback_method: Union[str, object] = values.unset,
|
||||
deauthorize_callback_url: Union[str, object] = values.unset,
|
||||
description: Union[str, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
homepage_url: Union[str, object] = values.unset,
|
||||
permissions: Union[
|
||||
List["ConnectAppInstance.Permission"], object
|
||||
] = values.unset,
|
||||
) -> ConnectAppInstance:
|
||||
"""
|
||||
Update the ConnectAppInstance
|
||||
|
||||
:param authorize_redirect_url: The URL to redirect the user to after we authenticate the user and obtain authorization to access the Connect App.
|
||||
:param company_name: The company name to set for the Connect App.
|
||||
:param deauthorize_callback_method: The HTTP method to use when calling `deauthorize_callback_url`.
|
||||
:param deauthorize_callback_url: The URL to call using the `deauthorize_callback_method` to de-authorize the Connect App.
|
||||
:param description: A description of the Connect App.
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long.
|
||||
:param homepage_url: A public URL where users can obtain more information about this Connect App.
|
||||
:param permissions: A comma-separated list of the permissions you will request from the users of this ConnectApp. Can include: `get-all` and `post-all`.
|
||||
|
||||
:returns: The updated ConnectAppInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"AuthorizeRedirectUrl": authorize_redirect_url,
|
||||
"CompanyName": company_name,
|
||||
"DeauthorizeCallbackMethod": deauthorize_callback_method,
|
||||
"DeauthorizeCallbackUrl": deauthorize_callback_url,
|
||||
"Description": description,
|
||||
"FriendlyName": friendly_name,
|
||||
"HomepageUrl": homepage_url,
|
||||
"Permissions": serialize.map(permissions, lambda e: e),
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return ConnectAppInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
authorize_redirect_url: Union[str, object] = values.unset,
|
||||
company_name: Union[str, object] = values.unset,
|
||||
deauthorize_callback_method: Union[str, object] = values.unset,
|
||||
deauthorize_callback_url: Union[str, object] = values.unset,
|
||||
description: Union[str, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
homepage_url: Union[str, object] = values.unset,
|
||||
permissions: Union[
|
||||
List["ConnectAppInstance.Permission"], object
|
||||
] = values.unset,
|
||||
) -> ConnectAppInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the ConnectAppInstance
|
||||
|
||||
:param authorize_redirect_url: The URL to redirect the user to after we authenticate the user and obtain authorization to access the Connect App.
|
||||
:param company_name: The company name to set for the Connect App.
|
||||
:param deauthorize_callback_method: The HTTP method to use when calling `deauthorize_callback_url`.
|
||||
:param deauthorize_callback_url: The URL to call using the `deauthorize_callback_method` to de-authorize the Connect App.
|
||||
:param description: A description of the Connect App.
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long.
|
||||
:param homepage_url: A public URL where users can obtain more information about this Connect App.
|
||||
:param permissions: A comma-separated list of the permissions you will request from the users of this ConnectApp. Can include: `get-all` and `post-all`.
|
||||
|
||||
:returns: The updated ConnectAppInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"AuthorizeRedirectUrl": authorize_redirect_url,
|
||||
"CompanyName": company_name,
|
||||
"DeauthorizeCallbackMethod": deauthorize_callback_method,
|
||||
"DeauthorizeCallbackUrl": deauthorize_callback_url,
|
||||
"Description": description,
|
||||
"FriendlyName": friendly_name,
|
||||
"HomepageUrl": homepage_url,
|
||||
"Permissions": serialize.map(permissions, lambda e: e),
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return ConnectAppInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.ConnectAppContext {}>".format(context)
|
||||
|
||||
|
||||
class ConnectAppPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> ConnectAppInstance:
|
||||
"""
|
||||
Build an instance of ConnectAppInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return ConnectAppInstance(
|
||||
self._version, payload, account_sid=self._solution["account_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.ConnectAppPage>"
|
||||
|
||||
|
||||
class ConnectAppList(ListResource):
|
||||
def __init__(self, version: Version, account_sid: str):
|
||||
"""
|
||||
Initialize the ConnectAppList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the ConnectApp resources to read.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/ConnectApps.json".format(**self._solution)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[ConnectAppInstance]:
|
||||
"""
|
||||
Streams ConnectAppInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[ConnectAppInstance]:
|
||||
"""
|
||||
Asynchronously streams ConnectAppInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[ConnectAppInstance]:
|
||||
"""
|
||||
Lists ConnectAppInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return list(
|
||||
self.stream(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[ConnectAppInstance]:
|
||||
"""
|
||||
Asynchronously lists ConnectAppInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return [
|
||||
record
|
||||
async for record in await self.stream_async(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> ConnectAppPage:
|
||||
"""
|
||||
Retrieve a single page of ConnectAppInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of ConnectAppInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return ConnectAppPage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> ConnectAppPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of ConnectAppInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of ConnectAppInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return ConnectAppPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> ConnectAppPage:
|
||||
"""
|
||||
Retrieve a specific page of ConnectAppInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of ConnectAppInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return ConnectAppPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> ConnectAppPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of ConnectAppInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of ConnectAppInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return ConnectAppPage(self._version, response, self._solution)
|
||||
|
||||
def get(self, sid: str) -> ConnectAppContext:
|
||||
"""
|
||||
Constructs a ConnectAppContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the ConnectApp resource to update.
|
||||
"""
|
||||
return ConnectAppContext(
|
||||
self._version, account_sid=self._solution["account_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> ConnectAppContext:
|
||||
"""
|
||||
Constructs a ConnectAppContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the ConnectApp resource to update.
|
||||
"""
|
||||
return ConnectAppContext(
|
||||
self._version, account_sid=self._solution["account_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.ConnectAppList>"
|
||||
+1267
File diff suppressed because it is too large
Load Diff
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
+577
@@ -0,0 +1,577 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, values
|
||||
from twilio.base.instance_context import InstanceContext
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.page import Page
|
||||
from twilio.rest.api.v2010.account.incoming_phone_number.assigned_add_on.assigned_add_on_extension import (
|
||||
AssignedAddOnExtensionList,
|
||||
)
|
||||
|
||||
|
||||
class AssignedAddOnInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar sid: The unique string that that we created to identify the resource.
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the resource.
|
||||
:ivar resource_sid: The SID of the Phone Number to which the Add-on is assigned.
|
||||
:ivar friendly_name: The string that you assigned to describe the resource.
|
||||
:ivar description: A short description of the functionality that the Add-on provides.
|
||||
:ivar configuration: A JSON string that represents the current configuration of this Add-on installation.
|
||||
:ivar unique_name: An application-defined string that uniquely identifies the resource. It can be used in place of the resource's `sid` in the URL to address the resource.
|
||||
:ivar date_created: The date and time in GMT that the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar date_updated: The date and time in GMT that the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar uri: The URI of the resource, relative to `https://api.twilio.com`.
|
||||
:ivar subresource_uris: A list of related resources identified by their relative URIs.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
account_sid: str,
|
||||
resource_sid: str,
|
||||
sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.resource_sid: Optional[str] = payload.get("resource_sid")
|
||||
self.friendly_name: Optional[str] = payload.get("friendly_name")
|
||||
self.description: Optional[str] = payload.get("description")
|
||||
self.configuration: Optional[Dict[str, object]] = payload.get("configuration")
|
||||
self.unique_name: Optional[str] = payload.get("unique_name")
|
||||
self.date_created: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.uri: Optional[str] = payload.get("uri")
|
||||
self.subresource_uris: Optional[Dict[str, object]] = payload.get(
|
||||
"subresource_uris"
|
||||
)
|
||||
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"resource_sid": resource_sid,
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[AssignedAddOnContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "AssignedAddOnContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: AssignedAddOnContext for this AssignedAddOnInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = AssignedAddOnContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
resource_sid=self._solution["resource_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the AssignedAddOnInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the AssignedAddOnInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
def fetch(self) -> "AssignedAddOnInstance":
|
||||
"""
|
||||
Fetch the AssignedAddOnInstance
|
||||
|
||||
|
||||
:returns: The fetched AssignedAddOnInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "AssignedAddOnInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the AssignedAddOnInstance
|
||||
|
||||
|
||||
:returns: The fetched AssignedAddOnInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
@property
|
||||
def extensions(self) -> AssignedAddOnExtensionList:
|
||||
"""
|
||||
Access the extensions
|
||||
"""
|
||||
return self._proxy.extensions
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.AssignedAddOnInstance {}>".format(context)
|
||||
|
||||
|
||||
class AssignedAddOnContext(InstanceContext):
|
||||
def __init__(self, version: Version, account_sid: str, resource_sid: str, sid: str):
|
||||
"""
|
||||
Initialize the AssignedAddOnContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the resource to fetch.
|
||||
:param resource_sid: The SID of the Phone Number to which the Add-on is assigned.
|
||||
:param sid: The Twilio-provided string that uniquely identifies the resource to fetch.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"resource_sid": resource_sid,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/IncomingPhoneNumbers/{resource_sid}/AssignedAddOns/{sid}.json".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
self._extensions: Optional[AssignedAddOnExtensionList] = None
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the AssignedAddOnInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._version.delete(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the AssignedAddOnInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
def fetch(self) -> AssignedAddOnInstance:
|
||||
"""
|
||||
Fetch the AssignedAddOnInstance
|
||||
|
||||
|
||||
:returns: The fetched AssignedAddOnInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return AssignedAddOnInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
resource_sid=self._solution["resource_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> AssignedAddOnInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the AssignedAddOnInstance
|
||||
|
||||
|
||||
:returns: The fetched AssignedAddOnInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return AssignedAddOnInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
resource_sid=self._solution["resource_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
@property
|
||||
def extensions(self) -> AssignedAddOnExtensionList:
|
||||
"""
|
||||
Access the extensions
|
||||
"""
|
||||
if self._extensions is None:
|
||||
self._extensions = AssignedAddOnExtensionList(
|
||||
self._version,
|
||||
self._solution["account_sid"],
|
||||
self._solution["resource_sid"],
|
||||
self._solution["sid"],
|
||||
)
|
||||
return self._extensions
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.AssignedAddOnContext {}>".format(context)
|
||||
|
||||
|
||||
class AssignedAddOnPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> AssignedAddOnInstance:
|
||||
"""
|
||||
Build an instance of AssignedAddOnInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return AssignedAddOnInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
resource_sid=self._solution["resource_sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.AssignedAddOnPage>"
|
||||
|
||||
|
||||
class AssignedAddOnList(ListResource):
|
||||
def __init__(self, version: Version, account_sid: str, resource_sid: str):
|
||||
"""
|
||||
Initialize the AssignedAddOnList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the resources to read.
|
||||
:param resource_sid: The SID of the Phone Number to which the Add-on is assigned.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"resource_sid": resource_sid,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/IncomingPhoneNumbers/{resource_sid}/AssignedAddOns.json".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def create(self, installed_add_on_sid: str) -> AssignedAddOnInstance:
|
||||
"""
|
||||
Create the AssignedAddOnInstance
|
||||
|
||||
:param installed_add_on_sid: The SID that identifies the Add-on installation.
|
||||
|
||||
:returns: The created AssignedAddOnInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"InstalledAddOnSid": installed_add_on_sid,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return AssignedAddOnInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
resource_sid=self._solution["resource_sid"],
|
||||
)
|
||||
|
||||
async def create_async(self, installed_add_on_sid: str) -> AssignedAddOnInstance:
|
||||
"""
|
||||
Asynchronously create the AssignedAddOnInstance
|
||||
|
||||
:param installed_add_on_sid: The SID that identifies the Add-on installation.
|
||||
|
||||
:returns: The created AssignedAddOnInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"InstalledAddOnSid": installed_add_on_sid,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return AssignedAddOnInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
resource_sid=self._solution["resource_sid"],
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[AssignedAddOnInstance]:
|
||||
"""
|
||||
Streams AssignedAddOnInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[AssignedAddOnInstance]:
|
||||
"""
|
||||
Asynchronously streams AssignedAddOnInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[AssignedAddOnInstance]:
|
||||
"""
|
||||
Lists AssignedAddOnInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return list(
|
||||
self.stream(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[AssignedAddOnInstance]:
|
||||
"""
|
||||
Asynchronously lists AssignedAddOnInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return [
|
||||
record
|
||||
async for record in await self.stream_async(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> AssignedAddOnPage:
|
||||
"""
|
||||
Retrieve a single page of AssignedAddOnInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of AssignedAddOnInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return AssignedAddOnPage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> AssignedAddOnPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of AssignedAddOnInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of AssignedAddOnInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return AssignedAddOnPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> AssignedAddOnPage:
|
||||
"""
|
||||
Retrieve a specific page of AssignedAddOnInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of AssignedAddOnInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return AssignedAddOnPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> AssignedAddOnPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of AssignedAddOnInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of AssignedAddOnInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return AssignedAddOnPage(self._version, response, self._solution)
|
||||
|
||||
def get(self, sid: str) -> AssignedAddOnContext:
|
||||
"""
|
||||
Constructs a AssignedAddOnContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the resource to fetch.
|
||||
"""
|
||||
return AssignedAddOnContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
resource_sid=self._solution["resource_sid"],
|
||||
sid=sid,
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> AssignedAddOnContext:
|
||||
"""
|
||||
Constructs a AssignedAddOnContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the resource to fetch.
|
||||
"""
|
||||
return AssignedAddOnContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
resource_sid=self._solution["resource_sid"],
|
||||
sid=sid,
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.AssignedAddOnList>"
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
+469
@@ -0,0 +1,469 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import values
|
||||
from twilio.base.instance_context import InstanceContext
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.page import Page
|
||||
|
||||
|
||||
class AssignedAddOnExtensionInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar sid: The unique string that that we created to identify the resource.
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the resource.
|
||||
:ivar resource_sid: The SID of the Phone Number to which the Add-on is assigned.
|
||||
:ivar assigned_add_on_sid: The SID that uniquely identifies the assigned Add-on installation.
|
||||
:ivar friendly_name: The string that you assigned to describe the resource.
|
||||
:ivar product_name: A string that you assigned to describe the Product this Extension is used within.
|
||||
:ivar unique_name: An application-defined string that uniquely identifies the resource. It can be used in place of the resource's `sid` in the URL to address the resource.
|
||||
:ivar uri: The URI of the resource, relative to `https://api.twilio.com`.
|
||||
:ivar enabled: Whether the Extension will be invoked.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
account_sid: str,
|
||||
resource_sid: str,
|
||||
assigned_add_on_sid: str,
|
||||
sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.resource_sid: Optional[str] = payload.get("resource_sid")
|
||||
self.assigned_add_on_sid: Optional[str] = payload.get("assigned_add_on_sid")
|
||||
self.friendly_name: Optional[str] = payload.get("friendly_name")
|
||||
self.product_name: Optional[str] = payload.get("product_name")
|
||||
self.unique_name: Optional[str] = payload.get("unique_name")
|
||||
self.uri: Optional[str] = payload.get("uri")
|
||||
self.enabled: Optional[bool] = payload.get("enabled")
|
||||
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"resource_sid": resource_sid,
|
||||
"assigned_add_on_sid": assigned_add_on_sid,
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[AssignedAddOnExtensionContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "AssignedAddOnExtensionContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: AssignedAddOnExtensionContext for this AssignedAddOnExtensionInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = AssignedAddOnExtensionContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
resource_sid=self._solution["resource_sid"],
|
||||
assigned_add_on_sid=self._solution["assigned_add_on_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def fetch(self) -> "AssignedAddOnExtensionInstance":
|
||||
"""
|
||||
Fetch the AssignedAddOnExtensionInstance
|
||||
|
||||
|
||||
:returns: The fetched AssignedAddOnExtensionInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "AssignedAddOnExtensionInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the AssignedAddOnExtensionInstance
|
||||
|
||||
|
||||
:returns: The fetched AssignedAddOnExtensionInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.AssignedAddOnExtensionInstance {}>".format(context)
|
||||
|
||||
|
||||
class AssignedAddOnExtensionContext(InstanceContext):
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
account_sid: str,
|
||||
resource_sid: str,
|
||||
assigned_add_on_sid: str,
|
||||
sid: str,
|
||||
):
|
||||
"""
|
||||
Initialize the AssignedAddOnExtensionContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the resource to fetch.
|
||||
:param resource_sid: The SID of the Phone Number to which the Add-on is assigned.
|
||||
:param assigned_add_on_sid: The SID that uniquely identifies the assigned Add-on installation.
|
||||
:param sid: The Twilio-provided string that uniquely identifies the resource to fetch.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"resource_sid": resource_sid,
|
||||
"assigned_add_on_sid": assigned_add_on_sid,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/IncomingPhoneNumbers/{resource_sid}/AssignedAddOns/{assigned_add_on_sid}/Extensions/{sid}.json".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def fetch(self) -> AssignedAddOnExtensionInstance:
|
||||
"""
|
||||
Fetch the AssignedAddOnExtensionInstance
|
||||
|
||||
|
||||
:returns: The fetched AssignedAddOnExtensionInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return AssignedAddOnExtensionInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
resource_sid=self._solution["resource_sid"],
|
||||
assigned_add_on_sid=self._solution["assigned_add_on_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> AssignedAddOnExtensionInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the AssignedAddOnExtensionInstance
|
||||
|
||||
|
||||
:returns: The fetched AssignedAddOnExtensionInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return AssignedAddOnExtensionInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
resource_sid=self._solution["resource_sid"],
|
||||
assigned_add_on_sid=self._solution["assigned_add_on_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.AssignedAddOnExtensionContext {}>".format(context)
|
||||
|
||||
|
||||
class AssignedAddOnExtensionPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> AssignedAddOnExtensionInstance:
|
||||
"""
|
||||
Build an instance of AssignedAddOnExtensionInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return AssignedAddOnExtensionInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
resource_sid=self._solution["resource_sid"],
|
||||
assigned_add_on_sid=self._solution["assigned_add_on_sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.AssignedAddOnExtensionPage>"
|
||||
|
||||
|
||||
class AssignedAddOnExtensionList(ListResource):
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
account_sid: str,
|
||||
resource_sid: str,
|
||||
assigned_add_on_sid: str,
|
||||
):
|
||||
"""
|
||||
Initialize the AssignedAddOnExtensionList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the resources to read.
|
||||
:param resource_sid: The SID of the Phone Number to which the Add-on is assigned.
|
||||
:param assigned_add_on_sid: The SID that uniquely identifies the assigned Add-on installation.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"resource_sid": resource_sid,
|
||||
"assigned_add_on_sid": assigned_add_on_sid,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/IncomingPhoneNumbers/{resource_sid}/AssignedAddOns/{assigned_add_on_sid}/Extensions.json".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[AssignedAddOnExtensionInstance]:
|
||||
"""
|
||||
Streams AssignedAddOnExtensionInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page 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[AssignedAddOnExtensionInstance]:
|
||||
"""
|
||||
Asynchronously streams AssignedAddOnExtensionInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page 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[AssignedAddOnExtensionInstance]:
|
||||
"""
|
||||
Lists AssignedAddOnExtensionInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to 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[AssignedAddOnExtensionInstance]:
|
||||
"""
|
||||
Asynchronously lists AssignedAddOnExtensionInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to 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,
|
||||
) -> AssignedAddOnExtensionPage:
|
||||
"""
|
||||
Retrieve a single page of AssignedAddOnExtensionInstance 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 AssignedAddOnExtensionInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return AssignedAddOnExtensionPage(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,
|
||||
) -> AssignedAddOnExtensionPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of AssignedAddOnExtensionInstance 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 AssignedAddOnExtensionInstance
|
||||
"""
|
||||
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 AssignedAddOnExtensionPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> AssignedAddOnExtensionPage:
|
||||
"""
|
||||
Retrieve a specific page of AssignedAddOnExtensionInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of AssignedAddOnExtensionInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return AssignedAddOnExtensionPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> AssignedAddOnExtensionPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of AssignedAddOnExtensionInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of AssignedAddOnExtensionInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return AssignedAddOnExtensionPage(self._version, response, self._solution)
|
||||
|
||||
def get(self, sid: str) -> AssignedAddOnExtensionContext:
|
||||
"""
|
||||
Constructs a AssignedAddOnExtensionContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the resource to fetch.
|
||||
"""
|
||||
return AssignedAddOnExtensionContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
resource_sid=self._solution["resource_sid"],
|
||||
assigned_add_on_sid=self._solution["assigned_add_on_sid"],
|
||||
sid=sid,
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> AssignedAddOnExtensionContext:
|
||||
"""
|
||||
Constructs a AssignedAddOnExtensionContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the resource to fetch.
|
||||
"""
|
||||
return AssignedAddOnExtensionContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
resource_sid=self._solution["resource_sid"],
|
||||
assigned_add_on_sid=self._solution["assigned_add_on_sid"],
|
||||
sid=sid,
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.AssignedAddOnExtensionList>"
|
||||
+648
@@ -0,0 +1,648 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, values
|
||||
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.page import Page
|
||||
|
||||
|
||||
class LocalInstance(InstanceResource):
|
||||
class AddressRequirement(object):
|
||||
NONE = "none"
|
||||
ANY = "any"
|
||||
LOCAL = "local"
|
||||
FOREIGN = "foreign"
|
||||
|
||||
class EmergencyAddressStatus(object):
|
||||
REGISTERED = "registered"
|
||||
UNREGISTERED = "unregistered"
|
||||
PENDING_REGISTRATION = "pending-registration"
|
||||
REGISTRATION_FAILURE = "registration-failure"
|
||||
PENDING_UNREGISTRATION = "pending-unregistration"
|
||||
UNREGISTRATION_FAILURE = "unregistration-failure"
|
||||
|
||||
class EmergencyStatus(object):
|
||||
ACTIVE = "Active"
|
||||
INACTIVE = "Inactive"
|
||||
|
||||
class VoiceReceiveMode(object):
|
||||
VOICE = "voice"
|
||||
FAX = "fax"
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the resource.
|
||||
:ivar address_sid: The SID of the Address resource associated with the phone number.
|
||||
:ivar address_requirements:
|
||||
:ivar api_version: The API version used to start a new TwiML session.
|
||||
:ivar beta: Whether the phone number is new to the Twilio platform. Can be: `true` or `false`.
|
||||
:ivar capabilities:
|
||||
:ivar date_created: The date and time in GMT that the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar date_updated: The date and time in GMT that the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar friendly_name: The string that you assigned to describe the resource.
|
||||
:ivar identity_sid: The SID of the Identity resource that we associate with the phone number. Some regions require an Identity to meet local regulations.
|
||||
:ivar phone_number: The phone number in [E.164](https://www.twilio.com/docs/glossary/what-e164) format, which consists of a + followed by the country code and subscriber number.
|
||||
:ivar origin: The phone number's origin. `twilio` identifies Twilio-owned phone numbers and `hosted` identifies hosted phone numbers.
|
||||
:ivar sid: The unique string that that we created to identify the resource.
|
||||
:ivar sms_application_sid: The SID of the application that handles SMS messages sent to the phone number. If an `sms_application_sid` is present, we ignore all `sms_*_url` values and use those of the application.
|
||||
:ivar sms_fallback_method: The HTTP method we use to call `sms_fallback_url`. Can be: `GET` or `POST`.
|
||||
:ivar sms_fallback_url: The URL that we call when an error occurs while retrieving or executing the TwiML from `sms_url`.
|
||||
:ivar sms_method: The HTTP method we use to call `sms_url`. Can be: `GET` or `POST`.
|
||||
:ivar sms_url: The URL we call when the phone number receives an incoming SMS message.
|
||||
:ivar status_callback: The URL we call using the `status_callback_method` to send status information to your application.
|
||||
:ivar status_callback_method: The HTTP method we use to call `status_callback`. Can be: `GET` or `POST`.
|
||||
:ivar trunk_sid: The SID of the Trunk that handles calls to the phone number. If a `trunk_sid` is present, we ignore all of the voice urls and voice applications and use those set on the Trunk. Setting a `trunk_sid` will automatically delete your `voice_application_sid` and vice versa.
|
||||
:ivar uri: The URI of the resource, relative to `https://api.twilio.com`.
|
||||
:ivar voice_receive_mode:
|
||||
:ivar voice_application_sid: The SID of the application that handles calls to the phone number. If a `voice_application_sid` is present, we ignore all of the voice urls and use those set on the application. Setting a `voice_application_sid` will automatically delete your `trunk_sid` and vice versa.
|
||||
:ivar voice_caller_id_lookup: Whether we look up the caller's caller-ID name from the CNAM database ($0.01 per look up). Can be: `true` or `false`.
|
||||
:ivar voice_fallback_method: The HTTP method we use to call `voice_fallback_url`. Can be: `GET` or `POST`.
|
||||
:ivar voice_fallback_url: The URL that we call when an error occurs retrieving or executing the TwiML requested by `url`.
|
||||
:ivar voice_method: The HTTP method we use to call `voice_url`. Can be: `GET` or `POST`.
|
||||
:ivar voice_url: The URL we call when this phone number receives a call. The `voice_url` will not be used if a `voice_application_sid` or a `trunk_sid` is set.
|
||||
:ivar emergency_status:
|
||||
:ivar emergency_address_sid: The SID of the emergency address configuration that we use for emergency calling from this phone number.
|
||||
:ivar emergency_address_status:
|
||||
:ivar bundle_sid: The SID of the Bundle resource that you associate with the phone number. Some regions require a Bundle to meet local Regulations.
|
||||
:ivar status:
|
||||
"""
|
||||
|
||||
def __init__(self, version: Version, payload: Dict[str, Any], account_sid: str):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.address_sid: Optional[str] = payload.get("address_sid")
|
||||
self.address_requirements: Optional[
|
||||
"LocalInstance.AddressRequirement"
|
||||
] = payload.get("address_requirements")
|
||||
self.api_version: Optional[str] = payload.get("api_version")
|
||||
self.beta: Optional[bool] = payload.get("beta")
|
||||
self.capabilities: Optional[str] = payload.get("capabilities")
|
||||
self.date_created: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.friendly_name: Optional[str] = payload.get("friendly_name")
|
||||
self.identity_sid: Optional[str] = payload.get("identity_sid")
|
||||
self.phone_number: Optional[str] = payload.get("phone_number")
|
||||
self.origin: Optional[str] = payload.get("origin")
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.sms_application_sid: Optional[str] = payload.get("sms_application_sid")
|
||||
self.sms_fallback_method: Optional[str] = payload.get("sms_fallback_method")
|
||||
self.sms_fallback_url: Optional[str] = payload.get("sms_fallback_url")
|
||||
self.sms_method: Optional[str] = payload.get("sms_method")
|
||||
self.sms_url: Optional[str] = payload.get("sms_url")
|
||||
self.status_callback: Optional[str] = payload.get("status_callback")
|
||||
self.status_callback_method: Optional[str] = payload.get(
|
||||
"status_callback_method"
|
||||
)
|
||||
self.trunk_sid: Optional[str] = payload.get("trunk_sid")
|
||||
self.uri: Optional[str] = payload.get("uri")
|
||||
self.voice_receive_mode: Optional[
|
||||
"LocalInstance.VoiceReceiveMode"
|
||||
] = payload.get("voice_receive_mode")
|
||||
self.voice_application_sid: Optional[str] = payload.get("voice_application_sid")
|
||||
self.voice_caller_id_lookup: Optional[bool] = payload.get(
|
||||
"voice_caller_id_lookup"
|
||||
)
|
||||
self.voice_fallback_method: Optional[str] = payload.get("voice_fallback_method")
|
||||
self.voice_fallback_url: Optional[str] = payload.get("voice_fallback_url")
|
||||
self.voice_method: Optional[str] = payload.get("voice_method")
|
||||
self.voice_url: Optional[str] = payload.get("voice_url")
|
||||
self.emergency_status: Optional["LocalInstance.EmergencyStatus"] = payload.get(
|
||||
"emergency_status"
|
||||
)
|
||||
self.emergency_address_sid: Optional[str] = payload.get("emergency_address_sid")
|
||||
self.emergency_address_status: Optional[
|
||||
"LocalInstance.EmergencyAddressStatus"
|
||||
] = payload.get("emergency_address_status")
|
||||
self.bundle_sid: Optional[str] = payload.get("bundle_sid")
|
||||
self.status: Optional[str] = payload.get("status")
|
||||
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
}
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.LocalInstance {}>".format(context)
|
||||
|
||||
|
||||
class LocalPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> LocalInstance:
|
||||
"""
|
||||
Build an instance of LocalInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return LocalInstance(
|
||||
self._version, payload, account_sid=self._solution["account_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.LocalPage>"
|
||||
|
||||
|
||||
class LocalList(ListResource):
|
||||
def __init__(self, version: Version, account_sid: str):
|
||||
"""
|
||||
Initialize the LocalList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the resources to read.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/IncomingPhoneNumbers/Local.json".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def create(
|
||||
self,
|
||||
phone_number: str,
|
||||
api_version: Union[str, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
sms_application_sid: Union[str, object] = values.unset,
|
||||
sms_fallback_method: Union[str, object] = values.unset,
|
||||
sms_fallback_url: Union[str, object] = values.unset,
|
||||
sms_method: Union[str, object] = values.unset,
|
||||
sms_url: Union[str, object] = values.unset,
|
||||
status_callback: Union[str, object] = values.unset,
|
||||
status_callback_method: Union[str, object] = values.unset,
|
||||
voice_application_sid: Union[str, object] = values.unset,
|
||||
voice_caller_id_lookup: Union[bool, object] = values.unset,
|
||||
voice_fallback_method: Union[str, object] = values.unset,
|
||||
voice_fallback_url: Union[str, object] = values.unset,
|
||||
voice_method: Union[str, object] = values.unset,
|
||||
voice_url: Union[str, object] = values.unset,
|
||||
identity_sid: Union[str, object] = values.unset,
|
||||
address_sid: Union[str, object] = values.unset,
|
||||
emergency_status: Union["LocalInstance.EmergencyStatus", object] = values.unset,
|
||||
emergency_address_sid: Union[str, object] = values.unset,
|
||||
trunk_sid: Union[str, object] = values.unset,
|
||||
voice_receive_mode: Union[
|
||||
"LocalInstance.VoiceReceiveMode", object
|
||||
] = values.unset,
|
||||
bundle_sid: Union[str, object] = values.unset,
|
||||
) -> LocalInstance:
|
||||
"""
|
||||
Create the LocalInstance
|
||||
|
||||
:param phone_number: The phone number to purchase specified in [E.164](https://www.twilio.com/docs/glossary/what-e164) format. E.164 phone numbers consist of a + followed by the country code and subscriber number without punctuation characters. For example, +14155551234.
|
||||
:param api_version: The API version to use for incoming calls made to the new phone number. The default is `2010-04-01`.
|
||||
:param friendly_name: A descriptive string that you created to describe the new phone number. It can be up to 64 characters long. By default, this is a formatted version of the phone number.
|
||||
:param sms_application_sid: The SID of the application that should handle SMS messages sent to the new phone number. If an `sms_application_sid` is present, we ignore all of the `sms_*_url` urls and use those set on the application.
|
||||
:param sms_fallback_method: The HTTP method that we should use to call `sms_fallback_url`. Can be: `GET` or `POST` and defaults to `POST`.
|
||||
:param sms_fallback_url: The URL that we should call when an error occurs while requesting or executing the TwiML defined by `sms_url`.
|
||||
:param sms_method: The HTTP method that we should use to call `sms_url`. Can be: `GET` or `POST` and defaults to `POST`.
|
||||
:param sms_url: The URL we should call when the new phone number receives an incoming SMS message.
|
||||
:param status_callback: The URL we should call using the `status_callback_method` to send status information to your application.
|
||||
:param status_callback_method: The HTTP method we should use to call `status_callback`. Can be: `GET` or `POST` and defaults to `POST`.
|
||||
:param voice_application_sid: The SID of the application we should use to handle calls to the new phone number. If a `voice_application_sid` is present, we ignore all of the voice urls and use only those set on the application. Setting a `voice_application_sid` will automatically delete your `trunk_sid` and vice versa.
|
||||
:param voice_caller_id_lookup: Whether to lookup the caller's name from the CNAM database and post it to your app. Can be: `true` or `false` and defaults to `false`.
|
||||
:param voice_fallback_method: The HTTP method that we should use to call `voice_fallback_url`. Can be: `GET` or `POST` and defaults to `POST`.
|
||||
:param voice_fallback_url: The URL that we should call when an error occurs retrieving or executing the TwiML requested by `url`.
|
||||
:param voice_method: The HTTP method that we should use to call `voice_url`. Can be: `GET` or `POST` and defaults to `POST`.
|
||||
:param voice_url: The URL that we should call to answer a call to the new phone number. The `voice_url` will not be called if a `voice_application_sid` or a `trunk_sid` is set.
|
||||
:param identity_sid: The SID of the Identity resource that we should associate with the new phone number. Some regions require an identity to meet local regulations.
|
||||
:param address_sid: The SID of the Address resource we should associate with the new phone number. Some regions require addresses to meet local regulations.
|
||||
:param emergency_status:
|
||||
:param emergency_address_sid: The SID of the emergency address configuration to use for emergency calling from the new phone number.
|
||||
:param trunk_sid: The SID of the Trunk we should use to handle calls to the new phone number. If a `trunk_sid` is present, we ignore all of the voice urls and voice applications and use only those set on the Trunk. Setting a `trunk_sid` will automatically delete your `voice_application_sid` and vice versa.
|
||||
:param voice_receive_mode:
|
||||
:param bundle_sid: The SID of the Bundle resource that you associate with the phone number. Some regions require a Bundle to meet local Regulations.
|
||||
|
||||
:returns: The created LocalInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PhoneNumber": phone_number,
|
||||
"ApiVersion": api_version,
|
||||
"FriendlyName": friendly_name,
|
||||
"SmsApplicationSid": sms_application_sid,
|
||||
"SmsFallbackMethod": sms_fallback_method,
|
||||
"SmsFallbackUrl": sms_fallback_url,
|
||||
"SmsMethod": sms_method,
|
||||
"SmsUrl": sms_url,
|
||||
"StatusCallback": status_callback,
|
||||
"StatusCallbackMethod": status_callback_method,
|
||||
"VoiceApplicationSid": voice_application_sid,
|
||||
"VoiceCallerIdLookup": voice_caller_id_lookup,
|
||||
"VoiceFallbackMethod": voice_fallback_method,
|
||||
"VoiceFallbackUrl": voice_fallback_url,
|
||||
"VoiceMethod": voice_method,
|
||||
"VoiceUrl": voice_url,
|
||||
"IdentitySid": identity_sid,
|
||||
"AddressSid": address_sid,
|
||||
"EmergencyStatus": emergency_status,
|
||||
"EmergencyAddressSid": emergency_address_sid,
|
||||
"TrunkSid": trunk_sid,
|
||||
"VoiceReceiveMode": voice_receive_mode,
|
||||
"BundleSid": bundle_sid,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return LocalInstance(
|
||||
self._version, payload, account_sid=self._solution["account_sid"]
|
||||
)
|
||||
|
||||
async def create_async(
|
||||
self,
|
||||
phone_number: str,
|
||||
api_version: Union[str, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
sms_application_sid: Union[str, object] = values.unset,
|
||||
sms_fallback_method: Union[str, object] = values.unset,
|
||||
sms_fallback_url: Union[str, object] = values.unset,
|
||||
sms_method: Union[str, object] = values.unset,
|
||||
sms_url: Union[str, object] = values.unset,
|
||||
status_callback: Union[str, object] = values.unset,
|
||||
status_callback_method: Union[str, object] = values.unset,
|
||||
voice_application_sid: Union[str, object] = values.unset,
|
||||
voice_caller_id_lookup: Union[bool, object] = values.unset,
|
||||
voice_fallback_method: Union[str, object] = values.unset,
|
||||
voice_fallback_url: Union[str, object] = values.unset,
|
||||
voice_method: Union[str, object] = values.unset,
|
||||
voice_url: Union[str, object] = values.unset,
|
||||
identity_sid: Union[str, object] = values.unset,
|
||||
address_sid: Union[str, object] = values.unset,
|
||||
emergency_status: Union["LocalInstance.EmergencyStatus", object] = values.unset,
|
||||
emergency_address_sid: Union[str, object] = values.unset,
|
||||
trunk_sid: Union[str, object] = values.unset,
|
||||
voice_receive_mode: Union[
|
||||
"LocalInstance.VoiceReceiveMode", object
|
||||
] = values.unset,
|
||||
bundle_sid: Union[str, object] = values.unset,
|
||||
) -> LocalInstance:
|
||||
"""
|
||||
Asynchronously create the LocalInstance
|
||||
|
||||
:param phone_number: The phone number to purchase specified in [E.164](https://www.twilio.com/docs/glossary/what-e164) format. E.164 phone numbers consist of a + followed by the country code and subscriber number without punctuation characters. For example, +14155551234.
|
||||
:param api_version: The API version to use for incoming calls made to the new phone number. The default is `2010-04-01`.
|
||||
:param friendly_name: A descriptive string that you created to describe the new phone number. It can be up to 64 characters long. By default, this is a formatted version of the phone number.
|
||||
:param sms_application_sid: The SID of the application that should handle SMS messages sent to the new phone number. If an `sms_application_sid` is present, we ignore all of the `sms_*_url` urls and use those set on the application.
|
||||
:param sms_fallback_method: The HTTP method that we should use to call `sms_fallback_url`. Can be: `GET` or `POST` and defaults to `POST`.
|
||||
:param sms_fallback_url: The URL that we should call when an error occurs while requesting or executing the TwiML defined by `sms_url`.
|
||||
:param sms_method: The HTTP method that we should use to call `sms_url`. Can be: `GET` or `POST` and defaults to `POST`.
|
||||
:param sms_url: The URL we should call when the new phone number receives an incoming SMS message.
|
||||
:param status_callback: The URL we should call using the `status_callback_method` to send status information to your application.
|
||||
:param status_callback_method: The HTTP method we should use to call `status_callback`. Can be: `GET` or `POST` and defaults to `POST`.
|
||||
:param voice_application_sid: The SID of the application we should use to handle calls to the new phone number. If a `voice_application_sid` is present, we ignore all of the voice urls and use only those set on the application. Setting a `voice_application_sid` will automatically delete your `trunk_sid` and vice versa.
|
||||
:param voice_caller_id_lookup: Whether to lookup the caller's name from the CNAM database and post it to your app. Can be: `true` or `false` and defaults to `false`.
|
||||
:param voice_fallback_method: The HTTP method that we should use to call `voice_fallback_url`. Can be: `GET` or `POST` and defaults to `POST`.
|
||||
:param voice_fallback_url: The URL that we should call when an error occurs retrieving or executing the TwiML requested by `url`.
|
||||
:param voice_method: The HTTP method that we should use to call `voice_url`. Can be: `GET` or `POST` and defaults to `POST`.
|
||||
:param voice_url: The URL that we should call to answer a call to the new phone number. The `voice_url` will not be called if a `voice_application_sid` or a `trunk_sid` is set.
|
||||
:param identity_sid: The SID of the Identity resource that we should associate with the new phone number. Some regions require an identity to meet local regulations.
|
||||
:param address_sid: The SID of the Address resource we should associate with the new phone number. Some regions require addresses to meet local regulations.
|
||||
:param emergency_status:
|
||||
:param emergency_address_sid: The SID of the emergency address configuration to use for emergency calling from the new phone number.
|
||||
:param trunk_sid: The SID of the Trunk we should use to handle calls to the new phone number. If a `trunk_sid` is present, we ignore all of the voice urls and voice applications and use only those set on the Trunk. Setting a `trunk_sid` will automatically delete your `voice_application_sid` and vice versa.
|
||||
:param voice_receive_mode:
|
||||
:param bundle_sid: The SID of the Bundle resource that you associate with the phone number. Some regions require a Bundle to meet local Regulations.
|
||||
|
||||
:returns: The created LocalInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PhoneNumber": phone_number,
|
||||
"ApiVersion": api_version,
|
||||
"FriendlyName": friendly_name,
|
||||
"SmsApplicationSid": sms_application_sid,
|
||||
"SmsFallbackMethod": sms_fallback_method,
|
||||
"SmsFallbackUrl": sms_fallback_url,
|
||||
"SmsMethod": sms_method,
|
||||
"SmsUrl": sms_url,
|
||||
"StatusCallback": status_callback,
|
||||
"StatusCallbackMethod": status_callback_method,
|
||||
"VoiceApplicationSid": voice_application_sid,
|
||||
"VoiceCallerIdLookup": voice_caller_id_lookup,
|
||||
"VoiceFallbackMethod": voice_fallback_method,
|
||||
"VoiceFallbackUrl": voice_fallback_url,
|
||||
"VoiceMethod": voice_method,
|
||||
"VoiceUrl": voice_url,
|
||||
"IdentitySid": identity_sid,
|
||||
"AddressSid": address_sid,
|
||||
"EmergencyStatus": emergency_status,
|
||||
"EmergencyAddressSid": emergency_address_sid,
|
||||
"TrunkSid": trunk_sid,
|
||||
"VoiceReceiveMode": voice_receive_mode,
|
||||
"BundleSid": bundle_sid,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return LocalInstance(
|
||||
self._version, payload, account_sid=self._solution["account_sid"]
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
phone_number: Union[str, object] = values.unset,
|
||||
origin: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[LocalInstance]:
|
||||
"""
|
||||
Streams LocalInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param bool beta: Whether to include phone numbers new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str friendly_name: A string that identifies the resources to read.
|
||||
:param str phone_number: The phone numbers of the IncomingPhoneNumber resources to read. You can specify partial numbers and use '*' as a wildcard for any digit.
|
||||
:param str origin: Whether to include phone numbers based on their origin. Can be: `twilio` or `hosted`. By default, phone numbers of all origin are included.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page 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(
|
||||
beta=beta,
|
||||
friendly_name=friendly_name,
|
||||
phone_number=phone_number,
|
||||
origin=origin,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
phone_number: Union[str, object] = values.unset,
|
||||
origin: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[LocalInstance]:
|
||||
"""
|
||||
Asynchronously streams LocalInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param bool beta: Whether to include phone numbers new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str friendly_name: A string that identifies the resources to read.
|
||||
:param str phone_number: The phone numbers of the IncomingPhoneNumber resources to read. You can specify partial numbers and use '*' as a wildcard for any digit.
|
||||
:param str origin: Whether to include phone numbers based on their origin. Can be: `twilio` or `hosted`. By default, phone numbers of all origin are included.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page 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(
|
||||
beta=beta,
|
||||
friendly_name=friendly_name,
|
||||
phone_number=phone_number,
|
||||
origin=origin,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
phone_number: Union[str, object] = values.unset,
|
||||
origin: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[LocalInstance]:
|
||||
"""
|
||||
Lists LocalInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param bool beta: Whether to include phone numbers new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str friendly_name: A string that identifies the resources to read.
|
||||
:param str phone_number: The phone numbers of the IncomingPhoneNumber resources to read. You can specify partial numbers and use '*' as a wildcard for any digit.
|
||||
:param str origin: Whether to include phone numbers based on their origin. Can be: `twilio` or `hosted`. By default, phone numbers of all origin are included.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to 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(
|
||||
beta=beta,
|
||||
friendly_name=friendly_name,
|
||||
phone_number=phone_number,
|
||||
origin=origin,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
phone_number: Union[str, object] = values.unset,
|
||||
origin: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[LocalInstance]:
|
||||
"""
|
||||
Asynchronously lists LocalInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param bool beta: Whether to include phone numbers new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str friendly_name: A string that identifies the resources to read.
|
||||
:param str phone_number: The phone numbers of the IncomingPhoneNumber resources to read. You can specify partial numbers and use '*' as a wildcard for any digit.
|
||||
:param str origin: Whether to include phone numbers based on their origin. Can be: `twilio` or `hosted`. By default, phone numbers of all origin are included.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to 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(
|
||||
beta=beta,
|
||||
friendly_name=friendly_name,
|
||||
phone_number=phone_number,
|
||||
origin=origin,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
phone_number: Union[str, object] = values.unset,
|
||||
origin: Union[str, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> LocalPage:
|
||||
"""
|
||||
Retrieve a single page of LocalInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param beta: Whether to include phone numbers new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param friendly_name: A string that identifies the resources to read.
|
||||
:param phone_number: The phone numbers of the IncomingPhoneNumber resources to read. You can specify partial numbers and use '*' as a wildcard for any digit.
|
||||
:param origin: Whether to include phone numbers based on their origin. Can be: `twilio` or `hosted`. By default, phone numbers of all origin are included.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of LocalInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Beta": beta,
|
||||
"FriendlyName": friendly_name,
|
||||
"PhoneNumber": phone_number,
|
||||
"Origin": origin,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return LocalPage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
phone_number: Union[str, object] = values.unset,
|
||||
origin: Union[str, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> LocalPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of LocalInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param beta: Whether to include phone numbers new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param friendly_name: A string that identifies the resources to read.
|
||||
:param phone_number: The phone numbers of the IncomingPhoneNumber resources to read. You can specify partial numbers and use '*' as a wildcard for any digit.
|
||||
:param origin: Whether to include phone numbers based on their origin. Can be: `twilio` or `hosted`. By default, phone numbers of all origin are included.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of LocalInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Beta": beta,
|
||||
"FriendlyName": friendly_name,
|
||||
"PhoneNumber": phone_number,
|
||||
"Origin": origin,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return LocalPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> LocalPage:
|
||||
"""
|
||||
Retrieve a specific page of LocalInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of LocalInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return LocalPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> LocalPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of LocalInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of LocalInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return LocalPage(self._version, response, self._solution)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.LocalList>"
|
||||
+652
@@ -0,0 +1,652 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, values
|
||||
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.page import Page
|
||||
|
||||
|
||||
class MobileInstance(InstanceResource):
|
||||
class AddressRequirement(object):
|
||||
NONE = "none"
|
||||
ANY = "any"
|
||||
LOCAL = "local"
|
||||
FOREIGN = "foreign"
|
||||
|
||||
class EmergencyAddressStatus(object):
|
||||
REGISTERED = "registered"
|
||||
UNREGISTERED = "unregistered"
|
||||
PENDING_REGISTRATION = "pending-registration"
|
||||
REGISTRATION_FAILURE = "registration-failure"
|
||||
PENDING_UNREGISTRATION = "pending-unregistration"
|
||||
UNREGISTRATION_FAILURE = "unregistration-failure"
|
||||
|
||||
class EmergencyStatus(object):
|
||||
ACTIVE = "Active"
|
||||
INACTIVE = "Inactive"
|
||||
|
||||
class VoiceReceiveMode(object):
|
||||
VOICE = "voice"
|
||||
FAX = "fax"
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the resource.
|
||||
:ivar address_sid: The SID of the Address resource associated with the phone number.
|
||||
:ivar address_requirements:
|
||||
:ivar api_version: The API version used to start a new TwiML session.
|
||||
:ivar beta: Whether the phone number is new to the Twilio platform. Can be: `true` or `false`.
|
||||
:ivar capabilities:
|
||||
:ivar date_created: The date and time in GMT that the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar date_updated: The date and time in GMT that the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar friendly_name: The string that you assigned to describe the resource.
|
||||
:ivar identity_sid: The SID of the Identity resource that we associate with the phone number. Some regions require an Identity to meet local regulations.
|
||||
:ivar phone_number: The phone number in [E.164](https://www.twilio.com/docs/glossary/what-e164) format, which consists of a + followed by the country code and subscriber number.
|
||||
:ivar origin: The phone number's origin. `twilio` identifies Twilio-owned phone numbers and `hosted` identifies hosted phone numbers.
|
||||
:ivar sid: The unique string that that we created to identify the resource.
|
||||
:ivar sms_application_sid: The SID of the application that handles SMS messages sent to the phone number. If an `sms_application_sid` is present, we ignore all `sms_*_url` values and use those of the application.
|
||||
:ivar sms_fallback_method: The HTTP method we use to call `sms_fallback_url`. Can be: `GET` or `POST`.
|
||||
:ivar sms_fallback_url: The URL that we call when an error occurs while retrieving or executing the TwiML from `sms_url`.
|
||||
:ivar sms_method: The HTTP method we use to call `sms_url`. Can be: `GET` or `POST`.
|
||||
:ivar sms_url: The URL we call when the phone number receives an incoming SMS message.
|
||||
:ivar status_callback: The URL we call using the `status_callback_method` to send status information to your application.
|
||||
:ivar status_callback_method: The HTTP method we use to call `status_callback`. Can be: `GET` or `POST`.
|
||||
:ivar trunk_sid: The SID of the Trunk that handles calls to the phone number. If a `trunk_sid` is present, we ignore all of the voice urls and voice applications and use those set on the Trunk. Setting a `trunk_sid` will automatically delete your `voice_application_sid` and vice versa.
|
||||
:ivar uri: The URI of the resource, relative to `https://api.twilio.com`.
|
||||
:ivar voice_receive_mode:
|
||||
:ivar voice_application_sid: The SID of the application that handles calls to the phone number. If a `voice_application_sid` is present, we ignore all of the voice urls and use those set on the application. Setting a `voice_application_sid` will automatically delete your `trunk_sid` and vice versa.
|
||||
:ivar voice_caller_id_lookup: Whether we look up the caller's caller-ID name from the CNAM database ($0.01 per look up). Can be: `true` or `false`.
|
||||
:ivar voice_fallback_method: The HTTP method we use to call `voice_fallback_url`. Can be: `GET` or `POST`.
|
||||
:ivar voice_fallback_url: The URL that we call when an error occurs retrieving or executing the TwiML requested by `url`.
|
||||
:ivar voice_method: The HTTP method we use to call `voice_url`. Can be: `GET` or `POST`.
|
||||
:ivar voice_url: The URL we call when the phone number receives a call. The `voice_url` will not be used if a `voice_application_sid` or a `trunk_sid` is set.
|
||||
:ivar emergency_status:
|
||||
:ivar emergency_address_sid: The SID of the emergency address configuration that we use for emergency calling from this phone number.
|
||||
:ivar emergency_address_status:
|
||||
:ivar bundle_sid: The SID of the Bundle resource that you associate with the phone number. Some regions require a Bundle to meet local Regulations.
|
||||
:ivar status:
|
||||
"""
|
||||
|
||||
def __init__(self, version: Version, payload: Dict[str, Any], account_sid: str):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.address_sid: Optional[str] = payload.get("address_sid")
|
||||
self.address_requirements: Optional[
|
||||
"MobileInstance.AddressRequirement"
|
||||
] = payload.get("address_requirements")
|
||||
self.api_version: Optional[str] = payload.get("api_version")
|
||||
self.beta: Optional[bool] = payload.get("beta")
|
||||
self.capabilities: Optional[str] = payload.get("capabilities")
|
||||
self.date_created: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.friendly_name: Optional[str] = payload.get("friendly_name")
|
||||
self.identity_sid: Optional[str] = payload.get("identity_sid")
|
||||
self.phone_number: Optional[str] = payload.get("phone_number")
|
||||
self.origin: Optional[str] = payload.get("origin")
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.sms_application_sid: Optional[str] = payload.get("sms_application_sid")
|
||||
self.sms_fallback_method: Optional[str] = payload.get("sms_fallback_method")
|
||||
self.sms_fallback_url: Optional[str] = payload.get("sms_fallback_url")
|
||||
self.sms_method: Optional[str] = payload.get("sms_method")
|
||||
self.sms_url: Optional[str] = payload.get("sms_url")
|
||||
self.status_callback: Optional[str] = payload.get("status_callback")
|
||||
self.status_callback_method: Optional[str] = payload.get(
|
||||
"status_callback_method"
|
||||
)
|
||||
self.trunk_sid: Optional[str] = payload.get("trunk_sid")
|
||||
self.uri: Optional[str] = payload.get("uri")
|
||||
self.voice_receive_mode: Optional[
|
||||
"MobileInstance.VoiceReceiveMode"
|
||||
] = payload.get("voice_receive_mode")
|
||||
self.voice_application_sid: Optional[str] = payload.get("voice_application_sid")
|
||||
self.voice_caller_id_lookup: Optional[bool] = payload.get(
|
||||
"voice_caller_id_lookup"
|
||||
)
|
||||
self.voice_fallback_method: Optional[str] = payload.get("voice_fallback_method")
|
||||
self.voice_fallback_url: Optional[str] = payload.get("voice_fallback_url")
|
||||
self.voice_method: Optional[str] = payload.get("voice_method")
|
||||
self.voice_url: Optional[str] = payload.get("voice_url")
|
||||
self.emergency_status: Optional["MobileInstance.EmergencyStatus"] = payload.get(
|
||||
"emergency_status"
|
||||
)
|
||||
self.emergency_address_sid: Optional[str] = payload.get("emergency_address_sid")
|
||||
self.emergency_address_status: Optional[
|
||||
"MobileInstance.EmergencyAddressStatus"
|
||||
] = payload.get("emergency_address_status")
|
||||
self.bundle_sid: Optional[str] = payload.get("bundle_sid")
|
||||
self.status: Optional[str] = payload.get("status")
|
||||
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
}
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.MobileInstance {}>".format(context)
|
||||
|
||||
|
||||
class MobilePage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> MobileInstance:
|
||||
"""
|
||||
Build an instance of MobileInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return MobileInstance(
|
||||
self._version, payload, account_sid=self._solution["account_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.MobilePage>"
|
||||
|
||||
|
||||
class MobileList(ListResource):
|
||||
def __init__(self, version: Version, account_sid: str):
|
||||
"""
|
||||
Initialize the MobileList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the resources to read.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/IncomingPhoneNumbers/Mobile.json".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def create(
|
||||
self,
|
||||
phone_number: str,
|
||||
api_version: Union[str, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
sms_application_sid: Union[str, object] = values.unset,
|
||||
sms_fallback_method: Union[str, object] = values.unset,
|
||||
sms_fallback_url: Union[str, object] = values.unset,
|
||||
sms_method: Union[str, object] = values.unset,
|
||||
sms_url: Union[str, object] = values.unset,
|
||||
status_callback: Union[str, object] = values.unset,
|
||||
status_callback_method: Union[str, object] = values.unset,
|
||||
voice_application_sid: Union[str, object] = values.unset,
|
||||
voice_caller_id_lookup: Union[bool, object] = values.unset,
|
||||
voice_fallback_method: Union[str, object] = values.unset,
|
||||
voice_fallback_url: Union[str, object] = values.unset,
|
||||
voice_method: Union[str, object] = values.unset,
|
||||
voice_url: Union[str, object] = values.unset,
|
||||
identity_sid: Union[str, object] = values.unset,
|
||||
address_sid: Union[str, object] = values.unset,
|
||||
emergency_status: Union[
|
||||
"MobileInstance.EmergencyStatus", object
|
||||
] = values.unset,
|
||||
emergency_address_sid: Union[str, object] = values.unset,
|
||||
trunk_sid: Union[str, object] = values.unset,
|
||||
voice_receive_mode: Union[
|
||||
"MobileInstance.VoiceReceiveMode", object
|
||||
] = values.unset,
|
||||
bundle_sid: Union[str, object] = values.unset,
|
||||
) -> MobileInstance:
|
||||
"""
|
||||
Create the MobileInstance
|
||||
|
||||
:param phone_number: The phone number to purchase specified in [E.164](https://www.twilio.com/docs/glossary/what-e164) format. E.164 phone numbers consist of a + followed by the country code and subscriber number without punctuation characters. For example, +14155551234.
|
||||
:param api_version: The API version to use for incoming calls made to the new phone number. The default is `2010-04-01`.
|
||||
:param friendly_name: A descriptive string that you created to describe the new phone number. It can be up to 64 characters long. By default, the is a formatted version of the phone number.
|
||||
:param sms_application_sid: The SID of the application that should handle SMS messages sent to the new phone number. If an `sms_application_sid` is present, we ignore all of the `sms_*_url` urls and use those of the application.
|
||||
:param sms_fallback_method: The HTTP method that we should use to call `sms_fallback_url`. Can be: `GET` or `POST` and defaults to `POST`.
|
||||
:param sms_fallback_url: The URL that we should call when an error occurs while requesting or executing the TwiML defined by `sms_url`.
|
||||
:param sms_method: The HTTP method that we should use to call `sms_url`. Can be: `GET` or `POST` and defaults to `POST`.
|
||||
:param sms_url: The URL we should call when the new phone number receives an incoming SMS message.
|
||||
:param status_callback: The URL we should call using the `status_callback_method` to send status information to your application.
|
||||
:param status_callback_method: The HTTP method we should use to call `status_callback`. Can be: `GET` or `POST` and defaults to `POST`.
|
||||
:param voice_application_sid: The SID of the application we should use to handle calls to the new phone number. If a `voice_application_sid` is present, we ignore all of the voice urls and use only those set on the application. Setting a `voice_application_sid` will automatically delete your `trunk_sid` and vice versa.
|
||||
:param voice_caller_id_lookup: Whether to lookup the caller's name from the CNAM database and post it to your app. Can be: `true` or `false` and defaults to `false`.
|
||||
:param voice_fallback_method: The HTTP method that we should use to call `voice_fallback_url`. Can be: `GET` or `POST` and defaults to `POST`.
|
||||
:param voice_fallback_url: The URL that we should call when an error occurs retrieving or executing the TwiML requested by `url`.
|
||||
:param voice_method: The HTTP method that we should use to call `voice_url`. Can be: `GET` or `POST` and defaults to `POST`.
|
||||
:param voice_url: The URL that we should call to answer a call to the new phone number. The `voice_url` will not be called if a `voice_application_sid` or a `trunk_sid` is set.
|
||||
:param identity_sid: The SID of the Identity resource that we should associate with the new phone number. Some regions require an identity to meet local regulations.
|
||||
:param address_sid: The SID of the Address resource we should associate with the new phone number. Some regions require addresses to meet local regulations.
|
||||
:param emergency_status:
|
||||
:param emergency_address_sid: The SID of the emergency address configuration to use for emergency calling from the new phone number.
|
||||
:param trunk_sid: The SID of the Trunk we should use to handle calls to the new phone number. If a `trunk_sid` is present, we ignore all of the voice urls and voice applications and use only those set on the Trunk. Setting a `trunk_sid` will automatically delete your `voice_application_sid` and vice versa.
|
||||
:param voice_receive_mode:
|
||||
:param bundle_sid: The SID of the Bundle resource that you associate with the phone number. Some regions require a Bundle to meet local Regulations.
|
||||
|
||||
:returns: The created MobileInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PhoneNumber": phone_number,
|
||||
"ApiVersion": api_version,
|
||||
"FriendlyName": friendly_name,
|
||||
"SmsApplicationSid": sms_application_sid,
|
||||
"SmsFallbackMethod": sms_fallback_method,
|
||||
"SmsFallbackUrl": sms_fallback_url,
|
||||
"SmsMethod": sms_method,
|
||||
"SmsUrl": sms_url,
|
||||
"StatusCallback": status_callback,
|
||||
"StatusCallbackMethod": status_callback_method,
|
||||
"VoiceApplicationSid": voice_application_sid,
|
||||
"VoiceCallerIdLookup": voice_caller_id_lookup,
|
||||
"VoiceFallbackMethod": voice_fallback_method,
|
||||
"VoiceFallbackUrl": voice_fallback_url,
|
||||
"VoiceMethod": voice_method,
|
||||
"VoiceUrl": voice_url,
|
||||
"IdentitySid": identity_sid,
|
||||
"AddressSid": address_sid,
|
||||
"EmergencyStatus": emergency_status,
|
||||
"EmergencyAddressSid": emergency_address_sid,
|
||||
"TrunkSid": trunk_sid,
|
||||
"VoiceReceiveMode": voice_receive_mode,
|
||||
"BundleSid": bundle_sid,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return MobileInstance(
|
||||
self._version, payload, account_sid=self._solution["account_sid"]
|
||||
)
|
||||
|
||||
async def create_async(
|
||||
self,
|
||||
phone_number: str,
|
||||
api_version: Union[str, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
sms_application_sid: Union[str, object] = values.unset,
|
||||
sms_fallback_method: Union[str, object] = values.unset,
|
||||
sms_fallback_url: Union[str, object] = values.unset,
|
||||
sms_method: Union[str, object] = values.unset,
|
||||
sms_url: Union[str, object] = values.unset,
|
||||
status_callback: Union[str, object] = values.unset,
|
||||
status_callback_method: Union[str, object] = values.unset,
|
||||
voice_application_sid: Union[str, object] = values.unset,
|
||||
voice_caller_id_lookup: Union[bool, object] = values.unset,
|
||||
voice_fallback_method: Union[str, object] = values.unset,
|
||||
voice_fallback_url: Union[str, object] = values.unset,
|
||||
voice_method: Union[str, object] = values.unset,
|
||||
voice_url: Union[str, object] = values.unset,
|
||||
identity_sid: Union[str, object] = values.unset,
|
||||
address_sid: Union[str, object] = values.unset,
|
||||
emergency_status: Union[
|
||||
"MobileInstance.EmergencyStatus", object
|
||||
] = values.unset,
|
||||
emergency_address_sid: Union[str, object] = values.unset,
|
||||
trunk_sid: Union[str, object] = values.unset,
|
||||
voice_receive_mode: Union[
|
||||
"MobileInstance.VoiceReceiveMode", object
|
||||
] = values.unset,
|
||||
bundle_sid: Union[str, object] = values.unset,
|
||||
) -> MobileInstance:
|
||||
"""
|
||||
Asynchronously create the MobileInstance
|
||||
|
||||
:param phone_number: The phone number to purchase specified in [E.164](https://www.twilio.com/docs/glossary/what-e164) format. E.164 phone numbers consist of a + followed by the country code and subscriber number without punctuation characters. For example, +14155551234.
|
||||
:param api_version: The API version to use for incoming calls made to the new phone number. The default is `2010-04-01`.
|
||||
:param friendly_name: A descriptive string that you created to describe the new phone number. It can be up to 64 characters long. By default, the is a formatted version of the phone number.
|
||||
:param sms_application_sid: The SID of the application that should handle SMS messages sent to the new phone number. If an `sms_application_sid` is present, we ignore all of the `sms_*_url` urls and use those of the application.
|
||||
:param sms_fallback_method: The HTTP method that we should use to call `sms_fallback_url`. Can be: `GET` or `POST` and defaults to `POST`.
|
||||
:param sms_fallback_url: The URL that we should call when an error occurs while requesting or executing the TwiML defined by `sms_url`.
|
||||
:param sms_method: The HTTP method that we should use to call `sms_url`. Can be: `GET` or `POST` and defaults to `POST`.
|
||||
:param sms_url: The URL we should call when the new phone number receives an incoming SMS message.
|
||||
:param status_callback: The URL we should call using the `status_callback_method` to send status information to your application.
|
||||
:param status_callback_method: The HTTP method we should use to call `status_callback`. Can be: `GET` or `POST` and defaults to `POST`.
|
||||
:param voice_application_sid: The SID of the application we should use to handle calls to the new phone number. If a `voice_application_sid` is present, we ignore all of the voice urls and use only those set on the application. Setting a `voice_application_sid` will automatically delete your `trunk_sid` and vice versa.
|
||||
:param voice_caller_id_lookup: Whether to lookup the caller's name from the CNAM database and post it to your app. Can be: `true` or `false` and defaults to `false`.
|
||||
:param voice_fallback_method: The HTTP method that we should use to call `voice_fallback_url`. Can be: `GET` or `POST` and defaults to `POST`.
|
||||
:param voice_fallback_url: The URL that we should call when an error occurs retrieving or executing the TwiML requested by `url`.
|
||||
:param voice_method: The HTTP method that we should use to call `voice_url`. Can be: `GET` or `POST` and defaults to `POST`.
|
||||
:param voice_url: The URL that we should call to answer a call to the new phone number. The `voice_url` will not be called if a `voice_application_sid` or a `trunk_sid` is set.
|
||||
:param identity_sid: The SID of the Identity resource that we should associate with the new phone number. Some regions require an identity to meet local regulations.
|
||||
:param address_sid: The SID of the Address resource we should associate with the new phone number. Some regions require addresses to meet local regulations.
|
||||
:param emergency_status:
|
||||
:param emergency_address_sid: The SID of the emergency address configuration to use for emergency calling from the new phone number.
|
||||
:param trunk_sid: The SID of the Trunk we should use to handle calls to the new phone number. If a `trunk_sid` is present, we ignore all of the voice urls and voice applications and use only those set on the Trunk. Setting a `trunk_sid` will automatically delete your `voice_application_sid` and vice versa.
|
||||
:param voice_receive_mode:
|
||||
:param bundle_sid: The SID of the Bundle resource that you associate with the phone number. Some regions require a Bundle to meet local Regulations.
|
||||
|
||||
:returns: The created MobileInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PhoneNumber": phone_number,
|
||||
"ApiVersion": api_version,
|
||||
"FriendlyName": friendly_name,
|
||||
"SmsApplicationSid": sms_application_sid,
|
||||
"SmsFallbackMethod": sms_fallback_method,
|
||||
"SmsFallbackUrl": sms_fallback_url,
|
||||
"SmsMethod": sms_method,
|
||||
"SmsUrl": sms_url,
|
||||
"StatusCallback": status_callback,
|
||||
"StatusCallbackMethod": status_callback_method,
|
||||
"VoiceApplicationSid": voice_application_sid,
|
||||
"VoiceCallerIdLookup": voice_caller_id_lookup,
|
||||
"VoiceFallbackMethod": voice_fallback_method,
|
||||
"VoiceFallbackUrl": voice_fallback_url,
|
||||
"VoiceMethod": voice_method,
|
||||
"VoiceUrl": voice_url,
|
||||
"IdentitySid": identity_sid,
|
||||
"AddressSid": address_sid,
|
||||
"EmergencyStatus": emergency_status,
|
||||
"EmergencyAddressSid": emergency_address_sid,
|
||||
"TrunkSid": trunk_sid,
|
||||
"VoiceReceiveMode": voice_receive_mode,
|
||||
"BundleSid": bundle_sid,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return MobileInstance(
|
||||
self._version, payload, account_sid=self._solution["account_sid"]
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
phone_number: Union[str, object] = values.unset,
|
||||
origin: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[MobileInstance]:
|
||||
"""
|
||||
Streams MobileInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param bool beta: Whether to include phone numbers new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str friendly_name: A string that identifies the resources to read.
|
||||
:param str phone_number: The phone numbers of the IncomingPhoneNumber resources to read. You can specify partial numbers and use '*' as a wildcard for any digit.
|
||||
:param str origin: Whether to include phone numbers based on their origin. Can be: `twilio` or `hosted`. By default, phone numbers of all origin are included.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page 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(
|
||||
beta=beta,
|
||||
friendly_name=friendly_name,
|
||||
phone_number=phone_number,
|
||||
origin=origin,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
phone_number: Union[str, object] = values.unset,
|
||||
origin: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[MobileInstance]:
|
||||
"""
|
||||
Asynchronously streams MobileInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param bool beta: Whether to include phone numbers new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str friendly_name: A string that identifies the resources to read.
|
||||
:param str phone_number: The phone numbers of the IncomingPhoneNumber resources to read. You can specify partial numbers and use '*' as a wildcard for any digit.
|
||||
:param str origin: Whether to include phone numbers based on their origin. Can be: `twilio` or `hosted`. By default, phone numbers of all origin are included.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page 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(
|
||||
beta=beta,
|
||||
friendly_name=friendly_name,
|
||||
phone_number=phone_number,
|
||||
origin=origin,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
phone_number: Union[str, object] = values.unset,
|
||||
origin: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[MobileInstance]:
|
||||
"""
|
||||
Lists MobileInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param bool beta: Whether to include phone numbers new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str friendly_name: A string that identifies the resources to read.
|
||||
:param str phone_number: The phone numbers of the IncomingPhoneNumber resources to read. You can specify partial numbers and use '*' as a wildcard for any digit.
|
||||
:param str origin: Whether to include phone numbers based on their origin. Can be: `twilio` or `hosted`. By default, phone numbers of all origin are included.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to 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(
|
||||
beta=beta,
|
||||
friendly_name=friendly_name,
|
||||
phone_number=phone_number,
|
||||
origin=origin,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
phone_number: Union[str, object] = values.unset,
|
||||
origin: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[MobileInstance]:
|
||||
"""
|
||||
Asynchronously lists MobileInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param bool beta: Whether to include phone numbers new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str friendly_name: A string that identifies the resources to read.
|
||||
:param str phone_number: The phone numbers of the IncomingPhoneNumber resources to read. You can specify partial numbers and use '*' as a wildcard for any digit.
|
||||
:param str origin: Whether to include phone numbers based on their origin. Can be: `twilio` or `hosted`. By default, phone numbers of all origin are included.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to 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(
|
||||
beta=beta,
|
||||
friendly_name=friendly_name,
|
||||
phone_number=phone_number,
|
||||
origin=origin,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
phone_number: Union[str, object] = values.unset,
|
||||
origin: Union[str, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> MobilePage:
|
||||
"""
|
||||
Retrieve a single page of MobileInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param beta: Whether to include phone numbers new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param friendly_name: A string that identifies the resources to read.
|
||||
:param phone_number: The phone numbers of the IncomingPhoneNumber resources to read. You can specify partial numbers and use '*' as a wildcard for any digit.
|
||||
:param origin: Whether to include phone numbers based on their origin. Can be: `twilio` or `hosted`. By default, phone numbers of all origin are included.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of MobileInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Beta": beta,
|
||||
"FriendlyName": friendly_name,
|
||||
"PhoneNumber": phone_number,
|
||||
"Origin": origin,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return MobilePage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
phone_number: Union[str, object] = values.unset,
|
||||
origin: Union[str, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> MobilePage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of MobileInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param beta: Whether to include phone numbers new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param friendly_name: A string that identifies the resources to read.
|
||||
:param phone_number: The phone numbers of the IncomingPhoneNumber resources to read. You can specify partial numbers and use '*' as a wildcard for any digit.
|
||||
:param origin: Whether to include phone numbers based on their origin. Can be: `twilio` or `hosted`. By default, phone numbers of all origin are included.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of MobileInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Beta": beta,
|
||||
"FriendlyName": friendly_name,
|
||||
"PhoneNumber": phone_number,
|
||||
"Origin": origin,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return MobilePage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> MobilePage:
|
||||
"""
|
||||
Retrieve a specific page of MobileInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of MobileInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return MobilePage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> MobilePage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of MobileInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of MobileInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return MobilePage(self._version, response, self._solution)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.MobileList>"
|
||||
+652
@@ -0,0 +1,652 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, values
|
||||
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.page import Page
|
||||
|
||||
|
||||
class TollFreeInstance(InstanceResource):
|
||||
class AddressRequirement(object):
|
||||
NONE = "none"
|
||||
ANY = "any"
|
||||
LOCAL = "local"
|
||||
FOREIGN = "foreign"
|
||||
|
||||
class EmergencyAddressStatus(object):
|
||||
REGISTERED = "registered"
|
||||
UNREGISTERED = "unregistered"
|
||||
PENDING_REGISTRATION = "pending-registration"
|
||||
REGISTRATION_FAILURE = "registration-failure"
|
||||
PENDING_UNREGISTRATION = "pending-unregistration"
|
||||
UNREGISTRATION_FAILURE = "unregistration-failure"
|
||||
|
||||
class EmergencyStatus(object):
|
||||
ACTIVE = "Active"
|
||||
INACTIVE = "Inactive"
|
||||
|
||||
class VoiceReceiveMode(object):
|
||||
VOICE = "voice"
|
||||
FAX = "fax"
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the resource.
|
||||
:ivar address_sid: The SID of the Address resource associated with the phone number.
|
||||
:ivar address_requirements:
|
||||
:ivar api_version: The API version used to start a new TwiML session.
|
||||
:ivar beta: Whether the phone number is new to the Twilio platform. Can be: `true` or `false`.
|
||||
:ivar capabilities:
|
||||
:ivar date_created: The date and time in GMT that the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar date_updated: The date and time in GMT that the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar friendly_name: The string that you assigned to describe the resource.
|
||||
:ivar identity_sid: The SID of the Identity resource that we associate with the phone number. Some regions require an Identity to meet local regulations.
|
||||
:ivar phone_number: The phone number in [E.164](https://www.twilio.com/docs/glossary/what-e164) format, which consists of a + followed by the country code and subscriber number.
|
||||
:ivar origin: The phone number's origin. `twilio` identifies Twilio-owned phone numbers and `hosted` identifies hosted phone numbers.
|
||||
:ivar sid: The unique string that that we created to identify the resource.
|
||||
:ivar sms_application_sid: The SID of the application that handles SMS messages sent to the phone number. If an `sms_application_sid` is present, we ignore all `sms_*_url` values and use those of the application.
|
||||
:ivar sms_fallback_method: The HTTP method we use to call `sms_fallback_url`. Can be: `GET` or `POST`.
|
||||
:ivar sms_fallback_url: The URL that we call when an error occurs while retrieving or executing the TwiML from `sms_url`.
|
||||
:ivar sms_method: The HTTP method we use to call `sms_url`. Can be: `GET` or `POST`.
|
||||
:ivar sms_url: The URL we call when the phone number receives an incoming SMS message.
|
||||
:ivar status_callback: The URL we call using the `status_callback_method` to send status information to your application.
|
||||
:ivar status_callback_method: The HTTP method we use to call `status_callback`. Can be: `GET` or `POST`.
|
||||
:ivar trunk_sid: The SID of the Trunk that handles calls to the phone number. If a `trunk_sid` is present, we ignore all of the voice urls and voice applications and use those set on the Trunk. Setting a `trunk_sid` will automatically delete your `voice_application_sid` and vice versa.
|
||||
:ivar uri: The URI of the resource, relative to `https://api.twilio.com`.
|
||||
:ivar voice_receive_mode:
|
||||
:ivar voice_application_sid: The SID of the application that handles calls to the phone number. If a `voice_application_sid` is present, we ignore all of the voice urls and use those set on the application. Setting a `voice_application_sid` will automatically delete your `trunk_sid` and vice versa.
|
||||
:ivar voice_caller_id_lookup: Whether we look up the caller's caller-ID name from the CNAM database ($0.01 per look up). Can be: `true` or `false`.
|
||||
:ivar voice_fallback_method: The HTTP method we use to call `voice_fallback_url`. Can be: `GET` or `POST`.
|
||||
:ivar voice_fallback_url: The URL that we call when an error occurs retrieving or executing the TwiML requested by `url`.
|
||||
:ivar voice_method: The HTTP method we use to call `voice_url`. Can be: `GET` or `POST`.
|
||||
:ivar voice_url: The URL we call when the phone number receives a call. The `voice_url` will not be used if a `voice_application_sid` or a `trunk_sid` is set.
|
||||
:ivar emergency_status:
|
||||
:ivar emergency_address_sid: The SID of the emergency address configuration that we use for emergency calling from this phone number.
|
||||
:ivar emergency_address_status:
|
||||
:ivar bundle_sid: The SID of the Bundle resource that you associate with the phone number. Some regions require a Bundle to meet local Regulations.
|
||||
:ivar status:
|
||||
"""
|
||||
|
||||
def __init__(self, version: Version, payload: Dict[str, Any], account_sid: str):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.address_sid: Optional[str] = payload.get("address_sid")
|
||||
self.address_requirements: Optional[
|
||||
"TollFreeInstance.AddressRequirement"
|
||||
] = payload.get("address_requirements")
|
||||
self.api_version: Optional[str] = payload.get("api_version")
|
||||
self.beta: Optional[bool] = payload.get("beta")
|
||||
self.capabilities: Optional[str] = payload.get("capabilities")
|
||||
self.date_created: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.friendly_name: Optional[str] = payload.get("friendly_name")
|
||||
self.identity_sid: Optional[str] = payload.get("identity_sid")
|
||||
self.phone_number: Optional[str] = payload.get("phone_number")
|
||||
self.origin: Optional[str] = payload.get("origin")
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.sms_application_sid: Optional[str] = payload.get("sms_application_sid")
|
||||
self.sms_fallback_method: Optional[str] = payload.get("sms_fallback_method")
|
||||
self.sms_fallback_url: Optional[str] = payload.get("sms_fallback_url")
|
||||
self.sms_method: Optional[str] = payload.get("sms_method")
|
||||
self.sms_url: Optional[str] = payload.get("sms_url")
|
||||
self.status_callback: Optional[str] = payload.get("status_callback")
|
||||
self.status_callback_method: Optional[str] = payload.get(
|
||||
"status_callback_method"
|
||||
)
|
||||
self.trunk_sid: Optional[str] = payload.get("trunk_sid")
|
||||
self.uri: Optional[str] = payload.get("uri")
|
||||
self.voice_receive_mode: Optional[
|
||||
"TollFreeInstance.VoiceReceiveMode"
|
||||
] = payload.get("voice_receive_mode")
|
||||
self.voice_application_sid: Optional[str] = payload.get("voice_application_sid")
|
||||
self.voice_caller_id_lookup: Optional[bool] = payload.get(
|
||||
"voice_caller_id_lookup"
|
||||
)
|
||||
self.voice_fallback_method: Optional[str] = payload.get("voice_fallback_method")
|
||||
self.voice_fallback_url: Optional[str] = payload.get("voice_fallback_url")
|
||||
self.voice_method: Optional[str] = payload.get("voice_method")
|
||||
self.voice_url: Optional[str] = payload.get("voice_url")
|
||||
self.emergency_status: Optional[
|
||||
"TollFreeInstance.EmergencyStatus"
|
||||
] = payload.get("emergency_status")
|
||||
self.emergency_address_sid: Optional[str] = payload.get("emergency_address_sid")
|
||||
self.emergency_address_status: Optional[
|
||||
"TollFreeInstance.EmergencyAddressStatus"
|
||||
] = payload.get("emergency_address_status")
|
||||
self.bundle_sid: Optional[str] = payload.get("bundle_sid")
|
||||
self.status: Optional[str] = payload.get("status")
|
||||
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
}
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.TollFreeInstance {}>".format(context)
|
||||
|
||||
|
||||
class TollFreePage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> TollFreeInstance:
|
||||
"""
|
||||
Build an instance of TollFreeInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return TollFreeInstance(
|
||||
self._version, payload, account_sid=self._solution["account_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.TollFreePage>"
|
||||
|
||||
|
||||
class TollFreeList(ListResource):
|
||||
def __init__(self, version: Version, account_sid: str):
|
||||
"""
|
||||
Initialize the TollFreeList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the resources to read.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/IncomingPhoneNumbers/TollFree.json".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def create(
|
||||
self,
|
||||
phone_number: str,
|
||||
api_version: Union[str, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
sms_application_sid: Union[str, object] = values.unset,
|
||||
sms_fallback_method: Union[str, object] = values.unset,
|
||||
sms_fallback_url: Union[str, object] = values.unset,
|
||||
sms_method: Union[str, object] = values.unset,
|
||||
sms_url: Union[str, object] = values.unset,
|
||||
status_callback: Union[str, object] = values.unset,
|
||||
status_callback_method: Union[str, object] = values.unset,
|
||||
voice_application_sid: Union[str, object] = values.unset,
|
||||
voice_caller_id_lookup: Union[bool, object] = values.unset,
|
||||
voice_fallback_method: Union[str, object] = values.unset,
|
||||
voice_fallback_url: Union[str, object] = values.unset,
|
||||
voice_method: Union[str, object] = values.unset,
|
||||
voice_url: Union[str, object] = values.unset,
|
||||
identity_sid: Union[str, object] = values.unset,
|
||||
address_sid: Union[str, object] = values.unset,
|
||||
emergency_status: Union[
|
||||
"TollFreeInstance.EmergencyStatus", object
|
||||
] = values.unset,
|
||||
emergency_address_sid: Union[str, object] = values.unset,
|
||||
trunk_sid: Union[str, object] = values.unset,
|
||||
voice_receive_mode: Union[
|
||||
"TollFreeInstance.VoiceReceiveMode", object
|
||||
] = values.unset,
|
||||
bundle_sid: Union[str, object] = values.unset,
|
||||
) -> TollFreeInstance:
|
||||
"""
|
||||
Create the TollFreeInstance
|
||||
|
||||
:param phone_number: The phone number to purchase specified in [E.164](https://www.twilio.com/docs/glossary/what-e164) format. E.164 phone numbers consist of a + followed by the country code and subscriber number without punctuation characters. For example, +14155551234.
|
||||
:param api_version: The API version to use for incoming calls made to the new phone number. The default is `2010-04-01`.
|
||||
:param friendly_name: A descriptive string that you created to describe the new phone number. It can be up to 64 characters long. By default, this is a formatted version of the phone number.
|
||||
:param sms_application_sid: The SID of the application that should handle SMS messages sent to the new phone number. If an `sms_application_sid` is present, we ignore all `sms_*_url` values and use those of the application.
|
||||
:param sms_fallback_method: The HTTP method that we should use to call `sms_fallback_url`. Can be: `GET` or `POST` and defaults to `POST`.
|
||||
:param sms_fallback_url: The URL that we should call when an error occurs while requesting or executing the TwiML defined by `sms_url`.
|
||||
:param sms_method: The HTTP method that we should use to call `sms_url`. Can be: `GET` or `POST` and defaults to `POST`.
|
||||
:param sms_url: The URL we should call when the new phone number receives an incoming SMS message.
|
||||
:param status_callback: The URL we should call using the `status_callback_method` to send status information to your application.
|
||||
:param status_callback_method: The HTTP method we should use to call `status_callback`. Can be: `GET` or `POST` and defaults to `POST`.
|
||||
:param voice_application_sid: The SID of the application we should use to handle calls to the new phone number. If a `voice_application_sid` is present, we ignore all of the voice urls and use those set on the application. Setting a `voice_application_sid` will automatically delete your `trunk_sid` and vice versa.
|
||||
:param voice_caller_id_lookup: Whether to lookup the caller's name from the CNAM database and post it to your app. Can be: `true` or `false` and defaults to `false`.
|
||||
:param voice_fallback_method: The HTTP method that we should use to call `voice_fallback_url`. Can be: `GET` or `POST` and defaults to `POST`.
|
||||
:param voice_fallback_url: The URL that we should call when an error occurs retrieving or executing the TwiML requested by `url`.
|
||||
:param voice_method: The HTTP method that we should use to call `voice_url`. Can be: `GET` or `POST` and defaults to `POST`.
|
||||
:param voice_url: The URL that we should call to answer a call to the new phone number. The `voice_url` will not be called if a `voice_application_sid` or a `trunk_sid` is set.
|
||||
:param identity_sid: The SID of the Identity resource that we should associate with the new phone number. Some regions require an Identity to meet local regulations.
|
||||
:param address_sid: The SID of the Address resource we should associate with the new phone number. Some regions require addresses to meet local regulations.
|
||||
:param emergency_status:
|
||||
:param emergency_address_sid: The SID of the emergency address configuration to use for emergency calling from the new phone number.
|
||||
:param trunk_sid: The SID of the Trunk we should use to handle calls to the new phone number. If a `trunk_sid` is present, we ignore all of the voice urls and voice applications and use only those set on the Trunk. Setting a `trunk_sid` will automatically delete your `voice_application_sid` and vice versa.
|
||||
:param voice_receive_mode:
|
||||
:param bundle_sid: The SID of the Bundle resource that you associate with the phone number. Some regions require a Bundle to meet local Regulations.
|
||||
|
||||
:returns: The created TollFreeInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PhoneNumber": phone_number,
|
||||
"ApiVersion": api_version,
|
||||
"FriendlyName": friendly_name,
|
||||
"SmsApplicationSid": sms_application_sid,
|
||||
"SmsFallbackMethod": sms_fallback_method,
|
||||
"SmsFallbackUrl": sms_fallback_url,
|
||||
"SmsMethod": sms_method,
|
||||
"SmsUrl": sms_url,
|
||||
"StatusCallback": status_callback,
|
||||
"StatusCallbackMethod": status_callback_method,
|
||||
"VoiceApplicationSid": voice_application_sid,
|
||||
"VoiceCallerIdLookup": voice_caller_id_lookup,
|
||||
"VoiceFallbackMethod": voice_fallback_method,
|
||||
"VoiceFallbackUrl": voice_fallback_url,
|
||||
"VoiceMethod": voice_method,
|
||||
"VoiceUrl": voice_url,
|
||||
"IdentitySid": identity_sid,
|
||||
"AddressSid": address_sid,
|
||||
"EmergencyStatus": emergency_status,
|
||||
"EmergencyAddressSid": emergency_address_sid,
|
||||
"TrunkSid": trunk_sid,
|
||||
"VoiceReceiveMode": voice_receive_mode,
|
||||
"BundleSid": bundle_sid,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return TollFreeInstance(
|
||||
self._version, payload, account_sid=self._solution["account_sid"]
|
||||
)
|
||||
|
||||
async def create_async(
|
||||
self,
|
||||
phone_number: str,
|
||||
api_version: Union[str, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
sms_application_sid: Union[str, object] = values.unset,
|
||||
sms_fallback_method: Union[str, object] = values.unset,
|
||||
sms_fallback_url: Union[str, object] = values.unset,
|
||||
sms_method: Union[str, object] = values.unset,
|
||||
sms_url: Union[str, object] = values.unset,
|
||||
status_callback: Union[str, object] = values.unset,
|
||||
status_callback_method: Union[str, object] = values.unset,
|
||||
voice_application_sid: Union[str, object] = values.unset,
|
||||
voice_caller_id_lookup: Union[bool, object] = values.unset,
|
||||
voice_fallback_method: Union[str, object] = values.unset,
|
||||
voice_fallback_url: Union[str, object] = values.unset,
|
||||
voice_method: Union[str, object] = values.unset,
|
||||
voice_url: Union[str, object] = values.unset,
|
||||
identity_sid: Union[str, object] = values.unset,
|
||||
address_sid: Union[str, object] = values.unset,
|
||||
emergency_status: Union[
|
||||
"TollFreeInstance.EmergencyStatus", object
|
||||
] = values.unset,
|
||||
emergency_address_sid: Union[str, object] = values.unset,
|
||||
trunk_sid: Union[str, object] = values.unset,
|
||||
voice_receive_mode: Union[
|
||||
"TollFreeInstance.VoiceReceiveMode", object
|
||||
] = values.unset,
|
||||
bundle_sid: Union[str, object] = values.unset,
|
||||
) -> TollFreeInstance:
|
||||
"""
|
||||
Asynchronously create the TollFreeInstance
|
||||
|
||||
:param phone_number: The phone number to purchase specified in [E.164](https://www.twilio.com/docs/glossary/what-e164) format. E.164 phone numbers consist of a + followed by the country code and subscriber number without punctuation characters. For example, +14155551234.
|
||||
:param api_version: The API version to use for incoming calls made to the new phone number. The default is `2010-04-01`.
|
||||
:param friendly_name: A descriptive string that you created to describe the new phone number. It can be up to 64 characters long. By default, this is a formatted version of the phone number.
|
||||
:param sms_application_sid: The SID of the application that should handle SMS messages sent to the new phone number. If an `sms_application_sid` is present, we ignore all `sms_*_url` values and use those of the application.
|
||||
:param sms_fallback_method: The HTTP method that we should use to call `sms_fallback_url`. Can be: `GET` or `POST` and defaults to `POST`.
|
||||
:param sms_fallback_url: The URL that we should call when an error occurs while requesting or executing the TwiML defined by `sms_url`.
|
||||
:param sms_method: The HTTP method that we should use to call `sms_url`. Can be: `GET` or `POST` and defaults to `POST`.
|
||||
:param sms_url: The URL we should call when the new phone number receives an incoming SMS message.
|
||||
:param status_callback: The URL we should call using the `status_callback_method` to send status information to your application.
|
||||
:param status_callback_method: The HTTP method we should use to call `status_callback`. Can be: `GET` or `POST` and defaults to `POST`.
|
||||
:param voice_application_sid: The SID of the application we should use to handle calls to the new phone number. If a `voice_application_sid` is present, we ignore all of the voice urls and use those set on the application. Setting a `voice_application_sid` will automatically delete your `trunk_sid` and vice versa.
|
||||
:param voice_caller_id_lookup: Whether to lookup the caller's name from the CNAM database and post it to your app. Can be: `true` or `false` and defaults to `false`.
|
||||
:param voice_fallback_method: The HTTP method that we should use to call `voice_fallback_url`. Can be: `GET` or `POST` and defaults to `POST`.
|
||||
:param voice_fallback_url: The URL that we should call when an error occurs retrieving or executing the TwiML requested by `url`.
|
||||
:param voice_method: The HTTP method that we should use to call `voice_url`. Can be: `GET` or `POST` and defaults to `POST`.
|
||||
:param voice_url: The URL that we should call to answer a call to the new phone number. The `voice_url` will not be called if a `voice_application_sid` or a `trunk_sid` is set.
|
||||
:param identity_sid: The SID of the Identity resource that we should associate with the new phone number. Some regions require an Identity to meet local regulations.
|
||||
:param address_sid: The SID of the Address resource we should associate with the new phone number. Some regions require addresses to meet local regulations.
|
||||
:param emergency_status:
|
||||
:param emergency_address_sid: The SID of the emergency address configuration to use for emergency calling from the new phone number.
|
||||
:param trunk_sid: The SID of the Trunk we should use to handle calls to the new phone number. If a `trunk_sid` is present, we ignore all of the voice urls and voice applications and use only those set on the Trunk. Setting a `trunk_sid` will automatically delete your `voice_application_sid` and vice versa.
|
||||
:param voice_receive_mode:
|
||||
:param bundle_sid: The SID of the Bundle resource that you associate with the phone number. Some regions require a Bundle to meet local Regulations.
|
||||
|
||||
:returns: The created TollFreeInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PhoneNumber": phone_number,
|
||||
"ApiVersion": api_version,
|
||||
"FriendlyName": friendly_name,
|
||||
"SmsApplicationSid": sms_application_sid,
|
||||
"SmsFallbackMethod": sms_fallback_method,
|
||||
"SmsFallbackUrl": sms_fallback_url,
|
||||
"SmsMethod": sms_method,
|
||||
"SmsUrl": sms_url,
|
||||
"StatusCallback": status_callback,
|
||||
"StatusCallbackMethod": status_callback_method,
|
||||
"VoiceApplicationSid": voice_application_sid,
|
||||
"VoiceCallerIdLookup": voice_caller_id_lookup,
|
||||
"VoiceFallbackMethod": voice_fallback_method,
|
||||
"VoiceFallbackUrl": voice_fallback_url,
|
||||
"VoiceMethod": voice_method,
|
||||
"VoiceUrl": voice_url,
|
||||
"IdentitySid": identity_sid,
|
||||
"AddressSid": address_sid,
|
||||
"EmergencyStatus": emergency_status,
|
||||
"EmergencyAddressSid": emergency_address_sid,
|
||||
"TrunkSid": trunk_sid,
|
||||
"VoiceReceiveMode": voice_receive_mode,
|
||||
"BundleSid": bundle_sid,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return TollFreeInstance(
|
||||
self._version, payload, account_sid=self._solution["account_sid"]
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
phone_number: Union[str, object] = values.unset,
|
||||
origin: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[TollFreeInstance]:
|
||||
"""
|
||||
Streams TollFreeInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param bool beta: Whether to include phone numbers new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str friendly_name: A string that identifies the resources to read.
|
||||
:param str phone_number: The phone numbers of the IncomingPhoneNumber resources to read. You can specify partial numbers and use '*' as a wildcard for any digit.
|
||||
:param str origin: Whether to include phone numbers based on their origin. Can be: `twilio` or `hosted`. By default, phone numbers of all origin are included.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page 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(
|
||||
beta=beta,
|
||||
friendly_name=friendly_name,
|
||||
phone_number=phone_number,
|
||||
origin=origin,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
phone_number: Union[str, object] = values.unset,
|
||||
origin: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[TollFreeInstance]:
|
||||
"""
|
||||
Asynchronously streams TollFreeInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param bool beta: Whether to include phone numbers new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str friendly_name: A string that identifies the resources to read.
|
||||
:param str phone_number: The phone numbers of the IncomingPhoneNumber resources to read. You can specify partial numbers and use '*' as a wildcard for any digit.
|
||||
:param str origin: Whether to include phone numbers based on their origin. Can be: `twilio` or `hosted`. By default, phone numbers of all origin are included.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page 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(
|
||||
beta=beta,
|
||||
friendly_name=friendly_name,
|
||||
phone_number=phone_number,
|
||||
origin=origin,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
phone_number: Union[str, object] = values.unset,
|
||||
origin: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[TollFreeInstance]:
|
||||
"""
|
||||
Lists TollFreeInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param bool beta: Whether to include phone numbers new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str friendly_name: A string that identifies the resources to read.
|
||||
:param str phone_number: The phone numbers of the IncomingPhoneNumber resources to read. You can specify partial numbers and use '*' as a wildcard for any digit.
|
||||
:param str origin: Whether to include phone numbers based on their origin. Can be: `twilio` or `hosted`. By default, phone numbers of all origin are included.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to 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(
|
||||
beta=beta,
|
||||
friendly_name=friendly_name,
|
||||
phone_number=phone_number,
|
||||
origin=origin,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
phone_number: Union[str, object] = values.unset,
|
||||
origin: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[TollFreeInstance]:
|
||||
"""
|
||||
Asynchronously lists TollFreeInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param bool beta: Whether to include phone numbers new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param str friendly_name: A string that identifies the resources to read.
|
||||
:param str phone_number: The phone numbers of the IncomingPhoneNumber resources to read. You can specify partial numbers and use '*' as a wildcard for any digit.
|
||||
:param str origin: Whether to include phone numbers based on their origin. Can be: `twilio` or `hosted`. By default, phone numbers of all origin are included.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to 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(
|
||||
beta=beta,
|
||||
friendly_name=friendly_name,
|
||||
phone_number=phone_number,
|
||||
origin=origin,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
phone_number: Union[str, object] = values.unset,
|
||||
origin: Union[str, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> TollFreePage:
|
||||
"""
|
||||
Retrieve a single page of TollFreeInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param beta: Whether to include phone numbers new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param friendly_name: A string that identifies the resources to read.
|
||||
:param phone_number: The phone numbers of the IncomingPhoneNumber resources to read. You can specify partial numbers and use '*' as a wildcard for any digit.
|
||||
:param origin: Whether to include phone numbers based on their origin. Can be: `twilio` or `hosted`. By default, phone numbers of all origin are included.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of TollFreeInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Beta": beta,
|
||||
"FriendlyName": friendly_name,
|
||||
"PhoneNumber": phone_number,
|
||||
"Origin": origin,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return TollFreePage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
beta: Union[bool, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
phone_number: Union[str, object] = values.unset,
|
||||
origin: Union[str, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> TollFreePage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of TollFreeInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param beta: Whether to include phone numbers new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
|
||||
:param friendly_name: A string that identifies the resources to read.
|
||||
:param phone_number: The phone numbers of the IncomingPhoneNumber resources to read. You can specify partial numbers and use '*' as a wildcard for any digit.
|
||||
:param origin: Whether to include phone numbers based on their origin. Can be: `twilio` or `hosted`. By default, phone numbers of all origin are included.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of TollFreeInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Beta": beta,
|
||||
"FriendlyName": friendly_name,
|
||||
"PhoneNumber": phone_number,
|
||||
"Origin": origin,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return TollFreePage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> TollFreePage:
|
||||
"""
|
||||
Retrieve a specific page of TollFreeInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of TollFreeInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return TollFreePage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> TollFreePage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of TollFreeInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of TollFreeInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return TollFreePage(self._version, response, self._solution)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.TollFreeList>"
|
||||
@@ -0,0 +1,541 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, values
|
||||
from twilio.base.instance_context import InstanceContext
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.page import Page
|
||||
|
||||
|
||||
class KeyInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar sid: The unique string that that we created to identify the Key resource.
|
||||
:ivar friendly_name: The string that you assigned to describe the resource.
|
||||
:ivar date_created: The date and time in GMT that the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar date_updated: The date and time in GMT that the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
account_sid: str,
|
||||
sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.friendly_name: Optional[str] = payload.get("friendly_name")
|
||||
self.date_created: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[KeyContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "KeyContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: KeyContext for this KeyInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = KeyContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the KeyInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the KeyInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
def fetch(self) -> "KeyInstance":
|
||||
"""
|
||||
Fetch the KeyInstance
|
||||
|
||||
|
||||
:returns: The fetched KeyInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "KeyInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the KeyInstance
|
||||
|
||||
|
||||
:returns: The fetched KeyInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(self, friendly_name: Union[str, object] = values.unset) -> "KeyInstance":
|
||||
"""
|
||||
Update the KeyInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long.
|
||||
|
||||
:returns: The updated KeyInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
friendly_name=friendly_name,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self, friendly_name: Union[str, object] = values.unset
|
||||
) -> "KeyInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the KeyInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long.
|
||||
|
||||
:returns: The updated KeyInstance
|
||||
"""
|
||||
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.Api.V2010.KeyInstance {}>".format(context)
|
||||
|
||||
|
||||
class KeyContext(InstanceContext):
|
||||
def __init__(self, version: Version, account_sid: str, sid: str):
|
||||
"""
|
||||
Initialize the KeyContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Key resources to update.
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Key resource to update.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/Keys/{sid}.json".format(**self._solution)
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the KeyInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._version.delete(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the KeyInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
def fetch(self) -> KeyInstance:
|
||||
"""
|
||||
Fetch the KeyInstance
|
||||
|
||||
|
||||
:returns: The fetched KeyInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return KeyInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> KeyInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the KeyInstance
|
||||
|
||||
|
||||
:returns: The fetched KeyInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return KeyInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def update(self, friendly_name: Union[str, object] = values.unset) -> KeyInstance:
|
||||
"""
|
||||
Update the KeyInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long.
|
||||
|
||||
:returns: The updated KeyInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return KeyInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self, friendly_name: Union[str, object] = values.unset
|
||||
) -> KeyInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the KeyInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long.
|
||||
|
||||
:returns: The updated KeyInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return KeyInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.KeyContext {}>".format(context)
|
||||
|
||||
|
||||
class KeyPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> KeyInstance:
|
||||
"""
|
||||
Build an instance of KeyInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return KeyInstance(
|
||||
self._version, payload, account_sid=self._solution["account_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.KeyPage>"
|
||||
|
||||
|
||||
class KeyList(ListResource):
|
||||
def __init__(self, version: Version, account_sid: str):
|
||||
"""
|
||||
Initialize the KeyList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Key resources to read.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/Keys.json".format(**self._solution)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[KeyInstance]:
|
||||
"""
|
||||
Streams KeyInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page 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[KeyInstance]:
|
||||
"""
|
||||
Asynchronously streams KeyInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page 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[KeyInstance]:
|
||||
"""
|
||||
Lists KeyInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to 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[KeyInstance]:
|
||||
"""
|
||||
Asynchronously lists KeyInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to 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,
|
||||
) -> KeyPage:
|
||||
"""
|
||||
Retrieve a single page of KeyInstance 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 KeyInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return KeyPage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> KeyPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of KeyInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of KeyInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return KeyPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> KeyPage:
|
||||
"""
|
||||
Retrieve a specific page of KeyInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of KeyInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return KeyPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> KeyPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of KeyInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of KeyInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return KeyPage(self._version, response, self._solution)
|
||||
|
||||
def get(self, sid: str) -> KeyContext:
|
||||
"""
|
||||
Constructs a KeyContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Key resource to update.
|
||||
"""
|
||||
return KeyContext(
|
||||
self._version, account_sid=self._solution["account_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> KeyContext:
|
||||
"""
|
||||
Constructs a KeyContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Key resource to update.
|
||||
"""
|
||||
return KeyContext(
|
||||
self._version, account_sid=self._solution["account_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.KeyList>"
|
||||
@@ -0,0 +1,970 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, serialize, values
|
||||
from twilio.base.instance_context import InstanceContext
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.page import Page
|
||||
from twilio.rest.api.v2010.account.message.feedback import FeedbackList
|
||||
from twilio.rest.api.v2010.account.message.media import MediaList
|
||||
|
||||
|
||||
class MessageInstance(InstanceResource):
|
||||
class AddressRetention(object):
|
||||
RETAIN = "retain"
|
||||
OBFUSCATE = "obfuscate"
|
||||
|
||||
class ContentRetention(object):
|
||||
RETAIN = "retain"
|
||||
DISCARD = "discard"
|
||||
|
||||
class Direction(object):
|
||||
INBOUND = "inbound"
|
||||
OUTBOUND_API = "outbound-api"
|
||||
OUTBOUND_CALL = "outbound-call"
|
||||
OUTBOUND_REPLY = "outbound-reply"
|
||||
|
||||
class RiskCheck(object):
|
||||
ENABLE = "enable"
|
||||
DISABLE = "disable"
|
||||
|
||||
class ScheduleType(object):
|
||||
FIXED = "fixed"
|
||||
|
||||
class Status(object):
|
||||
QUEUED = "queued"
|
||||
SENDING = "sending"
|
||||
SENT = "sent"
|
||||
FAILED = "failed"
|
||||
DELIVERED = "delivered"
|
||||
UNDELIVERED = "undelivered"
|
||||
RECEIVING = "receiving"
|
||||
RECEIVED = "received"
|
||||
ACCEPTED = "accepted"
|
||||
SCHEDULED = "scheduled"
|
||||
READ = "read"
|
||||
PARTIALLY_DELIVERED = "partially_delivered"
|
||||
CANCELED = "canceled"
|
||||
|
||||
class UpdateStatus(object):
|
||||
CANCELED = "canceled"
|
||||
|
||||
"""
|
||||
:ivar body: The text content of the message
|
||||
:ivar num_segments: The number of segments that make up the complete message. SMS message bodies that exceed the [character limit](https://www.twilio.com/docs/glossary/what-sms-character-limit) are segmented and charged as multiple messages. Note: For messages sent via a Messaging Service, `num_segments` is initially `0`, since a sender hasn't yet been assigned.
|
||||
:ivar direction:
|
||||
:ivar from_: The sender's phone number (in [E.164](https://en.wikipedia.org/wiki/E.164) format), [alphanumeric sender ID](https://www.twilio.com/docs/sms/send-messages#use-an-alphanumeric-sender-id), [Wireless SIM](https://www.twilio.com/docs/iot/wireless/programmable-wireless-send-machine-machine-sms-commands), [short code](https://www.twilio.com/docs/sms/api/short-code), or [channel address](https://www.twilio.com/docs/messaging/channels) (e.g., `whatsapp:+15554449999`). For incoming messages, this is the number or channel address of the sender. For outgoing messages, this value is a Twilio phone number, alphanumeric sender ID, short code, or channel address from which the message is sent.
|
||||
:ivar to: The recipient's phone number (in [E.164](https://en.wikipedia.org/wiki/E.164) format) or [channel address](https://www.twilio.com/docs/messaging/channels) (e.g. `whatsapp:+15552229999`)
|
||||
:ivar date_updated: The [RFC 2822](https://datatracker.ietf.org/doc/html/rfc2822#section-3.3) timestamp (in GMT) of when the Message resource was last updated
|
||||
:ivar price: The amount billed for the message in the currency specified by `price_unit`. The `price` is populated after the message has been sent/received, and may not be immediately availalble. View the [Pricing page](https://www.twilio.com/en-us/pricing) for more details.
|
||||
:ivar error_message: The description of the `error_code` if the Message `status` is `failed` or `undelivered`. If no error was encountered, the value is `null`.
|
||||
:ivar uri: The URI of the Message resource, relative to `https://api.twilio.com`.
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) associated with the Message resource
|
||||
:ivar num_media: The number of media files associated with the Message resource.
|
||||
:ivar status:
|
||||
:ivar messaging_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) associated with the Message resource. The value is `null` if a Messaging Service was not used.
|
||||
:ivar sid: The unique, Twilio-provided string that identifies the Message resource.
|
||||
:ivar date_sent: The [RFC 2822](https://datatracker.ietf.org/doc/html/rfc2822#section-3.3) timestamp (in GMT) of when the Message was sent. For an outgoing message, this is when Twilio sent the message. For an incoming message, this is when Twilio sent the HTTP request to your incoming message webhook URL.
|
||||
:ivar date_created: The [RFC 2822](https://datatracker.ietf.org/doc/html/rfc2822#section-3.3) timestamp (in GMT) of when the Message resource was created
|
||||
:ivar error_code: The [error code](https://www.twilio.com/docs/api/errors) returned if the Message `status` is `failed` or `undelivered`. If no error was encountered, the value is `null`.
|
||||
:ivar price_unit: The currency in which `price` is measured, in [ISO 4127](https://www.iso.org/iso/home/standards/currency_codes.htm) format (e.g. `usd`, `eur`, `jpy`).
|
||||
:ivar api_version: The API version used to process the Message
|
||||
:ivar subresource_uris: A list of related resources identified by their URIs relative to `https://api.twilio.com`
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
account_sid: str,
|
||||
sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.body: Optional[str] = payload.get("body")
|
||||
self.num_segments: Optional[str] = payload.get("num_segments")
|
||||
self.direction: Optional["MessageInstance.Direction"] = payload.get("direction")
|
||||
self.from_: Optional[str] = payload.get("from")
|
||||
self.to: Optional[str] = payload.get("to")
|
||||
self.date_updated: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.price: Optional[str] = payload.get("price")
|
||||
self.error_message: Optional[str] = payload.get("error_message")
|
||||
self.uri: Optional[str] = payload.get("uri")
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.num_media: Optional[str] = payload.get("num_media")
|
||||
self.status: Optional["MessageInstance.Status"] = payload.get("status")
|
||||
self.messaging_service_sid: Optional[str] = payload.get("messaging_service_sid")
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.date_sent: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_sent")
|
||||
)
|
||||
self.date_created: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.error_code: Optional[int] = deserialize.integer(payload.get("error_code"))
|
||||
self.price_unit: Optional[str] = payload.get("price_unit")
|
||||
self.api_version: Optional[str] = payload.get("api_version")
|
||||
self.subresource_uris: Optional[Dict[str, object]] = payload.get(
|
||||
"subresource_uris"
|
||||
)
|
||||
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[MessageContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "MessageContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: MessageContext for this MessageInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = MessageContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the MessageInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the MessageInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
def fetch(self) -> "MessageInstance":
|
||||
"""
|
||||
Fetch the MessageInstance
|
||||
|
||||
|
||||
:returns: The fetched MessageInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "MessageInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the MessageInstance
|
||||
|
||||
|
||||
:returns: The fetched MessageInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self,
|
||||
body: Union[str, object] = values.unset,
|
||||
status: Union["MessageInstance.UpdateStatus", object] = values.unset,
|
||||
) -> "MessageInstance":
|
||||
"""
|
||||
Update the MessageInstance
|
||||
|
||||
:param body: The new `body` of the Message resource. To redact the text content of a Message, this parameter's value must be an empty string
|
||||
:param status:
|
||||
|
||||
:returns: The updated MessageInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
body=body,
|
||||
status=status,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
body: Union[str, object] = values.unset,
|
||||
status: Union["MessageInstance.UpdateStatus", object] = values.unset,
|
||||
) -> "MessageInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the MessageInstance
|
||||
|
||||
:param body: The new `body` of the Message resource. To redact the text content of a Message, this parameter's value must be an empty string
|
||||
:param status:
|
||||
|
||||
:returns: The updated MessageInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
body=body,
|
||||
status=status,
|
||||
)
|
||||
|
||||
@property
|
||||
def feedback(self) -> FeedbackList:
|
||||
"""
|
||||
Access the feedback
|
||||
"""
|
||||
return self._proxy.feedback
|
||||
|
||||
@property
|
||||
def media(self) -> MediaList:
|
||||
"""
|
||||
Access the media
|
||||
"""
|
||||
return self._proxy.media
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.MessageInstance {}>".format(context)
|
||||
|
||||
|
||||
class MessageContext(InstanceContext):
|
||||
def __init__(self, version: Version, account_sid: str, sid: str):
|
||||
"""
|
||||
Initialize the MessageContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Message resources to update.
|
||||
:param sid: The SID of the Message resource to be updated
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/Messages/{sid}.json".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
self._feedback: Optional[FeedbackList] = None
|
||||
self._media: Optional[MediaList] = None
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the MessageInstance
|
||||
|
||||
|
||||
: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 MessageInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
def fetch(self) -> MessageInstance:
|
||||
"""
|
||||
Fetch the MessageInstance
|
||||
|
||||
|
||||
:returns: The fetched MessageInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return MessageInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> MessageInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the MessageInstance
|
||||
|
||||
|
||||
:returns: The fetched MessageInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return MessageInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self,
|
||||
body: Union[str, object] = values.unset,
|
||||
status: Union["MessageInstance.UpdateStatus", object] = values.unset,
|
||||
) -> MessageInstance:
|
||||
"""
|
||||
Update the MessageInstance
|
||||
|
||||
:param body: The new `body` of the Message resource. To redact the text content of a Message, this parameter's value must be an empty string
|
||||
:param status:
|
||||
|
||||
:returns: The updated MessageInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Body": body,
|
||||
"Status": status,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return MessageInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
body: Union[str, object] = values.unset,
|
||||
status: Union["MessageInstance.UpdateStatus", object] = values.unset,
|
||||
) -> MessageInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the MessageInstance
|
||||
|
||||
:param body: The new `body` of the Message resource. To redact the text content of a Message, this parameter's value must be an empty string
|
||||
:param status:
|
||||
|
||||
:returns: The updated MessageInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Body": body,
|
||||
"Status": status,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return MessageInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
@property
|
||||
def feedback(self) -> FeedbackList:
|
||||
"""
|
||||
Access the feedback
|
||||
"""
|
||||
if self._feedback is None:
|
||||
self._feedback = FeedbackList(
|
||||
self._version,
|
||||
self._solution["account_sid"],
|
||||
self._solution["sid"],
|
||||
)
|
||||
return self._feedback
|
||||
|
||||
@property
|
||||
def media(self) -> MediaList:
|
||||
"""
|
||||
Access the media
|
||||
"""
|
||||
if self._media is None:
|
||||
self._media = MediaList(
|
||||
self._version,
|
||||
self._solution["account_sid"],
|
||||
self._solution["sid"],
|
||||
)
|
||||
return self._media
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.MessageContext {}>".format(context)
|
||||
|
||||
|
||||
class MessagePage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> MessageInstance:
|
||||
"""
|
||||
Build an instance of MessageInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return MessageInstance(
|
||||
self._version, payload, account_sid=self._solution["account_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.MessagePage>"
|
||||
|
||||
|
||||
class MessageList(ListResource):
|
||||
def __init__(self, version: Version, account_sid: str):
|
||||
"""
|
||||
Initialize the MessageList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) associated with the Message resources.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/Messages.json".format(**self._solution)
|
||||
|
||||
def create(
|
||||
self,
|
||||
to: str,
|
||||
status_callback: Union[str, object] = values.unset,
|
||||
application_sid: Union[str, object] = values.unset,
|
||||
max_price: Union[float, object] = values.unset,
|
||||
provide_feedback: Union[bool, object] = values.unset,
|
||||
attempt: Union[int, object] = values.unset,
|
||||
validity_period: Union[int, object] = values.unset,
|
||||
force_delivery: Union[bool, object] = values.unset,
|
||||
content_retention: Union[
|
||||
"MessageInstance.ContentRetention", object
|
||||
] = values.unset,
|
||||
address_retention: Union[
|
||||
"MessageInstance.AddressRetention", object
|
||||
] = values.unset,
|
||||
smart_encoded: Union[bool, object] = values.unset,
|
||||
persistent_action: Union[List[str], object] = values.unset,
|
||||
shorten_urls: Union[bool, object] = values.unset,
|
||||
schedule_type: Union["MessageInstance.ScheduleType", object] = values.unset,
|
||||
send_at: Union[datetime, object] = values.unset,
|
||||
send_as_mms: Union[bool, object] = values.unset,
|
||||
content_variables: Union[str, object] = values.unset,
|
||||
risk_check: Union["MessageInstance.RiskCheck", object] = values.unset,
|
||||
from_: Union[str, object] = values.unset,
|
||||
messaging_service_sid: Union[str, object] = values.unset,
|
||||
body: Union[str, object] = values.unset,
|
||||
media_url: Union[List[str], object] = values.unset,
|
||||
content_sid: Union[str, object] = values.unset,
|
||||
) -> MessageInstance:
|
||||
"""
|
||||
Create the MessageInstance
|
||||
|
||||
:param to: The recipient's phone number in [E.164](https://www.twilio.com/docs/glossary/what-e164) format (for SMS/MMS) or [channel address](https://www.twilio.com/docs/messaging/channels), e.g. `whatsapp:+15552229999`.
|
||||
:param status_callback: The URL of the endpoint to which Twilio sends [Message status callback requests](https://www.twilio.com/docs/sms/api/message-resource#twilios-request-to-the-statuscallback-url). URL must contain a valid hostname and underscores are not allowed. If you include this parameter with the `messaging_service_sid`, Twilio uses this URL instead of the Status Callback URL of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource).
|
||||
:param application_sid: The SID of the associated [TwiML Application](https://www.twilio.com/docs/usage/api/applications). If this parameter is provided, the `status_callback` parameter of this request is ignored; [Message status callback requests](https://www.twilio.com/docs/sms/api/message-resource#twilios-request-to-the-statuscallback-url) are sent to the TwiML App's `message_status_callback` URL.
|
||||
:param max_price: The maximum price in US dollars that you are willing to pay for this Message's delivery. The value can have up to four decimal places. When the `max_price` parameter is provided, the cost of a message is checked before it is sent. If the cost exceeds `max_price`, the message is not sent and the Message `status` is `failed`.
|
||||
:param provide_feedback: Boolean indicating whether or not you intend to provide delivery confirmation feedback to Twilio (used in conjunction with the [Message Feedback subresource](https://www.twilio.com/docs/sms/api/message-feedback-resource)). Default value is `false`.
|
||||
:param attempt: Total number of attempts made (including this request) to send the message regardless of the provider used
|
||||
:param validity_period: The maximum length in seconds that the Message can remain in Twilio's outgoing message queue. If a queued Message exceeds the `validity_period`, the Message is not sent. Accepted values are integers from `1` to `14400`. Default value is `14400`. A `validity_period` greater than `5` is recommended. [Learn more about the validity period](https://www.twilio.com/blog/take-more-control-of-outbound-messages-using-validity-period-html)
|
||||
:param force_delivery: Reserved
|
||||
:param content_retention:
|
||||
:param address_retention:
|
||||
:param smart_encoded: Whether to detect Unicode characters that have a similar GSM-7 character and replace them. Can be: `true` or `false`.
|
||||
:param persistent_action: Rich actions for non-SMS/MMS channels. Used for [sending location in WhatsApp messages](https://www.twilio.com/docs/whatsapp/message-features#location-messages-with-whatsapp).
|
||||
:param shorten_urls: For Messaging Services with [Link Shortening configured](https://www.twilio.com/docs/messaging/features/how-to-configure-link-shortening) only: A Boolean indicating whether or not Twilio should shorten links in the `body` of the Message. Default value is `false`. If `true`, the `messaging_service_sid` parameter must also be provided.
|
||||
:param schedule_type:
|
||||
:param send_at: The time that Twilio will send the message. Must be in ISO 8601 format.
|
||||
:param send_as_mms: If set to `true`, Twilio delivers the message as a single MMS message, regardless of the presence of media.
|
||||
:param content_variables: For [Content Editor/API](https://www.twilio.com/docs/content) only: Key-value pairs of [Template variables](https://www.twilio.com/docs/content/using-variables-with-content-api) and their substitution values. `content_sid` parameter must also be provided. If values are not defined in the `content_variables` parameter, the [Template's default placeholder values](https://www.twilio.com/docs/content/content-api-resources#create-templates) are used.
|
||||
:param risk_check:
|
||||
:param from_: The sender's Twilio phone number (in [E.164](https://en.wikipedia.org/wiki/E.164) format), [alphanumeric sender ID](https://www.twilio.com/docs/sms/send-messages#use-an-alphanumeric-sender-id), [Wireless SIM](https://www.twilio.com/docs/iot/wireless/programmable-wireless-send-machine-machine-sms-commands), [short code](https://www.twilio.com/docs/sms/api/short-code), or [channel address](https://www.twilio.com/docs/messaging/channels) (e.g., `whatsapp:+15554449999`). The value of the `from` parameter must be a sender that is hosted within Twilio and belongs to the Account creating the Message. If you are using `messaging_service_sid`, this parameter can be empty (Twilio assigns a `from` value from the Messaging Service's Sender Pool) or you can provide a specific sender from your Sender Pool.
|
||||
:param messaging_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/messaging/services) you want to associate with the Message. When this parameter is provided and the `from` parameter is omitted, Twilio selects the optimal sender from the Messaging Service's Sender Pool. You may also provide a `from` parameter if you want to use a specific Sender from the Sender Pool.
|
||||
:param body: The text content of the outgoing message. Can be up to 1,600 characters in length. SMS only: If the `body` contains more than 160 [GSM-7](https://www.twilio.com/docs/glossary/what-is-gsm-7-character-encoding) characters (or 70 [UCS-2](https://www.twilio.com/docs/glossary/what-is-ucs-2-character-encoding) characters), the message is segmented and charged accordingly. For long `body` text, consider using the [send_as_mms parameter](https://www.twilio.com/blog/mms-for-long-text-messages).
|
||||
:param media_url: The URL of media to include in the Message content. `jpeg`, `jpg`, `gif`, and `png` file types are fully supported by Twilio and content is formatted for delivery on destination devices. The media size limit is 5 MB for supported file types (`jpeg`, `jpg`, `png`, `gif`) and 500 KB for [other types](https://www.twilio.com/docs/sms/accepted-mime-types) of accepted media. To send more than one image in the message, provide multiple `media_url` parameters in the POST request. You can include up to ten `media_url` parameters per message. [International](https://support.twilio.com/hc/en-us/articles/223179808-Sending-and-receiving-MMS-messages) and [carrier](https://support.twilio.com/hc/en-us/articles/223133707-Is-MMS-supported-for-all-carriers-in-US-and-Canada-) limits apply.
|
||||
:param content_sid: For [Content Editor/API](https://www.twilio.com/docs/content) only: The SID of the Content Template to be used with the Message, e.g., `HXXXXXXXXXXXXXXXXXXXXXXXXXXXXX`. If this parameter is not provided, a Content Template is not used. Find the SID in the Console on the Content Editor page. For Content API users, the SID is found in Twilio's response when [creating the Template](https://www.twilio.com/docs/content/content-api-resources#create-templates) or by [fetching your Templates](https://www.twilio.com/docs/content/content-api-resources#fetch-all-content-resources).
|
||||
|
||||
:returns: The created MessageInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"To": to,
|
||||
"StatusCallback": status_callback,
|
||||
"ApplicationSid": application_sid,
|
||||
"MaxPrice": max_price,
|
||||
"ProvideFeedback": provide_feedback,
|
||||
"Attempt": attempt,
|
||||
"ValidityPeriod": validity_period,
|
||||
"ForceDelivery": force_delivery,
|
||||
"ContentRetention": content_retention,
|
||||
"AddressRetention": address_retention,
|
||||
"SmartEncoded": smart_encoded,
|
||||
"PersistentAction": serialize.map(persistent_action, lambda e: e),
|
||||
"ShortenUrls": shorten_urls,
|
||||
"ScheduleType": schedule_type,
|
||||
"SendAt": serialize.iso8601_datetime(send_at),
|
||||
"SendAsMms": send_as_mms,
|
||||
"ContentVariables": content_variables,
|
||||
"RiskCheck": risk_check,
|
||||
"From": from_,
|
||||
"MessagingServiceSid": messaging_service_sid,
|
||||
"Body": body,
|
||||
"MediaUrl": serialize.map(media_url, lambda e: e),
|
||||
"ContentSid": content_sid,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return MessageInstance(
|
||||
self._version, payload, account_sid=self._solution["account_sid"]
|
||||
)
|
||||
|
||||
async def create_async(
|
||||
self,
|
||||
to: str,
|
||||
status_callback: Union[str, object] = values.unset,
|
||||
application_sid: Union[str, object] = values.unset,
|
||||
max_price: Union[float, object] = values.unset,
|
||||
provide_feedback: Union[bool, object] = values.unset,
|
||||
attempt: Union[int, object] = values.unset,
|
||||
validity_period: Union[int, object] = values.unset,
|
||||
force_delivery: Union[bool, object] = values.unset,
|
||||
content_retention: Union[
|
||||
"MessageInstance.ContentRetention", object
|
||||
] = values.unset,
|
||||
address_retention: Union[
|
||||
"MessageInstance.AddressRetention", object
|
||||
] = values.unset,
|
||||
smart_encoded: Union[bool, object] = values.unset,
|
||||
persistent_action: Union[List[str], object] = values.unset,
|
||||
shorten_urls: Union[bool, object] = values.unset,
|
||||
schedule_type: Union["MessageInstance.ScheduleType", object] = values.unset,
|
||||
send_at: Union[datetime, object] = values.unset,
|
||||
send_as_mms: Union[bool, object] = values.unset,
|
||||
content_variables: Union[str, object] = values.unset,
|
||||
risk_check: Union["MessageInstance.RiskCheck", object] = values.unset,
|
||||
from_: Union[str, object] = values.unset,
|
||||
messaging_service_sid: Union[str, object] = values.unset,
|
||||
body: Union[str, object] = values.unset,
|
||||
media_url: Union[List[str], object] = values.unset,
|
||||
content_sid: Union[str, object] = values.unset,
|
||||
) -> MessageInstance:
|
||||
"""
|
||||
Asynchronously create the MessageInstance
|
||||
|
||||
:param to: The recipient's phone number in [E.164](https://www.twilio.com/docs/glossary/what-e164) format (for SMS/MMS) or [channel address](https://www.twilio.com/docs/messaging/channels), e.g. `whatsapp:+15552229999`.
|
||||
:param status_callback: The URL of the endpoint to which Twilio sends [Message status callback requests](https://www.twilio.com/docs/sms/api/message-resource#twilios-request-to-the-statuscallback-url). URL must contain a valid hostname and underscores are not allowed. If you include this parameter with the `messaging_service_sid`, Twilio uses this URL instead of the Status Callback URL of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource).
|
||||
:param application_sid: The SID of the associated [TwiML Application](https://www.twilio.com/docs/usage/api/applications). If this parameter is provided, the `status_callback` parameter of this request is ignored; [Message status callback requests](https://www.twilio.com/docs/sms/api/message-resource#twilios-request-to-the-statuscallback-url) are sent to the TwiML App's `message_status_callback` URL.
|
||||
:param max_price: The maximum price in US dollars that you are willing to pay for this Message's delivery. The value can have up to four decimal places. When the `max_price` parameter is provided, the cost of a message is checked before it is sent. If the cost exceeds `max_price`, the message is not sent and the Message `status` is `failed`.
|
||||
:param provide_feedback: Boolean indicating whether or not you intend to provide delivery confirmation feedback to Twilio (used in conjunction with the [Message Feedback subresource](https://www.twilio.com/docs/sms/api/message-feedback-resource)). Default value is `false`.
|
||||
:param attempt: Total number of attempts made (including this request) to send the message regardless of the provider used
|
||||
:param validity_period: The maximum length in seconds that the Message can remain in Twilio's outgoing message queue. If a queued Message exceeds the `validity_period`, the Message is not sent. Accepted values are integers from `1` to `14400`. Default value is `14400`. A `validity_period` greater than `5` is recommended. [Learn more about the validity period](https://www.twilio.com/blog/take-more-control-of-outbound-messages-using-validity-period-html)
|
||||
:param force_delivery: Reserved
|
||||
:param content_retention:
|
||||
:param address_retention:
|
||||
:param smart_encoded: Whether to detect Unicode characters that have a similar GSM-7 character and replace them. Can be: `true` or `false`.
|
||||
:param persistent_action: Rich actions for non-SMS/MMS channels. Used for [sending location in WhatsApp messages](https://www.twilio.com/docs/whatsapp/message-features#location-messages-with-whatsapp).
|
||||
:param shorten_urls: For Messaging Services with [Link Shortening configured](https://www.twilio.com/docs/messaging/features/how-to-configure-link-shortening) only: A Boolean indicating whether or not Twilio should shorten links in the `body` of the Message. Default value is `false`. If `true`, the `messaging_service_sid` parameter must also be provided.
|
||||
:param schedule_type:
|
||||
:param send_at: The time that Twilio will send the message. Must be in ISO 8601 format.
|
||||
:param send_as_mms: If set to `true`, Twilio delivers the message as a single MMS message, regardless of the presence of media.
|
||||
:param content_variables: For [Content Editor/API](https://www.twilio.com/docs/content) only: Key-value pairs of [Template variables](https://www.twilio.com/docs/content/using-variables-with-content-api) and their substitution values. `content_sid` parameter must also be provided. If values are not defined in the `content_variables` parameter, the [Template's default placeholder values](https://www.twilio.com/docs/content/content-api-resources#create-templates) are used.
|
||||
:param risk_check:
|
||||
:param from_: The sender's Twilio phone number (in [E.164](https://en.wikipedia.org/wiki/E.164) format), [alphanumeric sender ID](https://www.twilio.com/docs/sms/send-messages#use-an-alphanumeric-sender-id), [Wireless SIM](https://www.twilio.com/docs/iot/wireless/programmable-wireless-send-machine-machine-sms-commands), [short code](https://www.twilio.com/docs/sms/api/short-code), or [channel address](https://www.twilio.com/docs/messaging/channels) (e.g., `whatsapp:+15554449999`). The value of the `from` parameter must be a sender that is hosted within Twilio and belongs to the Account creating the Message. If you are using `messaging_service_sid`, this parameter can be empty (Twilio assigns a `from` value from the Messaging Service's Sender Pool) or you can provide a specific sender from your Sender Pool.
|
||||
:param messaging_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/messaging/services) you want to associate with the Message. When this parameter is provided and the `from` parameter is omitted, Twilio selects the optimal sender from the Messaging Service's Sender Pool. You may also provide a `from` parameter if you want to use a specific Sender from the Sender Pool.
|
||||
:param body: The text content of the outgoing message. Can be up to 1,600 characters in length. SMS only: If the `body` contains more than 160 [GSM-7](https://www.twilio.com/docs/glossary/what-is-gsm-7-character-encoding) characters (or 70 [UCS-2](https://www.twilio.com/docs/glossary/what-is-ucs-2-character-encoding) characters), the message is segmented and charged accordingly. For long `body` text, consider using the [send_as_mms parameter](https://www.twilio.com/blog/mms-for-long-text-messages).
|
||||
:param media_url: The URL of media to include in the Message content. `jpeg`, `jpg`, `gif`, and `png` file types are fully supported by Twilio and content is formatted for delivery on destination devices. The media size limit is 5 MB for supported file types (`jpeg`, `jpg`, `png`, `gif`) and 500 KB for [other types](https://www.twilio.com/docs/sms/accepted-mime-types) of accepted media. To send more than one image in the message, provide multiple `media_url` parameters in the POST request. You can include up to ten `media_url` parameters per message. [International](https://support.twilio.com/hc/en-us/articles/223179808-Sending-and-receiving-MMS-messages) and [carrier](https://support.twilio.com/hc/en-us/articles/223133707-Is-MMS-supported-for-all-carriers-in-US-and-Canada-) limits apply.
|
||||
:param content_sid: For [Content Editor/API](https://www.twilio.com/docs/content) only: The SID of the Content Template to be used with the Message, e.g., `HXXXXXXXXXXXXXXXXXXXXXXXXXXXXX`. If this parameter is not provided, a Content Template is not used. Find the SID in the Console on the Content Editor page. For Content API users, the SID is found in Twilio's response when [creating the Template](https://www.twilio.com/docs/content/content-api-resources#create-templates) or by [fetching your Templates](https://www.twilio.com/docs/content/content-api-resources#fetch-all-content-resources).
|
||||
|
||||
:returns: The created MessageInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"To": to,
|
||||
"StatusCallback": status_callback,
|
||||
"ApplicationSid": application_sid,
|
||||
"MaxPrice": max_price,
|
||||
"ProvideFeedback": provide_feedback,
|
||||
"Attempt": attempt,
|
||||
"ValidityPeriod": validity_period,
|
||||
"ForceDelivery": force_delivery,
|
||||
"ContentRetention": content_retention,
|
||||
"AddressRetention": address_retention,
|
||||
"SmartEncoded": smart_encoded,
|
||||
"PersistentAction": serialize.map(persistent_action, lambda e: e),
|
||||
"ShortenUrls": shorten_urls,
|
||||
"ScheduleType": schedule_type,
|
||||
"SendAt": serialize.iso8601_datetime(send_at),
|
||||
"SendAsMms": send_as_mms,
|
||||
"ContentVariables": content_variables,
|
||||
"RiskCheck": risk_check,
|
||||
"From": from_,
|
||||
"MessagingServiceSid": messaging_service_sid,
|
||||
"Body": body,
|
||||
"MediaUrl": serialize.map(media_url, lambda e: e),
|
||||
"ContentSid": content_sid,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return MessageInstance(
|
||||
self._version, payload, account_sid=self._solution["account_sid"]
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
to: Union[str, object] = values.unset,
|
||||
from_: Union[str, object] = values.unset,
|
||||
date_sent: Union[datetime, object] = values.unset,
|
||||
date_sent_before: Union[datetime, object] = values.unset,
|
||||
date_sent_after: Union[datetime, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[MessageInstance]:
|
||||
"""
|
||||
Streams MessageInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param str to: Filter by recipient. For example: Set this `to` parameter to `+15558881111` to retrieve a list of Message resources with `to` properties of `+15558881111`
|
||||
:param str from_: Filter by sender. For example: Set this `from` parameter to `+15552229999` to retrieve a list of Message resources with `from` properties of `+15552229999`
|
||||
:param datetime date_sent: Filter by Message `sent_date`. Accepts GMT dates in the following formats: `YYYY-MM-DD` (to find Messages with a specific `sent_date`), `<=YYYY-MM-DD` (to find Messages with `sent_date`s on and before a specific date), and `>=YYYY-MM-DD` (to find Messages with `sent_dates` on and after a specific date).
|
||||
:param datetime date_sent_before: Filter by Message `sent_date`. Accepts GMT dates in the following formats: `YYYY-MM-DD` (to find Messages with a specific `sent_date`), `<=YYYY-MM-DD` (to find Messages with `sent_date`s on and before a specific date), and `>=YYYY-MM-DD` (to find Messages with `sent_dates` on and after a specific date).
|
||||
:param datetime date_sent_after: Filter by Message `sent_date`. Accepts GMT dates in the following formats: `YYYY-MM-DD` (to find Messages with a specific `sent_date`), `<=YYYY-MM-DD` (to find Messages with `sent_date`s on and before a specific date), and `>=YYYY-MM-DD` (to find Messages with `sent_dates` on and after a specific date).
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page 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(
|
||||
to=to,
|
||||
from_=from_,
|
||||
date_sent=date_sent,
|
||||
date_sent_before=date_sent_before,
|
||||
date_sent_after=date_sent_after,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
to: Union[str, object] = values.unset,
|
||||
from_: Union[str, object] = values.unset,
|
||||
date_sent: Union[datetime, object] = values.unset,
|
||||
date_sent_before: Union[datetime, object] = values.unset,
|
||||
date_sent_after: Union[datetime, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[MessageInstance]:
|
||||
"""
|
||||
Asynchronously streams MessageInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param str to: Filter by recipient. For example: Set this `to` parameter to `+15558881111` to retrieve a list of Message resources with `to` properties of `+15558881111`
|
||||
:param str from_: Filter by sender. For example: Set this `from` parameter to `+15552229999` to retrieve a list of Message resources with `from` properties of `+15552229999`
|
||||
:param datetime date_sent: Filter by Message `sent_date`. Accepts GMT dates in the following formats: `YYYY-MM-DD` (to find Messages with a specific `sent_date`), `<=YYYY-MM-DD` (to find Messages with `sent_date`s on and before a specific date), and `>=YYYY-MM-DD` (to find Messages with `sent_dates` on and after a specific date).
|
||||
:param datetime date_sent_before: Filter by Message `sent_date`. Accepts GMT dates in the following formats: `YYYY-MM-DD` (to find Messages with a specific `sent_date`), `<=YYYY-MM-DD` (to find Messages with `sent_date`s on and before a specific date), and `>=YYYY-MM-DD` (to find Messages with `sent_dates` on and after a specific date).
|
||||
:param datetime date_sent_after: Filter by Message `sent_date`. Accepts GMT dates in the following formats: `YYYY-MM-DD` (to find Messages with a specific `sent_date`), `<=YYYY-MM-DD` (to find Messages with `sent_date`s on and before a specific date), and `>=YYYY-MM-DD` (to find Messages with `sent_dates` on and after a specific date).
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page 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(
|
||||
to=to,
|
||||
from_=from_,
|
||||
date_sent=date_sent,
|
||||
date_sent_before=date_sent_before,
|
||||
date_sent_after=date_sent_after,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
to: Union[str, object] = values.unset,
|
||||
from_: Union[str, object] = values.unset,
|
||||
date_sent: Union[datetime, object] = values.unset,
|
||||
date_sent_before: Union[datetime, object] = values.unset,
|
||||
date_sent_after: Union[datetime, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[MessageInstance]:
|
||||
"""
|
||||
Lists MessageInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param str to: Filter by recipient. For example: Set this `to` parameter to `+15558881111` to retrieve a list of Message resources with `to` properties of `+15558881111`
|
||||
:param str from_: Filter by sender. For example: Set this `from` parameter to `+15552229999` to retrieve a list of Message resources with `from` properties of `+15552229999`
|
||||
:param datetime date_sent: Filter by Message `sent_date`. Accepts GMT dates in the following formats: `YYYY-MM-DD` (to find Messages with a specific `sent_date`), `<=YYYY-MM-DD` (to find Messages with `sent_date`s on and before a specific date), and `>=YYYY-MM-DD` (to find Messages with `sent_dates` on and after a specific date).
|
||||
:param datetime date_sent_before: Filter by Message `sent_date`. Accepts GMT dates in the following formats: `YYYY-MM-DD` (to find Messages with a specific `sent_date`), `<=YYYY-MM-DD` (to find Messages with `sent_date`s on and before a specific date), and `>=YYYY-MM-DD` (to find Messages with `sent_dates` on and after a specific date).
|
||||
:param datetime date_sent_after: Filter by Message `sent_date`. Accepts GMT dates in the following formats: `YYYY-MM-DD` (to find Messages with a specific `sent_date`), `<=YYYY-MM-DD` (to find Messages with `sent_date`s on and before a specific date), and `>=YYYY-MM-DD` (to find Messages with `sent_dates` on and after a specific date).
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to 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(
|
||||
to=to,
|
||||
from_=from_,
|
||||
date_sent=date_sent,
|
||||
date_sent_before=date_sent_before,
|
||||
date_sent_after=date_sent_after,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
to: Union[str, object] = values.unset,
|
||||
from_: Union[str, object] = values.unset,
|
||||
date_sent: Union[datetime, object] = values.unset,
|
||||
date_sent_before: Union[datetime, object] = values.unset,
|
||||
date_sent_after: Union[datetime, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[MessageInstance]:
|
||||
"""
|
||||
Asynchronously lists MessageInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param str to: Filter by recipient. For example: Set this `to` parameter to `+15558881111` to retrieve a list of Message resources with `to` properties of `+15558881111`
|
||||
:param str from_: Filter by sender. For example: Set this `from` parameter to `+15552229999` to retrieve a list of Message resources with `from` properties of `+15552229999`
|
||||
:param datetime date_sent: Filter by Message `sent_date`. Accepts GMT dates in the following formats: `YYYY-MM-DD` (to find Messages with a specific `sent_date`), `<=YYYY-MM-DD` (to find Messages with `sent_date`s on and before a specific date), and `>=YYYY-MM-DD` (to find Messages with `sent_dates` on and after a specific date).
|
||||
:param datetime date_sent_before: Filter by Message `sent_date`. Accepts GMT dates in the following formats: `YYYY-MM-DD` (to find Messages with a specific `sent_date`), `<=YYYY-MM-DD` (to find Messages with `sent_date`s on and before a specific date), and `>=YYYY-MM-DD` (to find Messages with `sent_dates` on and after a specific date).
|
||||
:param datetime date_sent_after: Filter by Message `sent_date`. Accepts GMT dates in the following formats: `YYYY-MM-DD` (to find Messages with a specific `sent_date`), `<=YYYY-MM-DD` (to find Messages with `sent_date`s on and before a specific date), and `>=YYYY-MM-DD` (to find Messages with `sent_dates` on and after a specific date).
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to 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(
|
||||
to=to,
|
||||
from_=from_,
|
||||
date_sent=date_sent,
|
||||
date_sent_before=date_sent_before,
|
||||
date_sent_after=date_sent_after,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
to: Union[str, object] = values.unset,
|
||||
from_: Union[str, object] = values.unset,
|
||||
date_sent: Union[datetime, object] = values.unset,
|
||||
date_sent_before: Union[datetime, object] = values.unset,
|
||||
date_sent_after: Union[datetime, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> MessagePage:
|
||||
"""
|
||||
Retrieve a single page of MessageInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param to: Filter by recipient. For example: Set this `to` parameter to `+15558881111` to retrieve a list of Message resources with `to` properties of `+15558881111`
|
||||
:param from_: Filter by sender. For example: Set this `from` parameter to `+15552229999` to retrieve a list of Message resources with `from` properties of `+15552229999`
|
||||
:param date_sent: Filter by Message `sent_date`. Accepts GMT dates in the following formats: `YYYY-MM-DD` (to find Messages with a specific `sent_date`), `<=YYYY-MM-DD` (to find Messages with `sent_date`s on and before a specific date), and `>=YYYY-MM-DD` (to find Messages with `sent_dates` on and after a specific date).
|
||||
:param date_sent_before: Filter by Message `sent_date`. Accepts GMT dates in the following formats: `YYYY-MM-DD` (to find Messages with a specific `sent_date`), `<=YYYY-MM-DD` (to find Messages with `sent_date`s on and before a specific date), and `>=YYYY-MM-DD` (to find Messages with `sent_dates` on and after a specific date).
|
||||
:param date_sent_after: Filter by Message `sent_date`. Accepts GMT dates in the following formats: `YYYY-MM-DD` (to find Messages with a specific `sent_date`), `<=YYYY-MM-DD` (to find Messages with `sent_date`s on and before a specific date), and `>=YYYY-MM-DD` (to find Messages with `sent_dates` on and after a specific date).
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of MessageInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"To": to,
|
||||
"From": from_,
|
||||
"DateSent": serialize.iso8601_datetime(date_sent),
|
||||
"DateSent<": serialize.iso8601_datetime(date_sent_before),
|
||||
"DateSent>": serialize.iso8601_datetime(date_sent_after),
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return MessagePage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
to: Union[str, object] = values.unset,
|
||||
from_: Union[str, object] = values.unset,
|
||||
date_sent: Union[datetime, object] = values.unset,
|
||||
date_sent_before: Union[datetime, object] = values.unset,
|
||||
date_sent_after: Union[datetime, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> MessagePage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of MessageInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param to: Filter by recipient. For example: Set this `to` parameter to `+15558881111` to retrieve a list of Message resources with `to` properties of `+15558881111`
|
||||
:param from_: Filter by sender. For example: Set this `from` parameter to `+15552229999` to retrieve a list of Message resources with `from` properties of `+15552229999`
|
||||
:param date_sent: Filter by Message `sent_date`. Accepts GMT dates in the following formats: `YYYY-MM-DD` (to find Messages with a specific `sent_date`), `<=YYYY-MM-DD` (to find Messages with `sent_date`s on and before a specific date), and `>=YYYY-MM-DD` (to find Messages with `sent_dates` on and after a specific date).
|
||||
:param date_sent_before: Filter by Message `sent_date`. Accepts GMT dates in the following formats: `YYYY-MM-DD` (to find Messages with a specific `sent_date`), `<=YYYY-MM-DD` (to find Messages with `sent_date`s on and before a specific date), and `>=YYYY-MM-DD` (to find Messages with `sent_dates` on and after a specific date).
|
||||
:param date_sent_after: Filter by Message `sent_date`. Accepts GMT dates in the following formats: `YYYY-MM-DD` (to find Messages with a specific `sent_date`), `<=YYYY-MM-DD` (to find Messages with `sent_date`s on and before a specific date), and `>=YYYY-MM-DD` (to find Messages with `sent_dates` on and after a specific date).
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of MessageInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"To": to,
|
||||
"From": from_,
|
||||
"DateSent": serialize.iso8601_datetime(date_sent),
|
||||
"DateSent<": serialize.iso8601_datetime(date_sent_before),
|
||||
"DateSent>": serialize.iso8601_datetime(date_sent_after),
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return MessagePage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> MessagePage:
|
||||
"""
|
||||
Retrieve a specific page of MessageInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of MessageInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return MessagePage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> MessagePage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of MessageInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of MessageInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return MessagePage(self._version, response, self._solution)
|
||||
|
||||
def get(self, sid: str) -> MessageContext:
|
||||
"""
|
||||
Constructs a MessageContext
|
||||
|
||||
:param sid: The SID of the Message resource to be updated
|
||||
"""
|
||||
return MessageContext(
|
||||
self._version, account_sid=self._solution["account_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> MessageContext:
|
||||
"""
|
||||
Constructs a MessageContext
|
||||
|
||||
:param sid: The SID of the Message resource to be updated
|
||||
"""
|
||||
return MessageContext(
|
||||
self._version, account_sid=self._solution["account_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.MessageList>"
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -0,0 +1,161 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, Optional, Union
|
||||
from twilio.base import deserialize, values
|
||||
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
|
||||
|
||||
class FeedbackInstance(InstanceResource):
|
||||
class Outcome(object):
|
||||
CONFIRMED = "confirmed"
|
||||
UNCONFIRMED = "unconfirmed"
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) associated with this MessageFeedback resource.
|
||||
:ivar message_sid: The SID of the Message resource associated with this MessageFeedback resource.
|
||||
:ivar outcome:
|
||||
:ivar date_created: The date and time in GMT when this MessageFeedback resource was created, specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar date_updated: The date and time in GMT when this MessageFeedback resource was last updated, specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar uri: The URI of the resource, relative to `https://api.twilio.com`.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
account_sid: str,
|
||||
message_sid: str,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.message_sid: Optional[str] = payload.get("message_sid")
|
||||
self.outcome: Optional["FeedbackInstance.Outcome"] = payload.get("outcome")
|
||||
self.date_created: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.uri: Optional[str] = payload.get("uri")
|
||||
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"message_sid": message_sid,
|
||||
}
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.FeedbackInstance {}>".format(context)
|
||||
|
||||
|
||||
class FeedbackList(ListResource):
|
||||
def __init__(self, version: Version, account_sid: str, message_sid: str):
|
||||
"""
|
||||
Initialize the FeedbackList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) associated with the Message resource for which to create MessageFeedback.
|
||||
:param message_sid: The SID of the Message resource for which to create MessageFeedback.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"message_sid": message_sid,
|
||||
}
|
||||
self._uri = (
|
||||
"/Accounts/{account_sid}/Messages/{message_sid}/Feedback.json".format(
|
||||
**self._solution
|
||||
)
|
||||
)
|
||||
|
||||
def create(
|
||||
self, outcome: Union["FeedbackInstance.Outcome", object] = values.unset
|
||||
) -> FeedbackInstance:
|
||||
"""
|
||||
Create the FeedbackInstance
|
||||
|
||||
:param outcome:
|
||||
|
||||
:returns: The created FeedbackInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Outcome": outcome,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return FeedbackInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
message_sid=self._solution["message_sid"],
|
||||
)
|
||||
|
||||
async def create_async(
|
||||
self, outcome: Union["FeedbackInstance.Outcome", object] = values.unset
|
||||
) -> FeedbackInstance:
|
||||
"""
|
||||
Asynchronously create the FeedbackInstance
|
||||
|
||||
:param outcome:
|
||||
|
||||
:returns: The created FeedbackInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Outcome": outcome,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return FeedbackInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
message_sid=self._solution["message_sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.FeedbackList>"
|
||||
@@ -0,0 +1,547 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, serialize, values
|
||||
from twilio.base.instance_context import InstanceContext
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.page import Page
|
||||
|
||||
|
||||
class MediaInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) associated with this Media resource.
|
||||
:ivar content_type: The default [MIME type](https://en.wikipedia.org/wiki/Internet_media_type) of the media, for example `image/jpeg`, `image/png`, or `image/gif`.
|
||||
:ivar date_created: The date and time in GMT when this Media resource was created, specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar date_updated: The date and time in GMT when this Media resource was last updated, specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar parent_sid: The SID of the Message resource that is associated with this Media resource.
|
||||
:ivar sid: The unique string that identifies this Media resource.
|
||||
:ivar uri: The URI of this Media resource, relative to `https://api.twilio.com`.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
account_sid: str,
|
||||
message_sid: str,
|
||||
sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.content_type: Optional[str] = payload.get("content_type")
|
||||
self.date_created: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.parent_sid: Optional[str] = payload.get("parent_sid")
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.uri: Optional[str] = payload.get("uri")
|
||||
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"message_sid": message_sid,
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[MediaContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "MediaContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: MediaContext for this MediaInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = MediaContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
message_sid=self._solution["message_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the MediaInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the MediaInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
def fetch(self) -> "MediaInstance":
|
||||
"""
|
||||
Fetch the MediaInstance
|
||||
|
||||
|
||||
:returns: The fetched MediaInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "MediaInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the MediaInstance
|
||||
|
||||
|
||||
:returns: The fetched MediaInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.MediaInstance {}>".format(context)
|
||||
|
||||
|
||||
class MediaContext(InstanceContext):
|
||||
def __init__(self, version: Version, account_sid: str, message_sid: str, sid: str):
|
||||
"""
|
||||
Initialize the MediaContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) associated with the Media resource.
|
||||
:param message_sid: The SID of the Message resource that is associated with the Media resource.
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Media resource to fetch.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"message_sid": message_sid,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = (
|
||||
"/Accounts/{account_sid}/Messages/{message_sid}/Media/{sid}.json".format(
|
||||
**self._solution
|
||||
)
|
||||
)
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the MediaInstance
|
||||
|
||||
|
||||
: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 MediaInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
def fetch(self) -> MediaInstance:
|
||||
"""
|
||||
Fetch the MediaInstance
|
||||
|
||||
|
||||
:returns: The fetched MediaInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return MediaInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
message_sid=self._solution["message_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> MediaInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the MediaInstance
|
||||
|
||||
|
||||
:returns: The fetched MediaInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return MediaInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
message_sid=self._solution["message_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.MediaContext {}>".format(context)
|
||||
|
||||
|
||||
class MediaPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> MediaInstance:
|
||||
"""
|
||||
Build an instance of MediaInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return MediaInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
message_sid=self._solution["message_sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.MediaPage>"
|
||||
|
||||
|
||||
class MediaList(ListResource):
|
||||
def __init__(self, version: Version, account_sid: str, message_sid: str):
|
||||
"""
|
||||
Initialize the MediaList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that is associated with the Media resources.
|
||||
:param message_sid: The SID of the Message resource that is associated with the Media resources.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"message_sid": message_sid,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/Messages/{message_sid}/Media.json".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
date_created: Union[datetime, object] = values.unset,
|
||||
date_created_before: Union[datetime, object] = values.unset,
|
||||
date_created_after: Union[datetime, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[MediaInstance]:
|
||||
"""
|
||||
Streams MediaInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param datetime date_created: Only include Media resources that were created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read Media that were created on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read Media that were created on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read Media that were created on or after midnight of this date.
|
||||
:param datetime date_created_before: Only include Media resources that were created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read Media that were created on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read Media that were created on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read Media that were created on or after midnight of this date.
|
||||
:param datetime date_created_after: Only include Media resources that were created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read Media that were created on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read Media that were created on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read Media that were created on or after midnight of this date.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(
|
||||
date_created=date_created,
|
||||
date_created_before=date_created_before,
|
||||
date_created_after=date_created_after,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
date_created: Union[datetime, object] = values.unset,
|
||||
date_created_before: Union[datetime, object] = values.unset,
|
||||
date_created_after: Union[datetime, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[MediaInstance]:
|
||||
"""
|
||||
Asynchronously streams MediaInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param datetime date_created: Only include Media resources that were created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read Media that were created on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read Media that were created on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read Media that were created on or after midnight of this date.
|
||||
:param datetime date_created_before: Only include Media resources that were created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read Media that were created on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read Media that were created on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read Media that were created on or after midnight of this date.
|
||||
:param datetime date_created_after: Only include Media resources that were created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read Media that were created on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read Media that were created on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read Media that were created on or after midnight of this date.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(
|
||||
date_created=date_created,
|
||||
date_created_before=date_created_before,
|
||||
date_created_after=date_created_after,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
date_created: Union[datetime, object] = values.unset,
|
||||
date_created_before: Union[datetime, object] = values.unset,
|
||||
date_created_after: Union[datetime, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[MediaInstance]:
|
||||
"""
|
||||
Lists MediaInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param datetime date_created: Only include Media resources that were created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read Media that were created on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read Media that were created on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read Media that were created on or after midnight of this date.
|
||||
:param datetime date_created_before: Only include Media resources that were created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read Media that were created on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read Media that were created on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read Media that were created on or after midnight of this date.
|
||||
:param datetime date_created_after: Only include Media resources that were created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read Media that were created on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read Media that were created on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read Media that were created on or after midnight of this date.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return list(
|
||||
self.stream(
|
||||
date_created=date_created,
|
||||
date_created_before=date_created_before,
|
||||
date_created_after=date_created_after,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
date_created: Union[datetime, object] = values.unset,
|
||||
date_created_before: Union[datetime, object] = values.unset,
|
||||
date_created_after: Union[datetime, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[MediaInstance]:
|
||||
"""
|
||||
Asynchronously lists MediaInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param datetime date_created: Only include Media resources that were created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read Media that were created on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read Media that were created on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read Media that were created on or after midnight of this date.
|
||||
:param datetime date_created_before: Only include Media resources that were created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read Media that were created on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read Media that were created on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read Media that were created on or after midnight of this date.
|
||||
:param datetime date_created_after: Only include Media resources that were created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read Media that were created on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read Media that were created on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read Media that were created on or after midnight of this date.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return [
|
||||
record
|
||||
async for record in await self.stream_async(
|
||||
date_created=date_created,
|
||||
date_created_before=date_created_before,
|
||||
date_created_after=date_created_after,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
date_created: Union[datetime, object] = values.unset,
|
||||
date_created_before: Union[datetime, object] = values.unset,
|
||||
date_created_after: Union[datetime, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> MediaPage:
|
||||
"""
|
||||
Retrieve a single page of MediaInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param date_created: Only include Media resources that were created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read Media that were created on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read Media that were created on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read Media that were created on or after midnight of this date.
|
||||
:param date_created_before: Only include Media resources that were created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read Media that were created on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read Media that were created on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read Media that were created on or after midnight of this date.
|
||||
:param date_created_after: Only include Media resources that were created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read Media that were created on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read Media that were created on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read Media that were created on or after midnight of this date.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of MediaInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"DateCreated": serialize.iso8601_datetime(date_created),
|
||||
"DateCreated<": serialize.iso8601_datetime(date_created_before),
|
||||
"DateCreated>": serialize.iso8601_datetime(date_created_after),
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return MediaPage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
date_created: Union[datetime, object] = values.unset,
|
||||
date_created_before: Union[datetime, object] = values.unset,
|
||||
date_created_after: Union[datetime, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> MediaPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of MediaInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param date_created: Only include Media resources that were created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read Media that were created on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read Media that were created on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read Media that were created on or after midnight of this date.
|
||||
:param date_created_before: Only include Media resources that were created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read Media that were created on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read Media that were created on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read Media that were created on or after midnight of this date.
|
||||
:param date_created_after: Only include Media resources that were created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read Media that were created on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read Media that were created on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read Media that were created on or after midnight of this date.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of MediaInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"DateCreated": serialize.iso8601_datetime(date_created),
|
||||
"DateCreated<": serialize.iso8601_datetime(date_created_before),
|
||||
"DateCreated>": serialize.iso8601_datetime(date_created_after),
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return MediaPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> MediaPage:
|
||||
"""
|
||||
Retrieve a specific page of MediaInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of MediaInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return MediaPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> MediaPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of MediaInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of MediaInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return MediaPage(self._version, response, self._solution)
|
||||
|
||||
def get(self, sid: str) -> MediaContext:
|
||||
"""
|
||||
Constructs a MediaContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Media resource to fetch.
|
||||
"""
|
||||
return MediaContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
message_sid=self._solution["message_sid"],
|
||||
sid=sid,
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> MediaContext:
|
||||
"""
|
||||
Constructs a MediaContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Media resource to fetch.
|
||||
"""
|
||||
return MediaContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
message_sid=self._solution["message_sid"],
|
||||
sid=sid,
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.MediaList>"
|
||||
@@ -0,0 +1,137 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, Optional, Union
|
||||
from twilio.base import deserialize, values
|
||||
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
|
||||
|
||||
class NewKeyInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar sid: The unique string that that we created to identify the NewKey resource. You will use this as the basic-auth `user` when authenticating to the API.
|
||||
:ivar friendly_name: The string that you assigned to describe the resource.
|
||||
:ivar date_created: The date and time in GMT that the API Key was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar date_updated: The date and time in GMT that the new API Key was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar secret: The secret your application uses to sign Access Tokens and to authenticate to the REST API (you will use this as the basic-auth `password`). **Note that for security reasons, this field is ONLY returned when the API Key is first created.**
|
||||
"""
|
||||
|
||||
def __init__(self, version: Version, payload: Dict[str, Any], account_sid: str):
|
||||
super().__init__(version)
|
||||
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.friendly_name: Optional[str] = payload.get("friendly_name")
|
||||
self.date_created: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.secret: Optional[str] = payload.get("secret")
|
||||
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
}
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.NewKeyInstance {}>".format(context)
|
||||
|
||||
|
||||
class NewKeyList(ListResource):
|
||||
def __init__(self, version: Version, account_sid: str):
|
||||
"""
|
||||
Initialize the NewKeyList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that will be responsible for the new Key resource.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/Keys.json".format(**self._solution)
|
||||
|
||||
def create(
|
||||
self, friendly_name: Union[str, object] = values.unset
|
||||
) -> NewKeyInstance:
|
||||
"""
|
||||
Create the NewKeyInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long.
|
||||
|
||||
:returns: The created NewKeyInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return NewKeyInstance(
|
||||
self._version, payload, account_sid=self._solution["account_sid"]
|
||||
)
|
||||
|
||||
async def create_async(
|
||||
self, friendly_name: Union[str, object] = values.unset
|
||||
) -> NewKeyInstance:
|
||||
"""
|
||||
Asynchronously create the NewKeyInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long.
|
||||
|
||||
:returns: The created NewKeyInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return NewKeyInstance(
|
||||
self._version, payload, account_sid=self._solution["account_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.NewKeyList>"
|
||||
@@ -0,0 +1,137 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, Optional, Union
|
||||
from twilio.base import deserialize, values
|
||||
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
|
||||
|
||||
class NewSigningKeyInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar sid: The unique string that that we created to identify the NewSigningKey resource.
|
||||
:ivar friendly_name: The string that you assigned to describe the resource.
|
||||
: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 secret: The secret your application uses to sign Access Tokens and to authenticate to the REST API (you will use this as the basic-auth `password`). **Note that for security reasons, this field is ONLY returned when the API Key is first created.**
|
||||
"""
|
||||
|
||||
def __init__(self, version: Version, payload: Dict[str, Any], account_sid: str):
|
||||
super().__init__(version)
|
||||
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.friendly_name: Optional[str] = payload.get("friendly_name")
|
||||
self.date_created: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.secret: Optional[str] = payload.get("secret")
|
||||
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
}
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.NewSigningKeyInstance {}>".format(context)
|
||||
|
||||
|
||||
class NewSigningKeyList(ListResource):
|
||||
def __init__(self, version: Version, account_sid: str):
|
||||
"""
|
||||
Initialize the NewSigningKeyList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that will be responsible for the new Key resource.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/SigningKeys.json".format(**self._solution)
|
||||
|
||||
def create(
|
||||
self, friendly_name: Union[str, object] = values.unset
|
||||
) -> NewSigningKeyInstance:
|
||||
"""
|
||||
Create the NewSigningKeyInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long.
|
||||
|
||||
:returns: The created NewSigningKeyInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return NewSigningKeyInstance(
|
||||
self._version, payload, account_sid=self._solution["account_sid"]
|
||||
)
|
||||
|
||||
async def create_async(
|
||||
self, friendly_name: Union[str, object] = values.unset
|
||||
) -> NewSigningKeyInstance:
|
||||
"""
|
||||
Asynchronously create the NewSigningKeyInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long.
|
||||
|
||||
:returns: The created NewSigningKeyInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return NewSigningKeyInstance(
|
||||
self._version, payload, account_sid=self._solution["account_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.NewSigningKeyList>"
|
||||
@@ -0,0 +1,525 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from datetime import date, datetime
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, serialize, values
|
||||
from twilio.base.instance_context import InstanceContext
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.page import Page
|
||||
|
||||
|
||||
class NotificationInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Notification resource.
|
||||
:ivar api_version: The API version used to generate the notification. Can be empty for events that don't have a specific API version, such as incoming phone calls.
|
||||
:ivar call_sid: The SID of the [Call](https://www.twilio.com/docs/voice/api/call-resource) the Notification resource is associated with.
|
||||
:ivar date_created: The date and time in GMT that the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar date_updated: The date and time in GMT that the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar error_code: A unique error code for the error condition that is described in our [Error Dictionary](https://www.twilio.com/docs/api/errors).
|
||||
:ivar log: An integer log level that corresponds to the type of notification: `0` is ERROR, `1` is WARNING.
|
||||
:ivar message_date: The date the notification was actually generated in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. Message buffering can cause this value to differ from `date_created`.
|
||||
:ivar message_text: The text of the notification.
|
||||
:ivar more_info: The URL for more information about the error condition. This value is a page in our [Error Dictionary](https://www.twilio.com/docs/api/errors).
|
||||
:ivar request_method: The HTTP method used to generate the notification. If the notification was generated during a phone call, this is the HTTP Method used to request the resource on your server. If the notification was generated by your use of our REST API, this is the HTTP method used to call the resource on our servers.
|
||||
:ivar request_url: The URL of the resource that generated the notification. If the notification was generated during a phone call, this is the URL of the resource on your server that caused the notification. If the notification was generated by your use of our REST API, this is the URL of the resource you called.
|
||||
:ivar request_variables: The HTTP GET or POST variables we sent to your server. However, if the notification was generated by our REST API, this contains the HTTP POST or PUT variables you sent to our API.
|
||||
:ivar response_body: The HTTP body returned by your server.
|
||||
:ivar response_headers: The HTTP headers returned by your server.
|
||||
:ivar sid: The unique string that that we created to identify the Notification resource.
|
||||
:ivar uri: The URI of the resource, relative to `https://api.twilio.com`.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
account_sid: str,
|
||||
sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.api_version: Optional[str] = payload.get("api_version")
|
||||
self.call_sid: Optional[str] = payload.get("call_sid")
|
||||
self.date_created: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.error_code: Optional[str] = payload.get("error_code")
|
||||
self.log: Optional[str] = payload.get("log")
|
||||
self.message_date: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("message_date")
|
||||
)
|
||||
self.message_text: Optional[str] = payload.get("message_text")
|
||||
self.more_info: Optional[str] = payload.get("more_info")
|
||||
self.request_method: Optional[str] = payload.get("request_method")
|
||||
self.request_url: Optional[str] = payload.get("request_url")
|
||||
self.request_variables: Optional[str] = payload.get("request_variables")
|
||||
self.response_body: Optional[str] = payload.get("response_body")
|
||||
self.response_headers: Optional[str] = payload.get("response_headers")
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.uri: Optional[str] = payload.get("uri")
|
||||
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[NotificationContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "NotificationContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: NotificationContext for this NotificationInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = NotificationContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def fetch(self) -> "NotificationInstance":
|
||||
"""
|
||||
Fetch the NotificationInstance
|
||||
|
||||
|
||||
:returns: The fetched NotificationInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "NotificationInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the NotificationInstance
|
||||
|
||||
|
||||
:returns: The fetched NotificationInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.NotificationInstance {}>".format(context)
|
||||
|
||||
|
||||
class NotificationContext(InstanceContext):
|
||||
def __init__(self, version: Version, account_sid: str, sid: str):
|
||||
"""
|
||||
Initialize the NotificationContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Notification resource to fetch.
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Notification resource to fetch.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/Notifications/{sid}.json".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def fetch(self) -> NotificationInstance:
|
||||
"""
|
||||
Fetch the NotificationInstance
|
||||
|
||||
|
||||
:returns: The fetched NotificationInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return NotificationInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> NotificationInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the NotificationInstance
|
||||
|
||||
|
||||
:returns: The fetched NotificationInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return NotificationInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.NotificationContext {}>".format(context)
|
||||
|
||||
|
||||
class NotificationPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> NotificationInstance:
|
||||
"""
|
||||
Build an instance of NotificationInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return NotificationInstance(
|
||||
self._version, payload, account_sid=self._solution["account_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.NotificationPage>"
|
||||
|
||||
|
||||
class NotificationList(ListResource):
|
||||
def __init__(self, version: Version, account_sid: str):
|
||||
"""
|
||||
Initialize the NotificationList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Notification resources to read.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/Notifications.json".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
log: Union[int, object] = values.unset,
|
||||
message_date: Union[date, object] = values.unset,
|
||||
message_date_before: Union[date, object] = values.unset,
|
||||
message_date_after: Union[date, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[NotificationInstance]:
|
||||
"""
|
||||
Streams NotificationInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param int log: Only read notifications of the specified log level. Can be: `0` to read only ERROR notifications or `1` to read only WARNING notifications. By default, all notifications are read.
|
||||
:param date message_date: Only show notifications for the specified date, formatted as `YYYY-MM-DD`. You can also specify an inequality, such as `<=YYYY-MM-DD` for messages logged at or before midnight on a date, or `>=YYYY-MM-DD` for messages logged at or after midnight on a date.
|
||||
:param date message_date_before: Only show notifications for the specified date, formatted as `YYYY-MM-DD`. You can also specify an inequality, such as `<=YYYY-MM-DD` for messages logged at or before midnight on a date, or `>=YYYY-MM-DD` for messages logged at or after midnight on a date.
|
||||
:param date message_date_after: Only show notifications for the specified date, formatted as `YYYY-MM-DD`. You can also specify an inequality, such as `<=YYYY-MM-DD` for messages logged at or before midnight on a date, or `>=YYYY-MM-DD` for messages logged at or after midnight on a date.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(
|
||||
log=log,
|
||||
message_date=message_date,
|
||||
message_date_before=message_date_before,
|
||||
message_date_after=message_date_after,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
log: Union[int, object] = values.unset,
|
||||
message_date: Union[date, object] = values.unset,
|
||||
message_date_before: Union[date, object] = values.unset,
|
||||
message_date_after: Union[date, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[NotificationInstance]:
|
||||
"""
|
||||
Asynchronously streams NotificationInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param int log: Only read notifications of the specified log level. Can be: `0` to read only ERROR notifications or `1` to read only WARNING notifications. By default, all notifications are read.
|
||||
:param date message_date: Only show notifications for the specified date, formatted as `YYYY-MM-DD`. You can also specify an inequality, such as `<=YYYY-MM-DD` for messages logged at or before midnight on a date, or `>=YYYY-MM-DD` for messages logged at or after midnight on a date.
|
||||
:param date message_date_before: Only show notifications for the specified date, formatted as `YYYY-MM-DD`. You can also specify an inequality, such as `<=YYYY-MM-DD` for messages logged at or before midnight on a date, or `>=YYYY-MM-DD` for messages logged at or after midnight on a date.
|
||||
:param date message_date_after: Only show notifications for the specified date, formatted as `YYYY-MM-DD`. You can also specify an inequality, such as `<=YYYY-MM-DD` for messages logged at or before midnight on a date, or `>=YYYY-MM-DD` for messages logged at or after midnight on a date.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(
|
||||
log=log,
|
||||
message_date=message_date,
|
||||
message_date_before=message_date_before,
|
||||
message_date_after=message_date_after,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
log: Union[int, object] = values.unset,
|
||||
message_date: Union[date, object] = values.unset,
|
||||
message_date_before: Union[date, object] = values.unset,
|
||||
message_date_after: Union[date, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[NotificationInstance]:
|
||||
"""
|
||||
Lists NotificationInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param int log: Only read notifications of the specified log level. Can be: `0` to read only ERROR notifications or `1` to read only WARNING notifications. By default, all notifications are read.
|
||||
:param date message_date: Only show notifications for the specified date, formatted as `YYYY-MM-DD`. You can also specify an inequality, such as `<=YYYY-MM-DD` for messages logged at or before midnight on a date, or `>=YYYY-MM-DD` for messages logged at or after midnight on a date.
|
||||
:param date message_date_before: Only show notifications for the specified date, formatted as `YYYY-MM-DD`. You can also specify an inequality, such as `<=YYYY-MM-DD` for messages logged at or before midnight on a date, or `>=YYYY-MM-DD` for messages logged at or after midnight on a date.
|
||||
:param date message_date_after: Only show notifications for the specified date, formatted as `YYYY-MM-DD`. You can also specify an inequality, such as `<=YYYY-MM-DD` for messages logged at or before midnight on a date, or `>=YYYY-MM-DD` for messages logged at or after midnight on a date.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return list(
|
||||
self.stream(
|
||||
log=log,
|
||||
message_date=message_date,
|
||||
message_date_before=message_date_before,
|
||||
message_date_after=message_date_after,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
log: Union[int, object] = values.unset,
|
||||
message_date: Union[date, object] = values.unset,
|
||||
message_date_before: Union[date, object] = values.unset,
|
||||
message_date_after: Union[date, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[NotificationInstance]:
|
||||
"""
|
||||
Asynchronously lists NotificationInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param int log: Only read notifications of the specified log level. Can be: `0` to read only ERROR notifications or `1` to read only WARNING notifications. By default, all notifications are read.
|
||||
:param date message_date: Only show notifications for the specified date, formatted as `YYYY-MM-DD`. You can also specify an inequality, such as `<=YYYY-MM-DD` for messages logged at or before midnight on a date, or `>=YYYY-MM-DD` for messages logged at or after midnight on a date.
|
||||
:param date message_date_before: Only show notifications for the specified date, formatted as `YYYY-MM-DD`. You can also specify an inequality, such as `<=YYYY-MM-DD` for messages logged at or before midnight on a date, or `>=YYYY-MM-DD` for messages logged at or after midnight on a date.
|
||||
:param date message_date_after: Only show notifications for the specified date, formatted as `YYYY-MM-DD`. You can also specify an inequality, such as `<=YYYY-MM-DD` for messages logged at or before midnight on a date, or `>=YYYY-MM-DD` for messages logged at or after midnight on a date.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return [
|
||||
record
|
||||
async for record in await self.stream_async(
|
||||
log=log,
|
||||
message_date=message_date,
|
||||
message_date_before=message_date_before,
|
||||
message_date_after=message_date_after,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
log: Union[int, object] = values.unset,
|
||||
message_date: Union[date, object] = values.unset,
|
||||
message_date_before: Union[date, object] = values.unset,
|
||||
message_date_after: Union[date, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> NotificationPage:
|
||||
"""
|
||||
Retrieve a single page of NotificationInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param log: Only read notifications of the specified log level. Can be: `0` to read only ERROR notifications or `1` to read only WARNING notifications. By default, all notifications are read.
|
||||
:param message_date: Only show notifications for the specified date, formatted as `YYYY-MM-DD`. You can also specify an inequality, such as `<=YYYY-MM-DD` for messages logged at or before midnight on a date, or `>=YYYY-MM-DD` for messages logged at or after midnight on a date.
|
||||
:param message_date_before: Only show notifications for the specified date, formatted as `YYYY-MM-DD`. You can also specify an inequality, such as `<=YYYY-MM-DD` for messages logged at or before midnight on a date, or `>=YYYY-MM-DD` for messages logged at or after midnight on a date.
|
||||
:param message_date_after: Only show notifications for the specified date, formatted as `YYYY-MM-DD`. You can also specify an inequality, such as `<=YYYY-MM-DD` for messages logged at or before midnight on a date, or `>=YYYY-MM-DD` for messages logged at or after midnight on a date.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of NotificationInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Log": log,
|
||||
"MessageDate": serialize.iso8601_date(message_date),
|
||||
"MessageDate<": serialize.iso8601_date(message_date_before),
|
||||
"MessageDate>": serialize.iso8601_date(message_date_after),
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return NotificationPage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
log: Union[int, object] = values.unset,
|
||||
message_date: Union[date, object] = values.unset,
|
||||
message_date_before: Union[date, object] = values.unset,
|
||||
message_date_after: Union[date, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> NotificationPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of NotificationInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param log: Only read notifications of the specified log level. Can be: `0` to read only ERROR notifications or `1` to read only WARNING notifications. By default, all notifications are read.
|
||||
:param message_date: Only show notifications for the specified date, formatted as `YYYY-MM-DD`. You can also specify an inequality, such as `<=YYYY-MM-DD` for messages logged at or before midnight on a date, or `>=YYYY-MM-DD` for messages logged at or after midnight on a date.
|
||||
:param message_date_before: Only show notifications for the specified date, formatted as `YYYY-MM-DD`. You can also specify an inequality, such as `<=YYYY-MM-DD` for messages logged at or before midnight on a date, or `>=YYYY-MM-DD` for messages logged at or after midnight on a date.
|
||||
:param message_date_after: Only show notifications for the specified date, formatted as `YYYY-MM-DD`. You can also specify an inequality, such as `<=YYYY-MM-DD` for messages logged at or before midnight on a date, or `>=YYYY-MM-DD` for messages logged at or after midnight on a date.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of NotificationInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Log": log,
|
||||
"MessageDate": serialize.iso8601_date(message_date),
|
||||
"MessageDate<": serialize.iso8601_date(message_date_before),
|
||||
"MessageDate>": serialize.iso8601_date(message_date_after),
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return NotificationPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> NotificationPage:
|
||||
"""
|
||||
Retrieve a specific page of NotificationInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of NotificationInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return NotificationPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> NotificationPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of NotificationInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of NotificationInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return NotificationPage(self._version, response, self._solution)
|
||||
|
||||
def get(self, sid: str) -> NotificationContext:
|
||||
"""
|
||||
Constructs a NotificationContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Notification resource to fetch.
|
||||
"""
|
||||
return NotificationContext(
|
||||
self._version, account_sid=self._solution["account_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> NotificationContext:
|
||||
"""
|
||||
Constructs a NotificationContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Notification resource to fetch.
|
||||
"""
|
||||
return NotificationContext(
|
||||
self._version, account_sid=self._solution["account_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.NotificationList>"
|
||||
+595
@@ -0,0 +1,595 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, values
|
||||
from twilio.base.instance_context import InstanceContext
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.page import Page
|
||||
|
||||
|
||||
class OutgoingCallerIdInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar sid: The unique string that that we created to identify the OutgoingCallerId resource.
|
||||
:ivar date_created: The date and time in GMT that the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar date_updated: The date and time in GMT that the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar friendly_name: The string that you assigned to describe the resource.
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the OutgoingCallerId resource.
|
||||
:ivar phone_number: The phone number in [E.164](https://www.twilio.com/docs/glossary/what-e164) format, which consists of a + followed by the country code and subscriber number.
|
||||
:ivar uri: The URI of the resource, relative to `https://api.twilio.com`.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
account_sid: str,
|
||||
sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.date_created: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.friendly_name: Optional[str] = payload.get("friendly_name")
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.phone_number: Optional[str] = payload.get("phone_number")
|
||||
self.uri: Optional[str] = payload.get("uri")
|
||||
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[OutgoingCallerIdContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "OutgoingCallerIdContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: OutgoingCallerIdContext for this OutgoingCallerIdInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = OutgoingCallerIdContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the OutgoingCallerIdInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the OutgoingCallerIdInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
def fetch(self) -> "OutgoingCallerIdInstance":
|
||||
"""
|
||||
Fetch the OutgoingCallerIdInstance
|
||||
|
||||
|
||||
:returns: The fetched OutgoingCallerIdInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "OutgoingCallerIdInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the OutgoingCallerIdInstance
|
||||
|
||||
|
||||
:returns: The fetched OutgoingCallerIdInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self, friendly_name: Union[str, object] = values.unset
|
||||
) -> "OutgoingCallerIdInstance":
|
||||
"""
|
||||
Update the OutgoingCallerIdInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long.
|
||||
|
||||
:returns: The updated OutgoingCallerIdInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
friendly_name=friendly_name,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self, friendly_name: Union[str, object] = values.unset
|
||||
) -> "OutgoingCallerIdInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the OutgoingCallerIdInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long.
|
||||
|
||||
:returns: The updated OutgoingCallerIdInstance
|
||||
"""
|
||||
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.Api.V2010.OutgoingCallerIdInstance {}>".format(context)
|
||||
|
||||
|
||||
class OutgoingCallerIdContext(InstanceContext):
|
||||
def __init__(self, version: Version, account_sid: str, sid: str):
|
||||
"""
|
||||
Initialize the OutgoingCallerIdContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the OutgoingCallerId resources to update.
|
||||
:param sid: The Twilio-provided string that uniquely identifies the OutgoingCallerId resource to update.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/OutgoingCallerIds/{sid}.json".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the OutgoingCallerIdInstance
|
||||
|
||||
|
||||
: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 OutgoingCallerIdInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
def fetch(self) -> OutgoingCallerIdInstance:
|
||||
"""
|
||||
Fetch the OutgoingCallerIdInstance
|
||||
|
||||
|
||||
:returns: The fetched OutgoingCallerIdInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return OutgoingCallerIdInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> OutgoingCallerIdInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the OutgoingCallerIdInstance
|
||||
|
||||
|
||||
:returns: The fetched OutgoingCallerIdInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return OutgoingCallerIdInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self, friendly_name: Union[str, object] = values.unset
|
||||
) -> OutgoingCallerIdInstance:
|
||||
"""
|
||||
Update the OutgoingCallerIdInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long.
|
||||
|
||||
:returns: The updated OutgoingCallerIdInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return OutgoingCallerIdInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self, friendly_name: Union[str, object] = values.unset
|
||||
) -> OutgoingCallerIdInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the OutgoingCallerIdInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long.
|
||||
|
||||
:returns: The updated OutgoingCallerIdInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return OutgoingCallerIdInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.OutgoingCallerIdContext {}>".format(context)
|
||||
|
||||
|
||||
class OutgoingCallerIdPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> OutgoingCallerIdInstance:
|
||||
"""
|
||||
Build an instance of OutgoingCallerIdInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return OutgoingCallerIdInstance(
|
||||
self._version, payload, account_sid=self._solution["account_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.OutgoingCallerIdPage>"
|
||||
|
||||
|
||||
class OutgoingCallerIdList(ListResource):
|
||||
def __init__(self, version: Version, account_sid: str):
|
||||
"""
|
||||
Initialize the OutgoingCallerIdList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the OutgoingCallerId resources to read.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/OutgoingCallerIds.json".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
phone_number: Union[str, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[OutgoingCallerIdInstance]:
|
||||
"""
|
||||
Streams OutgoingCallerIdInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param str phone_number: The phone number of the OutgoingCallerId resources to read.
|
||||
:param str friendly_name: The string that identifies the OutgoingCallerId resources to read.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(
|
||||
phone_number=phone_number,
|
||||
friendly_name=friendly_name,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
phone_number: Union[str, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[OutgoingCallerIdInstance]:
|
||||
"""
|
||||
Asynchronously streams OutgoingCallerIdInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param str phone_number: The phone number of the OutgoingCallerId resources to read.
|
||||
:param str friendly_name: The string that identifies the OutgoingCallerId resources to read.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(
|
||||
phone_number=phone_number,
|
||||
friendly_name=friendly_name,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
phone_number: Union[str, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[OutgoingCallerIdInstance]:
|
||||
"""
|
||||
Lists OutgoingCallerIdInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param str phone_number: The phone number of the OutgoingCallerId resources to read.
|
||||
:param str friendly_name: The string that identifies the OutgoingCallerId resources to read.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return list(
|
||||
self.stream(
|
||||
phone_number=phone_number,
|
||||
friendly_name=friendly_name,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
phone_number: Union[str, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[OutgoingCallerIdInstance]:
|
||||
"""
|
||||
Asynchronously lists OutgoingCallerIdInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param str phone_number: The phone number of the OutgoingCallerId resources to read.
|
||||
:param str friendly_name: The string that identifies the OutgoingCallerId resources to read.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return [
|
||||
record
|
||||
async for record in await self.stream_async(
|
||||
phone_number=phone_number,
|
||||
friendly_name=friendly_name,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
phone_number: Union[str, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> OutgoingCallerIdPage:
|
||||
"""
|
||||
Retrieve a single page of OutgoingCallerIdInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param phone_number: The phone number of the OutgoingCallerId resources to read.
|
||||
:param friendly_name: The string that identifies the OutgoingCallerId resources to read.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of OutgoingCallerIdInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PhoneNumber": phone_number,
|
||||
"FriendlyName": friendly_name,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return OutgoingCallerIdPage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
phone_number: Union[str, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> OutgoingCallerIdPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of OutgoingCallerIdInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param phone_number: The phone number of the OutgoingCallerId resources to read.
|
||||
:param friendly_name: The string that identifies the OutgoingCallerId resources to read.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of OutgoingCallerIdInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PhoneNumber": phone_number,
|
||||
"FriendlyName": friendly_name,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return OutgoingCallerIdPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> OutgoingCallerIdPage:
|
||||
"""
|
||||
Retrieve a specific page of OutgoingCallerIdInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of OutgoingCallerIdInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return OutgoingCallerIdPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> OutgoingCallerIdPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of OutgoingCallerIdInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of OutgoingCallerIdInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return OutgoingCallerIdPage(self._version, response, self._solution)
|
||||
|
||||
def get(self, sid: str) -> OutgoingCallerIdContext:
|
||||
"""
|
||||
Constructs a OutgoingCallerIdContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the OutgoingCallerId resource to update.
|
||||
"""
|
||||
return OutgoingCallerIdContext(
|
||||
self._version, account_sid=self._solution["account_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> OutgoingCallerIdContext:
|
||||
"""
|
||||
Constructs a OutgoingCallerIdContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the OutgoingCallerId resource to update.
|
||||
"""
|
||||
return OutgoingCallerIdContext(
|
||||
self._version, account_sid=self._solution["account_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.OutgoingCallerIdList>"
|
||||
@@ -0,0 +1,654 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, values
|
||||
from twilio.base.instance_context import InstanceContext
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.page import Page
|
||||
from twilio.rest.api.v2010.account.queue.member import MemberList
|
||||
|
||||
|
||||
class QueueInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar date_updated: The date and time in GMT that this resource was last updated, specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar current_size: The number of calls currently in the queue.
|
||||
:ivar friendly_name: A string that you assigned to describe this resource.
|
||||
:ivar uri: The URI of this resource, relative to `https://api.twilio.com`.
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created this Queue resource.
|
||||
:ivar average_wait_time: The average wait time in seconds of the members in this queue. This is calculated at the time of the request.
|
||||
:ivar sid: The unique string that that we created to identify this Queue resource.
|
||||
:ivar date_created: The date and time in GMT that this resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar max_size: The maximum number of calls that can be in the queue. The default is 1000 and the maximum is 5000.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
account_sid: str,
|
||||
sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.date_updated: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.current_size: Optional[int] = deserialize.integer(
|
||||
payload.get("current_size")
|
||||
)
|
||||
self.friendly_name: Optional[str] = payload.get("friendly_name")
|
||||
self.uri: Optional[str] = payload.get("uri")
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.average_wait_time: Optional[int] = deserialize.integer(
|
||||
payload.get("average_wait_time")
|
||||
)
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.date_created: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.max_size: Optional[int] = deserialize.integer(payload.get("max_size"))
|
||||
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[QueueContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "QueueContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: QueueContext for this QueueInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = QueueContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the QueueInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the QueueInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
def fetch(self) -> "QueueInstance":
|
||||
"""
|
||||
Fetch the QueueInstance
|
||||
|
||||
|
||||
:returns: The fetched QueueInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "QueueInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the QueueInstance
|
||||
|
||||
|
||||
:returns: The fetched QueueInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
max_size: Union[int, object] = values.unset,
|
||||
) -> "QueueInstance":
|
||||
"""
|
||||
Update the QueueInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you created to describe this resource. It can be up to 64 characters long.
|
||||
:param max_size: The maximum number of calls allowed to be in the queue. The default is 1000. The maximum is 5000.
|
||||
|
||||
:returns: The updated QueueInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
friendly_name=friendly_name,
|
||||
max_size=max_size,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
max_size: Union[int, object] = values.unset,
|
||||
) -> "QueueInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the QueueInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you created to describe this resource. It can be up to 64 characters long.
|
||||
:param max_size: The maximum number of calls allowed to be in the queue. The default is 1000. The maximum is 5000.
|
||||
|
||||
:returns: The updated QueueInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
friendly_name=friendly_name,
|
||||
max_size=max_size,
|
||||
)
|
||||
|
||||
@property
|
||||
def members(self) -> MemberList:
|
||||
"""
|
||||
Access the members
|
||||
"""
|
||||
return self._proxy.members
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.QueueInstance {}>".format(context)
|
||||
|
||||
|
||||
class QueueContext(InstanceContext):
|
||||
def __init__(self, version: Version, account_sid: str, sid: str):
|
||||
"""
|
||||
Initialize the QueueContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Queue resource to update.
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Queue resource to update
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/Queues/{sid}.json".format(**self._solution)
|
||||
|
||||
self._members: Optional[MemberList] = None
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the QueueInstance
|
||||
|
||||
|
||||
: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 QueueInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
def fetch(self) -> QueueInstance:
|
||||
"""
|
||||
Fetch the QueueInstance
|
||||
|
||||
|
||||
:returns: The fetched QueueInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return QueueInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> QueueInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the QueueInstance
|
||||
|
||||
|
||||
:returns: The fetched QueueInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return QueueInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
max_size: Union[int, object] = values.unset,
|
||||
) -> QueueInstance:
|
||||
"""
|
||||
Update the QueueInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you created to describe this resource. It can be up to 64 characters long.
|
||||
:param max_size: The maximum number of calls allowed to be in the queue. The default is 1000. The maximum is 5000.
|
||||
|
||||
:returns: The updated QueueInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"MaxSize": max_size,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return QueueInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
max_size: Union[int, object] = values.unset,
|
||||
) -> QueueInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the QueueInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you created to describe this resource. It can be up to 64 characters long.
|
||||
:param max_size: The maximum number of calls allowed to be in the queue. The default is 1000. The maximum is 5000.
|
||||
|
||||
:returns: The updated QueueInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"MaxSize": max_size,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return QueueInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
@property
|
||||
def members(self) -> MemberList:
|
||||
"""
|
||||
Access the members
|
||||
"""
|
||||
if self._members is None:
|
||||
self._members = MemberList(
|
||||
self._version,
|
||||
self._solution["account_sid"],
|
||||
self._solution["sid"],
|
||||
)
|
||||
return self._members
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.QueueContext {}>".format(context)
|
||||
|
||||
|
||||
class QueuePage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> QueueInstance:
|
||||
"""
|
||||
Build an instance of QueueInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return QueueInstance(
|
||||
self._version, payload, account_sid=self._solution["account_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.QueuePage>"
|
||||
|
||||
|
||||
class QueueList(ListResource):
|
||||
def __init__(self, version: Version, account_sid: str):
|
||||
"""
|
||||
Initialize the QueueList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Queue resources to read.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/Queues.json".format(**self._solution)
|
||||
|
||||
def create(
|
||||
self, friendly_name: str, max_size: Union[int, object] = values.unset
|
||||
) -> QueueInstance:
|
||||
"""
|
||||
Create the QueueInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you created to describe this resource. It can be up to 64 characters long.
|
||||
:param max_size: The maximum number of calls allowed to be in the queue. The default is 1000. The maximum is 5000.
|
||||
|
||||
:returns: The created QueueInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"MaxSize": max_size,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return QueueInstance(
|
||||
self._version, payload, account_sid=self._solution["account_sid"]
|
||||
)
|
||||
|
||||
async def create_async(
|
||||
self, friendly_name: str, max_size: Union[int, object] = values.unset
|
||||
) -> QueueInstance:
|
||||
"""
|
||||
Asynchronously create the QueueInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you created to describe this resource. It can be up to 64 characters long.
|
||||
:param max_size: The maximum number of calls allowed to be in the queue. The default is 1000. The maximum is 5000.
|
||||
|
||||
:returns: The created QueueInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"MaxSize": max_size,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return QueueInstance(
|
||||
self._version, payload, account_sid=self._solution["account_sid"]
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[QueueInstance]:
|
||||
"""
|
||||
Streams QueueInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page 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[QueueInstance]:
|
||||
"""
|
||||
Asynchronously streams QueueInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page 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[QueueInstance]:
|
||||
"""
|
||||
Lists QueueInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to 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[QueueInstance]:
|
||||
"""
|
||||
Asynchronously lists QueueInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to 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,
|
||||
) -> QueuePage:
|
||||
"""
|
||||
Retrieve a single page of QueueInstance 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 QueueInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return QueuePage(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,
|
||||
) -> QueuePage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of QueueInstance 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 QueueInstance
|
||||
"""
|
||||
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 QueuePage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> QueuePage:
|
||||
"""
|
||||
Retrieve a specific page of QueueInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of QueueInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return QueuePage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> QueuePage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of QueueInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of QueueInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return QueuePage(self._version, response, self._solution)
|
||||
|
||||
def get(self, sid: str) -> QueueContext:
|
||||
"""
|
||||
Constructs a QueueContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Queue resource to update
|
||||
"""
|
||||
return QueueContext(
|
||||
self._version, account_sid=self._solution["account_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> QueueContext:
|
||||
"""
|
||||
Constructs a QueueContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Queue resource to update
|
||||
"""
|
||||
return QueueContext(
|
||||
self._version, account_sid=self._solution["account_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.QueueList>"
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -0,0 +1,541 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, values
|
||||
from twilio.base.instance_context import InstanceContext
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.page import Page
|
||||
|
||||
|
||||
class MemberInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar call_sid: The SID of the [Call](https://www.twilio.com/docs/voice/api/call-resource) the Member resource is associated with.
|
||||
:ivar date_enqueued: The date that the member was enqueued, given in RFC 2822 format.
|
||||
:ivar position: This member's current position in the queue.
|
||||
:ivar uri: The URI of the resource, relative to `https://api.twilio.com`.
|
||||
:ivar wait_time: The number of seconds the member has been in the queue.
|
||||
:ivar queue_sid: The SID of the Queue the member is in.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
account_sid: str,
|
||||
queue_sid: str,
|
||||
call_sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.call_sid: Optional[str] = payload.get("call_sid")
|
||||
self.date_enqueued: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_enqueued")
|
||||
)
|
||||
self.position: Optional[int] = deserialize.integer(payload.get("position"))
|
||||
self.uri: Optional[str] = payload.get("uri")
|
||||
self.wait_time: Optional[int] = deserialize.integer(payload.get("wait_time"))
|
||||
self.queue_sid: Optional[str] = payload.get("queue_sid")
|
||||
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"queue_sid": queue_sid,
|
||||
"call_sid": call_sid or self.call_sid,
|
||||
}
|
||||
self._context: Optional[MemberContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "MemberContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: MemberContext for this MemberInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = MemberContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
queue_sid=self._solution["queue_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def fetch(self) -> "MemberInstance":
|
||||
"""
|
||||
Fetch the MemberInstance
|
||||
|
||||
|
||||
:returns: The fetched MemberInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "MemberInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the MemberInstance
|
||||
|
||||
|
||||
:returns: The fetched MemberInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self, url: str, method: Union[str, object] = values.unset
|
||||
) -> "MemberInstance":
|
||||
"""
|
||||
Update the MemberInstance
|
||||
|
||||
:param url: The absolute URL of the Queue resource.
|
||||
:param method: How to pass the update request data. Can be `GET` or `POST` and the default is `POST`. `POST` sends the data as encoded form data and `GET` sends the data as query parameters.
|
||||
|
||||
:returns: The updated MemberInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
url=url,
|
||||
method=method,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self, url: str, method: Union[str, object] = values.unset
|
||||
) -> "MemberInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the MemberInstance
|
||||
|
||||
:param url: The absolute URL of the Queue resource.
|
||||
:param method: How to pass the update request data. Can be `GET` or `POST` and the default is `POST`. `POST` sends the data as encoded form data and `GET` sends the data as query parameters.
|
||||
|
||||
:returns: The updated MemberInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
url=url,
|
||||
method=method,
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.MemberInstance {}>".format(context)
|
||||
|
||||
|
||||
class MemberContext(InstanceContext):
|
||||
def __init__(
|
||||
self, version: Version, account_sid: str, queue_sid: str, call_sid: str
|
||||
):
|
||||
"""
|
||||
Initialize the MemberContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Member resource(s) to update.
|
||||
:param queue_sid: The SID of the Queue in which to find the members to update.
|
||||
:param call_sid: The [Call](https://www.twilio.com/docs/voice/api/call-resource) SID of the resource(s) to update.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"queue_sid": queue_sid,
|
||||
"call_sid": call_sid,
|
||||
}
|
||||
self._uri = (
|
||||
"/Accounts/{account_sid}/Queues/{queue_sid}/Members/{call_sid}.json".format(
|
||||
**self._solution
|
||||
)
|
||||
)
|
||||
|
||||
def fetch(self) -> MemberInstance:
|
||||
"""
|
||||
Fetch the MemberInstance
|
||||
|
||||
|
||||
:returns: The fetched MemberInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return MemberInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
queue_sid=self._solution["queue_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> MemberInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the MemberInstance
|
||||
|
||||
|
||||
:returns: The fetched MemberInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return MemberInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
queue_sid=self._solution["queue_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self, url: str, method: Union[str, object] = values.unset
|
||||
) -> MemberInstance:
|
||||
"""
|
||||
Update the MemberInstance
|
||||
|
||||
:param url: The absolute URL of the Queue resource.
|
||||
:param method: How to pass the update request data. Can be `GET` or `POST` and the default is `POST`. `POST` sends the data as encoded form data and `GET` sends the data as query parameters.
|
||||
|
||||
:returns: The updated MemberInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Url": url,
|
||||
"Method": method,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return MemberInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
queue_sid=self._solution["queue_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self, url: str, method: Union[str, object] = values.unset
|
||||
) -> MemberInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the MemberInstance
|
||||
|
||||
:param url: The absolute URL of the Queue resource.
|
||||
:param method: How to pass the update request data. Can be `GET` or `POST` and the default is `POST`. `POST` sends the data as encoded form data and `GET` sends the data as query parameters.
|
||||
|
||||
:returns: The updated MemberInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Url": url,
|
||||
"Method": method,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return MemberInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
queue_sid=self._solution["queue_sid"],
|
||||
call_sid=self._solution["call_sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.MemberContext {}>".format(context)
|
||||
|
||||
|
||||
class MemberPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> MemberInstance:
|
||||
"""
|
||||
Build an instance of MemberInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return MemberInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
queue_sid=self._solution["queue_sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.MemberPage>"
|
||||
|
||||
|
||||
class MemberList(ListResource):
|
||||
def __init__(self, version: Version, account_sid: str, queue_sid: str):
|
||||
"""
|
||||
Initialize the MemberList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Member resource(s) to read.
|
||||
:param queue_sid: The SID of the Queue in which to find the members
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"queue_sid": queue_sid,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/Queues/{queue_sid}/Members.json".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[MemberInstance]:
|
||||
"""
|
||||
Streams MemberInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page 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[MemberInstance]:
|
||||
"""
|
||||
Asynchronously streams MemberInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page 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[MemberInstance]:
|
||||
"""
|
||||
Lists MemberInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to 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[MemberInstance]:
|
||||
"""
|
||||
Asynchronously lists MemberInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to 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,
|
||||
) -> MemberPage:
|
||||
"""
|
||||
Retrieve a single page of MemberInstance 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 MemberInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return MemberPage(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,
|
||||
) -> MemberPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of MemberInstance 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 MemberInstance
|
||||
"""
|
||||
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 MemberPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> MemberPage:
|
||||
"""
|
||||
Retrieve a specific page of MemberInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of MemberInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return MemberPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> MemberPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of MemberInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of MemberInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return MemberPage(self._version, response, self._solution)
|
||||
|
||||
def get(self, call_sid: str) -> MemberContext:
|
||||
"""
|
||||
Constructs a MemberContext
|
||||
|
||||
:param call_sid: The [Call](https://www.twilio.com/docs/voice/api/call-resource) SID of the resource(s) to update.
|
||||
"""
|
||||
return MemberContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
queue_sid=self._solution["queue_sid"],
|
||||
call_sid=call_sid,
|
||||
)
|
||||
|
||||
def __call__(self, call_sid: str) -> MemberContext:
|
||||
"""
|
||||
Constructs a MemberContext
|
||||
|
||||
:param call_sid: The [Call](https://www.twilio.com/docs/voice/api/call-resource) SID of the resource(s) to update.
|
||||
"""
|
||||
return MemberContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
queue_sid=self._solution["queue_sid"],
|
||||
call_sid=call_sid,
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.MemberList>"
|
||||
+695
@@ -0,0 +1,695 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Api
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, serialize, values
|
||||
from twilio.base.instance_context import InstanceContext
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.page import Page
|
||||
from twilio.rest.api.v2010.account.recording.add_on_result import AddOnResultList
|
||||
from twilio.rest.api.v2010.account.recording.transcription import TranscriptionList
|
||||
|
||||
|
||||
class RecordingInstance(InstanceResource):
|
||||
class Source(object):
|
||||
DIALVERB = "DialVerb"
|
||||
CONFERENCE = "Conference"
|
||||
OUTBOUNDAPI = "OutboundAPI"
|
||||
TRUNKING = "Trunking"
|
||||
RECORDVERB = "RecordVerb"
|
||||
STARTCALLRECORDINGAPI = "StartCallRecordingAPI"
|
||||
STARTCONFERENCERECORDINGAPI = "StartConferenceRecordingAPI"
|
||||
|
||||
class Status(object):
|
||||
IN_PROGRESS = "in-progress"
|
||||
PAUSED = "paused"
|
||||
STOPPED = "stopped"
|
||||
PROCESSING = "processing"
|
||||
COMPLETED = "completed"
|
||||
ABSENT = "absent"
|
||||
DELETED = "deleted"
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Recording resource.
|
||||
:ivar api_version: The API version used during the recording.
|
||||
:ivar call_sid: The SID of the [Call](https://www.twilio.com/docs/voice/api/call-resource) the Recording resource is associated with. This will always refer to the parent leg of a two-leg call.
|
||||
:ivar conference_sid: The Conference SID that identifies the conference associated with the recording, if a conference recording.
|
||||
:ivar date_created: The date and time in GMT that the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar date_updated: The date and time in GMT that the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar start_time: The start time of the recording in GMT and in [RFC 2822](https://www.php.net/manual/en/class.datetime.php#datetime.constants.rfc2822) format.
|
||||
:ivar duration: The length of the recording in seconds.
|
||||
:ivar sid: The unique string that that we created to identify the Recording resource.
|
||||
:ivar price: The one-time cost of creating the recording in the `price_unit` currency.
|
||||
:ivar price_unit: The currency used in the `price` property. Example: `USD`.
|
||||
:ivar status:
|
||||
:ivar channels: The number of channels in the final recording file. Can be: `1` or `2`. You can split a call with two legs into two separate recording channels if you record using [TwiML Dial](https://www.twilio.com/docs/voice/twiml/dial#record) or the [Outbound Rest API](https://www.twilio.com/docs/voice/make-calls#manage-your-outbound-call).
|
||||
:ivar source:
|
||||
:ivar error_code: The error code that describes why the recording is `absent`. The error code is described in our [Error Dictionary](https://www.twilio.com/docs/api/errors). This value is null if the recording `status` is not `absent`.
|
||||
:ivar uri: The URI of the resource, relative to `https://api.twilio.com`.
|
||||
:ivar encryption_details: How to decrypt the recording if it was encrypted using [Call Recording Encryption](https://www.twilio.com/docs/voice/tutorials/voice-recording-encryption) feature.
|
||||
:ivar subresource_uris: A list of related resources identified by their relative URIs.
|
||||
:ivar media_url: The URL of the media file associated with this recording resource. When stored externally, this is the full URL location of the media file.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
account_sid: str,
|
||||
sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.api_version: Optional[str] = payload.get("api_version")
|
||||
self.call_sid: Optional[str] = payload.get("call_sid")
|
||||
self.conference_sid: Optional[str] = payload.get("conference_sid")
|
||||
self.date_created: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.start_time: Optional[datetime] = deserialize.rfc2822_datetime(
|
||||
payload.get("start_time")
|
||||
)
|
||||
self.duration: Optional[str] = payload.get("duration")
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.price: Optional[str] = payload.get("price")
|
||||
self.price_unit: Optional[str] = payload.get("price_unit")
|
||||
self.status: Optional["RecordingInstance.Status"] = payload.get("status")
|
||||
self.channels: Optional[int] = deserialize.integer(payload.get("channels"))
|
||||
self.source: Optional["RecordingInstance.Source"] = payload.get("source")
|
||||
self.error_code: Optional[int] = deserialize.integer(payload.get("error_code"))
|
||||
self.uri: Optional[str] = payload.get("uri")
|
||||
self.encryption_details: Optional[Dict[str, object]] = payload.get(
|
||||
"encryption_details"
|
||||
)
|
||||
self.subresource_uris: Optional[Dict[str, object]] = payload.get(
|
||||
"subresource_uris"
|
||||
)
|
||||
self.media_url: Optional[str] = payload.get("media_url")
|
||||
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[RecordingContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "RecordingContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: RecordingContext for this RecordingInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = RecordingContext(
|
||||
self._version,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the RecordingInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the RecordingInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
def fetch(
|
||||
self, include_soft_deleted: Union[bool, object] = values.unset
|
||||
) -> "RecordingInstance":
|
||||
"""
|
||||
Fetch the RecordingInstance
|
||||
|
||||
:param include_soft_deleted: A boolean parameter indicating whether to retrieve soft deleted recordings or not. Recordings metadata are kept after deletion for a retention period of 40 days.
|
||||
|
||||
:returns: The fetched RecordingInstance
|
||||
"""
|
||||
return self._proxy.fetch(
|
||||
include_soft_deleted=include_soft_deleted,
|
||||
)
|
||||
|
||||
async def fetch_async(
|
||||
self, include_soft_deleted: Union[bool, object] = values.unset
|
||||
) -> "RecordingInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the RecordingInstance
|
||||
|
||||
:param include_soft_deleted: A boolean parameter indicating whether to retrieve soft deleted recordings or not. Recordings metadata are kept after deletion for a retention period of 40 days.
|
||||
|
||||
:returns: The fetched RecordingInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async(
|
||||
include_soft_deleted=include_soft_deleted,
|
||||
)
|
||||
|
||||
@property
|
||||
def add_on_results(self) -> AddOnResultList:
|
||||
"""
|
||||
Access the add_on_results
|
||||
"""
|
||||
return self._proxy.add_on_results
|
||||
|
||||
@property
|
||||
def transcriptions(self) -> TranscriptionList:
|
||||
"""
|
||||
Access the transcriptions
|
||||
"""
|
||||
return self._proxy.transcriptions
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.RecordingInstance {}>".format(context)
|
||||
|
||||
|
||||
class RecordingContext(InstanceContext):
|
||||
def __init__(self, version: Version, account_sid: str, sid: str):
|
||||
"""
|
||||
Initialize the RecordingContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Recording resource to fetch.
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Recording resource to fetch.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/Recordings/{sid}.json".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
self._add_on_results: Optional[AddOnResultList] = None
|
||||
self._transcriptions: Optional[TranscriptionList] = None
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the RecordingInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._version.delete(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the RecordingInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
def fetch(
|
||||
self, include_soft_deleted: Union[bool, object] = values.unset
|
||||
) -> RecordingInstance:
|
||||
"""
|
||||
Fetch the RecordingInstance
|
||||
|
||||
:param include_soft_deleted: A boolean parameter indicating whether to retrieve soft deleted recordings or not. Recordings metadata are kept after deletion for a retention period of 40 days.
|
||||
|
||||
:returns: The fetched RecordingInstance
|
||||
"""
|
||||
|
||||
data = values.of(
|
||||
{
|
||||
"IncludeSoftDeleted": include_soft_deleted,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.fetch(method="GET", uri=self._uri, params=data)
|
||||
|
||||
return RecordingInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(
|
||||
self, include_soft_deleted: Union[bool, object] = values.unset
|
||||
) -> RecordingInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the RecordingInstance
|
||||
|
||||
:param include_soft_deleted: A boolean parameter indicating whether to retrieve soft deleted recordings or not. Recordings metadata are kept after deletion for a retention period of 40 days.
|
||||
|
||||
:returns: The fetched RecordingInstance
|
||||
"""
|
||||
|
||||
data = values.of(
|
||||
{
|
||||
"IncludeSoftDeleted": include_soft_deleted,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
|
||||
return RecordingInstance(
|
||||
self._version,
|
||||
payload,
|
||||
account_sid=self._solution["account_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
@property
|
||||
def add_on_results(self) -> AddOnResultList:
|
||||
"""
|
||||
Access the add_on_results
|
||||
"""
|
||||
if self._add_on_results is None:
|
||||
self._add_on_results = AddOnResultList(
|
||||
self._version,
|
||||
self._solution["account_sid"],
|
||||
self._solution["sid"],
|
||||
)
|
||||
return self._add_on_results
|
||||
|
||||
@property
|
||||
def transcriptions(self) -> TranscriptionList:
|
||||
"""
|
||||
Access the transcriptions
|
||||
"""
|
||||
if self._transcriptions is None:
|
||||
self._transcriptions = TranscriptionList(
|
||||
self._version,
|
||||
self._solution["account_sid"],
|
||||
self._solution["sid"],
|
||||
)
|
||||
return self._transcriptions
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Api.V2010.RecordingContext {}>".format(context)
|
||||
|
||||
|
||||
class RecordingPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> RecordingInstance:
|
||||
"""
|
||||
Build an instance of RecordingInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return RecordingInstance(
|
||||
self._version, payload, account_sid=self._solution["account_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.RecordingPage>"
|
||||
|
||||
|
||||
class RecordingList(ListResource):
|
||||
def __init__(self, version: Version, account_sid: str):
|
||||
"""
|
||||
Initialize the RecordingList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Recording resources to read.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"account_sid": account_sid,
|
||||
}
|
||||
self._uri = "/Accounts/{account_sid}/Recordings.json".format(**self._solution)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
date_created: Union[datetime, object] = values.unset,
|
||||
date_created_before: Union[datetime, object] = values.unset,
|
||||
date_created_after: Union[datetime, object] = values.unset,
|
||||
call_sid: Union[str, object] = values.unset,
|
||||
conference_sid: Union[str, object] = values.unset,
|
||||
include_soft_deleted: Union[bool, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[RecordingInstance]:
|
||||
"""
|
||||
Streams RecordingInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param datetime date_created: Only include recordings that were created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read recordings that were created on this date. You can also specify an inequality, such as `DateCreated<=YYYY-MM-DD`, to read recordings that were created on or before midnight of this date, and `DateCreated>=YYYY-MM-DD` to read recordings that were created on or after midnight of this date.
|
||||
:param datetime date_created_before: Only include recordings that were created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read recordings that were created on this date. You can also specify an inequality, such as `DateCreated<=YYYY-MM-DD`, to read recordings that were created on or before midnight of this date, and `DateCreated>=YYYY-MM-DD` to read recordings that were created on or after midnight of this date.
|
||||
:param datetime date_created_after: Only include recordings that were created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read recordings that were created on this date. You can also specify an inequality, such as `DateCreated<=YYYY-MM-DD`, to read recordings that were created on or before midnight of this date, and `DateCreated>=YYYY-MM-DD` to read recordings that were created on or after midnight of this date.
|
||||
:param str call_sid: The [Call](https://www.twilio.com/docs/voice/api/call-resource) SID of the resources to read.
|
||||
:param str conference_sid: The Conference SID that identifies the conference associated with the recording to read.
|
||||
:param bool include_soft_deleted: A boolean parameter indicating whether to retrieve soft deleted recordings or not. Recordings metadata are kept after deletion for a retention period of 40 days.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(
|
||||
date_created=date_created,
|
||||
date_created_before=date_created_before,
|
||||
date_created_after=date_created_after,
|
||||
call_sid=call_sid,
|
||||
conference_sid=conference_sid,
|
||||
include_soft_deleted=include_soft_deleted,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
date_created: Union[datetime, object] = values.unset,
|
||||
date_created_before: Union[datetime, object] = values.unset,
|
||||
date_created_after: Union[datetime, object] = values.unset,
|
||||
call_sid: Union[str, object] = values.unset,
|
||||
conference_sid: Union[str, object] = values.unset,
|
||||
include_soft_deleted: Union[bool, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[RecordingInstance]:
|
||||
"""
|
||||
Asynchronously streams RecordingInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param datetime date_created: Only include recordings that were created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read recordings that were created on this date. You can also specify an inequality, such as `DateCreated<=YYYY-MM-DD`, to read recordings that were created on or before midnight of this date, and `DateCreated>=YYYY-MM-DD` to read recordings that were created on or after midnight of this date.
|
||||
:param datetime date_created_before: Only include recordings that were created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read recordings that were created on this date. You can also specify an inequality, such as `DateCreated<=YYYY-MM-DD`, to read recordings that were created on or before midnight of this date, and `DateCreated>=YYYY-MM-DD` to read recordings that were created on or after midnight of this date.
|
||||
:param datetime date_created_after: Only include recordings that were created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read recordings that were created on this date. You can also specify an inequality, such as `DateCreated<=YYYY-MM-DD`, to read recordings that were created on or before midnight of this date, and `DateCreated>=YYYY-MM-DD` to read recordings that were created on or after midnight of this date.
|
||||
:param str call_sid: The [Call](https://www.twilio.com/docs/voice/api/call-resource) SID of the resources to read.
|
||||
:param str conference_sid: The Conference SID that identifies the conference associated with the recording to read.
|
||||
:param bool include_soft_deleted: A boolean parameter indicating whether to retrieve soft deleted recordings or not. Recordings metadata are kept after deletion for a retention period of 40 days.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(
|
||||
date_created=date_created,
|
||||
date_created_before=date_created_before,
|
||||
date_created_after=date_created_after,
|
||||
call_sid=call_sid,
|
||||
conference_sid=conference_sid,
|
||||
include_soft_deleted=include_soft_deleted,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
date_created: Union[datetime, object] = values.unset,
|
||||
date_created_before: Union[datetime, object] = values.unset,
|
||||
date_created_after: Union[datetime, object] = values.unset,
|
||||
call_sid: Union[str, object] = values.unset,
|
||||
conference_sid: Union[str, object] = values.unset,
|
||||
include_soft_deleted: Union[bool, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[RecordingInstance]:
|
||||
"""
|
||||
Lists RecordingInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param datetime date_created: Only include recordings that were created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read recordings that were created on this date. You can also specify an inequality, such as `DateCreated<=YYYY-MM-DD`, to read recordings that were created on or before midnight of this date, and `DateCreated>=YYYY-MM-DD` to read recordings that were created on or after midnight of this date.
|
||||
:param datetime date_created_before: Only include recordings that were created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read recordings that were created on this date. You can also specify an inequality, such as `DateCreated<=YYYY-MM-DD`, to read recordings that were created on or before midnight of this date, and `DateCreated>=YYYY-MM-DD` to read recordings that were created on or after midnight of this date.
|
||||
:param datetime date_created_after: Only include recordings that were created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read recordings that were created on this date. You can also specify an inequality, such as `DateCreated<=YYYY-MM-DD`, to read recordings that were created on or before midnight of this date, and `DateCreated>=YYYY-MM-DD` to read recordings that were created on or after midnight of this date.
|
||||
:param str call_sid: The [Call](https://www.twilio.com/docs/voice/api/call-resource) SID of the resources to read.
|
||||
:param str conference_sid: The Conference SID that identifies the conference associated with the recording to read.
|
||||
:param bool include_soft_deleted: A boolean parameter indicating whether to retrieve soft deleted recordings or not. Recordings metadata are kept after deletion for a retention period of 40 days.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return list(
|
||||
self.stream(
|
||||
date_created=date_created,
|
||||
date_created_before=date_created_before,
|
||||
date_created_after=date_created_after,
|
||||
call_sid=call_sid,
|
||||
conference_sid=conference_sid,
|
||||
include_soft_deleted=include_soft_deleted,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
date_created: Union[datetime, object] = values.unset,
|
||||
date_created_before: Union[datetime, object] = values.unset,
|
||||
date_created_after: Union[datetime, object] = values.unset,
|
||||
call_sid: Union[str, object] = values.unset,
|
||||
conference_sid: Union[str, object] = values.unset,
|
||||
include_soft_deleted: Union[bool, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[RecordingInstance]:
|
||||
"""
|
||||
Asynchronously lists RecordingInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param datetime date_created: Only include recordings that were created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read recordings that were created on this date. You can also specify an inequality, such as `DateCreated<=YYYY-MM-DD`, to read recordings that were created on or before midnight of this date, and `DateCreated>=YYYY-MM-DD` to read recordings that were created on or after midnight of this date.
|
||||
:param datetime date_created_before: Only include recordings that were created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read recordings that were created on this date. You can also specify an inequality, such as `DateCreated<=YYYY-MM-DD`, to read recordings that were created on or before midnight of this date, and `DateCreated>=YYYY-MM-DD` to read recordings that were created on or after midnight of this date.
|
||||
:param datetime date_created_after: Only include recordings that were created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read recordings that were created on this date. You can also specify an inequality, such as `DateCreated<=YYYY-MM-DD`, to read recordings that were created on or before midnight of this date, and `DateCreated>=YYYY-MM-DD` to read recordings that were created on or after midnight of this date.
|
||||
:param str call_sid: The [Call](https://www.twilio.com/docs/voice/api/call-resource) SID of the resources to read.
|
||||
:param str conference_sid: The Conference SID that identifies the conference associated with the recording to read.
|
||||
:param bool include_soft_deleted: A boolean parameter indicating whether to retrieve soft deleted recordings or not. Recordings metadata are kept after deletion for a retention period of 40 days.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return [
|
||||
record
|
||||
async for record in await self.stream_async(
|
||||
date_created=date_created,
|
||||
date_created_before=date_created_before,
|
||||
date_created_after=date_created_after,
|
||||
call_sid=call_sid,
|
||||
conference_sid=conference_sid,
|
||||
include_soft_deleted=include_soft_deleted,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
date_created: Union[datetime, object] = values.unset,
|
||||
date_created_before: Union[datetime, object] = values.unset,
|
||||
date_created_after: Union[datetime, object] = values.unset,
|
||||
call_sid: Union[str, object] = values.unset,
|
||||
conference_sid: Union[str, object] = values.unset,
|
||||
include_soft_deleted: 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,
|
||||
) -> RecordingPage:
|
||||
"""
|
||||
Retrieve a single page of RecordingInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param date_created: Only include recordings that were created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read recordings that were created on this date. You can also specify an inequality, such as `DateCreated<=YYYY-MM-DD`, to read recordings that were created on or before midnight of this date, and `DateCreated>=YYYY-MM-DD` to read recordings that were created on or after midnight of this date.
|
||||
:param date_created_before: Only include recordings that were created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read recordings that were created on this date. You can also specify an inequality, such as `DateCreated<=YYYY-MM-DD`, to read recordings that were created on or before midnight of this date, and `DateCreated>=YYYY-MM-DD` to read recordings that were created on or after midnight of this date.
|
||||
:param date_created_after: Only include recordings that were created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read recordings that were created on this date. You can also specify an inequality, such as `DateCreated<=YYYY-MM-DD`, to read recordings that were created on or before midnight of this date, and `DateCreated>=YYYY-MM-DD` to read recordings that were created on or after midnight of this date.
|
||||
:param call_sid: The [Call](https://www.twilio.com/docs/voice/api/call-resource) SID of the resources to read.
|
||||
:param conference_sid: The Conference SID that identifies the conference associated with the recording to read.
|
||||
:param include_soft_deleted: A boolean parameter indicating whether to retrieve soft deleted recordings or not. Recordings metadata are kept after deletion for a retention period of 40 days.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of RecordingInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"DateCreated": serialize.iso8601_datetime(date_created),
|
||||
"DateCreated<": serialize.iso8601_datetime(date_created_before),
|
||||
"DateCreated>": serialize.iso8601_datetime(date_created_after),
|
||||
"CallSid": call_sid,
|
||||
"ConferenceSid": conference_sid,
|
||||
"IncludeSoftDeleted": include_soft_deleted,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return RecordingPage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
date_created: Union[datetime, object] = values.unset,
|
||||
date_created_before: Union[datetime, object] = values.unset,
|
||||
date_created_after: Union[datetime, object] = values.unset,
|
||||
call_sid: Union[str, object] = values.unset,
|
||||
conference_sid: Union[str, object] = values.unset,
|
||||
include_soft_deleted: 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,
|
||||
) -> RecordingPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of RecordingInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param date_created: Only include recordings that were created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read recordings that were created on this date. You can also specify an inequality, such as `DateCreated<=YYYY-MM-DD`, to read recordings that were created on or before midnight of this date, and `DateCreated>=YYYY-MM-DD` to read recordings that were created on or after midnight of this date.
|
||||
:param date_created_before: Only include recordings that were created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read recordings that were created on this date. You can also specify an inequality, such as `DateCreated<=YYYY-MM-DD`, to read recordings that were created on or before midnight of this date, and `DateCreated>=YYYY-MM-DD` to read recordings that were created on or after midnight of this date.
|
||||
:param date_created_after: Only include recordings that were created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read recordings that were created on this date. You can also specify an inequality, such as `DateCreated<=YYYY-MM-DD`, to read recordings that were created on or before midnight of this date, and `DateCreated>=YYYY-MM-DD` to read recordings that were created on or after midnight of this date.
|
||||
:param call_sid: The [Call](https://www.twilio.com/docs/voice/api/call-resource) SID of the resources to read.
|
||||
:param conference_sid: The Conference SID that identifies the conference associated with the recording to read.
|
||||
:param include_soft_deleted: A boolean parameter indicating whether to retrieve soft deleted recordings or not. Recordings metadata are kept after deletion for a retention period of 40 days.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of RecordingInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"DateCreated": serialize.iso8601_datetime(date_created),
|
||||
"DateCreated<": serialize.iso8601_datetime(date_created_before),
|
||||
"DateCreated>": serialize.iso8601_datetime(date_created_after),
|
||||
"CallSid": call_sid,
|
||||
"ConferenceSid": conference_sid,
|
||||
"IncludeSoftDeleted": include_soft_deleted,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return RecordingPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> RecordingPage:
|
||||
"""
|
||||
Retrieve a specific page of RecordingInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of RecordingInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return RecordingPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> RecordingPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of RecordingInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of RecordingInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return RecordingPage(self._version, response, self._solution)
|
||||
|
||||
def get(self, sid: str) -> RecordingContext:
|
||||
"""
|
||||
Constructs a RecordingContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Recording resource to fetch.
|
||||
"""
|
||||
return RecordingContext(
|
||||
self._version, account_sid=self._solution["account_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> RecordingContext:
|
||||
"""
|
||||
Constructs a RecordingContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Recording resource to fetch.
|
||||
"""
|
||||
return RecordingContext(
|
||||
self._version, account_sid=self._solution["account_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Api.V2010.RecordingList>"
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user