Initial commit: Email alerts application

This commit is contained in:
Iyeoluwa Akinrinola
2025-07-25 11:31:36 +01:00
commit adfb625ae9
6322 changed files with 2882826 additions and 0 deletions
@@ -0,0 +1,98 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
NOTE: This class is auto generated by OpenAPI Generator.
https://openapi-generator.tech
Do not edit the class manually.
"""
from typing import Optional
from twilio.base.domain import Domain
from twilio.rest import Client
from twilio.rest.preview.deployed_devices import DeployedDevices
from twilio.rest.preview.hosted_numbers import HostedNumbers
from twilio.rest.preview.sync import Sync
from twilio.rest.preview.marketplace import Marketplace
from twilio.rest.preview.understand import Understand
from twilio.rest.preview.wireless import Wireless
class PreviewBase(Domain):
def __init__(self, twilio: Client):
"""
Initialize the Preview Domain
:returns: Domain for Preview
"""
super().__init__(twilio, "https://preview.twilio.com")
self._deployed_devices: Optional[DeployedDevices] = None
self._hosted_numbers: Optional[HostedNumbers] = None
self._sync: Optional[Sync] = None
self._marketplace: Optional[Marketplace] = None
self._understand: Optional[Understand] = None
self._wireless: Optional[Wireless] = None
@property
def deployed_devices(self) -> DeployedDevices:
"""
:returns: Versions deployed_devices of Preview
"""
if self._deployed_devices is None:
self._deployed_devices = DeployedDevices(self)
return self._deployed_devices
@property
def hosted_numbers(self) -> HostedNumbers:
"""
:returns: Versions hosted_numbers of Preview
"""
if self._hosted_numbers is None:
self._hosted_numbers = HostedNumbers(self)
return self._hosted_numbers
@property
def sync(self) -> Sync:
"""
:returns: Versions sync of Preview
"""
if self._sync is None:
self._sync = Sync(self)
return self._sync
@property
def marketplace(self) -> Marketplace:
"""
:returns: Versions marketplace of Preview
"""
if self._marketplace is None:
self._marketplace = Marketplace(self)
return self._marketplace
@property
def understand(self) -> Understand:
"""
:returns: Versions understand of Preview
"""
if self._understand is None:
self._understand = Understand(self)
return self._understand
@property
def wireless(self) -> Wireless:
"""
:returns: Versions wireless of Preview
"""
if self._wireless is None:
self._wireless = Wireless(self)
return self._wireless
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview>"
@@ -0,0 +1,107 @@
from warnings import warn
from twilio.rest.preview.PreviewBase import PreviewBase
from twilio.rest.preview.deployed_devices.fleet import FleetList
from twilio.rest.preview.hosted_numbers.authorization_document import (
AuthorizationDocumentList,
)
from twilio.rest.preview.hosted_numbers.hosted_number_order import HostedNumberOrderList
from twilio.rest.preview.marketplace.available_add_on import AvailableAddOnList
from twilio.rest.preview.marketplace.installed_add_on import InstalledAddOnList
from twilio.rest.preview.sync.service import ServiceList
from twilio.rest.preview.understand.assistant import AssistantList
from twilio.rest.preview.wireless.command import CommandList
from twilio.rest.preview.wireless.rate_plan import RatePlanList
from twilio.rest.preview.wireless.sim import SimList
class Preview(PreviewBase):
@property
def fleets(self) -> FleetList:
warn(
"fleets is deprecated. Use deployed_devices.fleets instead.",
DeprecationWarning,
stacklevel=2,
)
return self.deployed_devices.fleets
@property
def authorization_documents(self) -> AuthorizationDocumentList:
warn(
"authorization_documents is deprecated. Use hosted_numbers.authorization_documents instead.",
DeprecationWarning,
stacklevel=2,
)
return self.hosted_numbers.authorization_documents
@property
def hosted_number_orders(self) -> HostedNumberOrderList:
warn(
"hosted_number_orders is deprecated. Use hosted_numbers.hosted_number_orders instead.",
DeprecationWarning,
stacklevel=2,
)
return self.hosted_numbers.hosted_number_orders
@property
def available_add_ons(self) -> AvailableAddOnList:
warn(
"available_add_ons is deprecated. Use marketplace.available_add_ons instead.",
DeprecationWarning,
stacklevel=2,
)
return self.marketplace.available_add_ons
@property
def installed_add_ons(self) -> InstalledAddOnList:
warn(
"installed_add_ons is deprecated. Use marketplace.installed_add_ons instead.",
DeprecationWarning,
stacklevel=2,
)
return self.marketplace.installed_add_ons
@property
def services(self) -> ServiceList:
warn(
"services is deprecated. Use sync.services instead.",
DeprecationWarning,
stacklevel=2,
)
return self.sync.services
@property
def assistants(self) -> AssistantList:
warn(
"assistants is deprecated. Use understand.assistants instead.",
DeprecationWarning,
stacklevel=2,
)
return self.understand.assistants
@property
def commands(self) -> CommandList:
warn(
"commands is deprecated. Use wireless.commands instead.",
DeprecationWarning,
stacklevel=2,
)
return self.wireless.commands
@property
def rate_plans(self) -> RatePlanList:
warn(
"rate_plans is deprecated. Use wireless.rate_plans instead.",
DeprecationWarning,
stacklevel=2,
)
return self.wireless.rate_plans
@property
def sims(self) -> SimList:
warn(
"sims is deprecated. Use wireless.sims instead.",
DeprecationWarning,
stacklevel=2,
)
return self.wireless.sims
@@ -0,0 +1,42 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Preview
This is the public Twilio REST API.
NOTE: This class is auto generated by OpenAPI Generator.
https://openapi-generator.tech
Do not edit the class manually.
"""
from typing import Optional
from twilio.base.version import Version
from twilio.base.domain import Domain
from twilio.rest.preview.deployed_devices.fleet import FleetList
class DeployedDevices(Version):
def __init__(self, domain: Domain):
"""
Initialize the DeployedDevices version of Preview
:param domain: The Twilio.preview domain
"""
super().__init__(domain, "DeployedDevices")
self._fleets: Optional[FleetList] = None
@property
def fleets(self) -> FleetList:
if self._fleets is None:
self._fleets = FleetList(self)
return self._fleets
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.DeployedDevices>"
@@ -0,0 +1,673 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Preview
This is the public Twilio REST API.
NOTE: This class is auto generated by OpenAPI Generator.
https://openapi-generator.tech
Do not edit the class manually.
"""
from datetime import datetime
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
from twilio.base import deserialize, values
from twilio.base.instance_context import InstanceContext
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.version import Version
from twilio.base.page import Page
from twilio.rest.preview.deployed_devices.fleet.certificate import CertificateList
from twilio.rest.preview.deployed_devices.fleet.deployment import DeploymentList
from twilio.rest.preview.deployed_devices.fleet.device import DeviceList
from twilio.rest.preview.deployed_devices.fleet.key import KeyList
class FleetInstance(InstanceResource):
"""
:ivar sid: Contains a 34 character string that uniquely identifies this Fleet resource.
:ivar url: Contains an absolute URL for this Fleet resource.
:ivar unique_name: Contains a unique and addressable name of this Fleet, e.g. 'default', up to 128 characters long.
:ivar friendly_name: Contains a human readable descriptive text for this Fleet, up to 256 characters long.
:ivar account_sid: Speicifies the unique string identifier of the Account responsible for this Fleet.
:ivar default_deployment_sid: Contains the string identifier of the automatically provisioned default Deployment of this Fleet.
:ivar date_created: Specifies the date this Fleet was created, given in UTC ISO 8601 format.
:ivar date_updated: Specifies the date this Fleet was last updated, given in UTC ISO 8601 format.
:ivar links: Contains a dictionary of URL links to nested resources of this Fleet.
"""
def __init__(
self, version: Version, payload: Dict[str, Any], sid: Optional[str] = None
):
super().__init__(version)
self.sid: Optional[str] = payload.get("sid")
self.url: Optional[str] = payload.get("url")
self.unique_name: Optional[str] = payload.get("unique_name")
self.friendly_name: Optional[str] = payload.get("friendly_name")
self.account_sid: Optional[str] = payload.get("account_sid")
self.default_deployment_sid: Optional[str] = payload.get(
"default_deployment_sid"
)
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_created")
)
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_updated")
)
self.links: Optional[Dict[str, object]] = payload.get("links")
self._solution = {
"sid": sid or self.sid,
}
self._context: Optional[FleetContext] = None
@property
def _proxy(self) -> "FleetContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: FleetContext for this FleetInstance
"""
if self._context is None:
self._context = FleetContext(
self._version,
sid=self._solution["sid"],
)
return self._context
def delete(self) -> bool:
"""
Deletes the FleetInstance
:returns: True if delete succeeds, False otherwise
"""
return self._proxy.delete()
async def delete_async(self) -> bool:
"""
Asynchronous coroutine that deletes the FleetInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._proxy.delete_async()
def fetch(self) -> "FleetInstance":
"""
Fetch the FleetInstance
:returns: The fetched FleetInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "FleetInstance":
"""
Asynchronous coroutine to fetch the FleetInstance
:returns: The fetched FleetInstance
"""
return await self._proxy.fetch_async()
def update(
self,
friendly_name: Union[str, object] = values.unset,
default_deployment_sid: Union[str, object] = values.unset,
) -> "FleetInstance":
"""
Update the FleetInstance
:param friendly_name: Provides a human readable descriptive text for this Fleet, up to 256 characters long.
:param default_deployment_sid: Provides a string identifier of a Deployment that is going to be used as a default one for this Fleet.
:returns: The updated FleetInstance
"""
return self._proxy.update(
friendly_name=friendly_name,
default_deployment_sid=default_deployment_sid,
)
async def update_async(
self,
friendly_name: Union[str, object] = values.unset,
default_deployment_sid: Union[str, object] = values.unset,
) -> "FleetInstance":
"""
Asynchronous coroutine to update the FleetInstance
:param friendly_name: Provides a human readable descriptive text for this Fleet, up to 256 characters long.
:param default_deployment_sid: Provides a string identifier of a Deployment that is going to be used as a default one for this Fleet.
:returns: The updated FleetInstance
"""
return await self._proxy.update_async(
friendly_name=friendly_name,
default_deployment_sid=default_deployment_sid,
)
@property
def certificates(self) -> CertificateList:
"""
Access the certificates
"""
return self._proxy.certificates
@property
def deployments(self) -> DeploymentList:
"""
Access the deployments
"""
return self._proxy.deployments
@property
def devices(self) -> DeviceList:
"""
Access the devices
"""
return self._proxy.devices
@property
def keys(self) -> KeyList:
"""
Access the keys
"""
return self._proxy.keys
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Preview.DeployedDevices.FleetInstance {}>".format(context)
class FleetContext(InstanceContext):
def __init__(self, version: Version, sid: str):
"""
Initialize the FleetContext
:param version: Version that contains the resource
:param sid: Provides a 34 character string that uniquely identifies the requested Fleet resource.
"""
super().__init__(version)
# Path Solution
self._solution = {
"sid": sid,
}
self._uri = "/Fleets/{sid}".format(**self._solution)
self._certificates: Optional[CertificateList] = None
self._deployments: Optional[DeploymentList] = None
self._devices: Optional[DeviceList] = None
self._keys: Optional[KeyList] = None
def delete(self) -> bool:
"""
Deletes the FleetInstance
:returns: True if delete succeeds, False otherwise
"""
return self._version.delete(
method="DELETE",
uri=self._uri,
)
async def delete_async(self) -> bool:
"""
Asynchronous coroutine that deletes the FleetInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._version.delete_async(
method="DELETE",
uri=self._uri,
)
def fetch(self) -> FleetInstance:
"""
Fetch the FleetInstance
:returns: The fetched FleetInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return FleetInstance(
self._version,
payload,
sid=self._solution["sid"],
)
async def fetch_async(self) -> FleetInstance:
"""
Asynchronous coroutine to fetch the FleetInstance
:returns: The fetched FleetInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return FleetInstance(
self._version,
payload,
sid=self._solution["sid"],
)
def update(
self,
friendly_name: Union[str, object] = values.unset,
default_deployment_sid: Union[str, object] = values.unset,
) -> FleetInstance:
"""
Update the FleetInstance
:param friendly_name: Provides a human readable descriptive text for this Fleet, up to 256 characters long.
:param default_deployment_sid: Provides a string identifier of a Deployment that is going to be used as a default one for this Fleet.
:returns: The updated FleetInstance
"""
data = values.of(
{
"FriendlyName": friendly_name,
"DefaultDeploymentSid": default_deployment_sid,
}
)
payload = self._version.update(
method="POST",
uri=self._uri,
data=data,
)
return FleetInstance(self._version, payload, sid=self._solution["sid"])
async def update_async(
self,
friendly_name: Union[str, object] = values.unset,
default_deployment_sid: Union[str, object] = values.unset,
) -> FleetInstance:
"""
Asynchronous coroutine to update the FleetInstance
:param friendly_name: Provides a human readable descriptive text for this Fleet, up to 256 characters long.
:param default_deployment_sid: Provides a string identifier of a Deployment that is going to be used as a default one for this Fleet.
:returns: The updated FleetInstance
"""
data = values.of(
{
"FriendlyName": friendly_name,
"DefaultDeploymentSid": default_deployment_sid,
}
)
payload = await self._version.update_async(
method="POST",
uri=self._uri,
data=data,
)
return FleetInstance(self._version, payload, sid=self._solution["sid"])
@property
def certificates(self) -> CertificateList:
"""
Access the certificates
"""
if self._certificates is None:
self._certificates = CertificateList(
self._version,
self._solution["sid"],
)
return self._certificates
@property
def deployments(self) -> DeploymentList:
"""
Access the deployments
"""
if self._deployments is None:
self._deployments = DeploymentList(
self._version,
self._solution["sid"],
)
return self._deployments
@property
def devices(self) -> DeviceList:
"""
Access the devices
"""
if self._devices is None:
self._devices = DeviceList(
self._version,
self._solution["sid"],
)
return self._devices
@property
def keys(self) -> KeyList:
"""
Access the keys
"""
if self._keys is None:
self._keys = KeyList(
self._version,
self._solution["sid"],
)
return self._keys
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Preview.DeployedDevices.FleetContext {}>".format(context)
class FleetPage(Page):
def get_instance(self, payload: Dict[str, Any]) -> FleetInstance:
"""
Build an instance of FleetInstance
:param payload: Payload response from the API
"""
return FleetInstance(self._version, payload)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.DeployedDevices.FleetPage>"
class FleetList(ListResource):
def __init__(self, version: Version):
"""
Initialize the FleetList
:param version: Version that contains the resource
"""
super().__init__(version)
self._uri = "/Fleets"
def create(self, friendly_name: Union[str, object] = values.unset) -> FleetInstance:
"""
Create the FleetInstance
:param friendly_name: Provides a human readable descriptive text for this Fleet, up to 256 characters long.
:returns: The created FleetInstance
"""
data = values.of(
{
"FriendlyName": friendly_name,
}
)
payload = self._version.create(
method="POST",
uri=self._uri,
data=data,
)
return FleetInstance(self._version, payload)
async def create_async(
self, friendly_name: Union[str, object] = values.unset
) -> FleetInstance:
"""
Asynchronously create the FleetInstance
:param friendly_name: Provides a human readable descriptive text for this Fleet, up to 256 characters long.
:returns: The created FleetInstance
"""
data = values.of(
{
"FriendlyName": friendly_name,
}
)
payload = await self._version.create_async(
method="POST",
uri=self._uri,
data=data,
)
return FleetInstance(self._version, payload)
def stream(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[FleetInstance]:
"""
Streams FleetInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param limit: Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the
limit with the most efficient page size, i.e. min(limit, 1000)
:returns: Generator that will yield up to limit results
"""
limits = self._version.read_limits(limit, page_size)
page = self.page(page_size=limits["page_size"])
return self._version.stream(page, limits["limit"])
async def stream_async(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> AsyncIterator[FleetInstance]:
"""
Asynchronously streams FleetInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param limit: Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the
limit with the most efficient page size, i.e. min(limit, 1000)
:returns: Generator that will yield up to limit results
"""
limits = self._version.read_limits(limit, page_size)
page = await self.page_async(page_size=limits["page_size"])
return self._version.stream_async(page, limits["limit"])
def list(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[FleetInstance]:
"""
Lists FleetInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param limit: Upper limit for the number of records to return. list() guarantees
never to return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, list() will attempt to read the limit
with the most efficient page size, i.e. min(limit, 1000)
:returns: list that will contain up to limit results
"""
return list(
self.stream(
limit=limit,
page_size=page_size,
)
)
async def list_async(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[FleetInstance]:
"""
Asynchronously lists FleetInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param limit: Upper limit for the number of records to return. list() guarantees
never to return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, list() will attempt to read the limit
with the most efficient page size, i.e. min(limit, 1000)
:returns: list that will contain up to limit results
"""
return [
record
async for record in await self.stream_async(
limit=limit,
page_size=page_size,
)
]
def page(
self,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> FleetPage:
"""
Retrieve a single page of FleetInstance records from the API.
Request is executed immediately
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of FleetInstance
"""
data = values.of(
{
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return FleetPage(self._version, response)
async def page_async(
self,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> FleetPage:
"""
Asynchronously retrieve a single page of FleetInstance records from the API.
Request is executed immediately
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of FleetInstance
"""
data = values.of(
{
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = await self._version.page_async(
method="GET", uri=self._uri, params=data
)
return FleetPage(self._version, response)
def get_page(self, target_url: str) -> FleetPage:
"""
Retrieve a specific page of FleetInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of FleetInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return FleetPage(self._version, response)
async def get_page_async(self, target_url: str) -> FleetPage:
"""
Asynchronously retrieve a specific page of FleetInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of FleetInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return FleetPage(self._version, response)
def get(self, sid: str) -> FleetContext:
"""
Constructs a FleetContext
:param sid: Provides a 34 character string that uniquely identifies the requested Fleet resource.
"""
return FleetContext(self._version, sid=sid)
def __call__(self, sid: str) -> FleetContext:
"""
Constructs a FleetContext
:param sid: Provides a 34 character string that uniquely identifies the requested Fleet resource.
"""
return FleetContext(self._version, sid=sid)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.DeployedDevices.FleetList>"
@@ -0,0 +1,655 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Preview
This is the public Twilio REST API.
NOTE: This class is auto generated by OpenAPI Generator.
https://openapi-generator.tech
Do not edit the class manually.
"""
from datetime import datetime
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
from twilio.base import deserialize, values
from twilio.base.instance_context import InstanceContext
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.version import Version
from twilio.base.page import Page
class CertificateInstance(InstanceResource):
"""
:ivar sid: Contains a 34 character string that uniquely identifies this Certificate credential resource.
:ivar url: Contains an absolute URL for this Certificate credential resource.
:ivar friendly_name: Contains a human readable descriptive text for this Certificate credential, up to 256 characters long.
:ivar fleet_sid: Specifies the unique string identifier of the Fleet that the given Certificate credential belongs to.
:ivar account_sid: Specifies the unique string identifier of the Account responsible for this Certificate credential.
:ivar device_sid: Specifies the unique string identifier of a Device authenticated with this Certificate credential.
:ivar thumbprint: Contains a unique hash of the payload of this Certificate credential, used to authenticate the Device.
:ivar date_created: Specifies the date this Certificate credential was created, given in UTC ISO 8601 format.
:ivar date_updated: Specifies the date this Certificate credential was last updated, given in UTC ISO 8601 format.
"""
def __init__(
self,
version: Version,
payload: Dict[str, Any],
fleet_sid: str,
sid: Optional[str] = None,
):
super().__init__(version)
self.sid: Optional[str] = payload.get("sid")
self.url: Optional[str] = payload.get("url")
self.friendly_name: Optional[str] = payload.get("friendly_name")
self.fleet_sid: Optional[str] = payload.get("fleet_sid")
self.account_sid: Optional[str] = payload.get("account_sid")
self.device_sid: Optional[str] = payload.get("device_sid")
self.thumbprint: Optional[str] = payload.get("thumbprint")
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_created")
)
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_updated")
)
self._solution = {
"fleet_sid": fleet_sid,
"sid": sid or self.sid,
}
self._context: Optional[CertificateContext] = None
@property
def _proxy(self) -> "CertificateContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: CertificateContext for this CertificateInstance
"""
if self._context is None:
self._context = CertificateContext(
self._version,
fleet_sid=self._solution["fleet_sid"],
sid=self._solution["sid"],
)
return self._context
def delete(self) -> bool:
"""
Deletes the CertificateInstance
:returns: True if delete succeeds, False otherwise
"""
return self._proxy.delete()
async def delete_async(self) -> bool:
"""
Asynchronous coroutine that deletes the CertificateInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._proxy.delete_async()
def fetch(self) -> "CertificateInstance":
"""
Fetch the CertificateInstance
:returns: The fetched CertificateInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "CertificateInstance":
"""
Asynchronous coroutine to fetch the CertificateInstance
:returns: The fetched CertificateInstance
"""
return await self._proxy.fetch_async()
def update(
self,
friendly_name: Union[str, object] = values.unset,
device_sid: Union[str, object] = values.unset,
) -> "CertificateInstance":
"""
Update the CertificateInstance
:param friendly_name: Provides a human readable descriptive text for this Certificate credential, up to 256 characters long.
:param device_sid: Provides the unique string identifier of an existing Device to become authenticated with this Certificate credential.
:returns: The updated CertificateInstance
"""
return self._proxy.update(
friendly_name=friendly_name,
device_sid=device_sid,
)
async def update_async(
self,
friendly_name: Union[str, object] = values.unset,
device_sid: Union[str, object] = values.unset,
) -> "CertificateInstance":
"""
Asynchronous coroutine to update the CertificateInstance
:param friendly_name: Provides a human readable descriptive text for this Certificate credential, up to 256 characters long.
:param device_sid: Provides the unique string identifier of an existing Device to become authenticated with this Certificate credential.
:returns: The updated CertificateInstance
"""
return await self._proxy.update_async(
friendly_name=friendly_name,
device_sid=device_sid,
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Preview.DeployedDevices.CertificateInstance {}>".format(context)
class CertificateContext(InstanceContext):
def __init__(self, version: Version, fleet_sid: str, sid: str):
"""
Initialize the CertificateContext
:param version: Version that contains the resource
:param fleet_sid:
:param sid: Provides a 34 character string that uniquely identifies the requested Certificate credential resource.
"""
super().__init__(version)
# Path Solution
self._solution = {
"fleet_sid": fleet_sid,
"sid": sid,
}
self._uri = "/Fleets/{fleet_sid}/Certificates/{sid}".format(**self._solution)
def delete(self) -> bool:
"""
Deletes the CertificateInstance
:returns: True if delete succeeds, False otherwise
"""
return self._version.delete(
method="DELETE",
uri=self._uri,
)
async def delete_async(self) -> bool:
"""
Asynchronous coroutine that deletes the CertificateInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._version.delete_async(
method="DELETE",
uri=self._uri,
)
def fetch(self) -> CertificateInstance:
"""
Fetch the CertificateInstance
:returns: The fetched CertificateInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return CertificateInstance(
self._version,
payload,
fleet_sid=self._solution["fleet_sid"],
sid=self._solution["sid"],
)
async def fetch_async(self) -> CertificateInstance:
"""
Asynchronous coroutine to fetch the CertificateInstance
:returns: The fetched CertificateInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return CertificateInstance(
self._version,
payload,
fleet_sid=self._solution["fleet_sid"],
sid=self._solution["sid"],
)
def update(
self,
friendly_name: Union[str, object] = values.unset,
device_sid: Union[str, object] = values.unset,
) -> CertificateInstance:
"""
Update the CertificateInstance
:param friendly_name: Provides a human readable descriptive text for this Certificate credential, up to 256 characters long.
:param device_sid: Provides the unique string identifier of an existing Device to become authenticated with this Certificate credential.
:returns: The updated CertificateInstance
"""
data = values.of(
{
"FriendlyName": friendly_name,
"DeviceSid": device_sid,
}
)
payload = self._version.update(
method="POST",
uri=self._uri,
data=data,
)
return CertificateInstance(
self._version,
payload,
fleet_sid=self._solution["fleet_sid"],
sid=self._solution["sid"],
)
async def update_async(
self,
friendly_name: Union[str, object] = values.unset,
device_sid: Union[str, object] = values.unset,
) -> CertificateInstance:
"""
Asynchronous coroutine to update the CertificateInstance
:param friendly_name: Provides a human readable descriptive text for this Certificate credential, up to 256 characters long.
:param device_sid: Provides the unique string identifier of an existing Device to become authenticated with this Certificate credential.
:returns: The updated CertificateInstance
"""
data = values.of(
{
"FriendlyName": friendly_name,
"DeviceSid": device_sid,
}
)
payload = await self._version.update_async(
method="POST",
uri=self._uri,
data=data,
)
return CertificateInstance(
self._version,
payload,
fleet_sid=self._solution["fleet_sid"],
sid=self._solution["sid"],
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Preview.DeployedDevices.CertificateContext {}>".format(context)
class CertificatePage(Page):
def get_instance(self, payload: Dict[str, Any]) -> CertificateInstance:
"""
Build an instance of CertificateInstance
:param payload: Payload response from the API
"""
return CertificateInstance(
self._version, payload, fleet_sid=self._solution["fleet_sid"]
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.DeployedDevices.CertificatePage>"
class CertificateList(ListResource):
def __init__(self, version: Version, fleet_sid: str):
"""
Initialize the CertificateList
:param version: Version that contains the resource
:param fleet_sid:
"""
super().__init__(version)
# Path Solution
self._solution = {
"fleet_sid": fleet_sid,
}
self._uri = "/Fleets/{fleet_sid}/Certificates".format(**self._solution)
def create(
self,
certificate_data: str,
friendly_name: Union[str, object] = values.unset,
device_sid: Union[str, object] = values.unset,
) -> CertificateInstance:
"""
Create the CertificateInstance
:param certificate_data: Provides a URL encoded representation of the public certificate in PEM format.
:param friendly_name: Provides a human readable descriptive text for this Certificate credential, up to 256 characters long.
:param device_sid: Provides the unique string identifier of an existing Device to become authenticated with this Certificate credential.
:returns: The created CertificateInstance
"""
data = values.of(
{
"CertificateData": certificate_data,
"FriendlyName": friendly_name,
"DeviceSid": device_sid,
}
)
payload = self._version.create(
method="POST",
uri=self._uri,
data=data,
)
return CertificateInstance(
self._version, payload, fleet_sid=self._solution["fleet_sid"]
)
async def create_async(
self,
certificate_data: str,
friendly_name: Union[str, object] = values.unset,
device_sid: Union[str, object] = values.unset,
) -> CertificateInstance:
"""
Asynchronously create the CertificateInstance
:param certificate_data: Provides a URL encoded representation of the public certificate in PEM format.
:param friendly_name: Provides a human readable descriptive text for this Certificate credential, up to 256 characters long.
:param device_sid: Provides the unique string identifier of an existing Device to become authenticated with this Certificate credential.
:returns: The created CertificateInstance
"""
data = values.of(
{
"CertificateData": certificate_data,
"FriendlyName": friendly_name,
"DeviceSid": device_sid,
}
)
payload = await self._version.create_async(
method="POST",
uri=self._uri,
data=data,
)
return CertificateInstance(
self._version, payload, fleet_sid=self._solution["fleet_sid"]
)
def stream(
self,
device_sid: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[CertificateInstance]:
"""
Streams CertificateInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param str device_sid: Filters the resulting list of Certificates by a unique string identifier of an authenticated Device.
:param limit: Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the
limit with the most efficient page size, i.e. min(limit, 1000)
:returns: Generator that will yield up to limit results
"""
limits = self._version.read_limits(limit, page_size)
page = self.page(device_sid=device_sid, page_size=limits["page_size"])
return self._version.stream(page, limits["limit"])
async def stream_async(
self,
device_sid: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> AsyncIterator[CertificateInstance]:
"""
Asynchronously streams CertificateInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param str device_sid: Filters the resulting list of Certificates by a unique string identifier of an authenticated Device.
:param limit: Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the
limit with the most efficient page size, i.e. min(limit, 1000)
:returns: Generator that will yield up to limit results
"""
limits = self._version.read_limits(limit, page_size)
page = await self.page_async(
device_sid=device_sid, page_size=limits["page_size"]
)
return self._version.stream_async(page, limits["limit"])
def list(
self,
device_sid: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[CertificateInstance]:
"""
Lists CertificateInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param str device_sid: Filters the resulting list of Certificates by a unique string identifier of an authenticated Device.
:param limit: Upper limit for the number of records to return. list() guarantees
never to return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, list() will attempt to read the limit
with the most efficient page size, i.e. min(limit, 1000)
:returns: list that will contain up to limit results
"""
return list(
self.stream(
device_sid=device_sid,
limit=limit,
page_size=page_size,
)
)
async def list_async(
self,
device_sid: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[CertificateInstance]:
"""
Asynchronously lists CertificateInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param str device_sid: Filters the resulting list of Certificates by a unique string identifier of an authenticated Device.
:param limit: Upper limit for the number of records to return. list() guarantees
never to return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, list() will attempt to read the limit
with the most efficient page size, i.e. min(limit, 1000)
:returns: list that will contain up to limit results
"""
return [
record
async for record in await self.stream_async(
device_sid=device_sid,
limit=limit,
page_size=page_size,
)
]
def page(
self,
device_sid: Union[str, object] = values.unset,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> CertificatePage:
"""
Retrieve a single page of CertificateInstance records from the API.
Request is executed immediately
:param device_sid: Filters the resulting list of Certificates by a unique string identifier of an authenticated Device.
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of CertificateInstance
"""
data = values.of(
{
"DeviceSid": device_sid,
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return CertificatePage(self._version, response, self._solution)
async def page_async(
self,
device_sid: Union[str, object] = values.unset,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> CertificatePage:
"""
Asynchronously retrieve a single page of CertificateInstance records from the API.
Request is executed immediately
:param device_sid: Filters the resulting list of Certificates by a unique string identifier of an authenticated Device.
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of CertificateInstance
"""
data = values.of(
{
"DeviceSid": device_sid,
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = await self._version.page_async(
method="GET", uri=self._uri, params=data
)
return CertificatePage(self._version, response, self._solution)
def get_page(self, target_url: str) -> CertificatePage:
"""
Retrieve a specific page of CertificateInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of CertificateInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return CertificatePage(self._version, response, self._solution)
async def get_page_async(self, target_url: str) -> CertificatePage:
"""
Asynchronously retrieve a specific page of CertificateInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of CertificateInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return CertificatePage(self._version, response, self._solution)
def get(self, sid: str) -> CertificateContext:
"""
Constructs a CertificateContext
:param sid: Provides a 34 character string that uniquely identifies the requested Certificate credential resource.
"""
return CertificateContext(
self._version, fleet_sid=self._solution["fleet_sid"], sid=sid
)
def __call__(self, sid: str) -> CertificateContext:
"""
Constructs a CertificateContext
:param sid: Provides a 34 character string that uniquely identifies the requested Certificate credential resource.
"""
return CertificateContext(
self._version, fleet_sid=self._solution["fleet_sid"], sid=sid
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.DeployedDevices.CertificateList>"
@@ -0,0 +1,629 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Preview
This is the public Twilio REST API.
NOTE: This class is auto generated by OpenAPI Generator.
https://openapi-generator.tech
Do not edit the class manually.
"""
from datetime import datetime
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
from twilio.base import deserialize, values
from twilio.base.instance_context import InstanceContext
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.version import Version
from twilio.base.page import Page
class DeploymentInstance(InstanceResource):
"""
:ivar sid: Contains a 34 character string that uniquely identifies this Deployment resource.
:ivar url: Contains an absolute URL for this Deployment resource.
:ivar friendly_name: Contains a human readable descriptive text for this Deployment, up to 64 characters long
:ivar fleet_sid: Specifies the unique string identifier of the Fleet that the given Deployment belongs to.
:ivar account_sid: Specifies the unique string identifier of the Account responsible for this Deployment.
:ivar sync_service_sid: Specifies the unique string identifier of the Twilio Sync service instance linked to and accessible by this Deployment.
:ivar date_created: Specifies the date this Deployment was created, given in UTC ISO 8601 format.
:ivar date_updated: Specifies the date this Deployment was last updated, given in UTC ISO 8601 format.
"""
def __init__(
self,
version: Version,
payload: Dict[str, Any],
fleet_sid: str,
sid: Optional[str] = None,
):
super().__init__(version)
self.sid: Optional[str] = payload.get("sid")
self.url: Optional[str] = payload.get("url")
self.friendly_name: Optional[str] = payload.get("friendly_name")
self.fleet_sid: Optional[str] = payload.get("fleet_sid")
self.account_sid: Optional[str] = payload.get("account_sid")
self.sync_service_sid: Optional[str] = payload.get("sync_service_sid")
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_created")
)
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_updated")
)
self._solution = {
"fleet_sid": fleet_sid,
"sid": sid or self.sid,
}
self._context: Optional[DeploymentContext] = None
@property
def _proxy(self) -> "DeploymentContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: DeploymentContext for this DeploymentInstance
"""
if self._context is None:
self._context = DeploymentContext(
self._version,
fleet_sid=self._solution["fleet_sid"],
sid=self._solution["sid"],
)
return self._context
def delete(self) -> bool:
"""
Deletes the DeploymentInstance
:returns: True if delete succeeds, False otherwise
"""
return self._proxy.delete()
async def delete_async(self) -> bool:
"""
Asynchronous coroutine that deletes the DeploymentInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._proxy.delete_async()
def fetch(self) -> "DeploymentInstance":
"""
Fetch the DeploymentInstance
:returns: The fetched DeploymentInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "DeploymentInstance":
"""
Asynchronous coroutine to fetch the DeploymentInstance
:returns: The fetched DeploymentInstance
"""
return await self._proxy.fetch_async()
def update(
self,
friendly_name: Union[str, object] = values.unset,
sync_service_sid: Union[str, object] = values.unset,
) -> "DeploymentInstance":
"""
Update the DeploymentInstance
:param friendly_name: Provides a human readable descriptive text for this Deployment, up to 64 characters long
:param sync_service_sid: Provides the unique string identifier of the Twilio Sync service instance that will be linked to and accessible by this Deployment.
:returns: The updated DeploymentInstance
"""
return self._proxy.update(
friendly_name=friendly_name,
sync_service_sid=sync_service_sid,
)
async def update_async(
self,
friendly_name: Union[str, object] = values.unset,
sync_service_sid: Union[str, object] = values.unset,
) -> "DeploymentInstance":
"""
Asynchronous coroutine to update the DeploymentInstance
:param friendly_name: Provides a human readable descriptive text for this Deployment, up to 64 characters long
:param sync_service_sid: Provides the unique string identifier of the Twilio Sync service instance that will be linked to and accessible by this Deployment.
:returns: The updated DeploymentInstance
"""
return await self._proxy.update_async(
friendly_name=friendly_name,
sync_service_sid=sync_service_sid,
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Preview.DeployedDevices.DeploymentInstance {}>".format(context)
class DeploymentContext(InstanceContext):
def __init__(self, version: Version, fleet_sid: str, sid: str):
"""
Initialize the DeploymentContext
:param version: Version that contains the resource
:param fleet_sid:
:param sid: Provides a 34 character string that uniquely identifies the requested Deployment resource.
"""
super().__init__(version)
# Path Solution
self._solution = {
"fleet_sid": fleet_sid,
"sid": sid,
}
self._uri = "/Fleets/{fleet_sid}/Deployments/{sid}".format(**self._solution)
def delete(self) -> bool:
"""
Deletes the DeploymentInstance
:returns: True if delete succeeds, False otherwise
"""
return self._version.delete(
method="DELETE",
uri=self._uri,
)
async def delete_async(self) -> bool:
"""
Asynchronous coroutine that deletes the DeploymentInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._version.delete_async(
method="DELETE",
uri=self._uri,
)
def fetch(self) -> DeploymentInstance:
"""
Fetch the DeploymentInstance
:returns: The fetched DeploymentInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return DeploymentInstance(
self._version,
payload,
fleet_sid=self._solution["fleet_sid"],
sid=self._solution["sid"],
)
async def fetch_async(self) -> DeploymentInstance:
"""
Asynchronous coroutine to fetch the DeploymentInstance
:returns: The fetched DeploymentInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return DeploymentInstance(
self._version,
payload,
fleet_sid=self._solution["fleet_sid"],
sid=self._solution["sid"],
)
def update(
self,
friendly_name: Union[str, object] = values.unset,
sync_service_sid: Union[str, object] = values.unset,
) -> DeploymentInstance:
"""
Update the DeploymentInstance
:param friendly_name: Provides a human readable descriptive text for this Deployment, up to 64 characters long
:param sync_service_sid: Provides the unique string identifier of the Twilio Sync service instance that will be linked to and accessible by this Deployment.
:returns: The updated DeploymentInstance
"""
data = values.of(
{
"FriendlyName": friendly_name,
"SyncServiceSid": sync_service_sid,
}
)
payload = self._version.update(
method="POST",
uri=self._uri,
data=data,
)
return DeploymentInstance(
self._version,
payload,
fleet_sid=self._solution["fleet_sid"],
sid=self._solution["sid"],
)
async def update_async(
self,
friendly_name: Union[str, object] = values.unset,
sync_service_sid: Union[str, object] = values.unset,
) -> DeploymentInstance:
"""
Asynchronous coroutine to update the DeploymentInstance
:param friendly_name: Provides a human readable descriptive text for this Deployment, up to 64 characters long
:param sync_service_sid: Provides the unique string identifier of the Twilio Sync service instance that will be linked to and accessible by this Deployment.
:returns: The updated DeploymentInstance
"""
data = values.of(
{
"FriendlyName": friendly_name,
"SyncServiceSid": sync_service_sid,
}
)
payload = await self._version.update_async(
method="POST",
uri=self._uri,
data=data,
)
return DeploymentInstance(
self._version,
payload,
fleet_sid=self._solution["fleet_sid"],
sid=self._solution["sid"],
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Preview.DeployedDevices.DeploymentContext {}>".format(context)
class DeploymentPage(Page):
def get_instance(self, payload: Dict[str, Any]) -> DeploymentInstance:
"""
Build an instance of DeploymentInstance
:param payload: Payload response from the API
"""
return DeploymentInstance(
self._version, payload, fleet_sid=self._solution["fleet_sid"]
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.DeployedDevices.DeploymentPage>"
class DeploymentList(ListResource):
def __init__(self, version: Version, fleet_sid: str):
"""
Initialize the DeploymentList
:param version: Version that contains the resource
:param fleet_sid:
"""
super().__init__(version)
# Path Solution
self._solution = {
"fleet_sid": fleet_sid,
}
self._uri = "/Fleets/{fleet_sid}/Deployments".format(**self._solution)
def create(
self,
friendly_name: Union[str, object] = values.unset,
sync_service_sid: Union[str, object] = values.unset,
) -> DeploymentInstance:
"""
Create the DeploymentInstance
:param friendly_name: Provides a human readable descriptive text for this Deployment, up to 256 characters long.
:param sync_service_sid: Provides the unique string identifier of the Twilio Sync service instance that will be linked to and accessible by this Deployment.
:returns: The created DeploymentInstance
"""
data = values.of(
{
"FriendlyName": friendly_name,
"SyncServiceSid": sync_service_sid,
}
)
payload = self._version.create(
method="POST",
uri=self._uri,
data=data,
)
return DeploymentInstance(
self._version, payload, fleet_sid=self._solution["fleet_sid"]
)
async def create_async(
self,
friendly_name: Union[str, object] = values.unset,
sync_service_sid: Union[str, object] = values.unset,
) -> DeploymentInstance:
"""
Asynchronously create the DeploymentInstance
:param friendly_name: Provides a human readable descriptive text for this Deployment, up to 256 characters long.
:param sync_service_sid: Provides the unique string identifier of the Twilio Sync service instance that will be linked to and accessible by this Deployment.
:returns: The created DeploymentInstance
"""
data = values.of(
{
"FriendlyName": friendly_name,
"SyncServiceSid": sync_service_sid,
}
)
payload = await self._version.create_async(
method="POST",
uri=self._uri,
data=data,
)
return DeploymentInstance(
self._version, payload, fleet_sid=self._solution["fleet_sid"]
)
def stream(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[DeploymentInstance]:
"""
Streams DeploymentInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param limit: Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the
limit with the most efficient page size, i.e. min(limit, 1000)
:returns: Generator that will yield up to limit results
"""
limits = self._version.read_limits(limit, page_size)
page = self.page(page_size=limits["page_size"])
return self._version.stream(page, limits["limit"])
async def stream_async(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> AsyncIterator[DeploymentInstance]:
"""
Asynchronously streams DeploymentInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param limit: Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the
limit with the most efficient page size, i.e. min(limit, 1000)
:returns: Generator that will yield up to limit results
"""
limits = self._version.read_limits(limit, page_size)
page = await self.page_async(page_size=limits["page_size"])
return self._version.stream_async(page, limits["limit"])
def list(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[DeploymentInstance]:
"""
Lists DeploymentInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param limit: Upper limit for the number of records to return. list() guarantees
never to return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, list() will attempt to read the limit
with the most efficient page size, i.e. min(limit, 1000)
:returns: list that will contain up to limit results
"""
return list(
self.stream(
limit=limit,
page_size=page_size,
)
)
async def list_async(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[DeploymentInstance]:
"""
Asynchronously lists DeploymentInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param limit: Upper limit for the number of records to return. list() guarantees
never to return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, list() will attempt to read the limit
with the most efficient page size, i.e. min(limit, 1000)
:returns: list that will contain up to limit results
"""
return [
record
async for record in await self.stream_async(
limit=limit,
page_size=page_size,
)
]
def page(
self,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> DeploymentPage:
"""
Retrieve a single page of DeploymentInstance records from the API.
Request is executed immediately
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of DeploymentInstance
"""
data = values.of(
{
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return DeploymentPage(self._version, response, self._solution)
async def page_async(
self,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> DeploymentPage:
"""
Asynchronously retrieve a single page of DeploymentInstance records from the API.
Request is executed immediately
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of DeploymentInstance
"""
data = values.of(
{
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = await self._version.page_async(
method="GET", uri=self._uri, params=data
)
return DeploymentPage(self._version, response, self._solution)
def get_page(self, target_url: str) -> DeploymentPage:
"""
Retrieve a specific page of DeploymentInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of DeploymentInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return DeploymentPage(self._version, response, self._solution)
async def get_page_async(self, target_url: str) -> DeploymentPage:
"""
Asynchronously retrieve a specific page of DeploymentInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of DeploymentInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return DeploymentPage(self._version, response, self._solution)
def get(self, sid: str) -> DeploymentContext:
"""
Constructs a DeploymentContext
:param sid: Provides a 34 character string that uniquely identifies the requested Deployment resource.
"""
return DeploymentContext(
self._version, fleet_sid=self._solution["fleet_sid"], sid=sid
)
def __call__(self, sid: str) -> DeploymentContext:
"""
Constructs a DeploymentContext
:param sid: Provides a 34 character string that uniquely identifies the requested Deployment resource.
"""
return DeploymentContext(
self._version, fleet_sid=self._solution["fleet_sid"], sid=sid
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.DeployedDevices.DeploymentList>"
@@ -0,0 +1,699 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Preview
This is the public Twilio REST API.
NOTE: This class is auto generated by OpenAPI Generator.
https://openapi-generator.tech
Do not edit the class manually.
"""
from datetime import datetime
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
from twilio.base import deserialize, values
from twilio.base.instance_context import InstanceContext
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.version import Version
from twilio.base.page import Page
class DeviceInstance(InstanceResource):
"""
:ivar sid: Contains a 34 character string that uniquely identifies this Device resource.
:ivar url: Contains an absolute URL for this Device resource.
:ivar unique_name: Contains a unique and addressable name of this Device, assigned by the developer, up to 128 characters long.
:ivar friendly_name: Contains a human readable descriptive text for this Device, up to 256 characters long
:ivar fleet_sid: Specifies the unique string identifier of the Fleet that the given Device belongs to.
:ivar enabled: Contains a boolean flag indicating whether the device is enabled or not, blocks device connectivity if set to false.
:ivar account_sid: Specifies the unique string identifier of the Account responsible for this Device.
:ivar identity: Contains an arbitrary string identifier representing a human user associated with this Device, assigned by the developer, up to 256 characters long.
:ivar deployment_sid: Specifies the unique string identifier of the Deployment group that this Device is associated with.
:ivar date_created: Specifies the date this Device was created, given in UTC ISO 8601 format.
:ivar date_updated: Specifies the date this Device was last updated, given in UTC ISO 8601 format.
:ivar date_authenticated: Specifies the date this Device was last authenticated, given in UTC ISO 8601 format.
"""
def __init__(
self,
version: Version,
payload: Dict[str, Any],
fleet_sid: str,
sid: Optional[str] = None,
):
super().__init__(version)
self.sid: Optional[str] = payload.get("sid")
self.url: Optional[str] = payload.get("url")
self.unique_name: Optional[str] = payload.get("unique_name")
self.friendly_name: Optional[str] = payload.get("friendly_name")
self.fleet_sid: Optional[str] = payload.get("fleet_sid")
self.enabled: Optional[bool] = payload.get("enabled")
self.account_sid: Optional[str] = payload.get("account_sid")
self.identity: Optional[str] = payload.get("identity")
self.deployment_sid: Optional[str] = payload.get("deployment_sid")
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_created")
)
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_updated")
)
self.date_authenticated: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_authenticated")
)
self._solution = {
"fleet_sid": fleet_sid,
"sid": sid or self.sid,
}
self._context: Optional[DeviceContext] = None
@property
def _proxy(self) -> "DeviceContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: DeviceContext for this DeviceInstance
"""
if self._context is None:
self._context = DeviceContext(
self._version,
fleet_sid=self._solution["fleet_sid"],
sid=self._solution["sid"],
)
return self._context
def delete(self) -> bool:
"""
Deletes the DeviceInstance
:returns: True if delete succeeds, False otherwise
"""
return self._proxy.delete()
async def delete_async(self) -> bool:
"""
Asynchronous coroutine that deletes the DeviceInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._proxy.delete_async()
def fetch(self) -> "DeviceInstance":
"""
Fetch the DeviceInstance
:returns: The fetched DeviceInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "DeviceInstance":
"""
Asynchronous coroutine to fetch the DeviceInstance
:returns: The fetched DeviceInstance
"""
return await self._proxy.fetch_async()
def update(
self,
friendly_name: Union[str, object] = values.unset,
identity: Union[str, object] = values.unset,
deployment_sid: Union[str, object] = values.unset,
enabled: Union[bool, object] = values.unset,
) -> "DeviceInstance":
"""
Update the DeviceInstance
:param friendly_name: Provides a human readable descriptive text to be assigned to this Device, up to 256 characters long.
:param identity: Provides an arbitrary string identifier representing a human user to be associated with this Device, up to 256 characters long.
:param deployment_sid: Specifies the unique string identifier of the Deployment group that this Device is going to be associated with.
:param enabled:
:returns: The updated DeviceInstance
"""
return self._proxy.update(
friendly_name=friendly_name,
identity=identity,
deployment_sid=deployment_sid,
enabled=enabled,
)
async def update_async(
self,
friendly_name: Union[str, object] = values.unset,
identity: Union[str, object] = values.unset,
deployment_sid: Union[str, object] = values.unset,
enabled: Union[bool, object] = values.unset,
) -> "DeviceInstance":
"""
Asynchronous coroutine to update the DeviceInstance
:param friendly_name: Provides a human readable descriptive text to be assigned to this Device, up to 256 characters long.
:param identity: Provides an arbitrary string identifier representing a human user to be associated with this Device, up to 256 characters long.
:param deployment_sid: Specifies the unique string identifier of the Deployment group that this Device is going to be associated with.
:param enabled:
:returns: The updated DeviceInstance
"""
return await self._proxy.update_async(
friendly_name=friendly_name,
identity=identity,
deployment_sid=deployment_sid,
enabled=enabled,
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Preview.DeployedDevices.DeviceInstance {}>".format(context)
class DeviceContext(InstanceContext):
def __init__(self, version: Version, fleet_sid: str, sid: str):
"""
Initialize the DeviceContext
:param version: Version that contains the resource
:param fleet_sid:
:param sid: Provides a 34 character string that uniquely identifies the requested Device resource.
"""
super().__init__(version)
# Path Solution
self._solution = {
"fleet_sid": fleet_sid,
"sid": sid,
}
self._uri = "/Fleets/{fleet_sid}/Devices/{sid}".format(**self._solution)
def delete(self) -> bool:
"""
Deletes the DeviceInstance
:returns: True if delete succeeds, False otherwise
"""
return self._version.delete(
method="DELETE",
uri=self._uri,
)
async def delete_async(self) -> bool:
"""
Asynchronous coroutine that deletes the DeviceInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._version.delete_async(
method="DELETE",
uri=self._uri,
)
def fetch(self) -> DeviceInstance:
"""
Fetch the DeviceInstance
:returns: The fetched DeviceInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return DeviceInstance(
self._version,
payload,
fleet_sid=self._solution["fleet_sid"],
sid=self._solution["sid"],
)
async def fetch_async(self) -> DeviceInstance:
"""
Asynchronous coroutine to fetch the DeviceInstance
:returns: The fetched DeviceInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return DeviceInstance(
self._version,
payload,
fleet_sid=self._solution["fleet_sid"],
sid=self._solution["sid"],
)
def update(
self,
friendly_name: Union[str, object] = values.unset,
identity: Union[str, object] = values.unset,
deployment_sid: Union[str, object] = values.unset,
enabled: Union[bool, object] = values.unset,
) -> DeviceInstance:
"""
Update the DeviceInstance
:param friendly_name: Provides a human readable descriptive text to be assigned to this Device, up to 256 characters long.
:param identity: Provides an arbitrary string identifier representing a human user to be associated with this Device, up to 256 characters long.
:param deployment_sid: Specifies the unique string identifier of the Deployment group that this Device is going to be associated with.
:param enabled:
:returns: The updated DeviceInstance
"""
data = values.of(
{
"FriendlyName": friendly_name,
"Identity": identity,
"DeploymentSid": deployment_sid,
"Enabled": enabled,
}
)
payload = self._version.update(
method="POST",
uri=self._uri,
data=data,
)
return DeviceInstance(
self._version,
payload,
fleet_sid=self._solution["fleet_sid"],
sid=self._solution["sid"],
)
async def update_async(
self,
friendly_name: Union[str, object] = values.unset,
identity: Union[str, object] = values.unset,
deployment_sid: Union[str, object] = values.unset,
enabled: Union[bool, object] = values.unset,
) -> DeviceInstance:
"""
Asynchronous coroutine to update the DeviceInstance
:param friendly_name: Provides a human readable descriptive text to be assigned to this Device, up to 256 characters long.
:param identity: Provides an arbitrary string identifier representing a human user to be associated with this Device, up to 256 characters long.
:param deployment_sid: Specifies the unique string identifier of the Deployment group that this Device is going to be associated with.
:param enabled:
:returns: The updated DeviceInstance
"""
data = values.of(
{
"FriendlyName": friendly_name,
"Identity": identity,
"DeploymentSid": deployment_sid,
"Enabled": enabled,
}
)
payload = await self._version.update_async(
method="POST",
uri=self._uri,
data=data,
)
return DeviceInstance(
self._version,
payload,
fleet_sid=self._solution["fleet_sid"],
sid=self._solution["sid"],
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Preview.DeployedDevices.DeviceContext {}>".format(context)
class DevicePage(Page):
def get_instance(self, payload: Dict[str, Any]) -> DeviceInstance:
"""
Build an instance of DeviceInstance
:param payload: Payload response from the API
"""
return DeviceInstance(
self._version, payload, fleet_sid=self._solution["fleet_sid"]
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.DeployedDevices.DevicePage>"
class DeviceList(ListResource):
def __init__(self, version: Version, fleet_sid: str):
"""
Initialize the DeviceList
:param version: Version that contains the resource
:param fleet_sid:
"""
super().__init__(version)
# Path Solution
self._solution = {
"fleet_sid": fleet_sid,
}
self._uri = "/Fleets/{fleet_sid}/Devices".format(**self._solution)
def create(
self,
unique_name: Union[str, object] = values.unset,
friendly_name: Union[str, object] = values.unset,
identity: Union[str, object] = values.unset,
deployment_sid: Union[str, object] = values.unset,
enabled: Union[bool, object] = values.unset,
) -> DeviceInstance:
"""
Create the DeviceInstance
:param unique_name: Provides a unique and addressable name to be assigned to this Device, to be used in addition to SID, up to 128 characters long.
:param friendly_name: Provides a human readable descriptive text to be assigned to this Device, up to 256 characters long.
:param identity: Provides an arbitrary string identifier representing a human user to be associated with this Device, up to 256 characters long.
:param deployment_sid: Specifies the unique string identifier of the Deployment group that this Device is going to be associated with.
:param enabled:
:returns: The created DeviceInstance
"""
data = values.of(
{
"UniqueName": unique_name,
"FriendlyName": friendly_name,
"Identity": identity,
"DeploymentSid": deployment_sid,
"Enabled": enabled,
}
)
payload = self._version.create(
method="POST",
uri=self._uri,
data=data,
)
return DeviceInstance(
self._version, payload, fleet_sid=self._solution["fleet_sid"]
)
async def create_async(
self,
unique_name: Union[str, object] = values.unset,
friendly_name: Union[str, object] = values.unset,
identity: Union[str, object] = values.unset,
deployment_sid: Union[str, object] = values.unset,
enabled: Union[bool, object] = values.unset,
) -> DeviceInstance:
"""
Asynchronously create the DeviceInstance
:param unique_name: Provides a unique and addressable name to be assigned to this Device, to be used in addition to SID, up to 128 characters long.
:param friendly_name: Provides a human readable descriptive text to be assigned to this Device, up to 256 characters long.
:param identity: Provides an arbitrary string identifier representing a human user to be associated with this Device, up to 256 characters long.
:param deployment_sid: Specifies the unique string identifier of the Deployment group that this Device is going to be associated with.
:param enabled:
:returns: The created DeviceInstance
"""
data = values.of(
{
"UniqueName": unique_name,
"FriendlyName": friendly_name,
"Identity": identity,
"DeploymentSid": deployment_sid,
"Enabled": enabled,
}
)
payload = await self._version.create_async(
method="POST",
uri=self._uri,
data=data,
)
return DeviceInstance(
self._version, payload, fleet_sid=self._solution["fleet_sid"]
)
def stream(
self,
deployment_sid: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[DeviceInstance]:
"""
Streams DeviceInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param str deployment_sid: Filters the resulting list of Devices by a unique string identifier of the Deployment they are associated with.
:param limit: Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the
limit with the most efficient page size, i.e. min(limit, 1000)
:returns: Generator that will yield up to limit results
"""
limits = self._version.read_limits(limit, page_size)
page = self.page(deployment_sid=deployment_sid, page_size=limits["page_size"])
return self._version.stream(page, limits["limit"])
async def stream_async(
self,
deployment_sid: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> AsyncIterator[DeviceInstance]:
"""
Asynchronously streams DeviceInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param str deployment_sid: Filters the resulting list of Devices by a unique string identifier of the Deployment they are associated with.
:param limit: Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the
limit with the most efficient page size, i.e. min(limit, 1000)
:returns: Generator that will yield up to limit results
"""
limits = self._version.read_limits(limit, page_size)
page = await self.page_async(
deployment_sid=deployment_sid, page_size=limits["page_size"]
)
return self._version.stream_async(page, limits["limit"])
def list(
self,
deployment_sid: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[DeviceInstance]:
"""
Lists DeviceInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param str deployment_sid: Filters the resulting list of Devices by a unique string identifier of the Deployment they are associated with.
:param limit: Upper limit for the number of records to return. list() guarantees
never to return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, list() will attempt to read the limit
with the most efficient page size, i.e. min(limit, 1000)
:returns: list that will contain up to limit results
"""
return list(
self.stream(
deployment_sid=deployment_sid,
limit=limit,
page_size=page_size,
)
)
async def list_async(
self,
deployment_sid: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[DeviceInstance]:
"""
Asynchronously lists DeviceInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param str deployment_sid: Filters the resulting list of Devices by a unique string identifier of the Deployment they are associated with.
:param limit: Upper limit for the number of records to return. list() guarantees
never to return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, list() will attempt to read the limit
with the most efficient page size, i.e. min(limit, 1000)
:returns: list that will contain up to limit results
"""
return [
record
async for record in await self.stream_async(
deployment_sid=deployment_sid,
limit=limit,
page_size=page_size,
)
]
def page(
self,
deployment_sid: Union[str, object] = values.unset,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> DevicePage:
"""
Retrieve a single page of DeviceInstance records from the API.
Request is executed immediately
:param deployment_sid: Filters the resulting list of Devices by a unique string identifier of the Deployment they are associated with.
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of DeviceInstance
"""
data = values.of(
{
"DeploymentSid": deployment_sid,
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return DevicePage(self._version, response, self._solution)
async def page_async(
self,
deployment_sid: Union[str, object] = values.unset,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> DevicePage:
"""
Asynchronously retrieve a single page of DeviceInstance records from the API.
Request is executed immediately
:param deployment_sid: Filters the resulting list of Devices by a unique string identifier of the Deployment they are associated with.
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of DeviceInstance
"""
data = values.of(
{
"DeploymentSid": deployment_sid,
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = await self._version.page_async(
method="GET", uri=self._uri, params=data
)
return DevicePage(self._version, response, self._solution)
def get_page(self, target_url: str) -> DevicePage:
"""
Retrieve a specific page of DeviceInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of DeviceInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return DevicePage(self._version, response, self._solution)
async def get_page_async(self, target_url: str) -> DevicePage:
"""
Asynchronously retrieve a specific page of DeviceInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of DeviceInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return DevicePage(self._version, response, self._solution)
def get(self, sid: str) -> DeviceContext:
"""
Constructs a DeviceContext
:param sid: Provides a 34 character string that uniquely identifies the requested Device resource.
"""
return DeviceContext(
self._version, fleet_sid=self._solution["fleet_sid"], sid=sid
)
def __call__(self, sid: str) -> DeviceContext:
"""
Constructs a DeviceContext
:param sid: Provides a 34 character string that uniquely identifies the requested Device resource.
"""
return DeviceContext(
self._version, fleet_sid=self._solution["fleet_sid"], sid=sid
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.DeployedDevices.DeviceList>"
@@ -0,0 +1,645 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Preview
This is the public Twilio REST API.
NOTE: This class is auto generated by OpenAPI Generator.
https://openapi-generator.tech
Do not edit the class manually.
"""
from datetime import datetime
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
from twilio.base import deserialize, values
from twilio.base.instance_context import InstanceContext
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.version import Version
from twilio.base.page import Page
class KeyInstance(InstanceResource):
"""
:ivar sid: Contains a 34 character string that uniquely identifies this Key credential resource.
:ivar url: Contains an absolute URL for this Key credential resource.
:ivar friendly_name: Contains a human readable descriptive text for this Key credential, up to 256 characters long.
:ivar fleet_sid: Specifies the unique string identifier of the Fleet that the given Key credential belongs to.
:ivar account_sid: Specifies the unique string identifier of the Account responsible for this Key credential.
:ivar device_sid: Specifies the unique string identifier of a Device authenticated with this Key credential.
:ivar secret: Contains the automatically generated secret belonging to this Key credential, used to authenticate the Device.
:ivar date_created: Specifies the date this Key credential was created, given in UTC ISO 8601 format.
:ivar date_updated: Specifies the date this Key credential was last updated, given in UTC ISO 8601 format.
"""
def __init__(
self,
version: Version,
payload: Dict[str, Any],
fleet_sid: str,
sid: Optional[str] = None,
):
super().__init__(version)
self.sid: Optional[str] = payload.get("sid")
self.url: Optional[str] = payload.get("url")
self.friendly_name: Optional[str] = payload.get("friendly_name")
self.fleet_sid: Optional[str] = payload.get("fleet_sid")
self.account_sid: Optional[str] = payload.get("account_sid")
self.device_sid: Optional[str] = payload.get("device_sid")
self.secret: Optional[str] = payload.get("secret")
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_created")
)
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_updated")
)
self._solution = {
"fleet_sid": fleet_sid,
"sid": sid or self.sid,
}
self._context: Optional[KeyContext] = None
@property
def _proxy(self) -> "KeyContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: KeyContext for this KeyInstance
"""
if self._context is None:
self._context = KeyContext(
self._version,
fleet_sid=self._solution["fleet_sid"],
sid=self._solution["sid"],
)
return self._context
def delete(self) -> bool:
"""
Deletes the KeyInstance
:returns: True if delete succeeds, False otherwise
"""
return self._proxy.delete()
async def delete_async(self) -> bool:
"""
Asynchronous coroutine that deletes the KeyInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._proxy.delete_async()
def fetch(self) -> "KeyInstance":
"""
Fetch the KeyInstance
:returns: The fetched KeyInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "KeyInstance":
"""
Asynchronous coroutine to fetch the KeyInstance
:returns: The fetched KeyInstance
"""
return await self._proxy.fetch_async()
def update(
self,
friendly_name: Union[str, object] = values.unset,
device_sid: Union[str, object] = values.unset,
) -> "KeyInstance":
"""
Update the KeyInstance
:param friendly_name: Provides a human readable descriptive text for this Key credential, up to 256 characters long.
:param device_sid: Provides the unique string identifier of an existing Device to become authenticated with this Key credential.
:returns: The updated KeyInstance
"""
return self._proxy.update(
friendly_name=friendly_name,
device_sid=device_sid,
)
async def update_async(
self,
friendly_name: Union[str, object] = values.unset,
device_sid: Union[str, object] = values.unset,
) -> "KeyInstance":
"""
Asynchronous coroutine to update the KeyInstance
:param friendly_name: Provides a human readable descriptive text for this Key credential, up to 256 characters long.
:param device_sid: Provides the unique string identifier of an existing Device to become authenticated with this Key credential.
:returns: The updated KeyInstance
"""
return await self._proxy.update_async(
friendly_name=friendly_name,
device_sid=device_sid,
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Preview.DeployedDevices.KeyInstance {}>".format(context)
class KeyContext(InstanceContext):
def __init__(self, version: Version, fleet_sid: str, sid: str):
"""
Initialize the KeyContext
:param version: Version that contains the resource
:param fleet_sid:
:param sid: Provides a 34 character string that uniquely identifies the requested Key credential resource.
"""
super().__init__(version)
# Path Solution
self._solution = {
"fleet_sid": fleet_sid,
"sid": sid,
}
self._uri = "/Fleets/{fleet_sid}/Keys/{sid}".format(**self._solution)
def delete(self) -> bool:
"""
Deletes the KeyInstance
:returns: True if delete succeeds, False otherwise
"""
return self._version.delete(
method="DELETE",
uri=self._uri,
)
async def delete_async(self) -> bool:
"""
Asynchronous coroutine that deletes the KeyInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._version.delete_async(
method="DELETE",
uri=self._uri,
)
def fetch(self) -> KeyInstance:
"""
Fetch the KeyInstance
:returns: The fetched KeyInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return KeyInstance(
self._version,
payload,
fleet_sid=self._solution["fleet_sid"],
sid=self._solution["sid"],
)
async def fetch_async(self) -> KeyInstance:
"""
Asynchronous coroutine to fetch the KeyInstance
:returns: The fetched KeyInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return KeyInstance(
self._version,
payload,
fleet_sid=self._solution["fleet_sid"],
sid=self._solution["sid"],
)
def update(
self,
friendly_name: Union[str, object] = values.unset,
device_sid: Union[str, object] = values.unset,
) -> KeyInstance:
"""
Update the KeyInstance
:param friendly_name: Provides a human readable descriptive text for this Key credential, up to 256 characters long.
:param device_sid: Provides the unique string identifier of an existing Device to become authenticated with this Key credential.
:returns: The updated KeyInstance
"""
data = values.of(
{
"FriendlyName": friendly_name,
"DeviceSid": device_sid,
}
)
payload = self._version.update(
method="POST",
uri=self._uri,
data=data,
)
return KeyInstance(
self._version,
payload,
fleet_sid=self._solution["fleet_sid"],
sid=self._solution["sid"],
)
async def update_async(
self,
friendly_name: Union[str, object] = values.unset,
device_sid: Union[str, object] = values.unset,
) -> KeyInstance:
"""
Asynchronous coroutine to update the KeyInstance
:param friendly_name: Provides a human readable descriptive text for this Key credential, up to 256 characters long.
:param device_sid: Provides the unique string identifier of an existing Device to become authenticated with this Key credential.
:returns: The updated KeyInstance
"""
data = values.of(
{
"FriendlyName": friendly_name,
"DeviceSid": device_sid,
}
)
payload = await self._version.update_async(
method="POST",
uri=self._uri,
data=data,
)
return KeyInstance(
self._version,
payload,
fleet_sid=self._solution["fleet_sid"],
sid=self._solution["sid"],
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Preview.DeployedDevices.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, fleet_sid=self._solution["fleet_sid"]
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.DeployedDevices.KeyPage>"
class KeyList(ListResource):
def __init__(self, version: Version, fleet_sid: str):
"""
Initialize the KeyList
:param version: Version that contains the resource
:param fleet_sid:
"""
super().__init__(version)
# Path Solution
self._solution = {
"fleet_sid": fleet_sid,
}
self._uri = "/Fleets/{fleet_sid}/Keys".format(**self._solution)
def create(
self,
friendly_name: Union[str, object] = values.unset,
device_sid: Union[str, object] = values.unset,
) -> KeyInstance:
"""
Create the KeyInstance
:param friendly_name: Provides a human readable descriptive text for this Key credential, up to 256 characters long.
:param device_sid: Provides the unique string identifier of an existing Device to become authenticated with this Key credential.
:returns: The created KeyInstance
"""
data = values.of(
{
"FriendlyName": friendly_name,
"DeviceSid": device_sid,
}
)
payload = self._version.create(
method="POST",
uri=self._uri,
data=data,
)
return KeyInstance(
self._version, payload, fleet_sid=self._solution["fleet_sid"]
)
async def create_async(
self,
friendly_name: Union[str, object] = values.unset,
device_sid: Union[str, object] = values.unset,
) -> KeyInstance:
"""
Asynchronously create the KeyInstance
:param friendly_name: Provides a human readable descriptive text for this Key credential, up to 256 characters long.
:param device_sid: Provides the unique string identifier of an existing Device to become authenticated with this Key credential.
:returns: The created KeyInstance
"""
data = values.of(
{
"FriendlyName": friendly_name,
"DeviceSid": device_sid,
}
)
payload = await self._version.create_async(
method="POST",
uri=self._uri,
data=data,
)
return KeyInstance(
self._version, payload, fleet_sid=self._solution["fleet_sid"]
)
def stream(
self,
device_sid: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[KeyInstance]:
"""
Streams KeyInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param str device_sid: Filters the resulting list of Keys by a unique string identifier of an authenticated Device.
:param limit: Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the
limit with the most efficient page size, i.e. min(limit, 1000)
:returns: Generator that will yield up to limit results
"""
limits = self._version.read_limits(limit, page_size)
page = self.page(device_sid=device_sid, page_size=limits["page_size"])
return self._version.stream(page, limits["limit"])
async def stream_async(
self,
device_sid: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> AsyncIterator[KeyInstance]:
"""
Asynchronously streams KeyInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param str device_sid: Filters the resulting list of Keys by a unique string identifier of an authenticated Device.
:param limit: Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the
limit with the most efficient page size, i.e. min(limit, 1000)
:returns: Generator that will yield up to limit results
"""
limits = self._version.read_limits(limit, page_size)
page = await self.page_async(
device_sid=device_sid, page_size=limits["page_size"]
)
return self._version.stream_async(page, limits["limit"])
def list(
self,
device_sid: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[KeyInstance]:
"""
Lists KeyInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param str device_sid: Filters the resulting list of Keys by a unique string identifier of an authenticated Device.
:param limit: Upper limit for the number of records to return. list() guarantees
never to return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, list() will attempt to read the limit
with the most efficient page size, i.e. min(limit, 1000)
:returns: list that will contain up to limit results
"""
return list(
self.stream(
device_sid=device_sid,
limit=limit,
page_size=page_size,
)
)
async def list_async(
self,
device_sid: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[KeyInstance]:
"""
Asynchronously lists KeyInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param str device_sid: Filters the resulting list of Keys by a unique string identifier of an authenticated Device.
:param limit: Upper limit for the number of records to return. list() guarantees
never to return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, list() will attempt to read the limit
with the most efficient page size, i.e. min(limit, 1000)
:returns: list that will contain up to limit results
"""
return [
record
async for record in await self.stream_async(
device_sid=device_sid,
limit=limit,
page_size=page_size,
)
]
def page(
self,
device_sid: Union[str, object] = values.unset,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> KeyPage:
"""
Retrieve a single page of KeyInstance records from the API.
Request is executed immediately
:param device_sid: Filters the resulting list of Keys by a unique string identifier of an authenticated Device.
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of KeyInstance
"""
data = values.of(
{
"DeviceSid": device_sid,
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return KeyPage(self._version, response, self._solution)
async def page_async(
self,
device_sid: Union[str, object] = values.unset,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> KeyPage:
"""
Asynchronously retrieve a single page of KeyInstance records from the API.
Request is executed immediately
:param device_sid: Filters the resulting list of Keys by a unique string identifier of an authenticated Device.
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of KeyInstance
"""
data = values.of(
{
"DeviceSid": device_sid,
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = await self._version.page_async(
method="GET", uri=self._uri, params=data
)
return KeyPage(self._version, response, self._solution)
def get_page(self, target_url: str) -> KeyPage:
"""
Retrieve a specific page of KeyInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of KeyInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return KeyPage(self._version, response, self._solution)
async def get_page_async(self, target_url: str) -> KeyPage:
"""
Asynchronously retrieve a specific page of KeyInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of KeyInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return KeyPage(self._version, response, self._solution)
def get(self, sid: str) -> KeyContext:
"""
Constructs a KeyContext
:param sid: Provides a 34 character string that uniquely identifies the requested Key credential resource.
"""
return KeyContext(self._version, fleet_sid=self._solution["fleet_sid"], sid=sid)
def __call__(self, sid: str) -> KeyContext:
"""
Constructs a KeyContext
:param sid: Provides a 34 character string that uniquely identifies the requested Key credential resource.
"""
return KeyContext(self._version, fleet_sid=self._solution["fleet_sid"], sid=sid)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.DeployedDevices.KeyList>"
@@ -0,0 +1,52 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Preview
This is the public Twilio REST API.
NOTE: This class is auto generated by OpenAPI Generator.
https://openapi-generator.tech
Do not edit the class manually.
"""
from typing import Optional
from twilio.base.version import Version
from twilio.base.domain import Domain
from twilio.rest.preview.hosted_numbers.authorization_document import (
AuthorizationDocumentList,
)
from twilio.rest.preview.hosted_numbers.hosted_number_order import HostedNumberOrderList
class HostedNumbers(Version):
def __init__(self, domain: Domain):
"""
Initialize the HostedNumbers version of Preview
:param domain: The Twilio.preview domain
"""
super().__init__(domain, "HostedNumbers")
self._authorization_documents: Optional[AuthorizationDocumentList] = None
self._hosted_number_orders: Optional[HostedNumberOrderList] = None
@property
def authorization_documents(self) -> AuthorizationDocumentList:
if self._authorization_documents is None:
self._authorization_documents = AuthorizationDocumentList(self)
return self._authorization_documents
@property
def hosted_number_orders(self) -> HostedNumberOrderList:
if self._hosted_number_orders is None:
self._hosted_number_orders = HostedNumberOrderList(self)
return self._hosted_number_orders
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.HostedNumbers>"
@@ -0,0 +1,722 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Preview
This is the public Twilio REST API.
NOTE: This class is auto generated by OpenAPI Generator.
https://openapi-generator.tech
Do not edit the class manually.
"""
from datetime import datetime
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
from twilio.base import deserialize, serialize, values
from twilio.base.instance_context import InstanceContext
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.version import Version
from twilio.base.page import Page
from twilio.rest.preview.hosted_numbers.authorization_document.dependent_hosted_number_order import (
DependentHostedNumberOrderList,
)
class AuthorizationDocumentInstance(InstanceResource):
class Status(object):
OPENED = "opened"
SIGNING = "signing"
SIGNED = "signed"
CANCELED = "canceled"
FAILED = "failed"
"""
:ivar sid: A 34 character string that uniquely identifies this AuthorizationDocument.
:ivar address_sid: A 34 character string that uniquely identifies the Address resource that is associated with this AuthorizationDocument.
:ivar status:
:ivar email: Email that this AuthorizationDocument will be sent to for signing.
:ivar cc_emails: Email recipients who will be informed when an Authorization Document has been sent and signed.
:ivar date_created: The date this resource was created, given as [GMT RFC 2822](http://www.ietf.org/rfc/rfc2822.txt) format.
:ivar date_updated: The date that this resource was updated, given as [GMT RFC 2822](http://www.ietf.org/rfc/rfc2822.txt) format.
:ivar url:
:ivar links:
"""
def __init__(
self, version: Version, payload: Dict[str, Any], sid: Optional[str] = None
):
super().__init__(version)
self.sid: Optional[str] = payload.get("sid")
self.address_sid: Optional[str] = payload.get("address_sid")
self.status: Optional["AuthorizationDocumentInstance.Status"] = payload.get(
"status"
)
self.email: Optional[str] = payload.get("email")
self.cc_emails: Optional[List[str]] = payload.get("cc_emails")
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_created")
)
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_updated")
)
self.url: Optional[str] = payload.get("url")
self.links: Optional[Dict[str, object]] = payload.get("links")
self._solution = {
"sid": sid or self.sid,
}
self._context: Optional[AuthorizationDocumentContext] = None
@property
def _proxy(self) -> "AuthorizationDocumentContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: AuthorizationDocumentContext for this AuthorizationDocumentInstance
"""
if self._context is None:
self._context = AuthorizationDocumentContext(
self._version,
sid=self._solution["sid"],
)
return self._context
def fetch(self) -> "AuthorizationDocumentInstance":
"""
Fetch the AuthorizationDocumentInstance
:returns: The fetched AuthorizationDocumentInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "AuthorizationDocumentInstance":
"""
Asynchronous coroutine to fetch the AuthorizationDocumentInstance
:returns: The fetched AuthorizationDocumentInstance
"""
return await self._proxy.fetch_async()
def update(
self,
hosted_number_order_sids: Union[List[str], object] = values.unset,
address_sid: Union[str, object] = values.unset,
email: Union[str, object] = values.unset,
cc_emails: Union[List[str], object] = values.unset,
status: Union["AuthorizationDocumentInstance.Status", object] = values.unset,
contact_title: Union[str, object] = values.unset,
contact_phone_number: Union[str, object] = values.unset,
) -> "AuthorizationDocumentInstance":
"""
Update the AuthorizationDocumentInstance
:param hosted_number_order_sids: A list of HostedNumberOrder sids that this AuthorizationDocument will authorize for hosting phone number capabilities on Twilio's platform.
:param address_sid: A 34 character string that uniquely identifies the Address resource that is associated with this AuthorizationDocument.
:param email: Email that this AuthorizationDocument will be sent to for signing.
:param cc_emails: Email recipients who will be informed when an Authorization Document has been sent and signed
:param status:
:param contact_title: The title of the person authorized to sign the Authorization Document for this phone number.
:param contact_phone_number: The contact phone number of the person authorized to sign the Authorization Document.
:returns: The updated AuthorizationDocumentInstance
"""
return self._proxy.update(
hosted_number_order_sids=hosted_number_order_sids,
address_sid=address_sid,
email=email,
cc_emails=cc_emails,
status=status,
contact_title=contact_title,
contact_phone_number=contact_phone_number,
)
async def update_async(
self,
hosted_number_order_sids: Union[List[str], object] = values.unset,
address_sid: Union[str, object] = values.unset,
email: Union[str, object] = values.unset,
cc_emails: Union[List[str], object] = values.unset,
status: Union["AuthorizationDocumentInstance.Status", object] = values.unset,
contact_title: Union[str, object] = values.unset,
contact_phone_number: Union[str, object] = values.unset,
) -> "AuthorizationDocumentInstance":
"""
Asynchronous coroutine to update the AuthorizationDocumentInstance
:param hosted_number_order_sids: A list of HostedNumberOrder sids that this AuthorizationDocument will authorize for hosting phone number capabilities on Twilio's platform.
:param address_sid: A 34 character string that uniquely identifies the Address resource that is associated with this AuthorizationDocument.
:param email: Email that this AuthorizationDocument will be sent to for signing.
:param cc_emails: Email recipients who will be informed when an Authorization Document has been sent and signed
:param status:
:param contact_title: The title of the person authorized to sign the Authorization Document for this phone number.
:param contact_phone_number: The contact phone number of the person authorized to sign the Authorization Document.
:returns: The updated AuthorizationDocumentInstance
"""
return await self._proxy.update_async(
hosted_number_order_sids=hosted_number_order_sids,
address_sid=address_sid,
email=email,
cc_emails=cc_emails,
status=status,
contact_title=contact_title,
contact_phone_number=contact_phone_number,
)
@property
def dependent_hosted_number_orders(self) -> DependentHostedNumberOrderList:
"""
Access the dependent_hosted_number_orders
"""
return self._proxy.dependent_hosted_number_orders
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Preview.HostedNumbers.AuthorizationDocumentInstance {}>".format(
context
)
class AuthorizationDocumentContext(InstanceContext):
def __init__(self, version: Version, sid: str):
"""
Initialize the AuthorizationDocumentContext
:param version: Version that contains the resource
:param sid: A 34 character string that uniquely identifies this AuthorizationDocument.
"""
super().__init__(version)
# Path Solution
self._solution = {
"sid": sid,
}
self._uri = "/AuthorizationDocuments/{sid}".format(**self._solution)
self._dependent_hosted_number_orders: Optional[
DependentHostedNumberOrderList
] = None
def fetch(self) -> AuthorizationDocumentInstance:
"""
Fetch the AuthorizationDocumentInstance
:returns: The fetched AuthorizationDocumentInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return AuthorizationDocumentInstance(
self._version,
payload,
sid=self._solution["sid"],
)
async def fetch_async(self) -> AuthorizationDocumentInstance:
"""
Asynchronous coroutine to fetch the AuthorizationDocumentInstance
:returns: The fetched AuthorizationDocumentInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return AuthorizationDocumentInstance(
self._version,
payload,
sid=self._solution["sid"],
)
def update(
self,
hosted_number_order_sids: Union[List[str], object] = values.unset,
address_sid: Union[str, object] = values.unset,
email: Union[str, object] = values.unset,
cc_emails: Union[List[str], object] = values.unset,
status: Union["AuthorizationDocumentInstance.Status", object] = values.unset,
contact_title: Union[str, object] = values.unset,
contact_phone_number: Union[str, object] = values.unset,
) -> AuthorizationDocumentInstance:
"""
Update the AuthorizationDocumentInstance
:param hosted_number_order_sids: A list of HostedNumberOrder sids that this AuthorizationDocument will authorize for hosting phone number capabilities on Twilio's platform.
:param address_sid: A 34 character string that uniquely identifies the Address resource that is associated with this AuthorizationDocument.
:param email: Email that this AuthorizationDocument will be sent to for signing.
:param cc_emails: Email recipients who will be informed when an Authorization Document has been sent and signed
:param status:
:param contact_title: The title of the person authorized to sign the Authorization Document for this phone number.
:param contact_phone_number: The contact phone number of the person authorized to sign the Authorization Document.
:returns: The updated AuthorizationDocumentInstance
"""
data = values.of(
{
"HostedNumberOrderSids": serialize.map(
hosted_number_order_sids, lambda e: e
),
"AddressSid": address_sid,
"Email": email,
"CcEmails": serialize.map(cc_emails, lambda e: e),
"Status": status,
"ContactTitle": contact_title,
"ContactPhoneNumber": contact_phone_number,
}
)
payload = self._version.update(
method="POST",
uri=self._uri,
data=data,
)
return AuthorizationDocumentInstance(
self._version, payload, sid=self._solution["sid"]
)
async def update_async(
self,
hosted_number_order_sids: Union[List[str], object] = values.unset,
address_sid: Union[str, object] = values.unset,
email: Union[str, object] = values.unset,
cc_emails: Union[List[str], object] = values.unset,
status: Union["AuthorizationDocumentInstance.Status", object] = values.unset,
contact_title: Union[str, object] = values.unset,
contact_phone_number: Union[str, object] = values.unset,
) -> AuthorizationDocumentInstance:
"""
Asynchronous coroutine to update the AuthorizationDocumentInstance
:param hosted_number_order_sids: A list of HostedNumberOrder sids that this AuthorizationDocument will authorize for hosting phone number capabilities on Twilio's platform.
:param address_sid: A 34 character string that uniquely identifies the Address resource that is associated with this AuthorizationDocument.
:param email: Email that this AuthorizationDocument will be sent to for signing.
:param cc_emails: Email recipients who will be informed when an Authorization Document has been sent and signed
:param status:
:param contact_title: The title of the person authorized to sign the Authorization Document for this phone number.
:param contact_phone_number: The contact phone number of the person authorized to sign the Authorization Document.
:returns: The updated AuthorizationDocumentInstance
"""
data = values.of(
{
"HostedNumberOrderSids": serialize.map(
hosted_number_order_sids, lambda e: e
),
"AddressSid": address_sid,
"Email": email,
"CcEmails": serialize.map(cc_emails, lambda e: e),
"Status": status,
"ContactTitle": contact_title,
"ContactPhoneNumber": contact_phone_number,
}
)
payload = await self._version.update_async(
method="POST",
uri=self._uri,
data=data,
)
return AuthorizationDocumentInstance(
self._version, payload, sid=self._solution["sid"]
)
@property
def dependent_hosted_number_orders(self) -> DependentHostedNumberOrderList:
"""
Access the dependent_hosted_number_orders
"""
if self._dependent_hosted_number_orders is None:
self._dependent_hosted_number_orders = DependentHostedNumberOrderList(
self._version,
self._solution["sid"],
)
return self._dependent_hosted_number_orders
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Preview.HostedNumbers.AuthorizationDocumentContext {}>".format(
context
)
class AuthorizationDocumentPage(Page):
def get_instance(self, payload: Dict[str, Any]) -> AuthorizationDocumentInstance:
"""
Build an instance of AuthorizationDocumentInstance
:param payload: Payload response from the API
"""
return AuthorizationDocumentInstance(self._version, payload)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.HostedNumbers.AuthorizationDocumentPage>"
class AuthorizationDocumentList(ListResource):
def __init__(self, version: Version):
"""
Initialize the AuthorizationDocumentList
:param version: Version that contains the resource
"""
super().__init__(version)
self._uri = "/AuthorizationDocuments"
def create(
self,
hosted_number_order_sids: List[str],
address_sid: str,
email: str,
contact_title: str,
contact_phone_number: str,
cc_emails: Union[List[str], object] = values.unset,
) -> AuthorizationDocumentInstance:
"""
Create the AuthorizationDocumentInstance
:param hosted_number_order_sids: A list of HostedNumberOrder sids that this AuthorizationDocument will authorize for hosting phone number capabilities on Twilio's platform.
:param address_sid: A 34 character string that uniquely identifies the Address resource that is associated with this AuthorizationDocument.
:param email: Email that this AuthorizationDocument will be sent to for signing.
:param contact_title: The title of the person authorized to sign the Authorization Document for this phone number.
:param contact_phone_number: The contact phone number of the person authorized to sign the Authorization Document.
:param cc_emails: Email recipients who will be informed when an Authorization Document has been sent and signed.
:returns: The created AuthorizationDocumentInstance
"""
data = values.of(
{
"HostedNumberOrderSids": serialize.map(
hosted_number_order_sids, lambda e: e
),
"AddressSid": address_sid,
"Email": email,
"ContactTitle": contact_title,
"ContactPhoneNumber": contact_phone_number,
"CcEmails": serialize.map(cc_emails, lambda e: e),
}
)
payload = self._version.create(
method="POST",
uri=self._uri,
data=data,
)
return AuthorizationDocumentInstance(self._version, payload)
async def create_async(
self,
hosted_number_order_sids: List[str],
address_sid: str,
email: str,
contact_title: str,
contact_phone_number: str,
cc_emails: Union[List[str], object] = values.unset,
) -> AuthorizationDocumentInstance:
"""
Asynchronously create the AuthorizationDocumentInstance
:param hosted_number_order_sids: A list of HostedNumberOrder sids that this AuthorizationDocument will authorize for hosting phone number capabilities on Twilio's platform.
:param address_sid: A 34 character string that uniquely identifies the Address resource that is associated with this AuthorizationDocument.
:param email: Email that this AuthorizationDocument will be sent to for signing.
:param contact_title: The title of the person authorized to sign the Authorization Document for this phone number.
:param contact_phone_number: The contact phone number of the person authorized to sign the Authorization Document.
:param cc_emails: Email recipients who will be informed when an Authorization Document has been sent and signed.
:returns: The created AuthorizationDocumentInstance
"""
data = values.of(
{
"HostedNumberOrderSids": serialize.map(
hosted_number_order_sids, lambda e: e
),
"AddressSid": address_sid,
"Email": email,
"ContactTitle": contact_title,
"ContactPhoneNumber": contact_phone_number,
"CcEmails": serialize.map(cc_emails, lambda e: e),
}
)
payload = await self._version.create_async(
method="POST",
uri=self._uri,
data=data,
)
return AuthorizationDocumentInstance(self._version, payload)
def stream(
self,
email: Union[str, object] = values.unset,
status: Union["AuthorizationDocumentInstance.Status", object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[AuthorizationDocumentInstance]:
"""
Streams AuthorizationDocumentInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param str email: Email that this AuthorizationDocument will be sent to for signing.
:param &quot;AuthorizationDocumentInstance.Status&quot; status: Status of an instance resource. It can hold one of the values: 1. opened 2. signing, 3. signed LOA, 4. canceled, 5. failed. See the section entitled [Status Values](https://www.twilio.com/docs/phone-numbers/hosted-numbers/hosted-numbers-api/authorization-document-resource#status-values) for more information on each of these statuses.
:param limit: Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the
limit with the most efficient page size, i.e. min(limit, 1000)
:returns: Generator that will yield up to limit results
"""
limits = self._version.read_limits(limit, page_size)
page = self.page(email=email, status=status, page_size=limits["page_size"])
return self._version.stream(page, limits["limit"])
async def stream_async(
self,
email: Union[str, object] = values.unset,
status: Union["AuthorizationDocumentInstance.Status", object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> AsyncIterator[AuthorizationDocumentInstance]:
"""
Asynchronously streams AuthorizationDocumentInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param str email: Email that this AuthorizationDocument will be sent to for signing.
:param &quot;AuthorizationDocumentInstance.Status&quot; status: Status of an instance resource. It can hold one of the values: 1. opened 2. signing, 3. signed LOA, 4. canceled, 5. failed. See the section entitled [Status Values](https://www.twilio.com/docs/phone-numbers/hosted-numbers/hosted-numbers-api/authorization-document-resource#status-values) for more information on each of these statuses.
:param limit: Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the
limit with the most efficient page size, i.e. min(limit, 1000)
:returns: Generator that will yield up to limit results
"""
limits = self._version.read_limits(limit, page_size)
page = await self.page_async(
email=email, status=status, page_size=limits["page_size"]
)
return self._version.stream_async(page, limits["limit"])
def list(
self,
email: Union[str, object] = values.unset,
status: Union["AuthorizationDocumentInstance.Status", object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[AuthorizationDocumentInstance]:
"""
Lists AuthorizationDocumentInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param str email: Email that this AuthorizationDocument will be sent to for signing.
:param &quot;AuthorizationDocumentInstance.Status&quot; status: Status of an instance resource. It can hold one of the values: 1. opened 2. signing, 3. signed LOA, 4. canceled, 5. failed. See the section entitled [Status Values](https://www.twilio.com/docs/phone-numbers/hosted-numbers/hosted-numbers-api/authorization-document-resource#status-values) for more information on each of these statuses.
:param limit: Upper limit for the number of records to return. list() guarantees
never to return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, list() will attempt to read the limit
with the most efficient page size, i.e. min(limit, 1000)
:returns: list that will contain up to limit results
"""
return list(
self.stream(
email=email,
status=status,
limit=limit,
page_size=page_size,
)
)
async def list_async(
self,
email: Union[str, object] = values.unset,
status: Union["AuthorizationDocumentInstance.Status", object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[AuthorizationDocumentInstance]:
"""
Asynchronously lists AuthorizationDocumentInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param str email: Email that this AuthorizationDocument will be sent to for signing.
:param &quot;AuthorizationDocumentInstance.Status&quot; status: Status of an instance resource. It can hold one of the values: 1. opened 2. signing, 3. signed LOA, 4. canceled, 5. failed. See the section entitled [Status Values](https://www.twilio.com/docs/phone-numbers/hosted-numbers/hosted-numbers-api/authorization-document-resource#status-values) for more information on each of these statuses.
:param limit: Upper limit for the number of records to return. list() guarantees
never to return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, list() will attempt to read the limit
with the most efficient page size, i.e. min(limit, 1000)
:returns: list that will contain up to limit results
"""
return [
record
async for record in await self.stream_async(
email=email,
status=status,
limit=limit,
page_size=page_size,
)
]
def page(
self,
email: Union[str, object] = values.unset,
status: Union["AuthorizationDocumentInstance.Status", object] = values.unset,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> AuthorizationDocumentPage:
"""
Retrieve a single page of AuthorizationDocumentInstance records from the API.
Request is executed immediately
:param email: Email that this AuthorizationDocument will be sent to for signing.
:param status: Status of an instance resource. It can hold one of the values: 1. opened 2. signing, 3. signed LOA, 4. canceled, 5. failed. See the section entitled [Status Values](https://www.twilio.com/docs/phone-numbers/hosted-numbers/hosted-numbers-api/authorization-document-resource#status-values) for more information on each of these statuses.
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of AuthorizationDocumentInstance
"""
data = values.of(
{
"Email": email,
"Status": status,
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return AuthorizationDocumentPage(self._version, response)
async def page_async(
self,
email: Union[str, object] = values.unset,
status: Union["AuthorizationDocumentInstance.Status", object] = values.unset,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> AuthorizationDocumentPage:
"""
Asynchronously retrieve a single page of AuthorizationDocumentInstance records from the API.
Request is executed immediately
:param email: Email that this AuthorizationDocument will be sent to for signing.
:param status: Status of an instance resource. It can hold one of the values: 1. opened 2. signing, 3. signed LOA, 4. canceled, 5. failed. See the section entitled [Status Values](https://www.twilio.com/docs/phone-numbers/hosted-numbers/hosted-numbers-api/authorization-document-resource#status-values) for more information on each of these statuses.
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of AuthorizationDocumentInstance
"""
data = values.of(
{
"Email": email,
"Status": status,
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = await self._version.page_async(
method="GET", uri=self._uri, params=data
)
return AuthorizationDocumentPage(self._version, response)
def get_page(self, target_url: str) -> AuthorizationDocumentPage:
"""
Retrieve a specific page of AuthorizationDocumentInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of AuthorizationDocumentInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return AuthorizationDocumentPage(self._version, response)
async def get_page_async(self, target_url: str) -> AuthorizationDocumentPage:
"""
Asynchronously retrieve a specific page of AuthorizationDocumentInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of AuthorizationDocumentInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return AuthorizationDocumentPage(self._version, response)
def get(self, sid: str) -> AuthorizationDocumentContext:
"""
Constructs a AuthorizationDocumentContext
:param sid: A 34 character string that uniquely identifies this AuthorizationDocument.
"""
return AuthorizationDocumentContext(self._version, sid=sid)
def __call__(self, sid: str) -> AuthorizationDocumentContext:
"""
Constructs a AuthorizationDocumentContext
:param sid: A 34 character string that uniquely identifies this AuthorizationDocument.
"""
return AuthorizationDocumentContext(self._version, sid=sid)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.HostedNumbers.AuthorizationDocumentList>"
@@ -0,0 +1,465 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Preview
This is the public Twilio REST API.
NOTE: This class is auto generated by OpenAPI Generator.
https://openapi-generator.tech
Do not edit the class manually.
"""
from datetime import datetime
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
from twilio.base import deserialize, values
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.version import Version
from twilio.base.page import Page
class DependentHostedNumberOrderInstance(InstanceResource):
class Status(object):
RECEIVED = "received"
PENDING_VERIFICATION = "pending-verification"
VERIFIED = "verified"
PENDING_LOA = "pending-loa"
CARRIER_PROCESSING = "carrier-processing"
TESTING = "testing"
COMPLETED = "completed"
FAILED = "failed"
ACTION_REQUIRED = "action-required"
class VerificationType(object):
PHONE_CALL = "phone-call"
PHONE_BILL = "phone-bill"
"""
:ivar sid: A 34 character string that uniquely identifies this Authorization Document
:ivar account_sid: The unique SID identifier of the Account.
:ivar incoming_phone_number_sid: A 34 character string that uniquely identifies the IncomingPhoneNumber resource created by this HostedNumberOrder.
:ivar address_sid: A 34 character string that uniquely identifies the Address resource that represents the address of the owner of this phone number.
:ivar signing_document_sid: A 34 character string that uniquely identifies the LOA document associated with this HostedNumberOrder.
:ivar phone_number: An E164 formatted phone number hosted by this HostedNumberOrder.
:ivar capabilities:
:ivar friendly_name: A human readable description of this resource, up to 64 characters.
:ivar unique_name: Provides a unique and addressable name to be assigned to this HostedNumberOrder, assigned by the developer, to be optionally used in addition to SID.
:ivar status:
:ivar failure_reason: A message that explains why a hosted_number_order went to status \"action-required\"
:ivar date_created: The date this resource was created, given as [GMT RFC 2822](http://www.ietf.org/rfc/rfc2822.txt) format.
:ivar date_updated: The date that this resource was updated, given as [GMT RFC 2822](http://www.ietf.org/rfc/rfc2822.txt) format.
:ivar verification_attempts: The number of attempts made to verify ownership of the phone number that is being hosted.
:ivar email: Email of the owner of this phone number that is being hosted.
:ivar cc_emails: Email recipients who will be informed when an Authorization Document has been sent and signed
:ivar verification_type:
:ivar verification_document_sid: A 34 character string that uniquely identifies the Identity Document resource that represents the document for verifying ownership of the number to be hosted.
:ivar extension: A numerical extension to be used when making the ownership verification call.
:ivar call_delay: A value between 0-30 specifying the number of seconds to delay initiating the ownership verification call.
:ivar verification_code: The digits passed during the ownership verification call.
:ivar verification_call_sids: A list of 34 character strings that are unique identifiers for the calls placed as part of ownership verification.
"""
def __init__(
self, version: Version, payload: Dict[str, Any], signing_document_sid: str
):
super().__init__(version)
self.sid: Optional[str] = payload.get("sid")
self.account_sid: Optional[str] = payload.get("account_sid")
self.incoming_phone_number_sid: Optional[str] = payload.get(
"incoming_phone_number_sid"
)
self.address_sid: Optional[str] = payload.get("address_sid")
self.signing_document_sid: Optional[str] = payload.get("signing_document_sid")
self.phone_number: Optional[str] = payload.get("phone_number")
self.capabilities: Optional[str] = payload.get("capabilities")
self.friendly_name: Optional[str] = payload.get("friendly_name")
self.unique_name: Optional[str] = payload.get("unique_name")
self.status: Optional[
"DependentHostedNumberOrderInstance.Status"
] = payload.get("status")
self.failure_reason: Optional[str] = payload.get("failure_reason")
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_created")
)
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_updated")
)
self.verification_attempts: Optional[int] = deserialize.integer(
payload.get("verification_attempts")
)
self.email: Optional[str] = payload.get("email")
self.cc_emails: Optional[List[str]] = payload.get("cc_emails")
self.verification_type: Optional[
"DependentHostedNumberOrderInstance.VerificationType"
] = payload.get("verification_type")
self.verification_document_sid: Optional[str] = payload.get(
"verification_document_sid"
)
self.extension: Optional[str] = payload.get("extension")
self.call_delay: Optional[int] = deserialize.integer(payload.get("call_delay"))
self.verification_code: Optional[str] = payload.get("verification_code")
self.verification_call_sids: Optional[List[str]] = payload.get(
"verification_call_sids"
)
self._solution = {
"signing_document_sid": signing_document_sid,
}
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Preview.HostedNumbers.DependentHostedNumberOrderInstance {}>".format(
context
)
class DependentHostedNumberOrderPage(Page):
def get_instance(
self, payload: Dict[str, Any]
) -> DependentHostedNumberOrderInstance:
"""
Build an instance of DependentHostedNumberOrderInstance
:param payload: Payload response from the API
"""
return DependentHostedNumberOrderInstance(
self._version,
payload,
signing_document_sid=self._solution["signing_document_sid"],
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.HostedNumbers.DependentHostedNumberOrderPage>"
class DependentHostedNumberOrderList(ListResource):
def __init__(self, version: Version, signing_document_sid: str):
"""
Initialize the DependentHostedNumberOrderList
:param version: Version that contains the resource
:param signing_document_sid: A 34 character string that uniquely identifies the LOA document associated with this HostedNumberOrder.
"""
super().__init__(version)
# Path Solution
self._solution = {
"signing_document_sid": signing_document_sid,
}
self._uri = "/AuthorizationDocuments/{signing_document_sid}/DependentHostedNumberOrders".format(
**self._solution
)
def stream(
self,
status: Union[
"DependentHostedNumberOrderInstance.Status", object
] = values.unset,
phone_number: Union[str, object] = values.unset,
incoming_phone_number_sid: Union[str, object] = values.unset,
friendly_name: Union[str, object] = values.unset,
unique_name: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[DependentHostedNumberOrderInstance]:
"""
Streams DependentHostedNumberOrderInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param &quot;DependentHostedNumberOrderInstance.Status&quot; status: Status of an instance resource. It can hold one of the values: 1. opened 2. signing, 3. signed LOA, 4. canceled, 5. failed. See the section entitled [Status Values](https://www.twilio.com/docs/phone-numbers/hosted-numbers/hosted-numbers-api/authorization-document-resource#status-values) for more information on each of these statuses.
:param str phone_number: An E164 formatted phone number hosted by this HostedNumberOrder.
:param str incoming_phone_number_sid: A 34 character string that uniquely identifies the IncomingPhoneNumber resource created by this HostedNumberOrder.
:param str friendly_name: A human readable description of this resource, up to 64 characters.
:param str unique_name: Provides a unique and addressable name to be assigned to this HostedNumberOrder, assigned by the developer, to be optionally used in addition to SID.
:param limit: Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the
limit with the most efficient page size, i.e. min(limit, 1000)
:returns: Generator that will yield up to limit results
"""
limits = self._version.read_limits(limit, page_size)
page = self.page(
status=status,
phone_number=phone_number,
incoming_phone_number_sid=incoming_phone_number_sid,
friendly_name=friendly_name,
unique_name=unique_name,
page_size=limits["page_size"],
)
return self._version.stream(page, limits["limit"])
async def stream_async(
self,
status: Union[
"DependentHostedNumberOrderInstance.Status", object
] = values.unset,
phone_number: Union[str, object] = values.unset,
incoming_phone_number_sid: Union[str, object] = values.unset,
friendly_name: Union[str, object] = values.unset,
unique_name: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> AsyncIterator[DependentHostedNumberOrderInstance]:
"""
Asynchronously streams DependentHostedNumberOrderInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param &quot;DependentHostedNumberOrderInstance.Status&quot; status: Status of an instance resource. It can hold one of the values: 1. opened 2. signing, 3. signed LOA, 4. canceled, 5. failed. See the section entitled [Status Values](https://www.twilio.com/docs/phone-numbers/hosted-numbers/hosted-numbers-api/authorization-document-resource#status-values) for more information on each of these statuses.
:param str phone_number: An E164 formatted phone number hosted by this HostedNumberOrder.
:param str incoming_phone_number_sid: A 34 character string that uniquely identifies the IncomingPhoneNumber resource created by this HostedNumberOrder.
:param str friendly_name: A human readable description of this resource, up to 64 characters.
:param str unique_name: Provides a unique and addressable name to be assigned to this HostedNumberOrder, assigned by the developer, to be optionally used in addition to SID.
:param limit: Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the
limit with the most efficient page size, i.e. min(limit, 1000)
:returns: Generator that will yield up to limit results
"""
limits = self._version.read_limits(limit, page_size)
page = await self.page_async(
status=status,
phone_number=phone_number,
incoming_phone_number_sid=incoming_phone_number_sid,
friendly_name=friendly_name,
unique_name=unique_name,
page_size=limits["page_size"],
)
return self._version.stream_async(page, limits["limit"])
def list(
self,
status: Union[
"DependentHostedNumberOrderInstance.Status", object
] = values.unset,
phone_number: Union[str, object] = values.unset,
incoming_phone_number_sid: Union[str, object] = values.unset,
friendly_name: Union[str, object] = values.unset,
unique_name: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[DependentHostedNumberOrderInstance]:
"""
Lists DependentHostedNumberOrderInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param &quot;DependentHostedNumberOrderInstance.Status&quot; status: Status of an instance resource. It can hold one of the values: 1. opened 2. signing, 3. signed LOA, 4. canceled, 5. failed. See the section entitled [Status Values](https://www.twilio.com/docs/phone-numbers/hosted-numbers/hosted-numbers-api/authorization-document-resource#status-values) for more information on each of these statuses.
:param str phone_number: An E164 formatted phone number hosted by this HostedNumberOrder.
:param str incoming_phone_number_sid: A 34 character string that uniquely identifies the IncomingPhoneNumber resource created by this HostedNumberOrder.
:param str friendly_name: A human readable description of this resource, up to 64 characters.
:param str unique_name: Provides a unique and addressable name to be assigned to this HostedNumberOrder, assigned by the developer, to be optionally used in addition to SID.
:param limit: Upper limit for the number of records to return. list() guarantees
never to return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, list() will attempt to read the limit
with the most efficient page size, i.e. min(limit, 1000)
:returns: list that will contain up to limit results
"""
return list(
self.stream(
status=status,
phone_number=phone_number,
incoming_phone_number_sid=incoming_phone_number_sid,
friendly_name=friendly_name,
unique_name=unique_name,
limit=limit,
page_size=page_size,
)
)
async def list_async(
self,
status: Union[
"DependentHostedNumberOrderInstance.Status", object
] = values.unset,
phone_number: Union[str, object] = values.unset,
incoming_phone_number_sid: Union[str, object] = values.unset,
friendly_name: Union[str, object] = values.unset,
unique_name: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[DependentHostedNumberOrderInstance]:
"""
Asynchronously lists DependentHostedNumberOrderInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param &quot;DependentHostedNumberOrderInstance.Status&quot; status: Status of an instance resource. It can hold one of the values: 1. opened 2. signing, 3. signed LOA, 4. canceled, 5. failed. See the section entitled [Status Values](https://www.twilio.com/docs/phone-numbers/hosted-numbers/hosted-numbers-api/authorization-document-resource#status-values) for more information on each of these statuses.
:param str phone_number: An E164 formatted phone number hosted by this HostedNumberOrder.
:param str incoming_phone_number_sid: A 34 character string that uniquely identifies the IncomingPhoneNumber resource created by this HostedNumberOrder.
:param str friendly_name: A human readable description of this resource, up to 64 characters.
:param str unique_name: Provides a unique and addressable name to be assigned to this HostedNumberOrder, assigned by the developer, to be optionally used in addition to SID.
:param limit: Upper limit for the number of records to return. list() guarantees
never to return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, list() will attempt to read the limit
with the most efficient page size, i.e. min(limit, 1000)
:returns: list that will contain up to limit results
"""
return [
record
async for record in await self.stream_async(
status=status,
phone_number=phone_number,
incoming_phone_number_sid=incoming_phone_number_sid,
friendly_name=friendly_name,
unique_name=unique_name,
limit=limit,
page_size=page_size,
)
]
def page(
self,
status: Union[
"DependentHostedNumberOrderInstance.Status", object
] = values.unset,
phone_number: Union[str, object] = values.unset,
incoming_phone_number_sid: Union[str, object] = values.unset,
friendly_name: Union[str, object] = values.unset,
unique_name: Union[str, object] = values.unset,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> DependentHostedNumberOrderPage:
"""
Retrieve a single page of DependentHostedNumberOrderInstance records from the API.
Request is executed immediately
:param status: Status of an instance resource. It can hold one of the values: 1. opened 2. signing, 3. signed LOA, 4. canceled, 5. failed. See the section entitled [Status Values](https://www.twilio.com/docs/phone-numbers/hosted-numbers/hosted-numbers-api/authorization-document-resource#status-values) for more information on each of these statuses.
:param phone_number: An E164 formatted phone number hosted by this HostedNumberOrder.
:param incoming_phone_number_sid: A 34 character string that uniquely identifies the IncomingPhoneNumber resource created by this HostedNumberOrder.
:param friendly_name: A human readable description of this resource, up to 64 characters.
:param unique_name: Provides a unique and addressable name to be assigned to this HostedNumberOrder, assigned by the developer, to be optionally used in addition to SID.
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of DependentHostedNumberOrderInstance
"""
data = values.of(
{
"Status": status,
"PhoneNumber": phone_number,
"IncomingPhoneNumberSid": incoming_phone_number_sid,
"FriendlyName": friendly_name,
"UniqueName": unique_name,
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return DependentHostedNumberOrderPage(self._version, response, self._solution)
async def page_async(
self,
status: Union[
"DependentHostedNumberOrderInstance.Status", object
] = values.unset,
phone_number: Union[str, object] = values.unset,
incoming_phone_number_sid: Union[str, object] = values.unset,
friendly_name: Union[str, object] = values.unset,
unique_name: Union[str, object] = values.unset,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> DependentHostedNumberOrderPage:
"""
Asynchronously retrieve a single page of DependentHostedNumberOrderInstance records from the API.
Request is executed immediately
:param status: Status of an instance resource. It can hold one of the values: 1. opened 2. signing, 3. signed LOA, 4. canceled, 5. failed. See the section entitled [Status Values](https://www.twilio.com/docs/phone-numbers/hosted-numbers/hosted-numbers-api/authorization-document-resource#status-values) for more information on each of these statuses.
:param phone_number: An E164 formatted phone number hosted by this HostedNumberOrder.
:param incoming_phone_number_sid: A 34 character string that uniquely identifies the IncomingPhoneNumber resource created by this HostedNumberOrder.
:param friendly_name: A human readable description of this resource, up to 64 characters.
:param unique_name: Provides a unique and addressable name to be assigned to this HostedNumberOrder, assigned by the developer, to be optionally used in addition to SID.
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of DependentHostedNumberOrderInstance
"""
data = values.of(
{
"Status": status,
"PhoneNumber": phone_number,
"IncomingPhoneNumberSid": incoming_phone_number_sid,
"FriendlyName": friendly_name,
"UniqueName": unique_name,
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = await self._version.page_async(
method="GET", uri=self._uri, params=data
)
return DependentHostedNumberOrderPage(self._version, response, self._solution)
def get_page(self, target_url: str) -> DependentHostedNumberOrderPage:
"""
Retrieve a specific page of DependentHostedNumberOrderInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of DependentHostedNumberOrderInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return DependentHostedNumberOrderPage(self._version, response, self._solution)
async def get_page_async(self, target_url: str) -> DependentHostedNumberOrderPage:
"""
Asynchronously retrieve a specific page of DependentHostedNumberOrderInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of DependentHostedNumberOrderInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return DependentHostedNumberOrderPage(self._version, response, self._solution)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.HostedNumbers.DependentHostedNumberOrderList>"
@@ -0,0 +1,950 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Preview
This is the public Twilio REST API.
NOTE: This class is auto generated by OpenAPI Generator.
https://openapi-generator.tech
Do not edit the class manually.
"""
from datetime import datetime
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
from twilio.base import deserialize, serialize, values
from twilio.base.instance_context import InstanceContext
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.version import Version
from twilio.base.page import Page
class HostedNumberOrderInstance(InstanceResource):
class Status(object):
RECEIVED = "received"
PENDING_VERIFICATION = "pending-verification"
VERIFIED = "verified"
PENDING_LOA = "pending-loa"
CARRIER_PROCESSING = "carrier-processing"
TESTING = "testing"
COMPLETED = "completed"
FAILED = "failed"
ACTION_REQUIRED = "action-required"
class VerificationType(object):
PHONE_CALL = "phone-call"
PHONE_BILL = "phone-bill"
"""
:ivar sid: A 34 character string that uniquely identifies this HostedNumberOrder.
:ivar account_sid: A 34 character string that uniquely identifies the account.
:ivar incoming_phone_number_sid: A 34 character string that uniquely identifies the [IncomingPhoneNumber](https://www.twilio.com/docs/phone-numbers/api/incomingphonenumber-resource) resource that represents the phone number being hosted.
:ivar address_sid: A 34 character string that uniquely identifies the Address resource that represents the address of the owner of this phone number.
:ivar signing_document_sid: A 34 character string that uniquely identifies the [Authorization Document](https://www.twilio.com/docs/phone-numbers/hosted-numbers/hosted-numbers-api/authorization-document-resource) the user needs to sign.
:ivar phone_number: Phone number to be hosted. This must be in [E.164](https://en.wikipedia.org/wiki/E.164) format, e.g., +16175551212
:ivar capabilities:
:ivar friendly_name: A 64 character string that is a human-readable text that describes this resource.
:ivar unique_name: Provides a unique and addressable name to be assigned to this HostedNumberOrder, assigned by the developer, to be optionally used in addition to SID.
:ivar status:
:ivar failure_reason: A message that explains why a hosted_number_order went to status \"action-required\"
:ivar date_created: The date this resource was created, given as [GMT RFC 2822](http://www.ietf.org/rfc/rfc2822.txt) format.
:ivar date_updated: The date that this resource was updated, given as [GMT RFC 2822](http://www.ietf.org/rfc/rfc2822.txt) format.
:ivar verification_attempts: The number of attempts made to verify ownership of the phone number that is being hosted.
:ivar email: Email of the owner of this phone number that is being hosted.
:ivar cc_emails: A list of emails that LOA document for this HostedNumberOrder will be carbon copied to.
:ivar url: The URL of this HostedNumberOrder.
:ivar verification_type:
:ivar verification_document_sid: A 34 character string that uniquely identifies the Identity Document resource that represents the document for verifying ownership of the number to be hosted.
:ivar extension: A numerical extension to be used when making the ownership verification call.
:ivar call_delay: A value between 0-30 specifying the number of seconds to delay initiating the ownership verification call.
:ivar verification_code: A verification code provided in the response for a user to enter when they pick up the phone call.
:ivar verification_call_sids: A list of 34 character strings that are unique identifiers for the calls placed as part of ownership verification.
"""
def __init__(
self, version: Version, payload: Dict[str, Any], sid: Optional[str] = None
):
super().__init__(version)
self.sid: Optional[str] = payload.get("sid")
self.account_sid: Optional[str] = payload.get("account_sid")
self.incoming_phone_number_sid: Optional[str] = payload.get(
"incoming_phone_number_sid"
)
self.address_sid: Optional[str] = payload.get("address_sid")
self.signing_document_sid: Optional[str] = payload.get("signing_document_sid")
self.phone_number: Optional[str] = payload.get("phone_number")
self.capabilities: Optional[str] = payload.get("capabilities")
self.friendly_name: Optional[str] = payload.get("friendly_name")
self.unique_name: Optional[str] = payload.get("unique_name")
self.status: Optional["HostedNumberOrderInstance.Status"] = payload.get(
"status"
)
self.failure_reason: Optional[str] = payload.get("failure_reason")
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_created")
)
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_updated")
)
self.verification_attempts: Optional[int] = deserialize.integer(
payload.get("verification_attempts")
)
self.email: Optional[str] = payload.get("email")
self.cc_emails: Optional[List[str]] = payload.get("cc_emails")
self.url: Optional[str] = payload.get("url")
self.verification_type: Optional[
"HostedNumberOrderInstance.VerificationType"
] = payload.get("verification_type")
self.verification_document_sid: Optional[str] = payload.get(
"verification_document_sid"
)
self.extension: Optional[str] = payload.get("extension")
self.call_delay: Optional[int] = deserialize.integer(payload.get("call_delay"))
self.verification_code: Optional[str] = payload.get("verification_code")
self.verification_call_sids: Optional[List[str]] = payload.get(
"verification_call_sids"
)
self._solution = {
"sid": sid or self.sid,
}
self._context: Optional[HostedNumberOrderContext] = None
@property
def _proxy(self) -> "HostedNumberOrderContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: HostedNumberOrderContext for this HostedNumberOrderInstance
"""
if self._context is None:
self._context = HostedNumberOrderContext(
self._version,
sid=self._solution["sid"],
)
return self._context
def delete(self) -> bool:
"""
Deletes the HostedNumberOrderInstance
:returns: True if delete succeeds, False otherwise
"""
return self._proxy.delete()
async def delete_async(self) -> bool:
"""
Asynchronous coroutine that deletes the HostedNumberOrderInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._proxy.delete_async()
def fetch(self) -> "HostedNumberOrderInstance":
"""
Fetch the HostedNumberOrderInstance
:returns: The fetched HostedNumberOrderInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "HostedNumberOrderInstance":
"""
Asynchronous coroutine to fetch the HostedNumberOrderInstance
:returns: The fetched HostedNumberOrderInstance
"""
return await self._proxy.fetch_async()
def update(
self,
friendly_name: Union[str, object] = values.unset,
unique_name: Union[str, object] = values.unset,
email: Union[str, object] = values.unset,
cc_emails: Union[List[str], object] = values.unset,
status: Union["HostedNumberOrderInstance.Status", object] = values.unset,
verification_code: Union[str, object] = values.unset,
verification_type: Union[
"HostedNumberOrderInstance.VerificationType", object
] = values.unset,
verification_document_sid: Union[str, object] = values.unset,
extension: Union[str, object] = values.unset,
call_delay: Union[int, object] = values.unset,
) -> "HostedNumberOrderInstance":
"""
Update the HostedNumberOrderInstance
:param friendly_name: A 64 character string that is a human readable text that describes this resource.
:param unique_name: Provides a unique and addressable name to be assigned to this HostedNumberOrder, assigned by the developer, to be optionally used in addition to SID.
:param email: Email of the owner of this phone number that is being hosted.
:param cc_emails: Optional. A list of emails that LOA document for this HostedNumberOrder will be carbon copied to.
:param status:
:param verification_code: A verification code that is given to the user via a phone call to the phone number that is being hosted.
:param verification_type:
:param verification_document_sid: Optional. The unique sid identifier of the Identity Document that represents the document for verifying ownership of the number to be hosted. Required when VerificationType is phone-bill.
:param extension: Digits to dial after connecting the verification call.
:param call_delay: The number of seconds, between 0 and 60, to delay before initiating the verification call. Defaults to 0.
:returns: The updated HostedNumberOrderInstance
"""
return self._proxy.update(
friendly_name=friendly_name,
unique_name=unique_name,
email=email,
cc_emails=cc_emails,
status=status,
verification_code=verification_code,
verification_type=verification_type,
verification_document_sid=verification_document_sid,
extension=extension,
call_delay=call_delay,
)
async def update_async(
self,
friendly_name: Union[str, object] = values.unset,
unique_name: Union[str, object] = values.unset,
email: Union[str, object] = values.unset,
cc_emails: Union[List[str], object] = values.unset,
status: Union["HostedNumberOrderInstance.Status", object] = values.unset,
verification_code: Union[str, object] = values.unset,
verification_type: Union[
"HostedNumberOrderInstance.VerificationType", object
] = values.unset,
verification_document_sid: Union[str, object] = values.unset,
extension: Union[str, object] = values.unset,
call_delay: Union[int, object] = values.unset,
) -> "HostedNumberOrderInstance":
"""
Asynchronous coroutine to update the HostedNumberOrderInstance
:param friendly_name: A 64 character string that is a human readable text that describes this resource.
:param unique_name: Provides a unique and addressable name to be assigned to this HostedNumberOrder, assigned by the developer, to be optionally used in addition to SID.
:param email: Email of the owner of this phone number that is being hosted.
:param cc_emails: Optional. A list of emails that LOA document for this HostedNumberOrder will be carbon copied to.
:param status:
:param verification_code: A verification code that is given to the user via a phone call to the phone number that is being hosted.
:param verification_type:
:param verification_document_sid: Optional. The unique sid identifier of the Identity Document that represents the document for verifying ownership of the number to be hosted. Required when VerificationType is phone-bill.
:param extension: Digits to dial after connecting the verification call.
:param call_delay: The number of seconds, between 0 and 60, to delay before initiating the verification call. Defaults to 0.
:returns: The updated HostedNumberOrderInstance
"""
return await self._proxy.update_async(
friendly_name=friendly_name,
unique_name=unique_name,
email=email,
cc_emails=cc_emails,
status=status,
verification_code=verification_code,
verification_type=verification_type,
verification_document_sid=verification_document_sid,
extension=extension,
call_delay=call_delay,
)
def __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.Preview.HostedNumbers.HostedNumberOrderInstance {}>".format(
context
)
class HostedNumberOrderContext(InstanceContext):
def __init__(self, version: Version, sid: str):
"""
Initialize the HostedNumberOrderContext
:param version: Version that contains the resource
:param sid: A 34 character string that uniquely identifies this HostedNumberOrder.
"""
super().__init__(version)
# Path Solution
self._solution = {
"sid": sid,
}
self._uri = "/HostedNumberOrders/{sid}".format(**self._solution)
def delete(self) -> bool:
"""
Deletes the HostedNumberOrderInstance
: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 HostedNumberOrderInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._version.delete_async(
method="DELETE",
uri=self._uri,
)
def fetch(self) -> HostedNumberOrderInstance:
"""
Fetch the HostedNumberOrderInstance
:returns: The fetched HostedNumberOrderInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return HostedNumberOrderInstance(
self._version,
payload,
sid=self._solution["sid"],
)
async def fetch_async(self) -> HostedNumberOrderInstance:
"""
Asynchronous coroutine to fetch the HostedNumberOrderInstance
:returns: The fetched HostedNumberOrderInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return HostedNumberOrderInstance(
self._version,
payload,
sid=self._solution["sid"],
)
def update(
self,
friendly_name: Union[str, object] = values.unset,
unique_name: Union[str, object] = values.unset,
email: Union[str, object] = values.unset,
cc_emails: Union[List[str], object] = values.unset,
status: Union["HostedNumberOrderInstance.Status", object] = values.unset,
verification_code: Union[str, object] = values.unset,
verification_type: Union[
"HostedNumberOrderInstance.VerificationType", object
] = values.unset,
verification_document_sid: Union[str, object] = values.unset,
extension: Union[str, object] = values.unset,
call_delay: Union[int, object] = values.unset,
) -> HostedNumberOrderInstance:
"""
Update the HostedNumberOrderInstance
:param friendly_name: A 64 character string that is a human readable text that describes this resource.
:param unique_name: Provides a unique and addressable name to be assigned to this HostedNumberOrder, assigned by the developer, to be optionally used in addition to SID.
:param email: Email of the owner of this phone number that is being hosted.
:param cc_emails: Optional. A list of emails that LOA document for this HostedNumberOrder will be carbon copied to.
:param status:
:param verification_code: A verification code that is given to the user via a phone call to the phone number that is being hosted.
:param verification_type:
:param verification_document_sid: Optional. The unique sid identifier of the Identity Document that represents the document for verifying ownership of the number to be hosted. Required when VerificationType is phone-bill.
:param extension: Digits to dial after connecting the verification call.
:param call_delay: The number of seconds, between 0 and 60, to delay before initiating the verification call. Defaults to 0.
:returns: The updated HostedNumberOrderInstance
"""
data = values.of(
{
"FriendlyName": friendly_name,
"UniqueName": unique_name,
"Email": email,
"CcEmails": serialize.map(cc_emails, lambda e: e),
"Status": status,
"VerificationCode": verification_code,
"VerificationType": verification_type,
"VerificationDocumentSid": verification_document_sid,
"Extension": extension,
"CallDelay": call_delay,
}
)
payload = self._version.update(
method="POST",
uri=self._uri,
data=data,
)
return HostedNumberOrderInstance(
self._version, payload, sid=self._solution["sid"]
)
async def update_async(
self,
friendly_name: Union[str, object] = values.unset,
unique_name: Union[str, object] = values.unset,
email: Union[str, object] = values.unset,
cc_emails: Union[List[str], object] = values.unset,
status: Union["HostedNumberOrderInstance.Status", object] = values.unset,
verification_code: Union[str, object] = values.unset,
verification_type: Union[
"HostedNumberOrderInstance.VerificationType", object
] = values.unset,
verification_document_sid: Union[str, object] = values.unset,
extension: Union[str, object] = values.unset,
call_delay: Union[int, object] = values.unset,
) -> HostedNumberOrderInstance:
"""
Asynchronous coroutine to update the HostedNumberOrderInstance
:param friendly_name: A 64 character string that is a human readable text that describes this resource.
:param unique_name: Provides a unique and addressable name to be assigned to this HostedNumberOrder, assigned by the developer, to be optionally used in addition to SID.
:param email: Email of the owner of this phone number that is being hosted.
:param cc_emails: Optional. A list of emails that LOA document for this HostedNumberOrder will be carbon copied to.
:param status:
:param verification_code: A verification code that is given to the user via a phone call to the phone number that is being hosted.
:param verification_type:
:param verification_document_sid: Optional. The unique sid identifier of the Identity Document that represents the document for verifying ownership of the number to be hosted. Required when VerificationType is phone-bill.
:param extension: Digits to dial after connecting the verification call.
:param call_delay: The number of seconds, between 0 and 60, to delay before initiating the verification call. Defaults to 0.
:returns: The updated HostedNumberOrderInstance
"""
data = values.of(
{
"FriendlyName": friendly_name,
"UniqueName": unique_name,
"Email": email,
"CcEmails": serialize.map(cc_emails, lambda e: e),
"Status": status,
"VerificationCode": verification_code,
"VerificationType": verification_type,
"VerificationDocumentSid": verification_document_sid,
"Extension": extension,
"CallDelay": call_delay,
}
)
payload = await self._version.update_async(
method="POST",
uri=self._uri,
data=data,
)
return HostedNumberOrderInstance(
self._version, payload, sid=self._solution["sid"]
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Preview.HostedNumbers.HostedNumberOrderContext {}>".format(
context
)
class HostedNumberOrderPage(Page):
def get_instance(self, payload: Dict[str, Any]) -> HostedNumberOrderInstance:
"""
Build an instance of HostedNumberOrderInstance
:param payload: Payload response from the API
"""
return HostedNumberOrderInstance(self._version, payload)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.HostedNumbers.HostedNumberOrderPage>"
class HostedNumberOrderList(ListResource):
def __init__(self, version: Version):
"""
Initialize the HostedNumberOrderList
:param version: Version that contains the resource
"""
super().__init__(version)
self._uri = "/HostedNumberOrders"
def create(
self,
phone_number: str,
sms_capability: bool,
account_sid: Union[str, object] = values.unset,
friendly_name: Union[str, object] = values.unset,
unique_name: Union[str, object] = values.unset,
cc_emails: Union[List[str], object] = values.unset,
sms_url: Union[str, object] = values.unset,
sms_method: Union[str, object] = values.unset,
sms_fallback_url: Union[str, object] = values.unset,
sms_fallback_method: Union[str, object] = values.unset,
status_callback_url: Union[str, object] = values.unset,
status_callback_method: Union[str, object] = values.unset,
sms_application_sid: Union[str, object] = values.unset,
address_sid: Union[str, object] = values.unset,
email: Union[str, object] = values.unset,
verification_type: Union[
"HostedNumberOrderInstance.VerificationType", object
] = values.unset,
verification_document_sid: Union[str, object] = values.unset,
) -> HostedNumberOrderInstance:
"""
Create the HostedNumberOrderInstance
:param phone_number: The number to host in [+E.164](https://en.wikipedia.org/wiki/E.164) format
:param sms_capability: Used to specify that the SMS capability will be hosted on Twilio's platform.
:param account_sid: This defaults to the AccountSid of the authorization the user is using. This can be provided to specify a subaccount to add the HostedNumberOrder to.
:param friendly_name: A 64 character string that is a human readable text that describes this resource.
:param unique_name: Optional. Provides a unique and addressable name to be assigned to this HostedNumberOrder, assigned by the developer, to be optionally used in addition to SID.
:param cc_emails: Optional. A list of emails that the LOA document for this HostedNumberOrder will be carbon copied to.
:param sms_url: The URL that Twilio should request when somebody sends an SMS to the phone number. This will be copied onto the IncomingPhoneNumber resource.
:param sms_method: The HTTP method that should be used to request the SmsUrl. Must be either `GET` or `POST`. This will be copied onto the IncomingPhoneNumber resource.
:param sms_fallback_url: A URL that Twilio will request if an error occurs requesting or executing the TwiML defined by SmsUrl. This will be copied onto the IncomingPhoneNumber resource.
:param sms_fallback_method: The HTTP method that should be used to request the SmsFallbackUrl. Must be either `GET` or `POST`. This will be copied onto the IncomingPhoneNumber resource.
:param status_callback_url: Optional. The Status Callback URL attached to the IncomingPhoneNumber resource.
:param status_callback_method: Optional. The Status Callback Method attached to the IncomingPhoneNumber resource.
:param sms_application_sid: Optional. The 34 character sid of the application Twilio should use to handle SMS messages sent to this number. If a `SmsApplicationSid` is present, Twilio will ignore all of the SMS urls above and use those set on the application.
:param address_sid: Optional. A 34 character string that uniquely identifies the Address resource that represents the address of the owner of this phone number.
:param email: Optional. Email of the owner of this phone number that is being hosted.
:param verification_type:
:param verification_document_sid: Optional. The unique sid identifier of the Identity Document that represents the document for verifying ownership of the number to be hosted. Required when VerificationType is phone-bill.
:returns: The created HostedNumberOrderInstance
"""
data = values.of(
{
"PhoneNumber": phone_number,
"SmsCapability": sms_capability,
"AccountSid": account_sid,
"FriendlyName": friendly_name,
"UniqueName": unique_name,
"CcEmails": serialize.map(cc_emails, lambda e: e),
"SmsUrl": sms_url,
"SmsMethod": sms_method,
"SmsFallbackUrl": sms_fallback_url,
"SmsFallbackMethod": sms_fallback_method,
"StatusCallbackUrl": status_callback_url,
"StatusCallbackMethod": status_callback_method,
"SmsApplicationSid": sms_application_sid,
"AddressSid": address_sid,
"Email": email,
"VerificationType": verification_type,
"VerificationDocumentSid": verification_document_sid,
}
)
payload = self._version.create(
method="POST",
uri=self._uri,
data=data,
)
return HostedNumberOrderInstance(self._version, payload)
async def create_async(
self,
phone_number: str,
sms_capability: bool,
account_sid: Union[str, object] = values.unset,
friendly_name: Union[str, object] = values.unset,
unique_name: Union[str, object] = values.unset,
cc_emails: Union[List[str], object] = values.unset,
sms_url: Union[str, object] = values.unset,
sms_method: Union[str, object] = values.unset,
sms_fallback_url: Union[str, object] = values.unset,
sms_fallback_method: Union[str, object] = values.unset,
status_callback_url: Union[str, object] = values.unset,
status_callback_method: Union[str, object] = values.unset,
sms_application_sid: Union[str, object] = values.unset,
address_sid: Union[str, object] = values.unset,
email: Union[str, object] = values.unset,
verification_type: Union[
"HostedNumberOrderInstance.VerificationType", object
] = values.unset,
verification_document_sid: Union[str, object] = values.unset,
) -> HostedNumberOrderInstance:
"""
Asynchronously create the HostedNumberOrderInstance
:param phone_number: The number to host in [+E.164](https://en.wikipedia.org/wiki/E.164) format
:param sms_capability: Used to specify that the SMS capability will be hosted on Twilio's platform.
:param account_sid: This defaults to the AccountSid of the authorization the user is using. This can be provided to specify a subaccount to add the HostedNumberOrder to.
:param friendly_name: A 64 character string that is a human readable text that describes this resource.
:param unique_name: Optional. Provides a unique and addressable name to be assigned to this HostedNumberOrder, assigned by the developer, to be optionally used in addition to SID.
:param cc_emails: Optional. A list of emails that the LOA document for this HostedNumberOrder will be carbon copied to.
:param sms_url: The URL that Twilio should request when somebody sends an SMS to the phone number. This will be copied onto the IncomingPhoneNumber resource.
:param sms_method: The HTTP method that should be used to request the SmsUrl. Must be either `GET` or `POST`. This will be copied onto the IncomingPhoneNumber resource.
:param sms_fallback_url: A URL that Twilio will request if an error occurs requesting or executing the TwiML defined by SmsUrl. This will be copied onto the IncomingPhoneNumber resource.
:param sms_fallback_method: The HTTP method that should be used to request the SmsFallbackUrl. Must be either `GET` or `POST`. This will be copied onto the IncomingPhoneNumber resource.
:param status_callback_url: Optional. The Status Callback URL attached to the IncomingPhoneNumber resource.
:param status_callback_method: Optional. The Status Callback Method attached to the IncomingPhoneNumber resource.
:param sms_application_sid: Optional. The 34 character sid of the application Twilio should use to handle SMS messages sent to this number. If a `SmsApplicationSid` is present, Twilio will ignore all of the SMS urls above and use those set on the application.
:param address_sid: Optional. A 34 character string that uniquely identifies the Address resource that represents the address of the owner of this phone number.
:param email: Optional. Email of the owner of this phone number that is being hosted.
:param verification_type:
:param verification_document_sid: Optional. The unique sid identifier of the Identity Document that represents the document for verifying ownership of the number to be hosted. Required when VerificationType is phone-bill.
:returns: The created HostedNumberOrderInstance
"""
data = values.of(
{
"PhoneNumber": phone_number,
"SmsCapability": sms_capability,
"AccountSid": account_sid,
"FriendlyName": friendly_name,
"UniqueName": unique_name,
"CcEmails": serialize.map(cc_emails, lambda e: e),
"SmsUrl": sms_url,
"SmsMethod": sms_method,
"SmsFallbackUrl": sms_fallback_url,
"SmsFallbackMethod": sms_fallback_method,
"StatusCallbackUrl": status_callback_url,
"StatusCallbackMethod": status_callback_method,
"SmsApplicationSid": sms_application_sid,
"AddressSid": address_sid,
"Email": email,
"VerificationType": verification_type,
"VerificationDocumentSid": verification_document_sid,
}
)
payload = await self._version.create_async(
method="POST",
uri=self._uri,
data=data,
)
return HostedNumberOrderInstance(self._version, payload)
def stream(
self,
status: Union["HostedNumberOrderInstance.Status", object] = values.unset,
phone_number: Union[str, object] = values.unset,
incoming_phone_number_sid: Union[str, object] = values.unset,
friendly_name: Union[str, object] = values.unset,
unique_name: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[HostedNumberOrderInstance]:
"""
Streams HostedNumberOrderInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param &quot;HostedNumberOrderInstance.Status&quot; status: The Status of this HostedNumberOrder. One of `received`, `pending-verification`, `verified`, `pending-loa`, `carrier-processing`, `testing`, `completed`, `failed`, or `action-required`.
:param str phone_number: An E164 formatted phone number hosted by this HostedNumberOrder.
:param str incoming_phone_number_sid: A 34 character string that uniquely identifies the IncomingPhoneNumber resource created by this HostedNumberOrder.
:param str friendly_name: A human readable description of this resource, up to 64 characters.
:param str unique_name: Provides a unique and addressable name to be assigned to this HostedNumberOrder, assigned by the developer, to be optionally used in addition to SID.
:param limit: Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the
limit with the most efficient page size, i.e. min(limit, 1000)
:returns: Generator that will yield up to limit results
"""
limits = self._version.read_limits(limit, page_size)
page = self.page(
status=status,
phone_number=phone_number,
incoming_phone_number_sid=incoming_phone_number_sid,
friendly_name=friendly_name,
unique_name=unique_name,
page_size=limits["page_size"],
)
return self._version.stream(page, limits["limit"])
async def stream_async(
self,
status: Union["HostedNumberOrderInstance.Status", object] = values.unset,
phone_number: Union[str, object] = values.unset,
incoming_phone_number_sid: Union[str, object] = values.unset,
friendly_name: Union[str, object] = values.unset,
unique_name: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> AsyncIterator[HostedNumberOrderInstance]:
"""
Asynchronously streams HostedNumberOrderInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param &quot;HostedNumberOrderInstance.Status&quot; status: The Status of this HostedNumberOrder. One of `received`, `pending-verification`, `verified`, `pending-loa`, `carrier-processing`, `testing`, `completed`, `failed`, or `action-required`.
:param str phone_number: An E164 formatted phone number hosted by this HostedNumberOrder.
:param str incoming_phone_number_sid: A 34 character string that uniquely identifies the IncomingPhoneNumber resource created by this HostedNumberOrder.
:param str friendly_name: A human readable description of this resource, up to 64 characters.
:param str unique_name: Provides a unique and addressable name to be assigned to this HostedNumberOrder, assigned by the developer, to be optionally used in addition to SID.
:param limit: Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the
limit with the most efficient page size, i.e. min(limit, 1000)
:returns: Generator that will yield up to limit results
"""
limits = self._version.read_limits(limit, page_size)
page = await self.page_async(
status=status,
phone_number=phone_number,
incoming_phone_number_sid=incoming_phone_number_sid,
friendly_name=friendly_name,
unique_name=unique_name,
page_size=limits["page_size"],
)
return self._version.stream_async(page, limits["limit"])
def list(
self,
status: Union["HostedNumberOrderInstance.Status", object] = values.unset,
phone_number: Union[str, object] = values.unset,
incoming_phone_number_sid: Union[str, object] = values.unset,
friendly_name: Union[str, object] = values.unset,
unique_name: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[HostedNumberOrderInstance]:
"""
Lists HostedNumberOrderInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param &quot;HostedNumberOrderInstance.Status&quot; status: The Status of this HostedNumberOrder. One of `received`, `pending-verification`, `verified`, `pending-loa`, `carrier-processing`, `testing`, `completed`, `failed`, or `action-required`.
:param str phone_number: An E164 formatted phone number hosted by this HostedNumberOrder.
:param str incoming_phone_number_sid: A 34 character string that uniquely identifies the IncomingPhoneNumber resource created by this HostedNumberOrder.
:param str friendly_name: A human readable description of this resource, up to 64 characters.
:param str unique_name: Provides a unique and addressable name to be assigned to this HostedNumberOrder, assigned by the developer, to be optionally used in addition to SID.
:param limit: Upper limit for the number of records to return. list() guarantees
never to return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, list() will attempt to read the limit
with the most efficient page size, i.e. min(limit, 1000)
:returns: list that will contain up to limit results
"""
return list(
self.stream(
status=status,
phone_number=phone_number,
incoming_phone_number_sid=incoming_phone_number_sid,
friendly_name=friendly_name,
unique_name=unique_name,
limit=limit,
page_size=page_size,
)
)
async def list_async(
self,
status: Union["HostedNumberOrderInstance.Status", object] = values.unset,
phone_number: Union[str, object] = values.unset,
incoming_phone_number_sid: Union[str, object] = values.unset,
friendly_name: Union[str, object] = values.unset,
unique_name: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[HostedNumberOrderInstance]:
"""
Asynchronously lists HostedNumberOrderInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param &quot;HostedNumberOrderInstance.Status&quot; status: The Status of this HostedNumberOrder. One of `received`, `pending-verification`, `verified`, `pending-loa`, `carrier-processing`, `testing`, `completed`, `failed`, or `action-required`.
:param str phone_number: An E164 formatted phone number hosted by this HostedNumberOrder.
:param str incoming_phone_number_sid: A 34 character string that uniquely identifies the IncomingPhoneNumber resource created by this HostedNumberOrder.
:param str friendly_name: A human readable description of this resource, up to 64 characters.
:param str unique_name: Provides a unique and addressable name to be assigned to this HostedNumberOrder, assigned by the developer, to be optionally used in addition to SID.
:param limit: Upper limit for the number of records to return. list() guarantees
never to return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, list() will attempt to read the limit
with the most efficient page size, i.e. min(limit, 1000)
:returns: list that will contain up to limit results
"""
return [
record
async for record in await self.stream_async(
status=status,
phone_number=phone_number,
incoming_phone_number_sid=incoming_phone_number_sid,
friendly_name=friendly_name,
unique_name=unique_name,
limit=limit,
page_size=page_size,
)
]
def page(
self,
status: Union["HostedNumberOrderInstance.Status", object] = values.unset,
phone_number: Union[str, object] = values.unset,
incoming_phone_number_sid: Union[str, object] = values.unset,
friendly_name: Union[str, object] = values.unset,
unique_name: Union[str, object] = values.unset,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> HostedNumberOrderPage:
"""
Retrieve a single page of HostedNumberOrderInstance records from the API.
Request is executed immediately
:param status: The Status of this HostedNumberOrder. One of `received`, `pending-verification`, `verified`, `pending-loa`, `carrier-processing`, `testing`, `completed`, `failed`, or `action-required`.
:param phone_number: An E164 formatted phone number hosted by this HostedNumberOrder.
:param incoming_phone_number_sid: A 34 character string that uniquely identifies the IncomingPhoneNumber resource created by this HostedNumberOrder.
:param friendly_name: A human readable description of this resource, up to 64 characters.
:param unique_name: Provides a unique and addressable name to be assigned to this HostedNumberOrder, assigned by the developer, to be optionally used in addition to SID.
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of HostedNumberOrderInstance
"""
data = values.of(
{
"Status": status,
"PhoneNumber": phone_number,
"IncomingPhoneNumberSid": incoming_phone_number_sid,
"FriendlyName": friendly_name,
"UniqueName": unique_name,
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return HostedNumberOrderPage(self._version, response)
async def page_async(
self,
status: Union["HostedNumberOrderInstance.Status", object] = values.unset,
phone_number: Union[str, object] = values.unset,
incoming_phone_number_sid: Union[str, object] = values.unset,
friendly_name: Union[str, object] = values.unset,
unique_name: Union[str, object] = values.unset,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> HostedNumberOrderPage:
"""
Asynchronously retrieve a single page of HostedNumberOrderInstance records from the API.
Request is executed immediately
:param status: The Status of this HostedNumberOrder. One of `received`, `pending-verification`, `verified`, `pending-loa`, `carrier-processing`, `testing`, `completed`, `failed`, or `action-required`.
:param phone_number: An E164 formatted phone number hosted by this HostedNumberOrder.
:param incoming_phone_number_sid: A 34 character string that uniquely identifies the IncomingPhoneNumber resource created by this HostedNumberOrder.
:param friendly_name: A human readable description of this resource, up to 64 characters.
:param unique_name: Provides a unique and addressable name to be assigned to this HostedNumberOrder, assigned by the developer, to be optionally used in addition to SID.
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of HostedNumberOrderInstance
"""
data = values.of(
{
"Status": status,
"PhoneNumber": phone_number,
"IncomingPhoneNumberSid": incoming_phone_number_sid,
"FriendlyName": friendly_name,
"UniqueName": unique_name,
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = await self._version.page_async(
method="GET", uri=self._uri, params=data
)
return HostedNumberOrderPage(self._version, response)
def get_page(self, target_url: str) -> HostedNumberOrderPage:
"""
Retrieve a specific page of HostedNumberOrderInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of HostedNumberOrderInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return HostedNumberOrderPage(self._version, response)
async def get_page_async(self, target_url: str) -> HostedNumberOrderPage:
"""
Asynchronously retrieve a specific page of HostedNumberOrderInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of HostedNumberOrderInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return HostedNumberOrderPage(self._version, response)
def get(self, sid: str) -> HostedNumberOrderContext:
"""
Constructs a HostedNumberOrderContext
:param sid: A 34 character string that uniquely identifies this HostedNumberOrder.
"""
return HostedNumberOrderContext(self._version, sid=sid)
def __call__(self, sid: str) -> HostedNumberOrderContext:
"""
Constructs a HostedNumberOrderContext
:param sid: A 34 character string that uniquely identifies this HostedNumberOrder.
"""
return HostedNumberOrderContext(self._version, sid=sid)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.HostedNumbers.HostedNumberOrderList>"
@@ -0,0 +1,50 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Preview
This is the public Twilio REST API.
NOTE: This class is auto generated by OpenAPI Generator.
https://openapi-generator.tech
Do not edit the class manually.
"""
from typing import Optional
from twilio.base.version import Version
from twilio.base.domain import Domain
from twilio.rest.preview.marketplace.available_add_on import AvailableAddOnList
from twilio.rest.preview.marketplace.installed_add_on import InstalledAddOnList
class Marketplace(Version):
def __init__(self, domain: Domain):
"""
Initialize the Marketplace version of Preview
:param domain: The Twilio.preview domain
"""
super().__init__(domain, "marketplace")
self._available_add_ons: Optional[AvailableAddOnList] = None
self._installed_add_ons: Optional[InstalledAddOnList] = None
@property
def available_add_ons(self) -> AvailableAddOnList:
if self._available_add_ons is None:
self._available_add_ons = AvailableAddOnList(self)
return self._available_add_ons
@property
def installed_add_ons(self) -> InstalledAddOnList:
if self._installed_add_ons is None:
self._installed_add_ons = InstalledAddOnList(self)
return self._installed_add_ons
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.Marketplace>"
@@ -0,0 +1,423 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Preview
This is the public Twilio REST API.
NOTE: This class is auto generated by OpenAPI Generator.
https://openapi-generator.tech
Do not edit the class manually.
"""
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
from twilio.base import values
from twilio.base.instance_context import InstanceContext
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.version import Version
from twilio.base.page import Page
from twilio.rest.preview.marketplace.available_add_on.available_add_on_extension import (
AvailableAddOnExtensionList,
)
class AvailableAddOnInstance(InstanceResource):
"""
:ivar sid: The unique string that we created to identify the AvailableAddOn resource.
:ivar friendly_name: The string that you assigned to describe the resource.
:ivar description: A short description of the Add-on's functionality.
:ivar pricing_type: How customers are charged for using this Add-on.
:ivar configuration_schema: The JSON object with the configuration that must be provided when installing a given Add-on.
:ivar url: The absolute URL of the resource.
:ivar links: The URLs of related resources.
"""
def __init__(
self, version: Version, payload: Dict[str, Any], sid: Optional[str] = None
):
super().__init__(version)
self.sid: Optional[str] = payload.get("sid")
self.friendly_name: Optional[str] = payload.get("friendly_name")
self.description: Optional[str] = payload.get("description")
self.pricing_type: Optional[str] = payload.get("pricing_type")
self.configuration_schema: Optional[Dict[str, object]] = payload.get(
"configuration_schema"
)
self.url: Optional[str] = payload.get("url")
self.links: Optional[Dict[str, object]] = payload.get("links")
self._solution = {
"sid": sid or self.sid,
}
self._context: Optional[AvailableAddOnContext] = None
@property
def _proxy(self) -> "AvailableAddOnContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: AvailableAddOnContext for this AvailableAddOnInstance
"""
if self._context is None:
self._context = AvailableAddOnContext(
self._version,
sid=self._solution["sid"],
)
return self._context
def fetch(self) -> "AvailableAddOnInstance":
"""
Fetch the AvailableAddOnInstance
:returns: The fetched AvailableAddOnInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "AvailableAddOnInstance":
"""
Asynchronous coroutine to fetch the AvailableAddOnInstance
:returns: The fetched AvailableAddOnInstance
"""
return await self._proxy.fetch_async()
@property
def extensions(self) -> AvailableAddOnExtensionList:
"""
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.Preview.Marketplace.AvailableAddOnInstance {}>".format(context)
class AvailableAddOnContext(InstanceContext):
def __init__(self, version: Version, sid: str):
"""
Initialize the AvailableAddOnContext
:param version: Version that contains the resource
:param sid: The SID of the AvailableAddOn resource to fetch.
"""
super().__init__(version)
# Path Solution
self._solution = {
"sid": sid,
}
self._uri = "/AvailableAddOns/{sid}".format(**self._solution)
self._extensions: Optional[AvailableAddOnExtensionList] = None
def fetch(self) -> AvailableAddOnInstance:
"""
Fetch the AvailableAddOnInstance
:returns: The fetched AvailableAddOnInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return AvailableAddOnInstance(
self._version,
payload,
sid=self._solution["sid"],
)
async def fetch_async(self) -> AvailableAddOnInstance:
"""
Asynchronous coroutine to fetch the AvailableAddOnInstance
:returns: The fetched AvailableAddOnInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return AvailableAddOnInstance(
self._version,
payload,
sid=self._solution["sid"],
)
@property
def extensions(self) -> AvailableAddOnExtensionList:
"""
Access the extensions
"""
if self._extensions is None:
self._extensions = AvailableAddOnExtensionList(
self._version,
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.Preview.Marketplace.AvailableAddOnContext {}>".format(context)
class AvailableAddOnPage(Page):
def get_instance(self, payload: Dict[str, Any]) -> AvailableAddOnInstance:
"""
Build an instance of AvailableAddOnInstance
:param payload: Payload response from the API
"""
return AvailableAddOnInstance(self._version, payload)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.Marketplace.AvailableAddOnPage>"
class AvailableAddOnList(ListResource):
def __init__(self, version: Version):
"""
Initialize the AvailableAddOnList
:param version: Version that contains the resource
"""
super().__init__(version)
self._uri = "/AvailableAddOns"
def stream(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[AvailableAddOnInstance]:
"""
Streams AvailableAddOnInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param limit: Upper limit for the number of records to return. stream()
guarantees to 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[AvailableAddOnInstance]:
"""
Asynchronously streams AvailableAddOnInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param limit: Upper limit for the number of records to return. stream()
guarantees to 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[AvailableAddOnInstance]:
"""
Lists AvailableAddOnInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param limit: Upper limit for the number of records to return. list() guarantees
never 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[AvailableAddOnInstance]:
"""
Asynchronously lists AvailableAddOnInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param limit: Upper limit for the number of records to return. list() guarantees
never 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,
) -> AvailableAddOnPage:
"""
Retrieve a single page of AvailableAddOnInstance records from the API.
Request is executed immediately
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of AvailableAddOnInstance
"""
data = values.of(
{
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return AvailableAddOnPage(self._version, response)
async def page_async(
self,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> AvailableAddOnPage:
"""
Asynchronously retrieve a single page of AvailableAddOnInstance records from the API.
Request is executed immediately
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of AvailableAddOnInstance
"""
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 AvailableAddOnPage(self._version, response)
def get_page(self, target_url: str) -> AvailableAddOnPage:
"""
Retrieve a specific page of AvailableAddOnInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of AvailableAddOnInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return AvailableAddOnPage(self._version, response)
async def get_page_async(self, target_url: str) -> AvailableAddOnPage:
"""
Asynchronously retrieve a specific page of AvailableAddOnInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of AvailableAddOnInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return AvailableAddOnPage(self._version, response)
def get(self, sid: str) -> AvailableAddOnContext:
"""
Constructs a AvailableAddOnContext
:param sid: The SID of the AvailableAddOn resource to fetch.
"""
return AvailableAddOnContext(self._version, sid=sid)
def __call__(self, sid: str) -> AvailableAddOnContext:
"""
Constructs a AvailableAddOnContext
:param sid: The SID of the AvailableAddOn resource to fetch.
"""
return AvailableAddOnContext(self._version, sid=sid)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.Marketplace.AvailableAddOnList>"
@@ -0,0 +1,430 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Preview
This is the public Twilio REST API.
NOTE: This class is auto generated by OpenAPI Generator.
https://openapi-generator.tech
Do not edit the class manually.
"""
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
from twilio.base import values
from twilio.base.instance_context import InstanceContext
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.version import Version
from twilio.base.page import Page
class AvailableAddOnExtensionInstance(InstanceResource):
"""
:ivar sid: The unique string that we created to identify the AvailableAddOnExtension resource.
:ivar available_add_on_sid: The SID of the AvailableAddOn resource to which this extension applies.
:ivar friendly_name: The string that you assigned to describe the resource.
:ivar product_name: The name of the Product this Extension is used within.
:ivar unique_name: An application-defined string that uniquely identifies the resource.
:ivar url: The absolute URL of the resource.
"""
def __init__(
self,
version: Version,
payload: Dict[str, Any],
available_add_on_sid: str,
sid: Optional[str] = None,
):
super().__init__(version)
self.sid: Optional[str] = payload.get("sid")
self.available_add_on_sid: Optional[str] = payload.get("available_add_on_sid")
self.friendly_name: Optional[str] = payload.get("friendly_name")
self.product_name: Optional[str] = payload.get("product_name")
self.unique_name: Optional[str] = payload.get("unique_name")
self.url: Optional[str] = payload.get("url")
self._solution = {
"available_add_on_sid": available_add_on_sid,
"sid": sid or self.sid,
}
self._context: Optional[AvailableAddOnExtensionContext] = None
@property
def _proxy(self) -> "AvailableAddOnExtensionContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: AvailableAddOnExtensionContext for this AvailableAddOnExtensionInstance
"""
if self._context is None:
self._context = AvailableAddOnExtensionContext(
self._version,
available_add_on_sid=self._solution["available_add_on_sid"],
sid=self._solution["sid"],
)
return self._context
def fetch(self) -> "AvailableAddOnExtensionInstance":
"""
Fetch the AvailableAddOnExtensionInstance
:returns: The fetched AvailableAddOnExtensionInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "AvailableAddOnExtensionInstance":
"""
Asynchronous coroutine to fetch the AvailableAddOnExtensionInstance
:returns: The fetched AvailableAddOnExtensionInstance
"""
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.Preview.Marketplace.AvailableAddOnExtensionInstance {}>".format(
context
)
class AvailableAddOnExtensionContext(InstanceContext):
def __init__(self, version: Version, available_add_on_sid: str, sid: str):
"""
Initialize the AvailableAddOnExtensionContext
:param version: Version that contains the resource
:param available_add_on_sid: The SID of the AvailableAddOn resource with the extension to fetch.
:param sid: The SID of the AvailableAddOn Extension resource to fetch.
"""
super().__init__(version)
# Path Solution
self._solution = {
"available_add_on_sid": available_add_on_sid,
"sid": sid,
}
self._uri = "/AvailableAddOns/{available_add_on_sid}/Extensions/{sid}".format(
**self._solution
)
def fetch(self) -> AvailableAddOnExtensionInstance:
"""
Fetch the AvailableAddOnExtensionInstance
:returns: The fetched AvailableAddOnExtensionInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return AvailableAddOnExtensionInstance(
self._version,
payload,
available_add_on_sid=self._solution["available_add_on_sid"],
sid=self._solution["sid"],
)
async def fetch_async(self) -> AvailableAddOnExtensionInstance:
"""
Asynchronous coroutine to fetch the AvailableAddOnExtensionInstance
:returns: The fetched AvailableAddOnExtensionInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return AvailableAddOnExtensionInstance(
self._version,
payload,
available_add_on_sid=self._solution["available_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.Preview.Marketplace.AvailableAddOnExtensionContext {}>".format(
context
)
class AvailableAddOnExtensionPage(Page):
def get_instance(self, payload: Dict[str, Any]) -> AvailableAddOnExtensionInstance:
"""
Build an instance of AvailableAddOnExtensionInstance
:param payload: Payload response from the API
"""
return AvailableAddOnExtensionInstance(
self._version,
payload,
available_add_on_sid=self._solution["available_add_on_sid"],
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.Marketplace.AvailableAddOnExtensionPage>"
class AvailableAddOnExtensionList(ListResource):
def __init__(self, version: Version, available_add_on_sid: str):
"""
Initialize the AvailableAddOnExtensionList
:param version: Version that contains the resource
:param available_add_on_sid: The SID of the AvailableAddOn resource with the extensions to read.
"""
super().__init__(version)
# Path Solution
self._solution = {
"available_add_on_sid": available_add_on_sid,
}
self._uri = "/AvailableAddOns/{available_add_on_sid}/Extensions".format(
**self._solution
)
def stream(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[AvailableAddOnExtensionInstance]:
"""
Streams AvailableAddOnExtensionInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param limit: Upper limit for the number of records to return. stream()
guarantees to 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[AvailableAddOnExtensionInstance]:
"""
Asynchronously streams AvailableAddOnExtensionInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param limit: Upper limit for the number of records to return. stream()
guarantees to 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[AvailableAddOnExtensionInstance]:
"""
Lists AvailableAddOnExtensionInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param limit: Upper limit for the number of records to return. list() guarantees
never 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[AvailableAddOnExtensionInstance]:
"""
Asynchronously lists AvailableAddOnExtensionInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param limit: Upper limit for the number of records to return. list() guarantees
never 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,
) -> AvailableAddOnExtensionPage:
"""
Retrieve a single page of AvailableAddOnExtensionInstance records from the API.
Request is executed immediately
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of AvailableAddOnExtensionInstance
"""
data = values.of(
{
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return AvailableAddOnExtensionPage(self._version, response, self._solution)
async def page_async(
self,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> AvailableAddOnExtensionPage:
"""
Asynchronously retrieve a single page of AvailableAddOnExtensionInstance records from the API.
Request is executed immediately
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of AvailableAddOnExtensionInstance
"""
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 AvailableAddOnExtensionPage(self._version, response, self._solution)
def get_page(self, target_url: str) -> AvailableAddOnExtensionPage:
"""
Retrieve a specific page of AvailableAddOnExtensionInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of AvailableAddOnExtensionInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return AvailableAddOnExtensionPage(self._version, response, self._solution)
async def get_page_async(self, target_url: str) -> AvailableAddOnExtensionPage:
"""
Asynchronously retrieve a specific page of AvailableAddOnExtensionInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of AvailableAddOnExtensionInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return AvailableAddOnExtensionPage(self._version, response, self._solution)
def get(self, sid: str) -> AvailableAddOnExtensionContext:
"""
Constructs a AvailableAddOnExtensionContext
:param sid: The SID of the AvailableAddOn Extension resource to fetch.
"""
return AvailableAddOnExtensionContext(
self._version,
available_add_on_sid=self._solution["available_add_on_sid"],
sid=sid,
)
def __call__(self, sid: str) -> AvailableAddOnExtensionContext:
"""
Constructs a AvailableAddOnExtensionContext
:param sid: The SID of the AvailableAddOn Extension resource to fetch.
"""
return AvailableAddOnExtensionContext(
self._version,
available_add_on_sid=self._solution["available_add_on_sid"],
sid=sid,
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.Marketplace.AvailableAddOnExtensionList>"
@@ -0,0 +1,634 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Preview
This is the public Twilio REST API.
NOTE: This class is auto generated by OpenAPI Generator.
https://openapi-generator.tech
Do not edit the class manually.
"""
from datetime import datetime
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
from twilio.base import deserialize, serialize, values
from twilio.base.instance_context import InstanceContext
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.version import Version
from twilio.base.page import Page
from twilio.rest.preview.marketplace.installed_add_on.installed_add_on_extension import (
InstalledAddOnExtensionList,
)
class InstalledAddOnInstance(InstanceResource):
"""
:ivar sid: The unique string that we created to identify the InstalledAddOn resource. This Sid can also be found in the Console on that specific Add-ons page as the 'Available Add-on Sid'.
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the InstalledAddOn resource.
:ivar friendly_name: The string that you assigned to describe the resource.
:ivar description: A short description of the Add-on's functionality.
:ivar configuration: The JSON object that represents the current configuration of installed Add-on.
:ivar unique_name: An application-defined string that uniquely identifies the resource.
:ivar date_created: The date and time in GMT when the resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
:ivar date_updated: The date and time in GMT when the resource was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
:ivar url: The absolute URL of the resource.
:ivar links: The URLs of related resources.
"""
def __init__(
self, version: Version, payload: Dict[str, Any], sid: Optional[str] = None
):
super().__init__(version)
self.sid: Optional[str] = payload.get("sid")
self.account_sid: Optional[str] = payload.get("account_sid")
self.friendly_name: Optional[str] = payload.get("friendly_name")
self.description: Optional[str] = payload.get("description")
self.configuration: Optional[Dict[str, object]] = payload.get("configuration")
self.unique_name: Optional[str] = payload.get("unique_name")
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_created")
)
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_updated")
)
self.url: Optional[str] = payload.get("url")
self.links: Optional[Dict[str, object]] = payload.get("links")
self._solution = {
"sid": sid or self.sid,
}
self._context: Optional[InstalledAddOnContext] = None
@property
def _proxy(self) -> "InstalledAddOnContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: InstalledAddOnContext for this InstalledAddOnInstance
"""
if self._context is None:
self._context = InstalledAddOnContext(
self._version,
sid=self._solution["sid"],
)
return self._context
def delete(self) -> bool:
"""
Deletes the InstalledAddOnInstance
:returns: True if delete succeeds, False otherwise
"""
return self._proxy.delete()
async def delete_async(self) -> bool:
"""
Asynchronous coroutine that deletes the InstalledAddOnInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._proxy.delete_async()
def fetch(self) -> "InstalledAddOnInstance":
"""
Fetch the InstalledAddOnInstance
:returns: The fetched InstalledAddOnInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "InstalledAddOnInstance":
"""
Asynchronous coroutine to fetch the InstalledAddOnInstance
:returns: The fetched InstalledAddOnInstance
"""
return await self._proxy.fetch_async()
def update(
self,
configuration: Union[object, object] = values.unset,
unique_name: Union[str, object] = values.unset,
) -> "InstalledAddOnInstance":
"""
Update the InstalledAddOnInstance
:param configuration: Valid JSON object that conform to the configuration schema exposed by the associated AvailableAddOn resource. This is only required by Add-ons that need to be configured
:param unique_name: An application-defined string that uniquely identifies the resource. This value must be unique within the Account.
:returns: The updated InstalledAddOnInstance
"""
return self._proxy.update(
configuration=configuration,
unique_name=unique_name,
)
async def update_async(
self,
configuration: Union[object, object] = values.unset,
unique_name: Union[str, object] = values.unset,
) -> "InstalledAddOnInstance":
"""
Asynchronous coroutine to update the InstalledAddOnInstance
:param configuration: Valid JSON object that conform to the configuration schema exposed by the associated AvailableAddOn resource. This is only required by Add-ons that need to be configured
:param unique_name: An application-defined string that uniquely identifies the resource. This value must be unique within the Account.
:returns: The updated InstalledAddOnInstance
"""
return await self._proxy.update_async(
configuration=configuration,
unique_name=unique_name,
)
@property
def extensions(self) -> InstalledAddOnExtensionList:
"""
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.Preview.Marketplace.InstalledAddOnInstance {}>".format(context)
class InstalledAddOnContext(InstanceContext):
def __init__(self, version: Version, sid: str):
"""
Initialize the InstalledAddOnContext
:param version: Version that contains the resource
:param sid: The SID of the InstalledAddOn resource to update.
"""
super().__init__(version)
# Path Solution
self._solution = {
"sid": sid,
}
self._uri = "/InstalledAddOns/{sid}".format(**self._solution)
self._extensions: Optional[InstalledAddOnExtensionList] = None
def delete(self) -> bool:
"""
Deletes the InstalledAddOnInstance
: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 InstalledAddOnInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._version.delete_async(
method="DELETE",
uri=self._uri,
)
def fetch(self) -> InstalledAddOnInstance:
"""
Fetch the InstalledAddOnInstance
:returns: The fetched InstalledAddOnInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return InstalledAddOnInstance(
self._version,
payload,
sid=self._solution["sid"],
)
async def fetch_async(self) -> InstalledAddOnInstance:
"""
Asynchronous coroutine to fetch the InstalledAddOnInstance
:returns: The fetched InstalledAddOnInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return InstalledAddOnInstance(
self._version,
payload,
sid=self._solution["sid"],
)
def update(
self,
configuration: Union[object, object] = values.unset,
unique_name: Union[str, object] = values.unset,
) -> InstalledAddOnInstance:
"""
Update the InstalledAddOnInstance
:param configuration: Valid JSON object that conform to the configuration schema exposed by the associated AvailableAddOn resource. This is only required by Add-ons that need to be configured
:param unique_name: An application-defined string that uniquely identifies the resource. This value must be unique within the Account.
:returns: The updated InstalledAddOnInstance
"""
data = values.of(
{
"Configuration": serialize.object(configuration),
"UniqueName": unique_name,
}
)
payload = self._version.update(
method="POST",
uri=self._uri,
data=data,
)
return InstalledAddOnInstance(self._version, payload, sid=self._solution["sid"])
async def update_async(
self,
configuration: Union[object, object] = values.unset,
unique_name: Union[str, object] = values.unset,
) -> InstalledAddOnInstance:
"""
Asynchronous coroutine to update the InstalledAddOnInstance
:param configuration: Valid JSON object that conform to the configuration schema exposed by the associated AvailableAddOn resource. This is only required by Add-ons that need to be configured
:param unique_name: An application-defined string that uniquely identifies the resource. This value must be unique within the Account.
:returns: The updated InstalledAddOnInstance
"""
data = values.of(
{
"Configuration": serialize.object(configuration),
"UniqueName": unique_name,
}
)
payload = await self._version.update_async(
method="POST",
uri=self._uri,
data=data,
)
return InstalledAddOnInstance(self._version, payload, sid=self._solution["sid"])
@property
def extensions(self) -> InstalledAddOnExtensionList:
"""
Access the extensions
"""
if self._extensions is None:
self._extensions = InstalledAddOnExtensionList(
self._version,
self._solution["sid"],
)
return self._extensions
def __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.Preview.Marketplace.InstalledAddOnContext {}>".format(context)
class InstalledAddOnPage(Page):
def get_instance(self, payload: Dict[str, Any]) -> InstalledAddOnInstance:
"""
Build an instance of InstalledAddOnInstance
:param payload: Payload response from the API
"""
return InstalledAddOnInstance(self._version, payload)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.Marketplace.InstalledAddOnPage>"
class InstalledAddOnList(ListResource):
def __init__(self, version: Version):
"""
Initialize the InstalledAddOnList
:param version: Version that contains the resource
"""
super().__init__(version)
self._uri = "/InstalledAddOns"
def create(
self,
available_add_on_sid: str,
accept_terms_of_service: bool,
configuration: Union[object, object] = values.unset,
unique_name: Union[str, object] = values.unset,
) -> InstalledAddOnInstance:
"""
Create the InstalledAddOnInstance
:param available_add_on_sid: The SID of the AvaliableAddOn to install.
:param accept_terms_of_service: Whether the Terms of Service were accepted.
:param configuration: The JSON object that represents the configuration of the new Add-on being installed.
:param unique_name: An application-defined string that uniquely identifies the resource. This value must be unique within the Account.
:returns: The created InstalledAddOnInstance
"""
data = values.of(
{
"AvailableAddOnSid": available_add_on_sid,
"AcceptTermsOfService": accept_terms_of_service,
"Configuration": serialize.object(configuration),
"UniqueName": unique_name,
}
)
payload = self._version.create(
method="POST",
uri=self._uri,
data=data,
)
return InstalledAddOnInstance(self._version, payload)
async def create_async(
self,
available_add_on_sid: str,
accept_terms_of_service: bool,
configuration: Union[object, object] = values.unset,
unique_name: Union[str, object] = values.unset,
) -> InstalledAddOnInstance:
"""
Asynchronously create the InstalledAddOnInstance
:param available_add_on_sid: The SID of the AvaliableAddOn to install.
:param accept_terms_of_service: Whether the Terms of Service were accepted.
:param configuration: The JSON object that represents the configuration of the new Add-on being installed.
:param unique_name: An application-defined string that uniquely identifies the resource. This value must be unique within the Account.
:returns: The created InstalledAddOnInstance
"""
data = values.of(
{
"AvailableAddOnSid": available_add_on_sid,
"AcceptTermsOfService": accept_terms_of_service,
"Configuration": serialize.object(configuration),
"UniqueName": unique_name,
}
)
payload = await self._version.create_async(
method="POST",
uri=self._uri,
data=data,
)
return InstalledAddOnInstance(self._version, payload)
def stream(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[InstalledAddOnInstance]:
"""
Streams InstalledAddOnInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param limit: Upper limit for the number of records to return. stream()
guarantees to 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[InstalledAddOnInstance]:
"""
Asynchronously streams InstalledAddOnInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param limit: Upper limit for the number of records to return. stream()
guarantees to 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[InstalledAddOnInstance]:
"""
Lists InstalledAddOnInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param limit: Upper limit for the number of records to return. list() guarantees
never 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[InstalledAddOnInstance]:
"""
Asynchronously lists InstalledAddOnInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param limit: Upper limit for the number of records to return. list() guarantees
never 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,
) -> InstalledAddOnPage:
"""
Retrieve a single page of InstalledAddOnInstance records from the API.
Request is executed immediately
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of InstalledAddOnInstance
"""
data = values.of(
{
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return InstalledAddOnPage(self._version, response)
async def page_async(
self,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> InstalledAddOnPage:
"""
Asynchronously retrieve a single page of InstalledAddOnInstance records from the API.
Request is executed immediately
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of InstalledAddOnInstance
"""
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 InstalledAddOnPage(self._version, response)
def get_page(self, target_url: str) -> InstalledAddOnPage:
"""
Retrieve a specific page of InstalledAddOnInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of InstalledAddOnInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return InstalledAddOnPage(self._version, response)
async def get_page_async(self, target_url: str) -> InstalledAddOnPage:
"""
Asynchronously retrieve a specific page of InstalledAddOnInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of InstalledAddOnInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return InstalledAddOnPage(self._version, response)
def get(self, sid: str) -> InstalledAddOnContext:
"""
Constructs a InstalledAddOnContext
:param sid: The SID of the InstalledAddOn resource to update.
"""
return InstalledAddOnContext(self._version, sid=sid)
def __call__(self, sid: str) -> InstalledAddOnContext:
"""
Constructs a InstalledAddOnContext
:param sid: The SID of the InstalledAddOn resource to update.
"""
return InstalledAddOnContext(self._version, sid=sid)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.Marketplace.InstalledAddOnList>"
@@ -0,0 +1,510 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Preview
This is the public Twilio REST API.
NOTE: This class is auto generated by OpenAPI Generator.
https://openapi-generator.tech
Do not edit the class manually.
"""
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
from twilio.base import values
from twilio.base.instance_context import InstanceContext
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.version import Version
from twilio.base.page import Page
class InstalledAddOnExtensionInstance(InstanceResource):
"""
:ivar sid: The unique string that we created to identify the InstalledAddOn Extension resource.
:ivar installed_add_on_sid: The SID of the InstalledAddOn resource to which this extension applies.
:ivar friendly_name: The string that you assigned to describe the resource.
:ivar product_name: The name of the Product this Extension is used within.
:ivar unique_name: An application-defined string that uniquely identifies the resource.
:ivar enabled: Whether the Extension will be invoked.
:ivar url: The absolute URL of the resource.
"""
def __init__(
self,
version: Version,
payload: Dict[str, Any],
installed_add_on_sid: str,
sid: Optional[str] = None,
):
super().__init__(version)
self.sid: Optional[str] = payload.get("sid")
self.installed_add_on_sid: Optional[str] = payload.get("installed_add_on_sid")
self.friendly_name: Optional[str] = payload.get("friendly_name")
self.product_name: Optional[str] = payload.get("product_name")
self.unique_name: Optional[str] = payload.get("unique_name")
self.enabled: Optional[bool] = payload.get("enabled")
self.url: Optional[str] = payload.get("url")
self._solution = {
"installed_add_on_sid": installed_add_on_sid,
"sid": sid or self.sid,
}
self._context: Optional[InstalledAddOnExtensionContext] = None
@property
def _proxy(self) -> "InstalledAddOnExtensionContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: InstalledAddOnExtensionContext for this InstalledAddOnExtensionInstance
"""
if self._context is None:
self._context = InstalledAddOnExtensionContext(
self._version,
installed_add_on_sid=self._solution["installed_add_on_sid"],
sid=self._solution["sid"],
)
return self._context
def fetch(self) -> "InstalledAddOnExtensionInstance":
"""
Fetch the InstalledAddOnExtensionInstance
:returns: The fetched InstalledAddOnExtensionInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "InstalledAddOnExtensionInstance":
"""
Asynchronous coroutine to fetch the InstalledAddOnExtensionInstance
:returns: The fetched InstalledAddOnExtensionInstance
"""
return await self._proxy.fetch_async()
def update(self, enabled: bool) -> "InstalledAddOnExtensionInstance":
"""
Update the InstalledAddOnExtensionInstance
:param enabled: Whether the Extension should be invoked.
:returns: The updated InstalledAddOnExtensionInstance
"""
return self._proxy.update(
enabled=enabled,
)
async def update_async(self, enabled: bool) -> "InstalledAddOnExtensionInstance":
"""
Asynchronous coroutine to update the InstalledAddOnExtensionInstance
:param enabled: Whether the Extension should be invoked.
:returns: The updated InstalledAddOnExtensionInstance
"""
return await self._proxy.update_async(
enabled=enabled,
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Preview.Marketplace.InstalledAddOnExtensionInstance {}>".format(
context
)
class InstalledAddOnExtensionContext(InstanceContext):
def __init__(self, version: Version, installed_add_on_sid: str, sid: str):
"""
Initialize the InstalledAddOnExtensionContext
:param version: Version that contains the resource
:param installed_add_on_sid: The SID of the InstalledAddOn resource with the extension to update.
:param sid: The SID of the InstalledAddOn Extension resource to update.
"""
super().__init__(version)
# Path Solution
self._solution = {
"installed_add_on_sid": installed_add_on_sid,
"sid": sid,
}
self._uri = "/InstalledAddOns/{installed_add_on_sid}/Extensions/{sid}".format(
**self._solution
)
def fetch(self) -> InstalledAddOnExtensionInstance:
"""
Fetch the InstalledAddOnExtensionInstance
:returns: The fetched InstalledAddOnExtensionInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return InstalledAddOnExtensionInstance(
self._version,
payload,
installed_add_on_sid=self._solution["installed_add_on_sid"],
sid=self._solution["sid"],
)
async def fetch_async(self) -> InstalledAddOnExtensionInstance:
"""
Asynchronous coroutine to fetch the InstalledAddOnExtensionInstance
:returns: The fetched InstalledAddOnExtensionInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return InstalledAddOnExtensionInstance(
self._version,
payload,
installed_add_on_sid=self._solution["installed_add_on_sid"],
sid=self._solution["sid"],
)
def update(self, enabled: bool) -> InstalledAddOnExtensionInstance:
"""
Update the InstalledAddOnExtensionInstance
:param enabled: Whether the Extension should be invoked.
:returns: The updated InstalledAddOnExtensionInstance
"""
data = values.of(
{
"Enabled": enabled,
}
)
payload = self._version.update(
method="POST",
uri=self._uri,
data=data,
)
return InstalledAddOnExtensionInstance(
self._version,
payload,
installed_add_on_sid=self._solution["installed_add_on_sid"],
sid=self._solution["sid"],
)
async def update_async(self, enabled: bool) -> InstalledAddOnExtensionInstance:
"""
Asynchronous coroutine to update the InstalledAddOnExtensionInstance
:param enabled: Whether the Extension should be invoked.
:returns: The updated InstalledAddOnExtensionInstance
"""
data = values.of(
{
"Enabled": enabled,
}
)
payload = await self._version.update_async(
method="POST",
uri=self._uri,
data=data,
)
return InstalledAddOnExtensionInstance(
self._version,
payload,
installed_add_on_sid=self._solution["installed_add_on_sid"],
sid=self._solution["sid"],
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Preview.Marketplace.InstalledAddOnExtensionContext {}>".format(
context
)
class InstalledAddOnExtensionPage(Page):
def get_instance(self, payload: Dict[str, Any]) -> InstalledAddOnExtensionInstance:
"""
Build an instance of InstalledAddOnExtensionInstance
:param payload: Payload response from the API
"""
return InstalledAddOnExtensionInstance(
self._version,
payload,
installed_add_on_sid=self._solution["installed_add_on_sid"],
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.Marketplace.InstalledAddOnExtensionPage>"
class InstalledAddOnExtensionList(ListResource):
def __init__(self, version: Version, installed_add_on_sid: str):
"""
Initialize the InstalledAddOnExtensionList
:param version: Version that contains the resource
:param installed_add_on_sid: The SID of the InstalledAddOn resource with the extensions to read.
"""
super().__init__(version)
# Path Solution
self._solution = {
"installed_add_on_sid": installed_add_on_sid,
}
self._uri = "/InstalledAddOns/{installed_add_on_sid}/Extensions".format(
**self._solution
)
def stream(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[InstalledAddOnExtensionInstance]:
"""
Streams InstalledAddOnExtensionInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param limit: Upper limit for the number of records to return. stream()
guarantees to 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[InstalledAddOnExtensionInstance]:
"""
Asynchronously streams InstalledAddOnExtensionInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param limit: Upper limit for the number of records to return. stream()
guarantees to 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[InstalledAddOnExtensionInstance]:
"""
Lists InstalledAddOnExtensionInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param limit: Upper limit for the number of records to return. list() guarantees
never 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[InstalledAddOnExtensionInstance]:
"""
Asynchronously lists InstalledAddOnExtensionInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param limit: Upper limit for the number of records to return. list() guarantees
never 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,
) -> InstalledAddOnExtensionPage:
"""
Retrieve a single page of InstalledAddOnExtensionInstance records from the API.
Request is executed immediately
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of InstalledAddOnExtensionInstance
"""
data = values.of(
{
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return InstalledAddOnExtensionPage(self._version, response, self._solution)
async def page_async(
self,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> InstalledAddOnExtensionPage:
"""
Asynchronously retrieve a single page of InstalledAddOnExtensionInstance records from the API.
Request is executed immediately
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of InstalledAddOnExtensionInstance
"""
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 InstalledAddOnExtensionPage(self._version, response, self._solution)
def get_page(self, target_url: str) -> InstalledAddOnExtensionPage:
"""
Retrieve a specific page of InstalledAddOnExtensionInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of InstalledAddOnExtensionInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return InstalledAddOnExtensionPage(self._version, response, self._solution)
async def get_page_async(self, target_url: str) -> InstalledAddOnExtensionPage:
"""
Asynchronously retrieve a specific page of InstalledAddOnExtensionInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of InstalledAddOnExtensionInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return InstalledAddOnExtensionPage(self._version, response, self._solution)
def get(self, sid: str) -> InstalledAddOnExtensionContext:
"""
Constructs a InstalledAddOnExtensionContext
:param sid: The SID of the InstalledAddOn Extension resource to update.
"""
return InstalledAddOnExtensionContext(
self._version,
installed_add_on_sid=self._solution["installed_add_on_sid"],
sid=sid,
)
def __call__(self, sid: str) -> InstalledAddOnExtensionContext:
"""
Constructs a InstalledAddOnExtensionContext
:param sid: The SID of the InstalledAddOn Extension resource to update.
"""
return InstalledAddOnExtensionContext(
self._version,
installed_add_on_sid=self._solution["installed_add_on_sid"],
sid=sid,
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.Marketplace.InstalledAddOnExtensionList>"
@@ -0,0 +1,42 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Preview
This is the public Twilio REST API.
NOTE: This class is auto generated by OpenAPI Generator.
https://openapi-generator.tech
Do not edit the class manually.
"""
from typing import Optional
from twilio.base.version import Version
from twilio.base.domain import Domain
from twilio.rest.preview.sync.service import ServiceList
class Sync(Version):
def __init__(self, domain: Domain):
"""
Initialize the Sync version of Preview
:param domain: The Twilio.preview domain
"""
super().__init__(domain, "Sync")
self._services: Optional[ServiceList] = None
@property
def services(self) -> ServiceList:
if self._services is None:
self._services = ServiceList(self)
return self._services
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.Sync>"
@@ -0,0 +1,700 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Preview
This is the public Twilio REST API.
NOTE: This class is auto generated by OpenAPI Generator.
https://openapi-generator.tech
Do not edit the class manually.
"""
from datetime import datetime
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
from twilio.base import deserialize, values
from twilio.base.instance_context import InstanceContext
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.version import Version
from twilio.base.page import Page
from twilio.rest.preview.sync.service.document import DocumentList
from twilio.rest.preview.sync.service.sync_list import SyncListList
from twilio.rest.preview.sync.service.sync_map import SyncMapList
class ServiceInstance(InstanceResource):
"""
:ivar sid:
:ivar account_sid:
:ivar friendly_name:
:ivar date_created:
:ivar date_updated:
:ivar url:
:ivar webhook_url:
:ivar reachability_webhooks_enabled:
:ivar acl_enabled:
:ivar links:
"""
def __init__(
self, version: Version, payload: Dict[str, Any], sid: Optional[str] = None
):
super().__init__(version)
self.sid: Optional[str] = payload.get("sid")
self.account_sid: Optional[str] = payload.get("account_sid")
self.friendly_name: Optional[str] = payload.get("friendly_name")
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_created")
)
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_updated")
)
self.url: Optional[str] = payload.get("url")
self.webhook_url: Optional[str] = payload.get("webhook_url")
self.reachability_webhooks_enabled: Optional[bool] = payload.get(
"reachability_webhooks_enabled"
)
self.acl_enabled: Optional[bool] = payload.get("acl_enabled")
self.links: Optional[Dict[str, object]] = payload.get("links")
self._solution = {
"sid": sid or self.sid,
}
self._context: Optional[ServiceContext] = None
@property
def _proxy(self) -> "ServiceContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: ServiceContext for this ServiceInstance
"""
if self._context is None:
self._context = ServiceContext(
self._version,
sid=self._solution["sid"],
)
return self._context
def delete(self) -> bool:
"""
Deletes the ServiceInstance
:returns: True if delete succeeds, False otherwise
"""
return self._proxy.delete()
async def delete_async(self) -> bool:
"""
Asynchronous coroutine that deletes the ServiceInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._proxy.delete_async()
def fetch(self) -> "ServiceInstance":
"""
Fetch the ServiceInstance
:returns: The fetched ServiceInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "ServiceInstance":
"""
Asynchronous coroutine to fetch the ServiceInstance
:returns: The fetched ServiceInstance
"""
return await self._proxy.fetch_async()
def update(
self,
webhook_url: Union[str, object] = values.unset,
friendly_name: Union[str, object] = values.unset,
reachability_webhooks_enabled: Union[bool, object] = values.unset,
acl_enabled: Union[bool, object] = values.unset,
) -> "ServiceInstance":
"""
Update the ServiceInstance
:param webhook_url:
:param friendly_name:
:param reachability_webhooks_enabled:
:param acl_enabled:
:returns: The updated ServiceInstance
"""
return self._proxy.update(
webhook_url=webhook_url,
friendly_name=friendly_name,
reachability_webhooks_enabled=reachability_webhooks_enabled,
acl_enabled=acl_enabled,
)
async def update_async(
self,
webhook_url: Union[str, object] = values.unset,
friendly_name: Union[str, object] = values.unset,
reachability_webhooks_enabled: Union[bool, object] = values.unset,
acl_enabled: Union[bool, object] = values.unset,
) -> "ServiceInstance":
"""
Asynchronous coroutine to update the ServiceInstance
:param webhook_url:
:param friendly_name:
:param reachability_webhooks_enabled:
:param acl_enabled:
:returns: The updated ServiceInstance
"""
return await self._proxy.update_async(
webhook_url=webhook_url,
friendly_name=friendly_name,
reachability_webhooks_enabled=reachability_webhooks_enabled,
acl_enabled=acl_enabled,
)
@property
def documents(self) -> DocumentList:
"""
Access the documents
"""
return self._proxy.documents
@property
def sync_lists(self) -> SyncListList:
"""
Access the sync_lists
"""
return self._proxy.sync_lists
@property
def sync_maps(self) -> SyncMapList:
"""
Access the sync_maps
"""
return self._proxy.sync_maps
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Preview.Sync.ServiceInstance {}>".format(context)
class ServiceContext(InstanceContext):
def __init__(self, version: Version, sid: str):
"""
Initialize the ServiceContext
:param version: Version that contains the resource
:param sid:
"""
super().__init__(version)
# Path Solution
self._solution = {
"sid": sid,
}
self._uri = "/Services/{sid}".format(**self._solution)
self._documents: Optional[DocumentList] = None
self._sync_lists: Optional[SyncListList] = None
self._sync_maps: Optional[SyncMapList] = None
def delete(self) -> bool:
"""
Deletes the ServiceInstance
:returns: True if delete succeeds, False otherwise
"""
return self._version.delete(
method="DELETE",
uri=self._uri,
)
async def delete_async(self) -> bool:
"""
Asynchronous coroutine that deletes the ServiceInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._version.delete_async(
method="DELETE",
uri=self._uri,
)
def fetch(self) -> ServiceInstance:
"""
Fetch the ServiceInstance
:returns: The fetched ServiceInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return ServiceInstance(
self._version,
payload,
sid=self._solution["sid"],
)
async def fetch_async(self) -> ServiceInstance:
"""
Asynchronous coroutine to fetch the ServiceInstance
:returns: The fetched ServiceInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return ServiceInstance(
self._version,
payload,
sid=self._solution["sid"],
)
def update(
self,
webhook_url: Union[str, object] = values.unset,
friendly_name: Union[str, object] = values.unset,
reachability_webhooks_enabled: Union[bool, object] = values.unset,
acl_enabled: Union[bool, object] = values.unset,
) -> ServiceInstance:
"""
Update the ServiceInstance
:param webhook_url:
:param friendly_name:
:param reachability_webhooks_enabled:
:param acl_enabled:
:returns: The updated ServiceInstance
"""
data = values.of(
{
"WebhookUrl": webhook_url,
"FriendlyName": friendly_name,
"ReachabilityWebhooksEnabled": reachability_webhooks_enabled,
"AclEnabled": acl_enabled,
}
)
payload = self._version.update(
method="POST",
uri=self._uri,
data=data,
)
return ServiceInstance(self._version, payload, sid=self._solution["sid"])
async def update_async(
self,
webhook_url: Union[str, object] = values.unset,
friendly_name: Union[str, object] = values.unset,
reachability_webhooks_enabled: Union[bool, object] = values.unset,
acl_enabled: Union[bool, object] = values.unset,
) -> ServiceInstance:
"""
Asynchronous coroutine to update the ServiceInstance
:param webhook_url:
:param friendly_name:
:param reachability_webhooks_enabled:
:param acl_enabled:
:returns: The updated ServiceInstance
"""
data = values.of(
{
"WebhookUrl": webhook_url,
"FriendlyName": friendly_name,
"ReachabilityWebhooksEnabled": reachability_webhooks_enabled,
"AclEnabled": acl_enabled,
}
)
payload = await self._version.update_async(
method="POST",
uri=self._uri,
data=data,
)
return ServiceInstance(self._version, payload, sid=self._solution["sid"])
@property
def documents(self) -> DocumentList:
"""
Access the documents
"""
if self._documents is None:
self._documents = DocumentList(
self._version,
self._solution["sid"],
)
return self._documents
@property
def sync_lists(self) -> SyncListList:
"""
Access the sync_lists
"""
if self._sync_lists is None:
self._sync_lists = SyncListList(
self._version,
self._solution["sid"],
)
return self._sync_lists
@property
def sync_maps(self) -> SyncMapList:
"""
Access the sync_maps
"""
if self._sync_maps is None:
self._sync_maps = SyncMapList(
self._version,
self._solution["sid"],
)
return self._sync_maps
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Preview.Sync.ServiceContext {}>".format(context)
class ServicePage(Page):
def get_instance(self, payload: Dict[str, Any]) -> ServiceInstance:
"""
Build an instance of ServiceInstance
:param payload: Payload response from the API
"""
return ServiceInstance(self._version, payload)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.Sync.ServicePage>"
class ServiceList(ListResource):
def __init__(self, version: Version):
"""
Initialize the ServiceList
:param version: Version that contains the resource
"""
super().__init__(version)
self._uri = "/Services"
def create(
self,
friendly_name: Union[str, object] = values.unset,
webhook_url: Union[str, object] = values.unset,
reachability_webhooks_enabled: Union[bool, object] = values.unset,
acl_enabled: Union[bool, object] = values.unset,
) -> ServiceInstance:
"""
Create the ServiceInstance
:param friendly_name:
:param webhook_url:
:param reachability_webhooks_enabled:
:param acl_enabled:
:returns: The created ServiceInstance
"""
data = values.of(
{
"FriendlyName": friendly_name,
"WebhookUrl": webhook_url,
"ReachabilityWebhooksEnabled": reachability_webhooks_enabled,
"AclEnabled": acl_enabled,
}
)
payload = self._version.create(
method="POST",
uri=self._uri,
data=data,
)
return ServiceInstance(self._version, payload)
async def create_async(
self,
friendly_name: Union[str, object] = values.unset,
webhook_url: Union[str, object] = values.unset,
reachability_webhooks_enabled: Union[bool, object] = values.unset,
acl_enabled: Union[bool, object] = values.unset,
) -> ServiceInstance:
"""
Asynchronously create the ServiceInstance
:param friendly_name:
:param webhook_url:
:param reachability_webhooks_enabled:
:param acl_enabled:
:returns: The created ServiceInstance
"""
data = values.of(
{
"FriendlyName": friendly_name,
"WebhookUrl": webhook_url,
"ReachabilityWebhooksEnabled": reachability_webhooks_enabled,
"AclEnabled": acl_enabled,
}
)
payload = await self._version.create_async(
method="POST",
uri=self._uri,
data=data,
)
return ServiceInstance(self._version, payload)
def stream(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[ServiceInstance]:
"""
Streams ServiceInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param limit: Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the
limit with the most efficient page size, i.e. min(limit, 1000)
:returns: Generator that will yield up to limit results
"""
limits = self._version.read_limits(limit, page_size)
page = self.page(page_size=limits["page_size"])
return self._version.stream(page, limits["limit"])
async def stream_async(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> AsyncIterator[ServiceInstance]:
"""
Asynchronously streams ServiceInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param limit: Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the
limit with the most efficient page size, i.e. min(limit, 1000)
:returns: Generator that will yield up to limit results
"""
limits = self._version.read_limits(limit, page_size)
page = await self.page_async(page_size=limits["page_size"])
return self._version.stream_async(page, limits["limit"])
def list(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[ServiceInstance]:
"""
Lists ServiceInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param limit: Upper limit for the number of records to return. list() guarantees
never to return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, list() will attempt to read the limit
with the most efficient page size, i.e. min(limit, 1000)
:returns: list that will contain up to limit results
"""
return list(
self.stream(
limit=limit,
page_size=page_size,
)
)
async def list_async(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[ServiceInstance]:
"""
Asynchronously lists ServiceInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param limit: Upper limit for the number of records to return. list() guarantees
never to return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, list() will attempt to read the limit
with the most efficient page size, i.e. min(limit, 1000)
:returns: list that will contain up to limit results
"""
return [
record
async for record in await self.stream_async(
limit=limit,
page_size=page_size,
)
]
def page(
self,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> ServicePage:
"""
Retrieve a single page of ServiceInstance records from the API.
Request is executed immediately
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of ServiceInstance
"""
data = values.of(
{
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return ServicePage(self._version, response)
async def page_async(
self,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> ServicePage:
"""
Asynchronously retrieve a single page of ServiceInstance records from the API.
Request is executed immediately
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of ServiceInstance
"""
data = values.of(
{
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = await self._version.page_async(
method="GET", uri=self._uri, params=data
)
return ServicePage(self._version, response)
def get_page(self, target_url: str) -> ServicePage:
"""
Retrieve a specific page of ServiceInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of ServiceInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return ServicePage(self._version, response)
async def get_page_async(self, target_url: str) -> ServicePage:
"""
Asynchronously retrieve a specific page of ServiceInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of ServiceInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return ServicePage(self._version, response)
def get(self, sid: str) -> ServiceContext:
"""
Constructs a ServiceContext
:param sid:
"""
return ServiceContext(self._version, sid=sid)
def __call__(self, sid: str) -> ServiceContext:
"""
Constructs a ServiceContext
:param sid:
"""
return ServiceContext(self._version, sid=sid)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.Sync.ServiceList>"
@@ -0,0 +1,656 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Preview
This is the public Twilio REST API.
NOTE: This class is auto generated by OpenAPI Generator.
https://openapi-generator.tech
Do not edit the class manually.
"""
from datetime import datetime
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
from twilio.base import deserialize, serialize, values
from twilio.base.instance_context import InstanceContext
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.version import Version
from twilio.base.page import Page
from twilio.rest.preview.sync.service.document.document_permission import (
DocumentPermissionList,
)
class DocumentInstance(InstanceResource):
"""
:ivar sid:
:ivar unique_name:
:ivar account_sid:
:ivar service_sid:
:ivar url:
:ivar links:
:ivar revision:
:ivar data:
:ivar date_created:
:ivar date_updated:
:ivar created_by:
"""
def __init__(
self,
version: Version,
payload: Dict[str, Any],
service_sid: str,
sid: Optional[str] = None,
):
super().__init__(version)
self.sid: Optional[str] = payload.get("sid")
self.unique_name: Optional[str] = payload.get("unique_name")
self.account_sid: Optional[str] = payload.get("account_sid")
self.service_sid: Optional[str] = payload.get("service_sid")
self.url: Optional[str] = payload.get("url")
self.links: Optional[Dict[str, object]] = payload.get("links")
self.revision: Optional[str] = payload.get("revision")
self.data: Optional[Dict[str, object]] = payload.get("data")
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_created")
)
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_updated")
)
self.created_by: Optional[str] = payload.get("created_by")
self._solution = {
"service_sid": service_sid,
"sid": sid or self.sid,
}
self._context: Optional[DocumentContext] = None
@property
def _proxy(self) -> "DocumentContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: DocumentContext for this DocumentInstance
"""
if self._context is None:
self._context = DocumentContext(
self._version,
service_sid=self._solution["service_sid"],
sid=self._solution["sid"],
)
return self._context
def delete(self) -> bool:
"""
Deletes the DocumentInstance
:returns: True if delete succeeds, False otherwise
"""
return self._proxy.delete()
async def delete_async(self) -> bool:
"""
Asynchronous coroutine that deletes the DocumentInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._proxy.delete_async()
def fetch(self) -> "DocumentInstance":
"""
Fetch the DocumentInstance
:returns: The fetched DocumentInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "DocumentInstance":
"""
Asynchronous coroutine to fetch the DocumentInstance
:returns: The fetched DocumentInstance
"""
return await self._proxy.fetch_async()
def update(
self, data: object, if_match: Union[str, object] = values.unset
) -> "DocumentInstance":
"""
Update the DocumentInstance
:param data:
:param if_match: The If-Match HTTP request header
:returns: The updated DocumentInstance
"""
return self._proxy.update(
data=data,
if_match=if_match,
)
async def update_async(
self, data: object, if_match: Union[str, object] = values.unset
) -> "DocumentInstance":
"""
Asynchronous coroutine to update the DocumentInstance
:param data:
:param if_match: The If-Match HTTP request header
:returns: The updated DocumentInstance
"""
return await self._proxy.update_async(
data=data,
if_match=if_match,
)
@property
def document_permissions(self) -> DocumentPermissionList:
"""
Access the document_permissions
"""
return self._proxy.document_permissions
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Preview.Sync.DocumentInstance {}>".format(context)
class DocumentContext(InstanceContext):
def __init__(self, version: Version, service_sid: str, sid: str):
"""
Initialize the DocumentContext
:param version: Version that contains the resource
:param service_sid:
:param sid:
"""
super().__init__(version)
# Path Solution
self._solution = {
"service_sid": service_sid,
"sid": sid,
}
self._uri = "/Services/{service_sid}/Documents/{sid}".format(**self._solution)
self._document_permissions: Optional[DocumentPermissionList] = None
def delete(self) -> bool:
"""
Deletes the DocumentInstance
:returns: True if delete succeeds, False otherwise
"""
return self._version.delete(
method="DELETE",
uri=self._uri,
)
async def delete_async(self) -> bool:
"""
Asynchronous coroutine that deletes the DocumentInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._version.delete_async(
method="DELETE",
uri=self._uri,
)
def fetch(self) -> DocumentInstance:
"""
Fetch the DocumentInstance
:returns: The fetched DocumentInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return DocumentInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
sid=self._solution["sid"],
)
async def fetch_async(self) -> DocumentInstance:
"""
Asynchronous coroutine to fetch the DocumentInstance
:returns: The fetched DocumentInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return DocumentInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
sid=self._solution["sid"],
)
def update(
self, data: object, if_match: Union[str, object] = values.unset
) -> DocumentInstance:
"""
Update the DocumentInstance
:param data:
:param if_match: The If-Match HTTP request header
:returns: The updated DocumentInstance
"""
data = values.of(
{
"Data": serialize.object(data),
}
)
headers = values.of(
{
"If-Match": if_match,
}
)
payload = self._version.update(
method="POST", uri=self._uri, data=data, headers=headers
)
return DocumentInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
sid=self._solution["sid"],
)
async def update_async(
self, data: object, if_match: Union[str, object] = values.unset
) -> DocumentInstance:
"""
Asynchronous coroutine to update the DocumentInstance
:param data:
:param if_match: The If-Match HTTP request header
:returns: The updated DocumentInstance
"""
data = values.of(
{
"Data": serialize.object(data),
}
)
headers = values.of(
{
"If-Match": if_match,
}
)
payload = await self._version.update_async(
method="POST", uri=self._uri, data=data, headers=headers
)
return DocumentInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
sid=self._solution["sid"],
)
@property
def document_permissions(self) -> DocumentPermissionList:
"""
Access the document_permissions
"""
if self._document_permissions is None:
self._document_permissions = DocumentPermissionList(
self._version,
self._solution["service_sid"],
self._solution["sid"],
)
return self._document_permissions
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Preview.Sync.DocumentContext {}>".format(context)
class DocumentPage(Page):
def get_instance(self, payload: Dict[str, Any]) -> DocumentInstance:
"""
Build an instance of DocumentInstance
:param payload: Payload response from the API
"""
return DocumentInstance(
self._version, payload, service_sid=self._solution["service_sid"]
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.Sync.DocumentPage>"
class DocumentList(ListResource):
def __init__(self, version: Version, service_sid: str):
"""
Initialize the DocumentList
:param version: Version that contains the resource
:param service_sid:
"""
super().__init__(version)
# Path Solution
self._solution = {
"service_sid": service_sid,
}
self._uri = "/Services/{service_sid}/Documents".format(**self._solution)
def create(
self,
unique_name: Union[str, object] = values.unset,
data: Union[object, object] = values.unset,
) -> DocumentInstance:
"""
Create the DocumentInstance
:param unique_name:
:param data:
:returns: The created DocumentInstance
"""
data = values.of(
{
"UniqueName": unique_name,
"Data": serialize.object(data),
}
)
payload = self._version.create(
method="POST",
uri=self._uri,
data=data,
)
return DocumentInstance(
self._version, payload, service_sid=self._solution["service_sid"]
)
async def create_async(
self,
unique_name: Union[str, object] = values.unset,
data: Union[object, object] = values.unset,
) -> DocumentInstance:
"""
Asynchronously create the DocumentInstance
:param unique_name:
:param data:
:returns: The created DocumentInstance
"""
data = values.of(
{
"UniqueName": unique_name,
"Data": serialize.object(data),
}
)
payload = await self._version.create_async(
method="POST",
uri=self._uri,
data=data,
)
return DocumentInstance(
self._version, payload, service_sid=self._solution["service_sid"]
)
def stream(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[DocumentInstance]:
"""
Streams DocumentInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param limit: Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the
limit with the most efficient page size, i.e. min(limit, 1000)
:returns: Generator that will yield up to limit results
"""
limits = self._version.read_limits(limit, page_size)
page = self.page(page_size=limits["page_size"])
return self._version.stream(page, limits["limit"])
async def stream_async(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> AsyncIterator[DocumentInstance]:
"""
Asynchronously streams DocumentInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param limit: Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the
limit with the most efficient page size, i.e. min(limit, 1000)
:returns: Generator that will yield up to limit results
"""
limits = self._version.read_limits(limit, page_size)
page = await self.page_async(page_size=limits["page_size"])
return self._version.stream_async(page, limits["limit"])
def list(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[DocumentInstance]:
"""
Lists DocumentInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param limit: Upper limit for the number of records to return. list() guarantees
never to return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, list() will attempt to read the limit
with the most efficient page size, i.e. min(limit, 1000)
:returns: list that will contain up to limit results
"""
return list(
self.stream(
limit=limit,
page_size=page_size,
)
)
async def list_async(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[DocumentInstance]:
"""
Asynchronously lists DocumentInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param limit: Upper limit for the number of records to return. list() guarantees
never to return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, list() will attempt to read the limit
with the most efficient page size, i.e. min(limit, 1000)
:returns: list that will contain up to limit results
"""
return [
record
async for record in await self.stream_async(
limit=limit,
page_size=page_size,
)
]
def page(
self,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> DocumentPage:
"""
Retrieve a single page of DocumentInstance records from the API.
Request is executed immediately
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of DocumentInstance
"""
data = values.of(
{
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return DocumentPage(self._version, response, self._solution)
async def page_async(
self,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> DocumentPage:
"""
Asynchronously retrieve a single page of DocumentInstance records from the API.
Request is executed immediately
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of DocumentInstance
"""
data = values.of(
{
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = await self._version.page_async(
method="GET", uri=self._uri, params=data
)
return DocumentPage(self._version, response, self._solution)
def get_page(self, target_url: str) -> DocumentPage:
"""
Retrieve a specific page of DocumentInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of DocumentInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return DocumentPage(self._version, response, self._solution)
async def get_page_async(self, target_url: str) -> DocumentPage:
"""
Asynchronously retrieve a specific page of DocumentInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of DocumentInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return DocumentPage(self._version, response, self._solution)
def get(self, sid: str) -> DocumentContext:
"""
Constructs a DocumentContext
:param sid:
"""
return DocumentContext(
self._version, service_sid=self._solution["service_sid"], sid=sid
)
def __call__(self, sid: str) -> DocumentContext:
"""
Constructs a DocumentContext
:param sid:
"""
return DocumentContext(
self._version, service_sid=self._solution["service_sid"], sid=sid
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.Sync.DocumentList>"
@@ -0,0 +1,592 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Preview
This is the public Twilio REST API.
NOTE: This class is auto generated by OpenAPI Generator.
https://openapi-generator.tech
Do not edit the class manually.
"""
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
from twilio.base import values
from twilio.base.instance_context import InstanceContext
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.version import Version
from twilio.base.page import Page
class DocumentPermissionInstance(InstanceResource):
"""
:ivar account_sid: The unique SID identifier of the Twilio Account.
:ivar service_sid: The unique SID identifier of the Sync Service Instance.
:ivar document_sid: The unique SID identifier of the Sync Document to which the Permission applies.
:ivar identity: Arbitrary string identifier representing a human user associated with an FPA token, assigned by the developer.
:ivar read: Boolean flag specifying whether the identity can read the Sync Document.
:ivar write: Boolean flag specifying whether the identity can update the Sync Document.
:ivar manage: Boolean flag specifying whether the identity can delete the Sync Document.
:ivar url: Contains an absolute URL for this Sync Document Permission.
"""
def __init__(
self,
version: Version,
payload: Dict[str, Any],
service_sid: str,
document_sid: str,
identity: Optional[str] = None,
):
super().__init__(version)
self.account_sid: Optional[str] = payload.get("account_sid")
self.service_sid: Optional[str] = payload.get("service_sid")
self.document_sid: Optional[str] = payload.get("document_sid")
self.identity: Optional[str] = payload.get("identity")
self.read: Optional[bool] = payload.get("read")
self.write: Optional[bool] = payload.get("write")
self.manage: Optional[bool] = payload.get("manage")
self.url: Optional[str] = payload.get("url")
self._solution = {
"service_sid": service_sid,
"document_sid": document_sid,
"identity": identity or self.identity,
}
self._context: Optional[DocumentPermissionContext] = None
@property
def _proxy(self) -> "DocumentPermissionContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: DocumentPermissionContext for this DocumentPermissionInstance
"""
if self._context is None:
self._context = DocumentPermissionContext(
self._version,
service_sid=self._solution["service_sid"],
document_sid=self._solution["document_sid"],
identity=self._solution["identity"],
)
return self._context
def delete(self) -> bool:
"""
Deletes the DocumentPermissionInstance
:returns: True if delete succeeds, False otherwise
"""
return self._proxy.delete()
async def delete_async(self) -> bool:
"""
Asynchronous coroutine that deletes the DocumentPermissionInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._proxy.delete_async()
def fetch(self) -> "DocumentPermissionInstance":
"""
Fetch the DocumentPermissionInstance
:returns: The fetched DocumentPermissionInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "DocumentPermissionInstance":
"""
Asynchronous coroutine to fetch the DocumentPermissionInstance
:returns: The fetched DocumentPermissionInstance
"""
return await self._proxy.fetch_async()
def update(
self, read: bool, write: bool, manage: bool
) -> "DocumentPermissionInstance":
"""
Update the DocumentPermissionInstance
:param read: Boolean flag specifying whether the identity can read the Sync Document.
:param write: Boolean flag specifying whether the identity can update the Sync Document.
:param manage: Boolean flag specifying whether the identity can delete the Sync Document.
:returns: The updated DocumentPermissionInstance
"""
return self._proxy.update(
read=read,
write=write,
manage=manage,
)
async def update_async(
self, read: bool, write: bool, manage: bool
) -> "DocumentPermissionInstance":
"""
Asynchronous coroutine to update the DocumentPermissionInstance
:param read: Boolean flag specifying whether the identity can read the Sync Document.
:param write: Boolean flag specifying whether the identity can update the Sync Document.
:param manage: Boolean flag specifying whether the identity can delete the Sync Document.
:returns: The updated DocumentPermissionInstance
"""
return await self._proxy.update_async(
read=read,
write=write,
manage=manage,
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Preview.Sync.DocumentPermissionInstance {}>".format(context)
class DocumentPermissionContext(InstanceContext):
def __init__(
self, version: Version, service_sid: str, document_sid: str, identity: str
):
"""
Initialize the DocumentPermissionContext
:param version: Version that contains the resource
:param service_sid: The unique SID identifier of the Sync Service Instance.
:param document_sid: Identifier of the Sync Document. Either a SID or a unique name.
:param identity: Arbitrary string identifier representing a human user associated with an FPA token, assigned by the developer.
"""
super().__init__(version)
# Path Solution
self._solution = {
"service_sid": service_sid,
"document_sid": document_sid,
"identity": identity,
}
self._uri = "/Services/{service_sid}/Documents/{document_sid}/Permissions/{identity}".format(
**self._solution
)
def delete(self) -> bool:
"""
Deletes the DocumentPermissionInstance
:returns: True if delete succeeds, False otherwise
"""
return self._version.delete(
method="DELETE",
uri=self._uri,
)
async def delete_async(self) -> bool:
"""
Asynchronous coroutine that deletes the DocumentPermissionInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._version.delete_async(
method="DELETE",
uri=self._uri,
)
def fetch(self) -> DocumentPermissionInstance:
"""
Fetch the DocumentPermissionInstance
:returns: The fetched DocumentPermissionInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return DocumentPermissionInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
document_sid=self._solution["document_sid"],
identity=self._solution["identity"],
)
async def fetch_async(self) -> DocumentPermissionInstance:
"""
Asynchronous coroutine to fetch the DocumentPermissionInstance
:returns: The fetched DocumentPermissionInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return DocumentPermissionInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
document_sid=self._solution["document_sid"],
identity=self._solution["identity"],
)
def update(
self, read: bool, write: bool, manage: bool
) -> DocumentPermissionInstance:
"""
Update the DocumentPermissionInstance
:param read: Boolean flag specifying whether the identity can read the Sync Document.
:param write: Boolean flag specifying whether the identity can update the Sync Document.
:param manage: Boolean flag specifying whether the identity can delete the Sync Document.
:returns: The updated DocumentPermissionInstance
"""
data = values.of(
{
"Read": read,
"Write": write,
"Manage": manage,
}
)
payload = self._version.update(
method="POST",
uri=self._uri,
data=data,
)
return DocumentPermissionInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
document_sid=self._solution["document_sid"],
identity=self._solution["identity"],
)
async def update_async(
self, read: bool, write: bool, manage: bool
) -> DocumentPermissionInstance:
"""
Asynchronous coroutine to update the DocumentPermissionInstance
:param read: Boolean flag specifying whether the identity can read the Sync Document.
:param write: Boolean flag specifying whether the identity can update the Sync Document.
:param manage: Boolean flag specifying whether the identity can delete the Sync Document.
:returns: The updated DocumentPermissionInstance
"""
data = values.of(
{
"Read": read,
"Write": write,
"Manage": manage,
}
)
payload = await self._version.update_async(
method="POST",
uri=self._uri,
data=data,
)
return DocumentPermissionInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
document_sid=self._solution["document_sid"],
identity=self._solution["identity"],
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Preview.Sync.DocumentPermissionContext {}>".format(context)
class DocumentPermissionPage(Page):
def get_instance(self, payload: Dict[str, Any]) -> DocumentPermissionInstance:
"""
Build an instance of DocumentPermissionInstance
:param payload: Payload response from the API
"""
return DocumentPermissionInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
document_sid=self._solution["document_sid"],
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.Sync.DocumentPermissionPage>"
class DocumentPermissionList(ListResource):
def __init__(self, version: Version, service_sid: str, document_sid: str):
"""
Initialize the DocumentPermissionList
:param version: Version that contains the resource
:param service_sid:
:param document_sid: Identifier of the Sync Document. Either a SID or a unique name.
"""
super().__init__(version)
# Path Solution
self._solution = {
"service_sid": service_sid,
"document_sid": document_sid,
}
self._uri = (
"/Services/{service_sid}/Documents/{document_sid}/Permissions".format(
**self._solution
)
)
def stream(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[DocumentPermissionInstance]:
"""
Streams DocumentPermissionInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param limit: Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the
limit with the most efficient page size, i.e. min(limit, 1000)
:returns: Generator that will yield up to limit results
"""
limits = self._version.read_limits(limit, page_size)
page = self.page(page_size=limits["page_size"])
return self._version.stream(page, limits["limit"])
async def stream_async(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> AsyncIterator[DocumentPermissionInstance]:
"""
Asynchronously streams DocumentPermissionInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param limit: Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the
limit with the most efficient page size, i.e. min(limit, 1000)
:returns: Generator that will yield up to limit results
"""
limits = self._version.read_limits(limit, page_size)
page = await self.page_async(page_size=limits["page_size"])
return self._version.stream_async(page, limits["limit"])
def list(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[DocumentPermissionInstance]:
"""
Lists DocumentPermissionInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param limit: Upper limit for the number of records to return. list() guarantees
never to return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, list() will attempt to read the limit
with the most efficient page size, i.e. min(limit, 1000)
:returns: list that will contain up to limit results
"""
return list(
self.stream(
limit=limit,
page_size=page_size,
)
)
async def list_async(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[DocumentPermissionInstance]:
"""
Asynchronously lists DocumentPermissionInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param limit: Upper limit for the number of records to return. list() guarantees
never to return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, list() will attempt to read the limit
with the most efficient page size, i.e. min(limit, 1000)
:returns: list that will contain up to limit results
"""
return [
record
async for record in await self.stream_async(
limit=limit,
page_size=page_size,
)
]
def page(
self,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> DocumentPermissionPage:
"""
Retrieve a single page of DocumentPermissionInstance records from the API.
Request is executed immediately
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of DocumentPermissionInstance
"""
data = values.of(
{
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return DocumentPermissionPage(self._version, response, self._solution)
async def page_async(
self,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> DocumentPermissionPage:
"""
Asynchronously retrieve a single page of DocumentPermissionInstance records from the API.
Request is executed immediately
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of DocumentPermissionInstance
"""
data = values.of(
{
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = await self._version.page_async(
method="GET", uri=self._uri, params=data
)
return DocumentPermissionPage(self._version, response, self._solution)
def get_page(self, target_url: str) -> DocumentPermissionPage:
"""
Retrieve a specific page of DocumentPermissionInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of DocumentPermissionInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return DocumentPermissionPage(self._version, response, self._solution)
async def get_page_async(self, target_url: str) -> DocumentPermissionPage:
"""
Asynchronously retrieve a specific page of DocumentPermissionInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of DocumentPermissionInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return DocumentPermissionPage(self._version, response, self._solution)
def get(self, identity: str) -> DocumentPermissionContext:
"""
Constructs a DocumentPermissionContext
:param identity: Arbitrary string identifier representing a human user associated with an FPA token, assigned by the developer.
"""
return DocumentPermissionContext(
self._version,
service_sid=self._solution["service_sid"],
document_sid=self._solution["document_sid"],
identity=identity,
)
def __call__(self, identity: str) -> DocumentPermissionContext:
"""
Constructs a DocumentPermissionContext
:param identity: Arbitrary string identifier representing a human user associated with an FPA token, assigned by the developer.
"""
return DocumentPermissionContext(
self._version,
service_sid=self._solution["service_sid"],
document_sid=self._solution["document_sid"],
identity=identity,
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.Sync.DocumentPermissionList>"
@@ -0,0 +1,570 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Preview
This is the public Twilio REST API.
NOTE: This class is auto generated by OpenAPI Generator.
https://openapi-generator.tech
Do not edit the class manually.
"""
from datetime import datetime
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
from twilio.base import deserialize, values
from twilio.base.instance_context import InstanceContext
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.version import Version
from twilio.base.page import Page
from twilio.rest.preview.sync.service.sync_list.sync_list_item import SyncListItemList
from twilio.rest.preview.sync.service.sync_list.sync_list_permission import (
SyncListPermissionList,
)
class SyncListInstance(InstanceResource):
"""
:ivar sid:
:ivar unique_name:
:ivar account_sid:
:ivar service_sid:
:ivar url:
:ivar links:
:ivar revision:
:ivar date_created:
:ivar date_updated:
:ivar created_by:
"""
def __init__(
self,
version: Version,
payload: Dict[str, Any],
service_sid: str,
sid: Optional[str] = None,
):
super().__init__(version)
self.sid: Optional[str] = payload.get("sid")
self.unique_name: Optional[str] = payload.get("unique_name")
self.account_sid: Optional[str] = payload.get("account_sid")
self.service_sid: Optional[str] = payload.get("service_sid")
self.url: Optional[str] = payload.get("url")
self.links: Optional[Dict[str, object]] = payload.get("links")
self.revision: Optional[str] = payload.get("revision")
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_created")
)
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_updated")
)
self.created_by: Optional[str] = payload.get("created_by")
self._solution = {
"service_sid": service_sid,
"sid": sid or self.sid,
}
self._context: Optional[SyncListContext] = None
@property
def _proxy(self) -> "SyncListContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: SyncListContext for this SyncListInstance
"""
if self._context is None:
self._context = SyncListContext(
self._version,
service_sid=self._solution["service_sid"],
sid=self._solution["sid"],
)
return self._context
def delete(self) -> bool:
"""
Deletes the SyncListInstance
:returns: True if delete succeeds, False otherwise
"""
return self._proxy.delete()
async def delete_async(self) -> bool:
"""
Asynchronous coroutine that deletes the SyncListInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._proxy.delete_async()
def fetch(self) -> "SyncListInstance":
"""
Fetch the SyncListInstance
:returns: The fetched SyncListInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "SyncListInstance":
"""
Asynchronous coroutine to fetch the SyncListInstance
:returns: The fetched SyncListInstance
"""
return await self._proxy.fetch_async()
@property
def sync_list_items(self) -> SyncListItemList:
"""
Access the sync_list_items
"""
return self._proxy.sync_list_items
@property
def sync_list_permissions(self) -> SyncListPermissionList:
"""
Access the sync_list_permissions
"""
return self._proxy.sync_list_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.Preview.Sync.SyncListInstance {}>".format(context)
class SyncListContext(InstanceContext):
def __init__(self, version: Version, service_sid: str, sid: str):
"""
Initialize the SyncListContext
:param version: Version that contains the resource
:param service_sid:
:param sid:
"""
super().__init__(version)
# Path Solution
self._solution = {
"service_sid": service_sid,
"sid": sid,
}
self._uri = "/Services/{service_sid}/Lists/{sid}".format(**self._solution)
self._sync_list_items: Optional[SyncListItemList] = None
self._sync_list_permissions: Optional[SyncListPermissionList] = None
def delete(self) -> bool:
"""
Deletes the SyncListInstance
: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 SyncListInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._version.delete_async(
method="DELETE",
uri=self._uri,
)
def fetch(self) -> SyncListInstance:
"""
Fetch the SyncListInstance
:returns: The fetched SyncListInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return SyncListInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
sid=self._solution["sid"],
)
async def fetch_async(self) -> SyncListInstance:
"""
Asynchronous coroutine to fetch the SyncListInstance
:returns: The fetched SyncListInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return SyncListInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
sid=self._solution["sid"],
)
@property
def sync_list_items(self) -> SyncListItemList:
"""
Access the sync_list_items
"""
if self._sync_list_items is None:
self._sync_list_items = SyncListItemList(
self._version,
self._solution["service_sid"],
self._solution["sid"],
)
return self._sync_list_items
@property
def sync_list_permissions(self) -> SyncListPermissionList:
"""
Access the sync_list_permissions
"""
if self._sync_list_permissions is None:
self._sync_list_permissions = SyncListPermissionList(
self._version,
self._solution["service_sid"],
self._solution["sid"],
)
return self._sync_list_permissions
def __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.Preview.Sync.SyncListContext {}>".format(context)
class SyncListPage(Page):
def get_instance(self, payload: Dict[str, Any]) -> SyncListInstance:
"""
Build an instance of SyncListInstance
:param payload: Payload response from the API
"""
return SyncListInstance(
self._version, payload, service_sid=self._solution["service_sid"]
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.Sync.SyncListPage>"
class SyncListList(ListResource):
def __init__(self, version: Version, service_sid: str):
"""
Initialize the SyncListList
:param version: Version that contains the resource
:param service_sid:
"""
super().__init__(version)
# Path Solution
self._solution = {
"service_sid": service_sid,
}
self._uri = "/Services/{service_sid}/Lists".format(**self._solution)
def create(
self, unique_name: Union[str, object] = values.unset
) -> SyncListInstance:
"""
Create the SyncListInstance
:param unique_name:
:returns: The created SyncListInstance
"""
data = values.of(
{
"UniqueName": unique_name,
}
)
payload = self._version.create(
method="POST",
uri=self._uri,
data=data,
)
return SyncListInstance(
self._version, payload, service_sid=self._solution["service_sid"]
)
async def create_async(
self, unique_name: Union[str, object] = values.unset
) -> SyncListInstance:
"""
Asynchronously create the SyncListInstance
:param unique_name:
:returns: The created SyncListInstance
"""
data = values.of(
{
"UniqueName": unique_name,
}
)
payload = await self._version.create_async(
method="POST",
uri=self._uri,
data=data,
)
return SyncListInstance(
self._version, payload, service_sid=self._solution["service_sid"]
)
def stream(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[SyncListInstance]:
"""
Streams SyncListInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param limit: Upper limit for the number of records to return. stream()
guarantees to 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[SyncListInstance]:
"""
Asynchronously streams SyncListInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param limit: Upper limit for the number of records to return. stream()
guarantees to 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[SyncListInstance]:
"""
Lists SyncListInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param limit: Upper limit for the number of records to return. list() guarantees
never 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[SyncListInstance]:
"""
Asynchronously lists SyncListInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param limit: Upper limit for the number of records to return. list() guarantees
never 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,
) -> SyncListPage:
"""
Retrieve a single page of SyncListInstance records from the API.
Request is executed immediately
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of SyncListInstance
"""
data = values.of(
{
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return SyncListPage(self._version, response, self._solution)
async def page_async(
self,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> SyncListPage:
"""
Asynchronously retrieve a single page of SyncListInstance records from the API.
Request is executed immediately
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of SyncListInstance
"""
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 SyncListPage(self._version, response, self._solution)
def get_page(self, target_url: str) -> SyncListPage:
"""
Retrieve a specific page of SyncListInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of SyncListInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return SyncListPage(self._version, response, self._solution)
async def get_page_async(self, target_url: str) -> SyncListPage:
"""
Asynchronously retrieve a specific page of SyncListInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of SyncListInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return SyncListPage(self._version, response, self._solution)
def get(self, sid: str) -> SyncListContext:
"""
Constructs a SyncListContext
:param sid:
"""
return SyncListContext(
self._version, service_sid=self._solution["service_sid"], sid=sid
)
def __call__(self, sid: str) -> SyncListContext:
"""
Constructs a SyncListContext
:param sid:
"""
return SyncListContext(
self._version, service_sid=self._solution["service_sid"], sid=sid
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.Sync.SyncListList>"
@@ -0,0 +1,722 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Preview
This is the public Twilio REST API.
NOTE: This class is auto generated by OpenAPI Generator.
https://openapi-generator.tech
Do not edit the class manually.
"""
from datetime import datetime
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
from twilio.base import deserialize, serialize, values
from twilio.base.instance_context import InstanceContext
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.version import Version
from twilio.base.page import Page
class SyncListItemInstance(InstanceResource):
class QueryFromBoundType(object):
INCLUSIVE = "inclusive"
EXCLUSIVE = "exclusive"
class QueryResultOrder(object):
ASC = "asc"
DESC = "desc"
"""
:ivar index:
:ivar account_sid:
:ivar service_sid:
:ivar list_sid:
:ivar url:
:ivar revision:
:ivar data:
:ivar date_created:
:ivar date_updated:
:ivar created_by:
"""
def __init__(
self,
version: Version,
payload: Dict[str, Any],
service_sid: str,
list_sid: str,
index: Optional[int] = None,
):
super().__init__(version)
self.index: Optional[int] = deserialize.integer(payload.get("index"))
self.account_sid: Optional[str] = payload.get("account_sid")
self.service_sid: Optional[str] = payload.get("service_sid")
self.list_sid: Optional[str] = payload.get("list_sid")
self.url: Optional[str] = payload.get("url")
self.revision: Optional[str] = payload.get("revision")
self.data: Optional[Dict[str, object]] = payload.get("data")
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_created")
)
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_updated")
)
self.created_by: Optional[str] = payload.get("created_by")
self._solution = {
"service_sid": service_sid,
"list_sid": list_sid,
"index": index or self.index,
}
self._context: Optional[SyncListItemContext] = None
@property
def _proxy(self) -> "SyncListItemContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: SyncListItemContext for this SyncListItemInstance
"""
if self._context is None:
self._context = SyncListItemContext(
self._version,
service_sid=self._solution["service_sid"],
list_sid=self._solution["list_sid"],
index=self._solution["index"],
)
return self._context
def delete(self, if_match: Union[str, object] = values.unset) -> bool:
"""
Deletes the SyncListItemInstance
:param if_match: The If-Match HTTP request header
:returns: True if delete succeeds, False otherwise
"""
return self._proxy.delete(
if_match=if_match,
)
async def delete_async(self, if_match: Union[str, object] = values.unset) -> bool:
"""
Asynchronous coroutine that deletes the SyncListItemInstance
:param if_match: The If-Match HTTP request header
:returns: True if delete succeeds, False otherwise
"""
return await self._proxy.delete_async(
if_match=if_match,
)
def fetch(self) -> "SyncListItemInstance":
"""
Fetch the SyncListItemInstance
:returns: The fetched SyncListItemInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "SyncListItemInstance":
"""
Asynchronous coroutine to fetch the SyncListItemInstance
:returns: The fetched SyncListItemInstance
"""
return await self._proxy.fetch_async()
def update(
self, data: object, if_match: Union[str, object] = values.unset
) -> "SyncListItemInstance":
"""
Update the SyncListItemInstance
:param data:
:param if_match: The If-Match HTTP request header
:returns: The updated SyncListItemInstance
"""
return self._proxy.update(
data=data,
if_match=if_match,
)
async def update_async(
self, data: object, if_match: Union[str, object] = values.unset
) -> "SyncListItemInstance":
"""
Asynchronous coroutine to update the SyncListItemInstance
:param data:
:param if_match: The If-Match HTTP request header
:returns: The updated SyncListItemInstance
"""
return await self._proxy.update_async(
data=data,
if_match=if_match,
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Preview.Sync.SyncListItemInstance {}>".format(context)
class SyncListItemContext(InstanceContext):
def __init__(self, version: Version, service_sid: str, list_sid: str, index: int):
"""
Initialize the SyncListItemContext
:param version: Version that contains the resource
:param service_sid:
:param list_sid:
:param index:
"""
super().__init__(version)
# Path Solution
self._solution = {
"service_sid": service_sid,
"list_sid": list_sid,
"index": index,
}
self._uri = "/Services/{service_sid}/Lists/{list_sid}/Items/{index}".format(
**self._solution
)
def delete(self, if_match: Union[str, object] = values.unset) -> bool:
"""
Deletes the SyncListItemInstance
:param if_match: The If-Match HTTP request header
:returns: True if delete succeeds, False otherwise
"""
headers = values.of(
{
"If-Match": if_match,
}
)
return self._version.delete(method="DELETE", uri=self._uri, headers=headers)
async def delete_async(self, if_match: Union[str, object] = values.unset) -> bool:
"""
Asynchronous coroutine that deletes the SyncListItemInstance
:param if_match: The If-Match HTTP request header
:returns: True if delete succeeds, False otherwise
"""
headers = values.of(
{
"If-Match": if_match,
}
)
return await self._version.delete_async(
method="DELETE", uri=self._uri, headers=headers
)
def fetch(self) -> SyncListItemInstance:
"""
Fetch the SyncListItemInstance
:returns: The fetched SyncListItemInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return SyncListItemInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
list_sid=self._solution["list_sid"],
index=self._solution["index"],
)
async def fetch_async(self) -> SyncListItemInstance:
"""
Asynchronous coroutine to fetch the SyncListItemInstance
:returns: The fetched SyncListItemInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return SyncListItemInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
list_sid=self._solution["list_sid"],
index=self._solution["index"],
)
def update(
self, data: object, if_match: Union[str, object] = values.unset
) -> SyncListItemInstance:
"""
Update the SyncListItemInstance
:param data:
:param if_match: The If-Match HTTP request header
:returns: The updated SyncListItemInstance
"""
data = values.of(
{
"Data": serialize.object(data),
}
)
headers = values.of(
{
"If-Match": if_match,
}
)
payload = self._version.update(
method="POST", uri=self._uri, data=data, headers=headers
)
return SyncListItemInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
list_sid=self._solution["list_sid"],
index=self._solution["index"],
)
async def update_async(
self, data: object, if_match: Union[str, object] = values.unset
) -> SyncListItemInstance:
"""
Asynchronous coroutine to update the SyncListItemInstance
:param data:
:param if_match: The If-Match HTTP request header
:returns: The updated SyncListItemInstance
"""
data = values.of(
{
"Data": serialize.object(data),
}
)
headers = values.of(
{
"If-Match": if_match,
}
)
payload = await self._version.update_async(
method="POST", uri=self._uri, data=data, headers=headers
)
return SyncListItemInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
list_sid=self._solution["list_sid"],
index=self._solution["index"],
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Preview.Sync.SyncListItemContext {}>".format(context)
class SyncListItemPage(Page):
def get_instance(self, payload: Dict[str, Any]) -> SyncListItemInstance:
"""
Build an instance of SyncListItemInstance
:param payload: Payload response from the API
"""
return SyncListItemInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
list_sid=self._solution["list_sid"],
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.Sync.SyncListItemPage>"
class SyncListItemList(ListResource):
def __init__(self, version: Version, service_sid: str, list_sid: str):
"""
Initialize the SyncListItemList
:param version: Version that contains the resource
:param service_sid:
:param list_sid:
"""
super().__init__(version)
# Path Solution
self._solution = {
"service_sid": service_sid,
"list_sid": list_sid,
}
self._uri = "/Services/{service_sid}/Lists/{list_sid}/Items".format(
**self._solution
)
def create(self, data: object) -> SyncListItemInstance:
"""
Create the SyncListItemInstance
:param data:
:returns: The created SyncListItemInstance
"""
data = values.of(
{
"Data": serialize.object(data),
}
)
payload = self._version.create(
method="POST",
uri=self._uri,
data=data,
)
return SyncListItemInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
list_sid=self._solution["list_sid"],
)
async def create_async(self, data: object) -> SyncListItemInstance:
"""
Asynchronously create the SyncListItemInstance
:param data:
:returns: The created SyncListItemInstance
"""
data = values.of(
{
"Data": serialize.object(data),
}
)
payload = await self._version.create_async(
method="POST",
uri=self._uri,
data=data,
)
return SyncListItemInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
list_sid=self._solution["list_sid"],
)
def stream(
self,
order: Union["SyncListItemInstance.QueryResultOrder", object] = values.unset,
from_: Union[str, object] = values.unset,
bounds: Union["SyncListItemInstance.QueryFromBoundType", object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[SyncListItemInstance]:
"""
Streams SyncListItemInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param &quot;SyncListItemInstance.QueryResultOrder&quot; order:
:param str from_:
:param &quot;SyncListItemInstance.QueryFromBoundType&quot; bounds:
:param limit: Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the
limit with the most efficient page size, i.e. min(limit, 1000)
:returns: Generator that will yield up to limit results
"""
limits = self._version.read_limits(limit, page_size)
page = self.page(
order=order, from_=from_, bounds=bounds, page_size=limits["page_size"]
)
return self._version.stream(page, limits["limit"])
async def stream_async(
self,
order: Union["SyncListItemInstance.QueryResultOrder", object] = values.unset,
from_: Union[str, object] = values.unset,
bounds: Union["SyncListItemInstance.QueryFromBoundType", object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> AsyncIterator[SyncListItemInstance]:
"""
Asynchronously streams SyncListItemInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param &quot;SyncListItemInstance.QueryResultOrder&quot; order:
:param str from_:
:param &quot;SyncListItemInstance.QueryFromBoundType&quot; bounds:
:param limit: Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the
limit with the most efficient page size, i.e. min(limit, 1000)
:returns: Generator that will yield up to limit results
"""
limits = self._version.read_limits(limit, page_size)
page = await self.page_async(
order=order, from_=from_, bounds=bounds, page_size=limits["page_size"]
)
return self._version.stream_async(page, limits["limit"])
def list(
self,
order: Union["SyncListItemInstance.QueryResultOrder", object] = values.unset,
from_: Union[str, object] = values.unset,
bounds: Union["SyncListItemInstance.QueryFromBoundType", object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[SyncListItemInstance]:
"""
Lists SyncListItemInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param &quot;SyncListItemInstance.QueryResultOrder&quot; order:
:param str from_:
:param &quot;SyncListItemInstance.QueryFromBoundType&quot; bounds:
:param limit: Upper limit for the number of records to return. list() guarantees
never to return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, list() will attempt to read the limit
with the most efficient page size, i.e. min(limit, 1000)
:returns: list that will contain up to limit results
"""
return list(
self.stream(
order=order,
from_=from_,
bounds=bounds,
limit=limit,
page_size=page_size,
)
)
async def list_async(
self,
order: Union["SyncListItemInstance.QueryResultOrder", object] = values.unset,
from_: Union[str, object] = values.unset,
bounds: Union["SyncListItemInstance.QueryFromBoundType", object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[SyncListItemInstance]:
"""
Asynchronously lists SyncListItemInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param &quot;SyncListItemInstance.QueryResultOrder&quot; order:
:param str from_:
:param &quot;SyncListItemInstance.QueryFromBoundType&quot; bounds:
:param limit: Upper limit for the number of records to return. list() guarantees
never to return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, list() will attempt to read the limit
with the most efficient page size, i.e. min(limit, 1000)
:returns: list that will contain up to limit results
"""
return [
record
async for record in await self.stream_async(
order=order,
from_=from_,
bounds=bounds,
limit=limit,
page_size=page_size,
)
]
def page(
self,
order: Union["SyncListItemInstance.QueryResultOrder", object] = values.unset,
from_: Union[str, object] = values.unset,
bounds: Union["SyncListItemInstance.QueryFromBoundType", object] = values.unset,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> SyncListItemPage:
"""
Retrieve a single page of SyncListItemInstance records from the API.
Request is executed immediately
:param order:
:param from_:
:param bounds:
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of SyncListItemInstance
"""
data = values.of(
{
"Order": order,
"From": from_,
"Bounds": bounds,
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return SyncListItemPage(self._version, response, self._solution)
async def page_async(
self,
order: Union["SyncListItemInstance.QueryResultOrder", object] = values.unset,
from_: Union[str, object] = values.unset,
bounds: Union["SyncListItemInstance.QueryFromBoundType", object] = values.unset,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> SyncListItemPage:
"""
Asynchronously retrieve a single page of SyncListItemInstance records from the API.
Request is executed immediately
:param order:
:param from_:
:param bounds:
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of SyncListItemInstance
"""
data = values.of(
{
"Order": order,
"From": from_,
"Bounds": bounds,
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = await self._version.page_async(
method="GET", uri=self._uri, params=data
)
return SyncListItemPage(self._version, response, self._solution)
def get_page(self, target_url: str) -> SyncListItemPage:
"""
Retrieve a specific page of SyncListItemInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of SyncListItemInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return SyncListItemPage(self._version, response, self._solution)
async def get_page_async(self, target_url: str) -> SyncListItemPage:
"""
Asynchronously retrieve a specific page of SyncListItemInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of SyncListItemInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return SyncListItemPage(self._version, response, self._solution)
def get(self, index: int) -> SyncListItemContext:
"""
Constructs a SyncListItemContext
:param index:
"""
return SyncListItemContext(
self._version,
service_sid=self._solution["service_sid"],
list_sid=self._solution["list_sid"],
index=index,
)
def __call__(self, index: int) -> SyncListItemContext:
"""
Constructs a SyncListItemContext
:param index:
"""
return SyncListItemContext(
self._version,
service_sid=self._solution["service_sid"],
list_sid=self._solution["list_sid"],
index=index,
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.Sync.SyncListItemList>"
@@ -0,0 +1,592 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Preview
This is the public Twilio REST API.
NOTE: This class is auto generated by OpenAPI Generator.
https://openapi-generator.tech
Do not edit the class manually.
"""
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
from twilio.base import values
from twilio.base.instance_context import InstanceContext
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.version import Version
from twilio.base.page import Page
class SyncListPermissionInstance(InstanceResource):
"""
:ivar account_sid: The unique SID identifier of the Twilio Account.
:ivar service_sid: The unique SID identifier of the Sync Service Instance.
:ivar list_sid: The unique SID identifier of the Sync List to which the Permission applies.
:ivar identity: Arbitrary string identifier representing a human user associated with an FPA token, assigned by the developer.
:ivar read: Boolean flag specifying whether the identity can read the Sync List and its Items.
:ivar write: Boolean flag specifying whether the identity can create, update and delete Items of the Sync List.
:ivar manage: Boolean flag specifying whether the identity can delete the Sync List.
:ivar url: Contains an absolute URL for this Sync List Permission.
"""
def __init__(
self,
version: Version,
payload: Dict[str, Any],
service_sid: str,
list_sid: str,
identity: Optional[str] = None,
):
super().__init__(version)
self.account_sid: Optional[str] = payload.get("account_sid")
self.service_sid: Optional[str] = payload.get("service_sid")
self.list_sid: Optional[str] = payload.get("list_sid")
self.identity: Optional[str] = payload.get("identity")
self.read: Optional[bool] = payload.get("read")
self.write: Optional[bool] = payload.get("write")
self.manage: Optional[bool] = payload.get("manage")
self.url: Optional[str] = payload.get("url")
self._solution = {
"service_sid": service_sid,
"list_sid": list_sid,
"identity": identity or self.identity,
}
self._context: Optional[SyncListPermissionContext] = None
@property
def _proxy(self) -> "SyncListPermissionContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: SyncListPermissionContext for this SyncListPermissionInstance
"""
if self._context is None:
self._context = SyncListPermissionContext(
self._version,
service_sid=self._solution["service_sid"],
list_sid=self._solution["list_sid"],
identity=self._solution["identity"],
)
return self._context
def delete(self) -> bool:
"""
Deletes the SyncListPermissionInstance
:returns: True if delete succeeds, False otherwise
"""
return self._proxy.delete()
async def delete_async(self) -> bool:
"""
Asynchronous coroutine that deletes the SyncListPermissionInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._proxy.delete_async()
def fetch(self) -> "SyncListPermissionInstance":
"""
Fetch the SyncListPermissionInstance
:returns: The fetched SyncListPermissionInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "SyncListPermissionInstance":
"""
Asynchronous coroutine to fetch the SyncListPermissionInstance
:returns: The fetched SyncListPermissionInstance
"""
return await self._proxy.fetch_async()
def update(
self, read: bool, write: bool, manage: bool
) -> "SyncListPermissionInstance":
"""
Update the SyncListPermissionInstance
:param read: Boolean flag specifying whether the identity can read the Sync List.
:param write: Boolean flag specifying whether the identity can create, update and delete Items of the Sync List.
:param manage: Boolean flag specifying whether the identity can delete the Sync List.
:returns: The updated SyncListPermissionInstance
"""
return self._proxy.update(
read=read,
write=write,
manage=manage,
)
async def update_async(
self, read: bool, write: bool, manage: bool
) -> "SyncListPermissionInstance":
"""
Asynchronous coroutine to update the SyncListPermissionInstance
:param read: Boolean flag specifying whether the identity can read the Sync List.
:param write: Boolean flag specifying whether the identity can create, update and delete Items of the Sync List.
:param manage: Boolean flag specifying whether the identity can delete the Sync List.
:returns: The updated SyncListPermissionInstance
"""
return await self._proxy.update_async(
read=read,
write=write,
manage=manage,
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Preview.Sync.SyncListPermissionInstance {}>".format(context)
class SyncListPermissionContext(InstanceContext):
def __init__(
self, version: Version, service_sid: str, list_sid: str, identity: str
):
"""
Initialize the SyncListPermissionContext
:param version: Version that contains the resource
:param service_sid: The unique SID identifier of the Sync Service Instance.
:param list_sid: Identifier of the Sync List. Either a SID or a unique name.
:param identity: Arbitrary string identifier representing a human user associated with an FPA token, assigned by the developer.
"""
super().__init__(version)
# Path Solution
self._solution = {
"service_sid": service_sid,
"list_sid": list_sid,
"identity": identity,
}
self._uri = (
"/Services/{service_sid}/Lists/{list_sid}/Permissions/{identity}".format(
**self._solution
)
)
def delete(self) -> bool:
"""
Deletes the SyncListPermissionInstance
:returns: True if delete succeeds, False otherwise
"""
return self._version.delete(
method="DELETE",
uri=self._uri,
)
async def delete_async(self) -> bool:
"""
Asynchronous coroutine that deletes the SyncListPermissionInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._version.delete_async(
method="DELETE",
uri=self._uri,
)
def fetch(self) -> SyncListPermissionInstance:
"""
Fetch the SyncListPermissionInstance
:returns: The fetched SyncListPermissionInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return SyncListPermissionInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
list_sid=self._solution["list_sid"],
identity=self._solution["identity"],
)
async def fetch_async(self) -> SyncListPermissionInstance:
"""
Asynchronous coroutine to fetch the SyncListPermissionInstance
:returns: The fetched SyncListPermissionInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return SyncListPermissionInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
list_sid=self._solution["list_sid"],
identity=self._solution["identity"],
)
def update(
self, read: bool, write: bool, manage: bool
) -> SyncListPermissionInstance:
"""
Update the SyncListPermissionInstance
:param read: Boolean flag specifying whether the identity can read the Sync List.
:param write: Boolean flag specifying whether the identity can create, update and delete Items of the Sync List.
:param manage: Boolean flag specifying whether the identity can delete the Sync List.
:returns: The updated SyncListPermissionInstance
"""
data = values.of(
{
"Read": read,
"Write": write,
"Manage": manage,
}
)
payload = self._version.update(
method="POST",
uri=self._uri,
data=data,
)
return SyncListPermissionInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
list_sid=self._solution["list_sid"],
identity=self._solution["identity"],
)
async def update_async(
self, read: bool, write: bool, manage: bool
) -> SyncListPermissionInstance:
"""
Asynchronous coroutine to update the SyncListPermissionInstance
:param read: Boolean flag specifying whether the identity can read the Sync List.
:param write: Boolean flag specifying whether the identity can create, update and delete Items of the Sync List.
:param manage: Boolean flag specifying whether the identity can delete the Sync List.
:returns: The updated SyncListPermissionInstance
"""
data = values.of(
{
"Read": read,
"Write": write,
"Manage": manage,
}
)
payload = await self._version.update_async(
method="POST",
uri=self._uri,
data=data,
)
return SyncListPermissionInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
list_sid=self._solution["list_sid"],
identity=self._solution["identity"],
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Preview.Sync.SyncListPermissionContext {}>".format(context)
class SyncListPermissionPage(Page):
def get_instance(self, payload: Dict[str, Any]) -> SyncListPermissionInstance:
"""
Build an instance of SyncListPermissionInstance
:param payload: Payload response from the API
"""
return SyncListPermissionInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
list_sid=self._solution["list_sid"],
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.Sync.SyncListPermissionPage>"
class SyncListPermissionList(ListResource):
def __init__(self, version: Version, service_sid: str, list_sid: str):
"""
Initialize the SyncListPermissionList
:param version: Version that contains the resource
:param service_sid:
:param list_sid: Identifier of the Sync List. Either a SID or a unique name.
"""
super().__init__(version)
# Path Solution
self._solution = {
"service_sid": service_sid,
"list_sid": list_sid,
}
self._uri = "/Services/{service_sid}/Lists/{list_sid}/Permissions".format(
**self._solution
)
def stream(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[SyncListPermissionInstance]:
"""
Streams SyncListPermissionInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param limit: Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the
limit with the most efficient page size, i.e. min(limit, 1000)
:returns: Generator that will yield up to limit results
"""
limits = self._version.read_limits(limit, page_size)
page = self.page(page_size=limits["page_size"])
return self._version.stream(page, limits["limit"])
async def stream_async(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> AsyncIterator[SyncListPermissionInstance]:
"""
Asynchronously streams SyncListPermissionInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param limit: Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the
limit with the most efficient page size, i.e. min(limit, 1000)
:returns: Generator that will yield up to limit results
"""
limits = self._version.read_limits(limit, page_size)
page = await self.page_async(page_size=limits["page_size"])
return self._version.stream_async(page, limits["limit"])
def list(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[SyncListPermissionInstance]:
"""
Lists SyncListPermissionInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param limit: Upper limit for the number of records to return. list() guarantees
never to return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, list() will attempt to read the limit
with the most efficient page size, i.e. min(limit, 1000)
:returns: list that will contain up to limit results
"""
return list(
self.stream(
limit=limit,
page_size=page_size,
)
)
async def list_async(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[SyncListPermissionInstance]:
"""
Asynchronously lists SyncListPermissionInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param limit: Upper limit for the number of records to return. list() guarantees
never to return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, list() will attempt to read the limit
with the most efficient page size, i.e. min(limit, 1000)
:returns: list that will contain up to limit results
"""
return [
record
async for record in await self.stream_async(
limit=limit,
page_size=page_size,
)
]
def page(
self,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> SyncListPermissionPage:
"""
Retrieve a single page of SyncListPermissionInstance records from the API.
Request is executed immediately
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of SyncListPermissionInstance
"""
data = values.of(
{
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return SyncListPermissionPage(self._version, response, self._solution)
async def page_async(
self,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> SyncListPermissionPage:
"""
Asynchronously retrieve a single page of SyncListPermissionInstance records from the API.
Request is executed immediately
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of SyncListPermissionInstance
"""
data = values.of(
{
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = await self._version.page_async(
method="GET", uri=self._uri, params=data
)
return SyncListPermissionPage(self._version, response, self._solution)
def get_page(self, target_url: str) -> SyncListPermissionPage:
"""
Retrieve a specific page of SyncListPermissionInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of SyncListPermissionInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return SyncListPermissionPage(self._version, response, self._solution)
async def get_page_async(self, target_url: str) -> SyncListPermissionPage:
"""
Asynchronously retrieve a specific page of SyncListPermissionInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of SyncListPermissionInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return SyncListPermissionPage(self._version, response, self._solution)
def get(self, identity: str) -> SyncListPermissionContext:
"""
Constructs a SyncListPermissionContext
:param identity: Arbitrary string identifier representing a human user associated with an FPA token, assigned by the developer.
"""
return SyncListPermissionContext(
self._version,
service_sid=self._solution["service_sid"],
list_sid=self._solution["list_sid"],
identity=identity,
)
def __call__(self, identity: str) -> SyncListPermissionContext:
"""
Constructs a SyncListPermissionContext
:param identity: Arbitrary string identifier representing a human user associated with an FPA token, assigned by the developer.
"""
return SyncListPermissionContext(
self._version,
service_sid=self._solution["service_sid"],
list_sid=self._solution["list_sid"],
identity=identity,
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.Sync.SyncListPermissionList>"
@@ -0,0 +1,568 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Preview
This is the public Twilio REST API.
NOTE: This class is auto generated by OpenAPI Generator.
https://openapi-generator.tech
Do not edit the class manually.
"""
from datetime import datetime
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
from twilio.base import deserialize, values
from twilio.base.instance_context import InstanceContext
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.version import Version
from twilio.base.page import Page
from twilio.rest.preview.sync.service.sync_map.sync_map_item import SyncMapItemList
from twilio.rest.preview.sync.service.sync_map.sync_map_permission import (
SyncMapPermissionList,
)
class SyncMapInstance(InstanceResource):
"""
:ivar sid:
:ivar unique_name:
:ivar account_sid:
:ivar service_sid:
:ivar url:
:ivar links:
:ivar revision:
:ivar date_created:
:ivar date_updated:
:ivar created_by:
"""
def __init__(
self,
version: Version,
payload: Dict[str, Any],
service_sid: str,
sid: Optional[str] = None,
):
super().__init__(version)
self.sid: Optional[str] = payload.get("sid")
self.unique_name: Optional[str] = payload.get("unique_name")
self.account_sid: Optional[str] = payload.get("account_sid")
self.service_sid: Optional[str] = payload.get("service_sid")
self.url: Optional[str] = payload.get("url")
self.links: Optional[Dict[str, object]] = payload.get("links")
self.revision: Optional[str] = payload.get("revision")
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_created")
)
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_updated")
)
self.created_by: Optional[str] = payload.get("created_by")
self._solution = {
"service_sid": service_sid,
"sid": sid or self.sid,
}
self._context: Optional[SyncMapContext] = None
@property
def _proxy(self) -> "SyncMapContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: SyncMapContext for this SyncMapInstance
"""
if self._context is None:
self._context = SyncMapContext(
self._version,
service_sid=self._solution["service_sid"],
sid=self._solution["sid"],
)
return self._context
def delete(self) -> bool:
"""
Deletes the SyncMapInstance
:returns: True if delete succeeds, False otherwise
"""
return self._proxy.delete()
async def delete_async(self) -> bool:
"""
Asynchronous coroutine that deletes the SyncMapInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._proxy.delete_async()
def fetch(self) -> "SyncMapInstance":
"""
Fetch the SyncMapInstance
:returns: The fetched SyncMapInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "SyncMapInstance":
"""
Asynchronous coroutine to fetch the SyncMapInstance
:returns: The fetched SyncMapInstance
"""
return await self._proxy.fetch_async()
@property
def sync_map_items(self) -> SyncMapItemList:
"""
Access the sync_map_items
"""
return self._proxy.sync_map_items
@property
def sync_map_permissions(self) -> SyncMapPermissionList:
"""
Access the sync_map_permissions
"""
return self._proxy.sync_map_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.Preview.Sync.SyncMapInstance {}>".format(context)
class SyncMapContext(InstanceContext):
def __init__(self, version: Version, service_sid: str, sid: str):
"""
Initialize the SyncMapContext
:param version: Version that contains the resource
:param service_sid:
:param sid:
"""
super().__init__(version)
# Path Solution
self._solution = {
"service_sid": service_sid,
"sid": sid,
}
self._uri = "/Services/{service_sid}/Maps/{sid}".format(**self._solution)
self._sync_map_items: Optional[SyncMapItemList] = None
self._sync_map_permissions: Optional[SyncMapPermissionList] = None
def delete(self) -> bool:
"""
Deletes the SyncMapInstance
: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 SyncMapInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._version.delete_async(
method="DELETE",
uri=self._uri,
)
def fetch(self) -> SyncMapInstance:
"""
Fetch the SyncMapInstance
:returns: The fetched SyncMapInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return SyncMapInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
sid=self._solution["sid"],
)
async def fetch_async(self) -> SyncMapInstance:
"""
Asynchronous coroutine to fetch the SyncMapInstance
:returns: The fetched SyncMapInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return SyncMapInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
sid=self._solution["sid"],
)
@property
def sync_map_items(self) -> SyncMapItemList:
"""
Access the sync_map_items
"""
if self._sync_map_items is None:
self._sync_map_items = SyncMapItemList(
self._version,
self._solution["service_sid"],
self._solution["sid"],
)
return self._sync_map_items
@property
def sync_map_permissions(self) -> SyncMapPermissionList:
"""
Access the sync_map_permissions
"""
if self._sync_map_permissions is None:
self._sync_map_permissions = SyncMapPermissionList(
self._version,
self._solution["service_sid"],
self._solution["sid"],
)
return self._sync_map_permissions
def __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.Preview.Sync.SyncMapContext {}>".format(context)
class SyncMapPage(Page):
def get_instance(self, payload: Dict[str, Any]) -> SyncMapInstance:
"""
Build an instance of SyncMapInstance
:param payload: Payload response from the API
"""
return SyncMapInstance(
self._version, payload, service_sid=self._solution["service_sid"]
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.Sync.SyncMapPage>"
class SyncMapList(ListResource):
def __init__(self, version: Version, service_sid: str):
"""
Initialize the SyncMapList
:param version: Version that contains the resource
:param service_sid:
"""
super().__init__(version)
# Path Solution
self._solution = {
"service_sid": service_sid,
}
self._uri = "/Services/{service_sid}/Maps".format(**self._solution)
def create(self, unique_name: Union[str, object] = values.unset) -> SyncMapInstance:
"""
Create the SyncMapInstance
:param unique_name:
:returns: The created SyncMapInstance
"""
data = values.of(
{
"UniqueName": unique_name,
}
)
payload = self._version.create(
method="POST",
uri=self._uri,
data=data,
)
return SyncMapInstance(
self._version, payload, service_sid=self._solution["service_sid"]
)
async def create_async(
self, unique_name: Union[str, object] = values.unset
) -> SyncMapInstance:
"""
Asynchronously create the SyncMapInstance
:param unique_name:
:returns: The created SyncMapInstance
"""
data = values.of(
{
"UniqueName": unique_name,
}
)
payload = await self._version.create_async(
method="POST",
uri=self._uri,
data=data,
)
return SyncMapInstance(
self._version, payload, service_sid=self._solution["service_sid"]
)
def stream(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[SyncMapInstance]:
"""
Streams SyncMapInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param limit: Upper limit for the number of records to return. stream()
guarantees to 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[SyncMapInstance]:
"""
Asynchronously streams SyncMapInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param limit: Upper limit for the number of records to return. stream()
guarantees to 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[SyncMapInstance]:
"""
Lists SyncMapInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param limit: Upper limit for the number of records to return. list() guarantees
never 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[SyncMapInstance]:
"""
Asynchronously lists SyncMapInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param limit: Upper limit for the number of records to return. list() guarantees
never 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,
) -> SyncMapPage:
"""
Retrieve a single page of SyncMapInstance records from the API.
Request is executed immediately
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of SyncMapInstance
"""
data = values.of(
{
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return SyncMapPage(self._version, response, self._solution)
async def page_async(
self,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> SyncMapPage:
"""
Asynchronously retrieve a single page of SyncMapInstance records from the API.
Request is executed immediately
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of SyncMapInstance
"""
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 SyncMapPage(self._version, response, self._solution)
def get_page(self, target_url: str) -> SyncMapPage:
"""
Retrieve a specific page of SyncMapInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of SyncMapInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return SyncMapPage(self._version, response, self._solution)
async def get_page_async(self, target_url: str) -> SyncMapPage:
"""
Asynchronously retrieve a specific page of SyncMapInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of SyncMapInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return SyncMapPage(self._version, response, self._solution)
def get(self, sid: str) -> SyncMapContext:
"""
Constructs a SyncMapContext
:param sid:
"""
return SyncMapContext(
self._version, service_sid=self._solution["service_sid"], sid=sid
)
def __call__(self, sid: str) -> SyncMapContext:
"""
Constructs a SyncMapContext
:param sid:
"""
return SyncMapContext(
self._version, service_sid=self._solution["service_sid"], sid=sid
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.Sync.SyncMapList>"
@@ -0,0 +1,726 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Preview
This is the public Twilio REST API.
NOTE: This class is auto generated by OpenAPI Generator.
https://openapi-generator.tech
Do not edit the class manually.
"""
from datetime import datetime
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
from twilio.base import deserialize, serialize, values
from twilio.base.instance_context import InstanceContext
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.version import Version
from twilio.base.page import Page
class SyncMapItemInstance(InstanceResource):
class QueryFromBoundType(object):
INCLUSIVE = "inclusive"
EXCLUSIVE = "exclusive"
class QueryResultOrder(object):
ASC = "asc"
DESC = "desc"
"""
:ivar key:
:ivar account_sid:
:ivar service_sid:
:ivar map_sid:
:ivar url:
:ivar revision:
:ivar data:
:ivar date_created:
:ivar date_updated:
:ivar created_by:
"""
def __init__(
self,
version: Version,
payload: Dict[str, Any],
service_sid: str,
map_sid: str,
key: Optional[str] = None,
):
super().__init__(version)
self.key: Optional[str] = payload.get("key")
self.account_sid: Optional[str] = payload.get("account_sid")
self.service_sid: Optional[str] = payload.get("service_sid")
self.map_sid: Optional[str] = payload.get("map_sid")
self.url: Optional[str] = payload.get("url")
self.revision: Optional[str] = payload.get("revision")
self.data: Optional[Dict[str, object]] = payload.get("data")
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_created")
)
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_updated")
)
self.created_by: Optional[str] = payload.get("created_by")
self._solution = {
"service_sid": service_sid,
"map_sid": map_sid,
"key": key or self.key,
}
self._context: Optional[SyncMapItemContext] = None
@property
def _proxy(self) -> "SyncMapItemContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: SyncMapItemContext for this SyncMapItemInstance
"""
if self._context is None:
self._context = SyncMapItemContext(
self._version,
service_sid=self._solution["service_sid"],
map_sid=self._solution["map_sid"],
key=self._solution["key"],
)
return self._context
def delete(self, if_match: Union[str, object] = values.unset) -> bool:
"""
Deletes the SyncMapItemInstance
:param if_match: The If-Match HTTP request header
:returns: True if delete succeeds, False otherwise
"""
return self._proxy.delete(
if_match=if_match,
)
async def delete_async(self, if_match: Union[str, object] = values.unset) -> bool:
"""
Asynchronous coroutine that deletes the SyncMapItemInstance
:param if_match: The If-Match HTTP request header
:returns: True if delete succeeds, False otherwise
"""
return await self._proxy.delete_async(
if_match=if_match,
)
def fetch(self) -> "SyncMapItemInstance":
"""
Fetch the SyncMapItemInstance
:returns: The fetched SyncMapItemInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "SyncMapItemInstance":
"""
Asynchronous coroutine to fetch the SyncMapItemInstance
:returns: The fetched SyncMapItemInstance
"""
return await self._proxy.fetch_async()
def update(
self, data: object, if_match: Union[str, object] = values.unset
) -> "SyncMapItemInstance":
"""
Update the SyncMapItemInstance
:param data:
:param if_match: The If-Match HTTP request header
:returns: The updated SyncMapItemInstance
"""
return self._proxy.update(
data=data,
if_match=if_match,
)
async def update_async(
self, data: object, if_match: Union[str, object] = values.unset
) -> "SyncMapItemInstance":
"""
Asynchronous coroutine to update the SyncMapItemInstance
:param data:
:param if_match: The If-Match HTTP request header
:returns: The updated SyncMapItemInstance
"""
return await self._proxy.update_async(
data=data,
if_match=if_match,
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Preview.Sync.SyncMapItemInstance {}>".format(context)
class SyncMapItemContext(InstanceContext):
def __init__(self, version: Version, service_sid: str, map_sid: str, key: str):
"""
Initialize the SyncMapItemContext
:param version: Version that contains the resource
:param service_sid:
:param map_sid:
:param key:
"""
super().__init__(version)
# Path Solution
self._solution = {
"service_sid": service_sid,
"map_sid": map_sid,
"key": key,
}
self._uri = "/Services/{service_sid}/Maps/{map_sid}/Items/{key}".format(
**self._solution
)
def delete(self, if_match: Union[str, object] = values.unset) -> bool:
"""
Deletes the SyncMapItemInstance
:param if_match: The If-Match HTTP request header
:returns: True if delete succeeds, False otherwise
"""
headers = values.of(
{
"If-Match": if_match,
}
)
return self._version.delete(method="DELETE", uri=self._uri, headers=headers)
async def delete_async(self, if_match: Union[str, object] = values.unset) -> bool:
"""
Asynchronous coroutine that deletes the SyncMapItemInstance
:param if_match: The If-Match HTTP request header
:returns: True if delete succeeds, False otherwise
"""
headers = values.of(
{
"If-Match": if_match,
}
)
return await self._version.delete_async(
method="DELETE", uri=self._uri, headers=headers
)
def fetch(self) -> SyncMapItemInstance:
"""
Fetch the SyncMapItemInstance
:returns: The fetched SyncMapItemInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return SyncMapItemInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
map_sid=self._solution["map_sid"],
key=self._solution["key"],
)
async def fetch_async(self) -> SyncMapItemInstance:
"""
Asynchronous coroutine to fetch the SyncMapItemInstance
:returns: The fetched SyncMapItemInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return SyncMapItemInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
map_sid=self._solution["map_sid"],
key=self._solution["key"],
)
def update(
self, data: object, if_match: Union[str, object] = values.unset
) -> SyncMapItemInstance:
"""
Update the SyncMapItemInstance
:param data:
:param if_match: The If-Match HTTP request header
:returns: The updated SyncMapItemInstance
"""
data = values.of(
{
"Data": serialize.object(data),
}
)
headers = values.of(
{
"If-Match": if_match,
}
)
payload = self._version.update(
method="POST", uri=self._uri, data=data, headers=headers
)
return SyncMapItemInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
map_sid=self._solution["map_sid"],
key=self._solution["key"],
)
async def update_async(
self, data: object, if_match: Union[str, object] = values.unset
) -> SyncMapItemInstance:
"""
Asynchronous coroutine to update the SyncMapItemInstance
:param data:
:param if_match: The If-Match HTTP request header
:returns: The updated SyncMapItemInstance
"""
data = values.of(
{
"Data": serialize.object(data),
}
)
headers = values.of(
{
"If-Match": if_match,
}
)
payload = await self._version.update_async(
method="POST", uri=self._uri, data=data, headers=headers
)
return SyncMapItemInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
map_sid=self._solution["map_sid"],
key=self._solution["key"],
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Preview.Sync.SyncMapItemContext {}>".format(context)
class SyncMapItemPage(Page):
def get_instance(self, payload: Dict[str, Any]) -> SyncMapItemInstance:
"""
Build an instance of SyncMapItemInstance
:param payload: Payload response from the API
"""
return SyncMapItemInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
map_sid=self._solution["map_sid"],
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.Sync.SyncMapItemPage>"
class SyncMapItemList(ListResource):
def __init__(self, version: Version, service_sid: str, map_sid: str):
"""
Initialize the SyncMapItemList
:param version: Version that contains the resource
:param service_sid:
:param map_sid:
"""
super().__init__(version)
# Path Solution
self._solution = {
"service_sid": service_sid,
"map_sid": map_sid,
}
self._uri = "/Services/{service_sid}/Maps/{map_sid}/Items".format(
**self._solution
)
def create(self, key: str, data: object) -> SyncMapItemInstance:
"""
Create the SyncMapItemInstance
:param key:
:param data:
:returns: The created SyncMapItemInstance
"""
data = values.of(
{
"Key": key,
"Data": serialize.object(data),
}
)
payload = self._version.create(
method="POST",
uri=self._uri,
data=data,
)
return SyncMapItemInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
map_sid=self._solution["map_sid"],
)
async def create_async(self, key: str, data: object) -> SyncMapItemInstance:
"""
Asynchronously create the SyncMapItemInstance
:param key:
:param data:
:returns: The created SyncMapItemInstance
"""
data = values.of(
{
"Key": key,
"Data": serialize.object(data),
}
)
payload = await self._version.create_async(
method="POST",
uri=self._uri,
data=data,
)
return SyncMapItemInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
map_sid=self._solution["map_sid"],
)
def stream(
self,
order: Union["SyncMapItemInstance.QueryResultOrder", object] = values.unset,
from_: Union[str, object] = values.unset,
bounds: Union["SyncMapItemInstance.QueryFromBoundType", object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[SyncMapItemInstance]:
"""
Streams SyncMapItemInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param &quot;SyncMapItemInstance.QueryResultOrder&quot; order:
:param str from_:
:param &quot;SyncMapItemInstance.QueryFromBoundType&quot; bounds:
:param limit: Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the
limit with the most efficient page size, i.e. min(limit, 1000)
:returns: Generator that will yield up to limit results
"""
limits = self._version.read_limits(limit, page_size)
page = self.page(
order=order, from_=from_, bounds=bounds, page_size=limits["page_size"]
)
return self._version.stream(page, limits["limit"])
async def stream_async(
self,
order: Union["SyncMapItemInstance.QueryResultOrder", object] = values.unset,
from_: Union[str, object] = values.unset,
bounds: Union["SyncMapItemInstance.QueryFromBoundType", object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> AsyncIterator[SyncMapItemInstance]:
"""
Asynchronously streams SyncMapItemInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param &quot;SyncMapItemInstance.QueryResultOrder&quot; order:
:param str from_:
:param &quot;SyncMapItemInstance.QueryFromBoundType&quot; bounds:
:param limit: Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the
limit with the most efficient page size, i.e. min(limit, 1000)
:returns: Generator that will yield up to limit results
"""
limits = self._version.read_limits(limit, page_size)
page = await self.page_async(
order=order, from_=from_, bounds=bounds, page_size=limits["page_size"]
)
return self._version.stream_async(page, limits["limit"])
def list(
self,
order: Union["SyncMapItemInstance.QueryResultOrder", object] = values.unset,
from_: Union[str, object] = values.unset,
bounds: Union["SyncMapItemInstance.QueryFromBoundType", object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[SyncMapItemInstance]:
"""
Lists SyncMapItemInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param &quot;SyncMapItemInstance.QueryResultOrder&quot; order:
:param str from_:
:param &quot;SyncMapItemInstance.QueryFromBoundType&quot; bounds:
:param limit: Upper limit for the number of records to return. list() guarantees
never to return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, list() will attempt to read the limit
with the most efficient page size, i.e. min(limit, 1000)
:returns: list that will contain up to limit results
"""
return list(
self.stream(
order=order,
from_=from_,
bounds=bounds,
limit=limit,
page_size=page_size,
)
)
async def list_async(
self,
order: Union["SyncMapItemInstance.QueryResultOrder", object] = values.unset,
from_: Union[str, object] = values.unset,
bounds: Union["SyncMapItemInstance.QueryFromBoundType", object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[SyncMapItemInstance]:
"""
Asynchronously lists SyncMapItemInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param &quot;SyncMapItemInstance.QueryResultOrder&quot; order:
:param str from_:
:param &quot;SyncMapItemInstance.QueryFromBoundType&quot; bounds:
:param limit: Upper limit for the number of records to return. list() guarantees
never to return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, list() will attempt to read the limit
with the most efficient page size, i.e. min(limit, 1000)
:returns: list that will contain up to limit results
"""
return [
record
async for record in await self.stream_async(
order=order,
from_=from_,
bounds=bounds,
limit=limit,
page_size=page_size,
)
]
def page(
self,
order: Union["SyncMapItemInstance.QueryResultOrder", object] = values.unset,
from_: Union[str, object] = values.unset,
bounds: Union["SyncMapItemInstance.QueryFromBoundType", object] = values.unset,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> SyncMapItemPage:
"""
Retrieve a single page of SyncMapItemInstance records from the API.
Request is executed immediately
:param order:
:param from_:
:param bounds:
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of SyncMapItemInstance
"""
data = values.of(
{
"Order": order,
"From": from_,
"Bounds": bounds,
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return SyncMapItemPage(self._version, response, self._solution)
async def page_async(
self,
order: Union["SyncMapItemInstance.QueryResultOrder", object] = values.unset,
from_: Union[str, object] = values.unset,
bounds: Union["SyncMapItemInstance.QueryFromBoundType", object] = values.unset,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> SyncMapItemPage:
"""
Asynchronously retrieve a single page of SyncMapItemInstance records from the API.
Request is executed immediately
:param order:
:param from_:
:param bounds:
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of SyncMapItemInstance
"""
data = values.of(
{
"Order": order,
"From": from_,
"Bounds": bounds,
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = await self._version.page_async(
method="GET", uri=self._uri, params=data
)
return SyncMapItemPage(self._version, response, self._solution)
def get_page(self, target_url: str) -> SyncMapItemPage:
"""
Retrieve a specific page of SyncMapItemInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of SyncMapItemInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return SyncMapItemPage(self._version, response, self._solution)
async def get_page_async(self, target_url: str) -> SyncMapItemPage:
"""
Asynchronously retrieve a specific page of SyncMapItemInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of SyncMapItemInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return SyncMapItemPage(self._version, response, self._solution)
def get(self, key: str) -> SyncMapItemContext:
"""
Constructs a SyncMapItemContext
:param key:
"""
return SyncMapItemContext(
self._version,
service_sid=self._solution["service_sid"],
map_sid=self._solution["map_sid"],
key=key,
)
def __call__(self, key: str) -> SyncMapItemContext:
"""
Constructs a SyncMapItemContext
:param key:
"""
return SyncMapItemContext(
self._version,
service_sid=self._solution["service_sid"],
map_sid=self._solution["map_sid"],
key=key,
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.Sync.SyncMapItemList>"
@@ -0,0 +1,590 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Preview
This is the public Twilio REST API.
NOTE: This class is auto generated by OpenAPI Generator.
https://openapi-generator.tech
Do not edit the class manually.
"""
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
from twilio.base import values
from twilio.base.instance_context import InstanceContext
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.version import Version
from twilio.base.page import Page
class SyncMapPermissionInstance(InstanceResource):
"""
:ivar account_sid: The unique SID identifier of the Twilio Account.
:ivar service_sid: The unique SID identifier of the Sync Service Instance.
:ivar map_sid: The unique SID identifier of the Sync Map to which the Permission applies.
:ivar identity: Arbitrary string identifier representing a human user associated with an FPA token, assigned by the developer.
:ivar read: Boolean flag specifying whether the identity can read the Sync Map and its Items.
:ivar write: Boolean flag specifying whether the identity can create, update and delete Items of the Sync Map.
:ivar manage: Boolean flag specifying whether the identity can delete the Sync Map.
:ivar url: Contains an absolute URL for this Sync Map Permission.
"""
def __init__(
self,
version: Version,
payload: Dict[str, Any],
service_sid: str,
map_sid: str,
identity: Optional[str] = None,
):
super().__init__(version)
self.account_sid: Optional[str] = payload.get("account_sid")
self.service_sid: Optional[str] = payload.get("service_sid")
self.map_sid: Optional[str] = payload.get("map_sid")
self.identity: Optional[str] = payload.get("identity")
self.read: Optional[bool] = payload.get("read")
self.write: Optional[bool] = payload.get("write")
self.manage: Optional[bool] = payload.get("manage")
self.url: Optional[str] = payload.get("url")
self._solution = {
"service_sid": service_sid,
"map_sid": map_sid,
"identity": identity or self.identity,
}
self._context: Optional[SyncMapPermissionContext] = None
@property
def _proxy(self) -> "SyncMapPermissionContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: SyncMapPermissionContext for this SyncMapPermissionInstance
"""
if self._context is None:
self._context = SyncMapPermissionContext(
self._version,
service_sid=self._solution["service_sid"],
map_sid=self._solution["map_sid"],
identity=self._solution["identity"],
)
return self._context
def delete(self) -> bool:
"""
Deletes the SyncMapPermissionInstance
:returns: True if delete succeeds, False otherwise
"""
return self._proxy.delete()
async def delete_async(self) -> bool:
"""
Asynchronous coroutine that deletes the SyncMapPermissionInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._proxy.delete_async()
def fetch(self) -> "SyncMapPermissionInstance":
"""
Fetch the SyncMapPermissionInstance
:returns: The fetched SyncMapPermissionInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "SyncMapPermissionInstance":
"""
Asynchronous coroutine to fetch the SyncMapPermissionInstance
:returns: The fetched SyncMapPermissionInstance
"""
return await self._proxy.fetch_async()
def update(
self, read: bool, write: bool, manage: bool
) -> "SyncMapPermissionInstance":
"""
Update the SyncMapPermissionInstance
:param read: Boolean flag specifying whether the identity can read the Sync Map.
:param write: Boolean flag specifying whether the identity can create, update and delete Items of the Sync Map.
:param manage: Boolean flag specifying whether the identity can delete the Sync Map.
:returns: The updated SyncMapPermissionInstance
"""
return self._proxy.update(
read=read,
write=write,
manage=manage,
)
async def update_async(
self, read: bool, write: bool, manage: bool
) -> "SyncMapPermissionInstance":
"""
Asynchronous coroutine to update the SyncMapPermissionInstance
:param read: Boolean flag specifying whether the identity can read the Sync Map.
:param write: Boolean flag specifying whether the identity can create, update and delete Items of the Sync Map.
:param manage: Boolean flag specifying whether the identity can delete the Sync Map.
:returns: The updated SyncMapPermissionInstance
"""
return await self._proxy.update_async(
read=read,
write=write,
manage=manage,
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Preview.Sync.SyncMapPermissionInstance {}>".format(context)
class SyncMapPermissionContext(InstanceContext):
def __init__(self, version: Version, service_sid: str, map_sid: str, identity: str):
"""
Initialize the SyncMapPermissionContext
:param version: Version that contains the resource
:param service_sid: The unique SID identifier of the Sync Service Instance.
:param map_sid: Identifier of the Sync Map. Either a SID or a unique name.
:param identity: Arbitrary string identifier representing a human user associated with an FPA token, assigned by the developer.
"""
super().__init__(version)
# Path Solution
self._solution = {
"service_sid": service_sid,
"map_sid": map_sid,
"identity": identity,
}
self._uri = (
"/Services/{service_sid}/Maps/{map_sid}/Permissions/{identity}".format(
**self._solution
)
)
def delete(self) -> bool:
"""
Deletes the SyncMapPermissionInstance
:returns: True if delete succeeds, False otherwise
"""
return self._version.delete(
method="DELETE",
uri=self._uri,
)
async def delete_async(self) -> bool:
"""
Asynchronous coroutine that deletes the SyncMapPermissionInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._version.delete_async(
method="DELETE",
uri=self._uri,
)
def fetch(self) -> SyncMapPermissionInstance:
"""
Fetch the SyncMapPermissionInstance
:returns: The fetched SyncMapPermissionInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return SyncMapPermissionInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
map_sid=self._solution["map_sid"],
identity=self._solution["identity"],
)
async def fetch_async(self) -> SyncMapPermissionInstance:
"""
Asynchronous coroutine to fetch the SyncMapPermissionInstance
:returns: The fetched SyncMapPermissionInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return SyncMapPermissionInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
map_sid=self._solution["map_sid"],
identity=self._solution["identity"],
)
def update(
self, read: bool, write: bool, manage: bool
) -> SyncMapPermissionInstance:
"""
Update the SyncMapPermissionInstance
:param read: Boolean flag specifying whether the identity can read the Sync Map.
:param write: Boolean flag specifying whether the identity can create, update and delete Items of the Sync Map.
:param manage: Boolean flag specifying whether the identity can delete the Sync Map.
:returns: The updated SyncMapPermissionInstance
"""
data = values.of(
{
"Read": read,
"Write": write,
"Manage": manage,
}
)
payload = self._version.update(
method="POST",
uri=self._uri,
data=data,
)
return SyncMapPermissionInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
map_sid=self._solution["map_sid"],
identity=self._solution["identity"],
)
async def update_async(
self, read: bool, write: bool, manage: bool
) -> SyncMapPermissionInstance:
"""
Asynchronous coroutine to update the SyncMapPermissionInstance
:param read: Boolean flag specifying whether the identity can read the Sync Map.
:param write: Boolean flag specifying whether the identity can create, update and delete Items of the Sync Map.
:param manage: Boolean flag specifying whether the identity can delete the Sync Map.
:returns: The updated SyncMapPermissionInstance
"""
data = values.of(
{
"Read": read,
"Write": write,
"Manage": manage,
}
)
payload = await self._version.update_async(
method="POST",
uri=self._uri,
data=data,
)
return SyncMapPermissionInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
map_sid=self._solution["map_sid"],
identity=self._solution["identity"],
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Preview.Sync.SyncMapPermissionContext {}>".format(context)
class SyncMapPermissionPage(Page):
def get_instance(self, payload: Dict[str, Any]) -> SyncMapPermissionInstance:
"""
Build an instance of SyncMapPermissionInstance
:param payload: Payload response from the API
"""
return SyncMapPermissionInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
map_sid=self._solution["map_sid"],
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.Sync.SyncMapPermissionPage>"
class SyncMapPermissionList(ListResource):
def __init__(self, version: Version, service_sid: str, map_sid: str):
"""
Initialize the SyncMapPermissionList
:param version: Version that contains the resource
:param service_sid:
:param map_sid: Identifier of the Sync Map. Either a SID or a unique name.
"""
super().__init__(version)
# Path Solution
self._solution = {
"service_sid": service_sid,
"map_sid": map_sid,
}
self._uri = "/Services/{service_sid}/Maps/{map_sid}/Permissions".format(
**self._solution
)
def stream(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[SyncMapPermissionInstance]:
"""
Streams SyncMapPermissionInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param limit: Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the
limit with the most efficient page size, i.e. min(limit, 1000)
:returns: Generator that will yield up to limit results
"""
limits = self._version.read_limits(limit, page_size)
page = self.page(page_size=limits["page_size"])
return self._version.stream(page, limits["limit"])
async def stream_async(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> AsyncIterator[SyncMapPermissionInstance]:
"""
Asynchronously streams SyncMapPermissionInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param limit: Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the
limit with the most efficient page size, i.e. min(limit, 1000)
:returns: Generator that will yield up to limit results
"""
limits = self._version.read_limits(limit, page_size)
page = await self.page_async(page_size=limits["page_size"])
return self._version.stream_async(page, limits["limit"])
def list(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[SyncMapPermissionInstance]:
"""
Lists SyncMapPermissionInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param limit: Upper limit for the number of records to return. list() guarantees
never to return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, list() will attempt to read the limit
with the most efficient page size, i.e. min(limit, 1000)
:returns: list that will contain up to limit results
"""
return list(
self.stream(
limit=limit,
page_size=page_size,
)
)
async def list_async(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[SyncMapPermissionInstance]:
"""
Asynchronously lists SyncMapPermissionInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param limit: Upper limit for the number of records to return. list() guarantees
never to return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, list() will attempt to read the limit
with the most efficient page size, i.e. min(limit, 1000)
:returns: list that will contain up to limit results
"""
return [
record
async for record in await self.stream_async(
limit=limit,
page_size=page_size,
)
]
def page(
self,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> SyncMapPermissionPage:
"""
Retrieve a single page of SyncMapPermissionInstance records from the API.
Request is executed immediately
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of SyncMapPermissionInstance
"""
data = values.of(
{
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return SyncMapPermissionPage(self._version, response, self._solution)
async def page_async(
self,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> SyncMapPermissionPage:
"""
Asynchronously retrieve a single page of SyncMapPermissionInstance records from the API.
Request is executed immediately
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of SyncMapPermissionInstance
"""
data = values.of(
{
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = await self._version.page_async(
method="GET", uri=self._uri, params=data
)
return SyncMapPermissionPage(self._version, response, self._solution)
def get_page(self, target_url: str) -> SyncMapPermissionPage:
"""
Retrieve a specific page of SyncMapPermissionInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of SyncMapPermissionInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return SyncMapPermissionPage(self._version, response, self._solution)
async def get_page_async(self, target_url: str) -> SyncMapPermissionPage:
"""
Asynchronously retrieve a specific page of SyncMapPermissionInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of SyncMapPermissionInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return SyncMapPermissionPage(self._version, response, self._solution)
def get(self, identity: str) -> SyncMapPermissionContext:
"""
Constructs a SyncMapPermissionContext
:param identity: Arbitrary string identifier representing a human user associated with an FPA token, assigned by the developer.
"""
return SyncMapPermissionContext(
self._version,
service_sid=self._solution["service_sid"],
map_sid=self._solution["map_sid"],
identity=identity,
)
def __call__(self, identity: str) -> SyncMapPermissionContext:
"""
Constructs a SyncMapPermissionContext
:param identity: Arbitrary string identifier representing a human user associated with an FPA token, assigned by the developer.
"""
return SyncMapPermissionContext(
self._version,
service_sid=self._solution["service_sid"],
map_sid=self._solution["map_sid"],
identity=identity,
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.Sync.SyncMapPermissionList>"
@@ -0,0 +1,42 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Preview
This is the public Twilio REST API.
NOTE: This class is auto generated by OpenAPI Generator.
https://openapi-generator.tech
Do not edit the class manually.
"""
from typing import Optional
from twilio.base.version import Version
from twilio.base.domain import Domain
from twilio.rest.preview.understand.assistant import AssistantList
class Understand(Version):
def __init__(self, domain: Domain):
"""
Initialize the Understand version of Preview
:param domain: The Twilio.preview domain
"""
super().__init__(domain, "understand")
self._assistants: Optional[AssistantList] = None
@property
def assistants(self) -> AssistantList:
if self._assistants is None:
self._assistants = AssistantList(self)
return self._assistants
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.Understand>"
@@ -0,0 +1,887 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Preview
This is the public Twilio REST API.
NOTE: This class is auto generated by OpenAPI Generator.
https://openapi-generator.tech
Do not edit the class manually.
"""
from datetime import datetime
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
from twilio.base import deserialize, serialize, values
from twilio.base.instance_context import InstanceContext
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.version import Version
from twilio.base.page import Page
from twilio.rest.preview.understand.assistant.assistant_fallback_actions import (
AssistantFallbackActionsList,
)
from twilio.rest.preview.understand.assistant.assistant_initiation_actions import (
AssistantInitiationActionsList,
)
from twilio.rest.preview.understand.assistant.dialogue import DialogueList
from twilio.rest.preview.understand.assistant.field_type import FieldTypeList
from twilio.rest.preview.understand.assistant.model_build import ModelBuildList
from twilio.rest.preview.understand.assistant.query import QueryList
from twilio.rest.preview.understand.assistant.style_sheet import StyleSheetList
from twilio.rest.preview.understand.assistant.task import TaskList
class AssistantInstance(InstanceResource):
"""
:ivar account_sid: The unique ID of the Account that created this Assistant.
:ivar date_created: The date that this resource was created
:ivar date_updated: The date that this resource was last updated
:ivar friendly_name: A text description for the Assistant. It is non-unique and can up to 255 characters long.
:ivar latest_model_build_sid: The unique ID (Sid) of the latest model build. Null if no model has been built.
:ivar links:
:ivar log_queries: A boolean that specifies whether queries should be logged for 30 days further training. If false, no queries will be stored, if true, queries will be stored for 30 days and deleted thereafter.
:ivar sid: A 34 character string that uniquely identifies this resource.
:ivar unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. You can use the unique name in the URL path. Unique up to 64 characters long.
:ivar url:
:ivar callback_url: A user-provided URL to send event callbacks to.
:ivar callback_events: Space-separated list of callback events that will trigger callbacks.
"""
def __init__(
self, version: Version, payload: Dict[str, Any], sid: Optional[str] = None
):
super().__init__(version)
self.account_sid: Optional[str] = payload.get("account_sid")
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_created")
)
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_updated")
)
self.friendly_name: Optional[str] = payload.get("friendly_name")
self.latest_model_build_sid: Optional[str] = payload.get(
"latest_model_build_sid"
)
self.links: Optional[Dict[str, object]] = payload.get("links")
self.log_queries: Optional[bool] = payload.get("log_queries")
self.sid: Optional[str] = payload.get("sid")
self.unique_name: Optional[str] = payload.get("unique_name")
self.url: Optional[str] = payload.get("url")
self.callback_url: Optional[str] = payload.get("callback_url")
self.callback_events: Optional[str] = payload.get("callback_events")
self._solution = {
"sid": sid or self.sid,
}
self._context: Optional[AssistantContext] = None
@property
def _proxy(self) -> "AssistantContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: AssistantContext for this AssistantInstance
"""
if self._context is None:
self._context = AssistantContext(
self._version,
sid=self._solution["sid"],
)
return self._context
def delete(self) -> bool:
"""
Deletes the AssistantInstance
:returns: True if delete succeeds, False otherwise
"""
return self._proxy.delete()
async def delete_async(self) -> bool:
"""
Asynchronous coroutine that deletes the AssistantInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._proxy.delete_async()
def fetch(self) -> "AssistantInstance":
"""
Fetch the AssistantInstance
:returns: The fetched AssistantInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "AssistantInstance":
"""
Asynchronous coroutine to fetch the AssistantInstance
:returns: The fetched AssistantInstance
"""
return await self._proxy.fetch_async()
def update(
self,
friendly_name: Union[str, object] = values.unset,
log_queries: Union[bool, object] = values.unset,
unique_name: Union[str, object] = values.unset,
callback_url: Union[str, object] = values.unset,
callback_events: Union[str, object] = values.unset,
fallback_actions: Union[object, object] = values.unset,
initiation_actions: Union[object, object] = values.unset,
style_sheet: Union[object, object] = values.unset,
) -> "AssistantInstance":
"""
Update the AssistantInstance
:param friendly_name: A text description for the Assistant. It is non-unique and can up to 255 characters long.
:param log_queries: A boolean that specifies whether queries should be logged for 30 days further training. If false, no queries will be stored, if true, queries will be stored for 30 days and deleted thereafter. Defaults to true if no value is provided.
:param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long.
:param callback_url: A user-provided URL to send event callbacks to.
:param callback_events: Space-separated list of callback events that will trigger callbacks.
:param fallback_actions: The JSON actions to be executed when the user's input is not recognized as matching any Task.
:param initiation_actions: The JSON actions to be executed on inbound phone calls when the Assistant has to say something first.
:param style_sheet: The JSON object that holds the style sheet for the assistant
:returns: The updated AssistantInstance
"""
return self._proxy.update(
friendly_name=friendly_name,
log_queries=log_queries,
unique_name=unique_name,
callback_url=callback_url,
callback_events=callback_events,
fallback_actions=fallback_actions,
initiation_actions=initiation_actions,
style_sheet=style_sheet,
)
async def update_async(
self,
friendly_name: Union[str, object] = values.unset,
log_queries: Union[bool, object] = values.unset,
unique_name: Union[str, object] = values.unset,
callback_url: Union[str, object] = values.unset,
callback_events: Union[str, object] = values.unset,
fallback_actions: Union[object, object] = values.unset,
initiation_actions: Union[object, object] = values.unset,
style_sheet: Union[object, object] = values.unset,
) -> "AssistantInstance":
"""
Asynchronous coroutine to update the AssistantInstance
:param friendly_name: A text description for the Assistant. It is non-unique and can up to 255 characters long.
:param log_queries: A boolean that specifies whether queries should be logged for 30 days further training. If false, no queries will be stored, if true, queries will be stored for 30 days and deleted thereafter. Defaults to true if no value is provided.
:param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long.
:param callback_url: A user-provided URL to send event callbacks to.
:param callback_events: Space-separated list of callback events that will trigger callbacks.
:param fallback_actions: The JSON actions to be executed when the user's input is not recognized as matching any Task.
:param initiation_actions: The JSON actions to be executed on inbound phone calls when the Assistant has to say something first.
:param style_sheet: The JSON object that holds the style sheet for the assistant
:returns: The updated AssistantInstance
"""
return await self._proxy.update_async(
friendly_name=friendly_name,
log_queries=log_queries,
unique_name=unique_name,
callback_url=callback_url,
callback_events=callback_events,
fallback_actions=fallback_actions,
initiation_actions=initiation_actions,
style_sheet=style_sheet,
)
@property
def assistant_fallback_actions(self) -> AssistantFallbackActionsList:
"""
Access the assistant_fallback_actions
"""
return self._proxy.assistant_fallback_actions
@property
def assistant_initiation_actions(self) -> AssistantInitiationActionsList:
"""
Access the assistant_initiation_actions
"""
return self._proxy.assistant_initiation_actions
@property
def dialogues(self) -> DialogueList:
"""
Access the dialogues
"""
return self._proxy.dialogues
@property
def field_types(self) -> FieldTypeList:
"""
Access the field_types
"""
return self._proxy.field_types
@property
def model_builds(self) -> ModelBuildList:
"""
Access the model_builds
"""
return self._proxy.model_builds
@property
def queries(self) -> QueryList:
"""
Access the queries
"""
return self._proxy.queries
@property
def style_sheet(self) -> StyleSheetList:
"""
Access the style_sheet
"""
return self._proxy.style_sheet
@property
def tasks(self) -> TaskList:
"""
Access the tasks
"""
return self._proxy.tasks
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Preview.Understand.AssistantInstance {}>".format(context)
class AssistantContext(InstanceContext):
def __init__(self, version: Version, sid: str):
"""
Initialize the AssistantContext
:param version: Version that contains the resource
:param sid: A 34 character string that uniquely identifies this resource.
"""
super().__init__(version)
# Path Solution
self._solution = {
"sid": sid,
}
self._uri = "/Assistants/{sid}".format(**self._solution)
self._assistant_fallback_actions: Optional[AssistantFallbackActionsList] = None
self._assistant_initiation_actions: Optional[
AssistantInitiationActionsList
] = None
self._dialogues: Optional[DialogueList] = None
self._field_types: Optional[FieldTypeList] = None
self._model_builds: Optional[ModelBuildList] = None
self._queries: Optional[QueryList] = None
self._style_sheet: Optional[StyleSheetList] = None
self._tasks: Optional[TaskList] = None
def delete(self) -> bool:
"""
Deletes the AssistantInstance
:returns: True if delete succeeds, False otherwise
"""
return self._version.delete(
method="DELETE",
uri=self._uri,
)
async def delete_async(self) -> bool:
"""
Asynchronous coroutine that deletes the AssistantInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._version.delete_async(
method="DELETE",
uri=self._uri,
)
def fetch(self) -> AssistantInstance:
"""
Fetch the AssistantInstance
:returns: The fetched AssistantInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return AssistantInstance(
self._version,
payload,
sid=self._solution["sid"],
)
async def fetch_async(self) -> AssistantInstance:
"""
Asynchronous coroutine to fetch the AssistantInstance
:returns: The fetched AssistantInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return AssistantInstance(
self._version,
payload,
sid=self._solution["sid"],
)
def update(
self,
friendly_name: Union[str, object] = values.unset,
log_queries: Union[bool, object] = values.unset,
unique_name: Union[str, object] = values.unset,
callback_url: Union[str, object] = values.unset,
callback_events: Union[str, object] = values.unset,
fallback_actions: Union[object, object] = values.unset,
initiation_actions: Union[object, object] = values.unset,
style_sheet: Union[object, object] = values.unset,
) -> AssistantInstance:
"""
Update the AssistantInstance
:param friendly_name: A text description for the Assistant. It is non-unique and can up to 255 characters long.
:param log_queries: A boolean that specifies whether queries should be logged for 30 days further training. If false, no queries will be stored, if true, queries will be stored for 30 days and deleted thereafter. Defaults to true if no value is provided.
:param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long.
:param callback_url: A user-provided URL to send event callbacks to.
:param callback_events: Space-separated list of callback events that will trigger callbacks.
:param fallback_actions: The JSON actions to be executed when the user's input is not recognized as matching any Task.
:param initiation_actions: The JSON actions to be executed on inbound phone calls when the Assistant has to say something first.
:param style_sheet: The JSON object that holds the style sheet for the assistant
:returns: The updated AssistantInstance
"""
data = values.of(
{
"FriendlyName": friendly_name,
"LogQueries": log_queries,
"UniqueName": unique_name,
"CallbackUrl": callback_url,
"CallbackEvents": callback_events,
"FallbackActions": serialize.object(fallback_actions),
"InitiationActions": serialize.object(initiation_actions),
"StyleSheet": serialize.object(style_sheet),
}
)
payload = self._version.update(
method="POST",
uri=self._uri,
data=data,
)
return AssistantInstance(self._version, payload, sid=self._solution["sid"])
async def update_async(
self,
friendly_name: Union[str, object] = values.unset,
log_queries: Union[bool, object] = values.unset,
unique_name: Union[str, object] = values.unset,
callback_url: Union[str, object] = values.unset,
callback_events: Union[str, object] = values.unset,
fallback_actions: Union[object, object] = values.unset,
initiation_actions: Union[object, object] = values.unset,
style_sheet: Union[object, object] = values.unset,
) -> AssistantInstance:
"""
Asynchronous coroutine to update the AssistantInstance
:param friendly_name: A text description for the Assistant. It is non-unique and can up to 255 characters long.
:param log_queries: A boolean that specifies whether queries should be logged for 30 days further training. If false, no queries will be stored, if true, queries will be stored for 30 days and deleted thereafter. Defaults to true if no value is provided.
:param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long.
:param callback_url: A user-provided URL to send event callbacks to.
:param callback_events: Space-separated list of callback events that will trigger callbacks.
:param fallback_actions: The JSON actions to be executed when the user's input is not recognized as matching any Task.
:param initiation_actions: The JSON actions to be executed on inbound phone calls when the Assistant has to say something first.
:param style_sheet: The JSON object that holds the style sheet for the assistant
:returns: The updated AssistantInstance
"""
data = values.of(
{
"FriendlyName": friendly_name,
"LogQueries": log_queries,
"UniqueName": unique_name,
"CallbackUrl": callback_url,
"CallbackEvents": callback_events,
"FallbackActions": serialize.object(fallback_actions),
"InitiationActions": serialize.object(initiation_actions),
"StyleSheet": serialize.object(style_sheet),
}
)
payload = await self._version.update_async(
method="POST",
uri=self._uri,
data=data,
)
return AssistantInstance(self._version, payload, sid=self._solution["sid"])
@property
def assistant_fallback_actions(self) -> AssistantFallbackActionsList:
"""
Access the assistant_fallback_actions
"""
if self._assistant_fallback_actions is None:
self._assistant_fallback_actions = AssistantFallbackActionsList(
self._version,
self._solution["sid"],
)
return self._assistant_fallback_actions
@property
def assistant_initiation_actions(self) -> AssistantInitiationActionsList:
"""
Access the assistant_initiation_actions
"""
if self._assistant_initiation_actions is None:
self._assistant_initiation_actions = AssistantInitiationActionsList(
self._version,
self._solution["sid"],
)
return self._assistant_initiation_actions
@property
def dialogues(self) -> DialogueList:
"""
Access the dialogues
"""
if self._dialogues is None:
self._dialogues = DialogueList(
self._version,
self._solution["sid"],
)
return self._dialogues
@property
def field_types(self) -> FieldTypeList:
"""
Access the field_types
"""
if self._field_types is None:
self._field_types = FieldTypeList(
self._version,
self._solution["sid"],
)
return self._field_types
@property
def model_builds(self) -> ModelBuildList:
"""
Access the model_builds
"""
if self._model_builds is None:
self._model_builds = ModelBuildList(
self._version,
self._solution["sid"],
)
return self._model_builds
@property
def queries(self) -> QueryList:
"""
Access the queries
"""
if self._queries is None:
self._queries = QueryList(
self._version,
self._solution["sid"],
)
return self._queries
@property
def style_sheet(self) -> StyleSheetList:
"""
Access the style_sheet
"""
if self._style_sheet is None:
self._style_sheet = StyleSheetList(
self._version,
self._solution["sid"],
)
return self._style_sheet
@property
def tasks(self) -> TaskList:
"""
Access the tasks
"""
if self._tasks is None:
self._tasks = TaskList(
self._version,
self._solution["sid"],
)
return self._tasks
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Preview.Understand.AssistantContext {}>".format(context)
class AssistantPage(Page):
def get_instance(self, payload: Dict[str, Any]) -> AssistantInstance:
"""
Build an instance of AssistantInstance
:param payload: Payload response from the API
"""
return AssistantInstance(self._version, payload)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.Understand.AssistantPage>"
class AssistantList(ListResource):
def __init__(self, version: Version):
"""
Initialize the AssistantList
:param version: Version that contains the resource
"""
super().__init__(version)
self._uri = "/Assistants"
def create(
self,
friendly_name: Union[str, object] = values.unset,
log_queries: Union[bool, object] = values.unset,
unique_name: Union[str, object] = values.unset,
callback_url: Union[str, object] = values.unset,
callback_events: Union[str, object] = values.unset,
fallback_actions: Union[object, object] = values.unset,
initiation_actions: Union[object, object] = values.unset,
style_sheet: Union[object, object] = values.unset,
) -> AssistantInstance:
"""
Create the AssistantInstance
:param friendly_name: A text description for the Assistant. It is non-unique and can up to 255 characters long.
:param log_queries: A boolean that specifies whether queries should be logged for 30 days further training. If false, no queries will be stored, if true, queries will be stored for 30 days and deleted thereafter. Defaults to true if no value is provided.
:param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long.
:param callback_url: A user-provided URL to send event callbacks to.
:param callback_events: Space-separated list of callback events that will trigger callbacks.
:param fallback_actions: The JSON actions to be executed when the user's input is not recognized as matching any Task.
:param initiation_actions: The JSON actions to be executed on inbound phone calls when the Assistant has to say something first.
:param style_sheet: The JSON object that holds the style sheet for the assistant
:returns: The created AssistantInstance
"""
data = values.of(
{
"FriendlyName": friendly_name,
"LogQueries": log_queries,
"UniqueName": unique_name,
"CallbackUrl": callback_url,
"CallbackEvents": callback_events,
"FallbackActions": serialize.object(fallback_actions),
"InitiationActions": serialize.object(initiation_actions),
"StyleSheet": serialize.object(style_sheet),
}
)
payload = self._version.create(
method="POST",
uri=self._uri,
data=data,
)
return AssistantInstance(self._version, payload)
async def create_async(
self,
friendly_name: Union[str, object] = values.unset,
log_queries: Union[bool, object] = values.unset,
unique_name: Union[str, object] = values.unset,
callback_url: Union[str, object] = values.unset,
callback_events: Union[str, object] = values.unset,
fallback_actions: Union[object, object] = values.unset,
initiation_actions: Union[object, object] = values.unset,
style_sheet: Union[object, object] = values.unset,
) -> AssistantInstance:
"""
Asynchronously create the AssistantInstance
:param friendly_name: A text description for the Assistant. It is non-unique and can up to 255 characters long.
:param log_queries: A boolean that specifies whether queries should be logged for 30 days further training. If false, no queries will be stored, if true, queries will be stored for 30 days and deleted thereafter. Defaults to true if no value is provided.
:param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long.
:param callback_url: A user-provided URL to send event callbacks to.
:param callback_events: Space-separated list of callback events that will trigger callbacks.
:param fallback_actions: The JSON actions to be executed when the user's input is not recognized as matching any Task.
:param initiation_actions: The JSON actions to be executed on inbound phone calls when the Assistant has to say something first.
:param style_sheet: The JSON object that holds the style sheet for the assistant
:returns: The created AssistantInstance
"""
data = values.of(
{
"FriendlyName": friendly_name,
"LogQueries": log_queries,
"UniqueName": unique_name,
"CallbackUrl": callback_url,
"CallbackEvents": callback_events,
"FallbackActions": serialize.object(fallback_actions),
"InitiationActions": serialize.object(initiation_actions),
"StyleSheet": serialize.object(style_sheet),
}
)
payload = await self._version.create_async(
method="POST",
uri=self._uri,
data=data,
)
return AssistantInstance(self._version, payload)
def stream(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[AssistantInstance]:
"""
Streams AssistantInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param limit: Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the
limit with the most efficient page size, i.e. min(limit, 1000)
:returns: Generator that will yield up to limit results
"""
limits = self._version.read_limits(limit, page_size)
page = self.page(page_size=limits["page_size"])
return self._version.stream(page, limits["limit"])
async def stream_async(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> AsyncIterator[AssistantInstance]:
"""
Asynchronously streams AssistantInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param limit: Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the
limit with the most efficient page size, i.e. min(limit, 1000)
:returns: Generator that will yield up to limit results
"""
limits = self._version.read_limits(limit, page_size)
page = await self.page_async(page_size=limits["page_size"])
return self._version.stream_async(page, limits["limit"])
def list(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[AssistantInstance]:
"""
Lists AssistantInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param limit: Upper limit for the number of records to return. list() guarantees
never to return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, list() will attempt to read the limit
with the most efficient page size, i.e. min(limit, 1000)
:returns: list that will contain up to limit results
"""
return list(
self.stream(
limit=limit,
page_size=page_size,
)
)
async def list_async(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[AssistantInstance]:
"""
Asynchronously lists AssistantInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param limit: Upper limit for the number of records to return. list() guarantees
never to return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, list() will attempt to read the limit
with the most efficient page size, i.e. min(limit, 1000)
:returns: list that will contain up to limit results
"""
return [
record
async for record in await self.stream_async(
limit=limit,
page_size=page_size,
)
]
def page(
self,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> AssistantPage:
"""
Retrieve a single page of AssistantInstance records from the API.
Request is executed immediately
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of AssistantInstance
"""
data = values.of(
{
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return AssistantPage(self._version, response)
async def page_async(
self,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> AssistantPage:
"""
Asynchronously retrieve a single page of AssistantInstance records from the API.
Request is executed immediately
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of AssistantInstance
"""
data = values.of(
{
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = await self._version.page_async(
method="GET", uri=self._uri, params=data
)
return AssistantPage(self._version, response)
def get_page(self, target_url: str) -> AssistantPage:
"""
Retrieve a specific page of AssistantInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of AssistantInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return AssistantPage(self._version, response)
async def get_page_async(self, target_url: str) -> AssistantPage:
"""
Asynchronously retrieve a specific page of AssistantInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of AssistantInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return AssistantPage(self._version, response)
def get(self, sid: str) -> AssistantContext:
"""
Constructs a AssistantContext
:param sid: A 34 character string that uniquely identifies this resource.
"""
return AssistantContext(self._version, sid=sid)
def __call__(self, sid: str) -> AssistantContext:
"""
Constructs a AssistantContext
:param sid: A 34 character string that uniquely identifies this resource.
"""
return AssistantContext(self._version, sid=sid)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.Understand.AssistantList>"
@@ -0,0 +1,279 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Preview
This is the public Twilio REST API.
NOTE: This class is auto generated by OpenAPI Generator.
https://openapi-generator.tech
Do not edit the class manually.
"""
from typing import Any, Dict, Optional, Union
from twilio.base import serialize, values
from twilio.base.instance_context import InstanceContext
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.version import Version
class AssistantFallbackActionsInstance(InstanceResource):
"""
:ivar account_sid:
:ivar assistant_sid:
:ivar url:
:ivar data:
"""
def __init__(self, version: Version, payload: Dict[str, Any], assistant_sid: str):
super().__init__(version)
self.account_sid: Optional[str] = payload.get("account_sid")
self.assistant_sid: Optional[str] = payload.get("assistant_sid")
self.url: Optional[str] = payload.get("url")
self.data: Optional[Dict[str, object]] = payload.get("data")
self._solution = {
"assistant_sid": assistant_sid,
}
self._context: Optional[AssistantFallbackActionsContext] = None
@property
def _proxy(self) -> "AssistantFallbackActionsContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: AssistantFallbackActionsContext for this AssistantFallbackActionsInstance
"""
if self._context is None:
self._context = AssistantFallbackActionsContext(
self._version,
assistant_sid=self._solution["assistant_sid"],
)
return self._context
def fetch(self) -> "AssistantFallbackActionsInstance":
"""
Fetch the AssistantFallbackActionsInstance
:returns: The fetched AssistantFallbackActionsInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "AssistantFallbackActionsInstance":
"""
Asynchronous coroutine to fetch the AssistantFallbackActionsInstance
:returns: The fetched AssistantFallbackActionsInstance
"""
return await self._proxy.fetch_async()
def update(
self, fallback_actions: Union[object, object] = values.unset
) -> "AssistantFallbackActionsInstance":
"""
Update the AssistantFallbackActionsInstance
:param fallback_actions:
:returns: The updated AssistantFallbackActionsInstance
"""
return self._proxy.update(
fallback_actions=fallback_actions,
)
async def update_async(
self, fallback_actions: Union[object, object] = values.unset
) -> "AssistantFallbackActionsInstance":
"""
Asynchronous coroutine to update the AssistantFallbackActionsInstance
:param fallback_actions:
:returns: The updated AssistantFallbackActionsInstance
"""
return await self._proxy.update_async(
fallback_actions=fallback_actions,
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Preview.Understand.AssistantFallbackActionsInstance {}>".format(
context
)
class AssistantFallbackActionsContext(InstanceContext):
def __init__(self, version: Version, assistant_sid: str):
"""
Initialize the AssistantFallbackActionsContext
:param version: Version that contains the resource
:param assistant_sid:
"""
super().__init__(version)
# Path Solution
self._solution = {
"assistant_sid": assistant_sid,
}
self._uri = "/Assistants/{assistant_sid}/FallbackActions".format(
**self._solution
)
def fetch(self) -> AssistantFallbackActionsInstance:
"""
Fetch the AssistantFallbackActionsInstance
:returns: The fetched AssistantFallbackActionsInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return AssistantFallbackActionsInstance(
self._version,
payload,
assistant_sid=self._solution["assistant_sid"],
)
async def fetch_async(self) -> AssistantFallbackActionsInstance:
"""
Asynchronous coroutine to fetch the AssistantFallbackActionsInstance
:returns: The fetched AssistantFallbackActionsInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return AssistantFallbackActionsInstance(
self._version,
payload,
assistant_sid=self._solution["assistant_sid"],
)
def update(
self, fallback_actions: Union[object, object] = values.unset
) -> AssistantFallbackActionsInstance:
"""
Update the AssistantFallbackActionsInstance
:param fallback_actions:
:returns: The updated AssistantFallbackActionsInstance
"""
data = values.of(
{
"FallbackActions": serialize.object(fallback_actions),
}
)
payload = self._version.update(
method="POST",
uri=self._uri,
data=data,
)
return AssistantFallbackActionsInstance(
self._version, payload, assistant_sid=self._solution["assistant_sid"]
)
async def update_async(
self, fallback_actions: Union[object, object] = values.unset
) -> AssistantFallbackActionsInstance:
"""
Asynchronous coroutine to update the AssistantFallbackActionsInstance
:param fallback_actions:
:returns: The updated AssistantFallbackActionsInstance
"""
data = values.of(
{
"FallbackActions": serialize.object(fallback_actions),
}
)
payload = await self._version.update_async(
method="POST",
uri=self._uri,
data=data,
)
return AssistantFallbackActionsInstance(
self._version, payload, assistant_sid=self._solution["assistant_sid"]
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Preview.Understand.AssistantFallbackActionsContext {}>".format(
context
)
class AssistantFallbackActionsList(ListResource):
def __init__(self, version: Version, assistant_sid: str):
"""
Initialize the AssistantFallbackActionsList
:param version: Version that contains the resource
:param assistant_sid:
"""
super().__init__(version)
# Path Solution
self._solution = {
"assistant_sid": assistant_sid,
}
def get(self) -> AssistantFallbackActionsContext:
"""
Constructs a AssistantFallbackActionsContext
"""
return AssistantFallbackActionsContext(
self._version, assistant_sid=self._solution["assistant_sid"]
)
def __call__(self) -> AssistantFallbackActionsContext:
"""
Constructs a AssistantFallbackActionsContext
"""
return AssistantFallbackActionsContext(
self._version, assistant_sid=self._solution["assistant_sid"]
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.Understand.AssistantFallbackActionsList>"
@@ -0,0 +1,283 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Preview
This is the public Twilio REST API.
NOTE: This class is auto generated by OpenAPI Generator.
https://openapi-generator.tech
Do not edit the class manually.
"""
from typing import Any, Dict, Optional, Union
from twilio.base import serialize, values
from twilio.base.instance_context import InstanceContext
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.version import Version
class AssistantInitiationActionsInstance(InstanceResource):
"""
:ivar account_sid:
:ivar assistant_sid:
:ivar url:
:ivar data:
"""
def __init__(self, version: Version, payload: Dict[str, Any], assistant_sid: str):
super().__init__(version)
self.account_sid: Optional[str] = payload.get("account_sid")
self.assistant_sid: Optional[str] = payload.get("assistant_sid")
self.url: Optional[str] = payload.get("url")
self.data: Optional[Dict[str, object]] = payload.get("data")
self._solution = {
"assistant_sid": assistant_sid,
}
self._context: Optional[AssistantInitiationActionsContext] = None
@property
def _proxy(self) -> "AssistantInitiationActionsContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: AssistantInitiationActionsContext for this AssistantInitiationActionsInstance
"""
if self._context is None:
self._context = AssistantInitiationActionsContext(
self._version,
assistant_sid=self._solution["assistant_sid"],
)
return self._context
def fetch(self) -> "AssistantInitiationActionsInstance":
"""
Fetch the AssistantInitiationActionsInstance
:returns: The fetched AssistantInitiationActionsInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "AssistantInitiationActionsInstance":
"""
Asynchronous coroutine to fetch the AssistantInitiationActionsInstance
:returns: The fetched AssistantInitiationActionsInstance
"""
return await self._proxy.fetch_async()
def update(
self, initiation_actions: Union[object, object] = values.unset
) -> "AssistantInitiationActionsInstance":
"""
Update the AssistantInitiationActionsInstance
:param initiation_actions:
:returns: The updated AssistantInitiationActionsInstance
"""
return self._proxy.update(
initiation_actions=initiation_actions,
)
async def update_async(
self, initiation_actions: Union[object, object] = values.unset
) -> "AssistantInitiationActionsInstance":
"""
Asynchronous coroutine to update the AssistantInitiationActionsInstance
:param initiation_actions:
:returns: The updated AssistantInitiationActionsInstance
"""
return await self._proxy.update_async(
initiation_actions=initiation_actions,
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return (
"<Twilio.Preview.Understand.AssistantInitiationActionsInstance {}>".format(
context
)
)
class AssistantInitiationActionsContext(InstanceContext):
def __init__(self, version: Version, assistant_sid: str):
"""
Initialize the AssistantInitiationActionsContext
:param version: Version that contains the resource
:param assistant_sid:
"""
super().__init__(version)
# Path Solution
self._solution = {
"assistant_sid": assistant_sid,
}
self._uri = "/Assistants/{assistant_sid}/InitiationActions".format(
**self._solution
)
def fetch(self) -> AssistantInitiationActionsInstance:
"""
Fetch the AssistantInitiationActionsInstance
:returns: The fetched AssistantInitiationActionsInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return AssistantInitiationActionsInstance(
self._version,
payload,
assistant_sid=self._solution["assistant_sid"],
)
async def fetch_async(self) -> AssistantInitiationActionsInstance:
"""
Asynchronous coroutine to fetch the AssistantInitiationActionsInstance
:returns: The fetched AssistantInitiationActionsInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return AssistantInitiationActionsInstance(
self._version,
payload,
assistant_sid=self._solution["assistant_sid"],
)
def update(
self, initiation_actions: Union[object, object] = values.unset
) -> AssistantInitiationActionsInstance:
"""
Update the AssistantInitiationActionsInstance
:param initiation_actions:
:returns: The updated AssistantInitiationActionsInstance
"""
data = values.of(
{
"InitiationActions": serialize.object(initiation_actions),
}
)
payload = self._version.update(
method="POST",
uri=self._uri,
data=data,
)
return AssistantInitiationActionsInstance(
self._version, payload, assistant_sid=self._solution["assistant_sid"]
)
async def update_async(
self, initiation_actions: Union[object, object] = values.unset
) -> AssistantInitiationActionsInstance:
"""
Asynchronous coroutine to update the AssistantInitiationActionsInstance
:param initiation_actions:
:returns: The updated AssistantInitiationActionsInstance
"""
data = values.of(
{
"InitiationActions": serialize.object(initiation_actions),
}
)
payload = await self._version.update_async(
method="POST",
uri=self._uri,
data=data,
)
return AssistantInitiationActionsInstance(
self._version, payload, assistant_sid=self._solution["assistant_sid"]
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return (
"<Twilio.Preview.Understand.AssistantInitiationActionsContext {}>".format(
context
)
)
class AssistantInitiationActionsList(ListResource):
def __init__(self, version: Version, assistant_sid: str):
"""
Initialize the AssistantInitiationActionsList
:param version: Version that contains the resource
:param assistant_sid:
"""
super().__init__(version)
# Path Solution
self._solution = {
"assistant_sid": assistant_sid,
}
def get(self) -> AssistantInitiationActionsContext:
"""
Constructs a AssistantInitiationActionsContext
"""
return AssistantInitiationActionsContext(
self._version, assistant_sid=self._solution["assistant_sid"]
)
def __call__(self) -> AssistantInitiationActionsContext:
"""
Constructs a AssistantInitiationActionsContext
"""
return AssistantInitiationActionsContext(
self._version, assistant_sid=self._solution["assistant_sid"]
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.Understand.AssistantInitiationActionsList>"
@@ -0,0 +1,210 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Preview
This is the public Twilio REST API.
NOTE: This class is auto generated by OpenAPI Generator.
https://openapi-generator.tech
Do not edit the class manually.
"""
from typing import Any, Dict, Optional
from twilio.base.instance_context import InstanceContext
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.version import Version
class DialogueInstance(InstanceResource):
"""
:ivar account_sid: The unique ID of the Account that created this Field.
:ivar assistant_sid: The unique ID of the parent Assistant.
:ivar sid: The unique ID of the Dialogue
:ivar data: The dialogue memory object as json
:ivar url:
"""
def __init__(
self,
version: Version,
payload: Dict[str, Any],
assistant_sid: str,
sid: Optional[str] = None,
):
super().__init__(version)
self.account_sid: Optional[str] = payload.get("account_sid")
self.assistant_sid: Optional[str] = payload.get("assistant_sid")
self.sid: Optional[str] = payload.get("sid")
self.data: Optional[Dict[str, object]] = payload.get("data")
self.url: Optional[str] = payload.get("url")
self._solution = {
"assistant_sid": assistant_sid,
"sid": sid or self.sid,
}
self._context: Optional[DialogueContext] = None
@property
def _proxy(self) -> "DialogueContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: DialogueContext for this DialogueInstance
"""
if self._context is None:
self._context = DialogueContext(
self._version,
assistant_sid=self._solution["assistant_sid"],
sid=self._solution["sid"],
)
return self._context
def fetch(self) -> "DialogueInstance":
"""
Fetch the DialogueInstance
:returns: The fetched DialogueInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "DialogueInstance":
"""
Asynchronous coroutine to fetch the DialogueInstance
:returns: The fetched DialogueInstance
"""
return await self._proxy.fetch_async()
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Preview.Understand.DialogueInstance {}>".format(context)
class DialogueContext(InstanceContext):
def __init__(self, version: Version, assistant_sid: str, sid: str):
"""
Initialize the DialogueContext
:param version: Version that contains the resource
:param assistant_sid:
:param sid:
"""
super().__init__(version)
# Path Solution
self._solution = {
"assistant_sid": assistant_sid,
"sid": sid,
}
self._uri = "/Assistants/{assistant_sid}/Dialogues/{sid}".format(
**self._solution
)
def fetch(self) -> DialogueInstance:
"""
Fetch the DialogueInstance
:returns: The fetched DialogueInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return DialogueInstance(
self._version,
payload,
assistant_sid=self._solution["assistant_sid"],
sid=self._solution["sid"],
)
async def fetch_async(self) -> DialogueInstance:
"""
Asynchronous coroutine to fetch the DialogueInstance
:returns: The fetched DialogueInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return DialogueInstance(
self._version,
payload,
assistant_sid=self._solution["assistant_sid"],
sid=self._solution["sid"],
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Preview.Understand.DialogueContext {}>".format(context)
class DialogueList(ListResource):
def __init__(self, version: Version, assistant_sid: str):
"""
Initialize the DialogueList
:param version: Version that contains the resource
:param assistant_sid:
"""
super().__init__(version)
# Path Solution
self._solution = {
"assistant_sid": assistant_sid,
}
def get(self, sid: str) -> DialogueContext:
"""
Constructs a DialogueContext
:param sid:
"""
return DialogueContext(
self._version, assistant_sid=self._solution["assistant_sid"], sid=sid
)
def __call__(self, sid: str) -> DialogueContext:
"""
Constructs a DialogueContext
:param sid:
"""
return DialogueContext(
self._version, assistant_sid=self._solution["assistant_sid"], sid=sid
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.Understand.DialogueList>"
@@ -0,0 +1,654 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Preview
This is the public Twilio REST API.
NOTE: This class is auto generated by OpenAPI Generator.
https://openapi-generator.tech
Do not edit the class manually.
"""
from datetime import datetime
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
from twilio.base import deserialize, values
from twilio.base.instance_context import InstanceContext
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.version import Version
from twilio.base.page import Page
from twilio.rest.preview.understand.assistant.field_type.field_value import (
FieldValueList,
)
class FieldTypeInstance(InstanceResource):
"""
:ivar account_sid: The unique ID of the Account that created this Field Type.
:ivar date_created: The date that this resource was created
:ivar date_updated: The date that this resource was last updated
:ivar friendly_name: A user-provided string that identifies this resource. It is non-unique and can up to 255 characters long.
:ivar links:
:ivar assistant_sid: The unique ID of the Assistant.
:ivar sid: A 34 character string that uniquely identifies this resource.
:ivar unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long.
:ivar url:
"""
def __init__(
self,
version: Version,
payload: Dict[str, Any],
assistant_sid: str,
sid: Optional[str] = None,
):
super().__init__(version)
self.account_sid: Optional[str] = payload.get("account_sid")
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_created")
)
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_updated")
)
self.friendly_name: Optional[str] = payload.get("friendly_name")
self.links: Optional[Dict[str, object]] = payload.get("links")
self.assistant_sid: Optional[str] = payload.get("assistant_sid")
self.sid: Optional[str] = payload.get("sid")
self.unique_name: Optional[str] = payload.get("unique_name")
self.url: Optional[str] = payload.get("url")
self._solution = {
"assistant_sid": assistant_sid,
"sid": sid or self.sid,
}
self._context: Optional[FieldTypeContext] = None
@property
def _proxy(self) -> "FieldTypeContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: FieldTypeContext for this FieldTypeInstance
"""
if self._context is None:
self._context = FieldTypeContext(
self._version,
assistant_sid=self._solution["assistant_sid"],
sid=self._solution["sid"],
)
return self._context
def delete(self) -> bool:
"""
Deletes the FieldTypeInstance
:returns: True if delete succeeds, False otherwise
"""
return self._proxy.delete()
async def delete_async(self) -> bool:
"""
Asynchronous coroutine that deletes the FieldTypeInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._proxy.delete_async()
def fetch(self) -> "FieldTypeInstance":
"""
Fetch the FieldTypeInstance
:returns: The fetched FieldTypeInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "FieldTypeInstance":
"""
Asynchronous coroutine to fetch the FieldTypeInstance
:returns: The fetched FieldTypeInstance
"""
return await self._proxy.fetch_async()
def update(
self,
friendly_name: Union[str, object] = values.unset,
unique_name: Union[str, object] = values.unset,
) -> "FieldTypeInstance":
"""
Update the FieldTypeInstance
:param friendly_name: A user-provided string that identifies this resource. It is non-unique and can up to 255 characters long.
:param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long.
:returns: The updated FieldTypeInstance
"""
return self._proxy.update(
friendly_name=friendly_name,
unique_name=unique_name,
)
async def update_async(
self,
friendly_name: Union[str, object] = values.unset,
unique_name: Union[str, object] = values.unset,
) -> "FieldTypeInstance":
"""
Asynchronous coroutine to update the FieldTypeInstance
:param friendly_name: A user-provided string that identifies this resource. It is non-unique and can up to 255 characters long.
:param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long.
:returns: The updated FieldTypeInstance
"""
return await self._proxy.update_async(
friendly_name=friendly_name,
unique_name=unique_name,
)
@property
def field_values(self) -> FieldValueList:
"""
Access the field_values
"""
return self._proxy.field_values
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Preview.Understand.FieldTypeInstance {}>".format(context)
class FieldTypeContext(InstanceContext):
def __init__(self, version: Version, assistant_sid: str, sid: str):
"""
Initialize the FieldTypeContext
:param version: Version that contains the resource
:param assistant_sid:
:param sid:
"""
super().__init__(version)
# Path Solution
self._solution = {
"assistant_sid": assistant_sid,
"sid": sid,
}
self._uri = "/Assistants/{assistant_sid}/FieldTypes/{sid}".format(
**self._solution
)
self._field_values: Optional[FieldValueList] = None
def delete(self) -> bool:
"""
Deletes the FieldTypeInstance
:returns: True if delete succeeds, False otherwise
"""
return self._version.delete(
method="DELETE",
uri=self._uri,
)
async def delete_async(self) -> bool:
"""
Asynchronous coroutine that deletes the FieldTypeInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._version.delete_async(
method="DELETE",
uri=self._uri,
)
def fetch(self) -> FieldTypeInstance:
"""
Fetch the FieldTypeInstance
:returns: The fetched FieldTypeInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return FieldTypeInstance(
self._version,
payload,
assistant_sid=self._solution["assistant_sid"],
sid=self._solution["sid"],
)
async def fetch_async(self) -> FieldTypeInstance:
"""
Asynchronous coroutine to fetch the FieldTypeInstance
:returns: The fetched FieldTypeInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return FieldTypeInstance(
self._version,
payload,
assistant_sid=self._solution["assistant_sid"],
sid=self._solution["sid"],
)
def update(
self,
friendly_name: Union[str, object] = values.unset,
unique_name: Union[str, object] = values.unset,
) -> FieldTypeInstance:
"""
Update the FieldTypeInstance
:param friendly_name: A user-provided string that identifies this resource. It is non-unique and can up to 255 characters long.
:param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long.
:returns: The updated FieldTypeInstance
"""
data = values.of(
{
"FriendlyName": friendly_name,
"UniqueName": unique_name,
}
)
payload = self._version.update(
method="POST",
uri=self._uri,
data=data,
)
return FieldTypeInstance(
self._version,
payload,
assistant_sid=self._solution["assistant_sid"],
sid=self._solution["sid"],
)
async def update_async(
self,
friendly_name: Union[str, object] = values.unset,
unique_name: Union[str, object] = values.unset,
) -> FieldTypeInstance:
"""
Asynchronous coroutine to update the FieldTypeInstance
:param friendly_name: A user-provided string that identifies this resource. It is non-unique and can up to 255 characters long.
:param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long.
:returns: The updated FieldTypeInstance
"""
data = values.of(
{
"FriendlyName": friendly_name,
"UniqueName": unique_name,
}
)
payload = await self._version.update_async(
method="POST",
uri=self._uri,
data=data,
)
return FieldTypeInstance(
self._version,
payload,
assistant_sid=self._solution["assistant_sid"],
sid=self._solution["sid"],
)
@property
def field_values(self) -> FieldValueList:
"""
Access the field_values
"""
if self._field_values is None:
self._field_values = FieldValueList(
self._version,
self._solution["assistant_sid"],
self._solution["sid"],
)
return self._field_values
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Preview.Understand.FieldTypeContext {}>".format(context)
class FieldTypePage(Page):
def get_instance(self, payload: Dict[str, Any]) -> FieldTypeInstance:
"""
Build an instance of FieldTypeInstance
:param payload: Payload response from the API
"""
return FieldTypeInstance(
self._version, payload, assistant_sid=self._solution["assistant_sid"]
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.Understand.FieldTypePage>"
class FieldTypeList(ListResource):
def __init__(self, version: Version, assistant_sid: str):
"""
Initialize the FieldTypeList
:param version: Version that contains the resource
:param assistant_sid:
"""
super().__init__(version)
# Path Solution
self._solution = {
"assistant_sid": assistant_sid,
}
self._uri = "/Assistants/{assistant_sid}/FieldTypes".format(**self._solution)
def create(
self, unique_name: str, friendly_name: Union[str, object] = values.unset
) -> FieldTypeInstance:
"""
Create the FieldTypeInstance
:param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long.
:param friendly_name: A user-provided string that identifies this resource. It is non-unique and can up to 255 characters long.
:returns: The created FieldTypeInstance
"""
data = values.of(
{
"UniqueName": unique_name,
"FriendlyName": friendly_name,
}
)
payload = self._version.create(
method="POST",
uri=self._uri,
data=data,
)
return FieldTypeInstance(
self._version, payload, assistant_sid=self._solution["assistant_sid"]
)
async def create_async(
self, unique_name: str, friendly_name: Union[str, object] = values.unset
) -> FieldTypeInstance:
"""
Asynchronously create the FieldTypeInstance
:param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long.
:param friendly_name: A user-provided string that identifies this resource. It is non-unique and can up to 255 characters long.
:returns: The created FieldTypeInstance
"""
data = values.of(
{
"UniqueName": unique_name,
"FriendlyName": friendly_name,
}
)
payload = await self._version.create_async(
method="POST",
uri=self._uri,
data=data,
)
return FieldTypeInstance(
self._version, payload, assistant_sid=self._solution["assistant_sid"]
)
def stream(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[FieldTypeInstance]:
"""
Streams FieldTypeInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param limit: Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the
limit with the most efficient page size, i.e. min(limit, 1000)
:returns: Generator that will yield up to limit results
"""
limits = self._version.read_limits(limit, page_size)
page = self.page(page_size=limits["page_size"])
return self._version.stream(page, limits["limit"])
async def stream_async(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> AsyncIterator[FieldTypeInstance]:
"""
Asynchronously streams FieldTypeInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param limit: Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the
limit with the most efficient page size, i.e. min(limit, 1000)
:returns: Generator that will yield up to limit results
"""
limits = self._version.read_limits(limit, page_size)
page = await self.page_async(page_size=limits["page_size"])
return self._version.stream_async(page, limits["limit"])
def list(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[FieldTypeInstance]:
"""
Lists FieldTypeInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param limit: Upper limit for the number of records to return. list() guarantees
never to return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, list() will attempt to read the limit
with the most efficient page size, i.e. min(limit, 1000)
:returns: list that will contain up to limit results
"""
return list(
self.stream(
limit=limit,
page_size=page_size,
)
)
async def list_async(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[FieldTypeInstance]:
"""
Asynchronously lists FieldTypeInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param limit: Upper limit for the number of records to return. list() guarantees
never to return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, list() will attempt to read the limit
with the most efficient page size, i.e. min(limit, 1000)
:returns: list that will contain up to limit results
"""
return [
record
async for record in await self.stream_async(
limit=limit,
page_size=page_size,
)
]
def page(
self,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> FieldTypePage:
"""
Retrieve a single page of FieldTypeInstance records from the API.
Request is executed immediately
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of FieldTypeInstance
"""
data = values.of(
{
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return FieldTypePage(self._version, response, self._solution)
async def page_async(
self,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> FieldTypePage:
"""
Asynchronously retrieve a single page of FieldTypeInstance records from the API.
Request is executed immediately
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of FieldTypeInstance
"""
data = values.of(
{
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = await self._version.page_async(
method="GET", uri=self._uri, params=data
)
return FieldTypePage(self._version, response, self._solution)
def get_page(self, target_url: str) -> FieldTypePage:
"""
Retrieve a specific page of FieldTypeInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of FieldTypeInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return FieldTypePage(self._version, response, self._solution)
async def get_page_async(self, target_url: str) -> FieldTypePage:
"""
Asynchronously retrieve a specific page of FieldTypeInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of FieldTypeInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return FieldTypePage(self._version, response, self._solution)
def get(self, sid: str) -> FieldTypeContext:
"""
Constructs a FieldTypeContext
:param sid:
"""
return FieldTypeContext(
self._version, assistant_sid=self._solution["assistant_sid"], sid=sid
)
def __call__(self, sid: str) -> FieldTypeContext:
"""
Constructs a FieldTypeContext
:param sid:
"""
return FieldTypeContext(
self._version, assistant_sid=self._solution["assistant_sid"], sid=sid
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.Understand.FieldTypeList>"
@@ -0,0 +1,577 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Preview
This is the public Twilio REST API.
NOTE: This class is auto generated by OpenAPI Generator.
https://openapi-generator.tech
Do not edit the class manually.
"""
from datetime import datetime
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
from twilio.base import deserialize, values
from twilio.base.instance_context import InstanceContext
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.version import Version
from twilio.base.page import Page
class FieldValueInstance(InstanceResource):
"""
:ivar account_sid: The unique ID of the Account that created this Field Value.
:ivar date_created: The date that this resource was created
:ivar date_updated: The date that this resource was last updated
:ivar field_type_sid: The unique ID of the Field Type associated with this Field Value.
:ivar language: An ISO language-country string of the value.
:ivar assistant_sid: The unique ID of the Assistant.
:ivar sid: A 34 character string that uniquely identifies this resource.
:ivar value: The Field Value itself.
:ivar url:
:ivar synonym_of: A value that indicates this field value is a synonym of. Empty if the value is not a synonym.
"""
def __init__(
self,
version: Version,
payload: Dict[str, Any],
assistant_sid: str,
field_type_sid: str,
sid: Optional[str] = None,
):
super().__init__(version)
self.account_sid: Optional[str] = payload.get("account_sid")
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_created")
)
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_updated")
)
self.field_type_sid: Optional[str] = payload.get("field_type_sid")
self.language: Optional[str] = payload.get("language")
self.assistant_sid: Optional[str] = payload.get("assistant_sid")
self.sid: Optional[str] = payload.get("sid")
self.value: Optional[str] = payload.get("value")
self.url: Optional[str] = payload.get("url")
self.synonym_of: Optional[str] = payload.get("synonym_of")
self._solution = {
"assistant_sid": assistant_sid,
"field_type_sid": field_type_sid,
"sid": sid or self.sid,
}
self._context: Optional[FieldValueContext] = None
@property
def _proxy(self) -> "FieldValueContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: FieldValueContext for this FieldValueInstance
"""
if self._context is None:
self._context = FieldValueContext(
self._version,
assistant_sid=self._solution["assistant_sid"],
field_type_sid=self._solution["field_type_sid"],
sid=self._solution["sid"],
)
return self._context
def delete(self) -> bool:
"""
Deletes the FieldValueInstance
:returns: True if delete succeeds, False otherwise
"""
return self._proxy.delete()
async def delete_async(self) -> bool:
"""
Asynchronous coroutine that deletes the FieldValueInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._proxy.delete_async()
def fetch(self) -> "FieldValueInstance":
"""
Fetch the FieldValueInstance
:returns: The fetched FieldValueInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "FieldValueInstance":
"""
Asynchronous coroutine to fetch the FieldValueInstance
:returns: The fetched FieldValueInstance
"""
return await self._proxy.fetch_async()
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Preview.Understand.FieldValueInstance {}>".format(context)
class FieldValueContext(InstanceContext):
def __init__(
self, version: Version, assistant_sid: str, field_type_sid: str, sid: str
):
"""
Initialize the FieldValueContext
:param version: Version that contains the resource
:param assistant_sid:
:param field_type_sid:
:param sid:
"""
super().__init__(version)
# Path Solution
self._solution = {
"assistant_sid": assistant_sid,
"field_type_sid": field_type_sid,
"sid": sid,
}
self._uri = "/Assistants/{assistant_sid}/FieldTypes/{field_type_sid}/FieldValues/{sid}".format(
**self._solution
)
def delete(self) -> bool:
"""
Deletes the FieldValueInstance
:returns: True if delete succeeds, False otherwise
"""
return self._version.delete(
method="DELETE",
uri=self._uri,
)
async def delete_async(self) -> bool:
"""
Asynchronous coroutine that deletes the FieldValueInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._version.delete_async(
method="DELETE",
uri=self._uri,
)
def fetch(self) -> FieldValueInstance:
"""
Fetch the FieldValueInstance
:returns: The fetched FieldValueInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return FieldValueInstance(
self._version,
payload,
assistant_sid=self._solution["assistant_sid"],
field_type_sid=self._solution["field_type_sid"],
sid=self._solution["sid"],
)
async def fetch_async(self) -> FieldValueInstance:
"""
Asynchronous coroutine to fetch the FieldValueInstance
:returns: The fetched FieldValueInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return FieldValueInstance(
self._version,
payload,
assistant_sid=self._solution["assistant_sid"],
field_type_sid=self._solution["field_type_sid"],
sid=self._solution["sid"],
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Preview.Understand.FieldValueContext {}>".format(context)
class FieldValuePage(Page):
def get_instance(self, payload: Dict[str, Any]) -> FieldValueInstance:
"""
Build an instance of FieldValueInstance
:param payload: Payload response from the API
"""
return FieldValueInstance(
self._version,
payload,
assistant_sid=self._solution["assistant_sid"],
field_type_sid=self._solution["field_type_sid"],
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.Understand.FieldValuePage>"
class FieldValueList(ListResource):
def __init__(self, version: Version, assistant_sid: str, field_type_sid: str):
"""
Initialize the FieldValueList
:param version: Version that contains the resource
:param assistant_sid:
:param field_type_sid:
"""
super().__init__(version)
# Path Solution
self._solution = {
"assistant_sid": assistant_sid,
"field_type_sid": field_type_sid,
}
self._uri = "/Assistants/{assistant_sid}/FieldTypes/{field_type_sid}/FieldValues".format(
**self._solution
)
def create(
self, language: str, value: str, synonym_of: Union[str, object] = values.unset
) -> FieldValueInstance:
"""
Create the FieldValueInstance
:param language: An ISO language-country string of the value.
:param value: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long.
:param synonym_of: A value that indicates this field value is a synonym of. Empty if the value is not a synonym.
:returns: The created FieldValueInstance
"""
data = values.of(
{
"Language": language,
"Value": value,
"SynonymOf": synonym_of,
}
)
payload = self._version.create(
method="POST",
uri=self._uri,
data=data,
)
return FieldValueInstance(
self._version,
payload,
assistant_sid=self._solution["assistant_sid"],
field_type_sid=self._solution["field_type_sid"],
)
async def create_async(
self, language: str, value: str, synonym_of: Union[str, object] = values.unset
) -> FieldValueInstance:
"""
Asynchronously create the FieldValueInstance
:param language: An ISO language-country string of the value.
:param value: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long.
:param synonym_of: A value that indicates this field value is a synonym of. Empty if the value is not a synonym.
:returns: The created FieldValueInstance
"""
data = values.of(
{
"Language": language,
"Value": value,
"SynonymOf": synonym_of,
}
)
payload = await self._version.create_async(
method="POST",
uri=self._uri,
data=data,
)
return FieldValueInstance(
self._version,
payload,
assistant_sid=self._solution["assistant_sid"],
field_type_sid=self._solution["field_type_sid"],
)
def stream(
self,
language: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[FieldValueInstance]:
"""
Streams FieldValueInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param str language: An ISO language-country string of the value. For example: *en-US*
:param limit: Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the
limit with the most efficient page size, i.e. min(limit, 1000)
:returns: Generator that will yield up to limit results
"""
limits = self._version.read_limits(limit, page_size)
page = self.page(language=language, page_size=limits["page_size"])
return self._version.stream(page, limits["limit"])
async def stream_async(
self,
language: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> AsyncIterator[FieldValueInstance]:
"""
Asynchronously streams FieldValueInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param str language: An ISO language-country string of the value. For example: *en-US*
:param limit: Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the
limit with the most efficient page size, i.e. min(limit, 1000)
:returns: Generator that will yield up to limit results
"""
limits = self._version.read_limits(limit, page_size)
page = await self.page_async(language=language, page_size=limits["page_size"])
return self._version.stream_async(page, limits["limit"])
def list(
self,
language: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[FieldValueInstance]:
"""
Lists FieldValueInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param str language: An ISO language-country string of the value. For example: *en-US*
:param limit: Upper limit for the number of records to return. list() guarantees
never to return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, list() will attempt to read the limit
with the most efficient page size, i.e. min(limit, 1000)
:returns: list that will contain up to limit results
"""
return list(
self.stream(
language=language,
limit=limit,
page_size=page_size,
)
)
async def list_async(
self,
language: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[FieldValueInstance]:
"""
Asynchronously lists FieldValueInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param str language: An ISO language-country string of the value. For example: *en-US*
:param limit: Upper limit for the number of records to return. list() guarantees
never to return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, list() will attempt to read the limit
with the most efficient page size, i.e. min(limit, 1000)
:returns: list that will contain up to limit results
"""
return [
record
async for record in await self.stream_async(
language=language,
limit=limit,
page_size=page_size,
)
]
def page(
self,
language: Union[str, object] = values.unset,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> FieldValuePage:
"""
Retrieve a single page of FieldValueInstance records from the API.
Request is executed immediately
:param language: An ISO language-country string of the value. For example: *en-US*
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of FieldValueInstance
"""
data = values.of(
{
"Language": language,
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return FieldValuePage(self._version, response, self._solution)
async def page_async(
self,
language: Union[str, object] = values.unset,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> FieldValuePage:
"""
Asynchronously retrieve a single page of FieldValueInstance records from the API.
Request is executed immediately
:param language: An ISO language-country string of the value. For example: *en-US*
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of FieldValueInstance
"""
data = values.of(
{
"Language": language,
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = await self._version.page_async(
method="GET", uri=self._uri, params=data
)
return FieldValuePage(self._version, response, self._solution)
def get_page(self, target_url: str) -> FieldValuePage:
"""
Retrieve a specific page of FieldValueInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of FieldValueInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return FieldValuePage(self._version, response, self._solution)
async def get_page_async(self, target_url: str) -> FieldValuePage:
"""
Asynchronously retrieve a specific page of FieldValueInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of FieldValueInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return FieldValuePage(self._version, response, self._solution)
def get(self, sid: str) -> FieldValueContext:
"""
Constructs a FieldValueContext
:param sid:
"""
return FieldValueContext(
self._version,
assistant_sid=self._solution["assistant_sid"],
field_type_sid=self._solution["field_type_sid"],
sid=sid,
)
def __call__(self, sid: str) -> FieldValueContext:
"""
Constructs a FieldValueContext
:param sid:
"""
return FieldValueContext(
self._version,
assistant_sid=self._solution["assistant_sid"],
field_type_sid=self._solution["field_type_sid"],
sid=sid,
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.Understand.FieldValueList>"
@@ -0,0 +1,627 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Preview
This is the public Twilio REST API.
NOTE: This class is auto generated by OpenAPI Generator.
https://openapi-generator.tech
Do not edit the class manually.
"""
from datetime import datetime
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
from twilio.base import deserialize, values
from twilio.base.instance_context import InstanceContext
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.version import Version
from twilio.base.page import Page
class ModelBuildInstance(InstanceResource):
class Status(object):
ENQUEUED = "enqueued"
BUILDING = "building"
COMPLETED = "completed"
FAILED = "failed"
CANCELED = "canceled"
"""
:ivar account_sid: The unique ID of the Account that created this Model Build.
:ivar date_created: The date that this resource was created
:ivar date_updated: The date that this resource was last updated
:ivar assistant_sid: The unique ID of the parent Assistant.
:ivar sid: A 34 character string that uniquely identifies this resource.
:ivar status:
:ivar unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long.
:ivar url:
:ivar build_duration: The time in seconds it took to build the model.
:ivar error_code:
"""
def __init__(
self,
version: Version,
payload: Dict[str, Any],
assistant_sid: str,
sid: Optional[str] = None,
):
super().__init__(version)
self.account_sid: Optional[str] = payload.get("account_sid")
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_created")
)
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_updated")
)
self.assistant_sid: Optional[str] = payload.get("assistant_sid")
self.sid: Optional[str] = payload.get("sid")
self.status: Optional["ModelBuildInstance.Status"] = payload.get("status")
self.unique_name: Optional[str] = payload.get("unique_name")
self.url: Optional[str] = payload.get("url")
self.build_duration: Optional[int] = deserialize.integer(
payload.get("build_duration")
)
self.error_code: Optional[int] = deserialize.integer(payload.get("error_code"))
self._solution = {
"assistant_sid": assistant_sid,
"sid": sid or self.sid,
}
self._context: Optional[ModelBuildContext] = None
@property
def _proxy(self) -> "ModelBuildContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: ModelBuildContext for this ModelBuildInstance
"""
if self._context is None:
self._context = ModelBuildContext(
self._version,
assistant_sid=self._solution["assistant_sid"],
sid=self._solution["sid"],
)
return self._context
def delete(self) -> bool:
"""
Deletes the ModelBuildInstance
:returns: True if delete succeeds, False otherwise
"""
return self._proxy.delete()
async def delete_async(self) -> bool:
"""
Asynchronous coroutine that deletes the ModelBuildInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._proxy.delete_async()
def fetch(self) -> "ModelBuildInstance":
"""
Fetch the ModelBuildInstance
:returns: The fetched ModelBuildInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "ModelBuildInstance":
"""
Asynchronous coroutine to fetch the ModelBuildInstance
:returns: The fetched ModelBuildInstance
"""
return await self._proxy.fetch_async()
def update(
self, unique_name: Union[str, object] = values.unset
) -> "ModelBuildInstance":
"""
Update the ModelBuildInstance
:param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. For example: v0.1
:returns: The updated ModelBuildInstance
"""
return self._proxy.update(
unique_name=unique_name,
)
async def update_async(
self, unique_name: Union[str, object] = values.unset
) -> "ModelBuildInstance":
"""
Asynchronous coroutine to update the ModelBuildInstance
:param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. For example: v0.1
:returns: The updated ModelBuildInstance
"""
return await self._proxy.update_async(
unique_name=unique_name,
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Preview.Understand.ModelBuildInstance {}>".format(context)
class ModelBuildContext(InstanceContext):
def __init__(self, version: Version, assistant_sid: str, sid: str):
"""
Initialize the ModelBuildContext
:param version: Version that contains the resource
:param assistant_sid:
:param sid:
"""
super().__init__(version)
# Path Solution
self._solution = {
"assistant_sid": assistant_sid,
"sid": sid,
}
self._uri = "/Assistants/{assistant_sid}/ModelBuilds/{sid}".format(
**self._solution
)
def delete(self) -> bool:
"""
Deletes the ModelBuildInstance
:returns: True if delete succeeds, False otherwise
"""
return self._version.delete(
method="DELETE",
uri=self._uri,
)
async def delete_async(self) -> bool:
"""
Asynchronous coroutine that deletes the ModelBuildInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._version.delete_async(
method="DELETE",
uri=self._uri,
)
def fetch(self) -> ModelBuildInstance:
"""
Fetch the ModelBuildInstance
:returns: The fetched ModelBuildInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return ModelBuildInstance(
self._version,
payload,
assistant_sid=self._solution["assistant_sid"],
sid=self._solution["sid"],
)
async def fetch_async(self) -> ModelBuildInstance:
"""
Asynchronous coroutine to fetch the ModelBuildInstance
:returns: The fetched ModelBuildInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return ModelBuildInstance(
self._version,
payload,
assistant_sid=self._solution["assistant_sid"],
sid=self._solution["sid"],
)
def update(
self, unique_name: Union[str, object] = values.unset
) -> ModelBuildInstance:
"""
Update the ModelBuildInstance
:param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. For example: v0.1
:returns: The updated ModelBuildInstance
"""
data = values.of(
{
"UniqueName": unique_name,
}
)
payload = self._version.update(
method="POST",
uri=self._uri,
data=data,
)
return ModelBuildInstance(
self._version,
payload,
assistant_sid=self._solution["assistant_sid"],
sid=self._solution["sid"],
)
async def update_async(
self, unique_name: Union[str, object] = values.unset
) -> ModelBuildInstance:
"""
Asynchronous coroutine to update the ModelBuildInstance
:param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. For example: v0.1
:returns: The updated ModelBuildInstance
"""
data = values.of(
{
"UniqueName": unique_name,
}
)
payload = await self._version.update_async(
method="POST",
uri=self._uri,
data=data,
)
return ModelBuildInstance(
self._version,
payload,
assistant_sid=self._solution["assistant_sid"],
sid=self._solution["sid"],
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Preview.Understand.ModelBuildContext {}>".format(context)
class ModelBuildPage(Page):
def get_instance(self, payload: Dict[str, Any]) -> ModelBuildInstance:
"""
Build an instance of ModelBuildInstance
:param payload: Payload response from the API
"""
return ModelBuildInstance(
self._version, payload, assistant_sid=self._solution["assistant_sid"]
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.Understand.ModelBuildPage>"
class ModelBuildList(ListResource):
def __init__(self, version: Version, assistant_sid: str):
"""
Initialize the ModelBuildList
:param version: Version that contains the resource
:param assistant_sid:
"""
super().__init__(version)
# Path Solution
self._solution = {
"assistant_sid": assistant_sid,
}
self._uri = "/Assistants/{assistant_sid}/ModelBuilds".format(**self._solution)
def create(
self,
status_callback: Union[str, object] = values.unset,
unique_name: Union[str, object] = values.unset,
) -> ModelBuildInstance:
"""
Create the ModelBuildInstance
:param status_callback:
:param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. For example: v0.1
:returns: The created ModelBuildInstance
"""
data = values.of(
{
"StatusCallback": status_callback,
"UniqueName": unique_name,
}
)
payload = self._version.create(
method="POST",
uri=self._uri,
data=data,
)
return ModelBuildInstance(
self._version, payload, assistant_sid=self._solution["assistant_sid"]
)
async def create_async(
self,
status_callback: Union[str, object] = values.unset,
unique_name: Union[str, object] = values.unset,
) -> ModelBuildInstance:
"""
Asynchronously create the ModelBuildInstance
:param status_callback:
:param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. For example: v0.1
:returns: The created ModelBuildInstance
"""
data = values.of(
{
"StatusCallback": status_callback,
"UniqueName": unique_name,
}
)
payload = await self._version.create_async(
method="POST",
uri=self._uri,
data=data,
)
return ModelBuildInstance(
self._version, payload, assistant_sid=self._solution["assistant_sid"]
)
def stream(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[ModelBuildInstance]:
"""
Streams ModelBuildInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param limit: Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the
limit with the most efficient page size, i.e. min(limit, 1000)
:returns: Generator that will yield up to limit results
"""
limits = self._version.read_limits(limit, page_size)
page = self.page(page_size=limits["page_size"])
return self._version.stream(page, limits["limit"])
async def stream_async(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> AsyncIterator[ModelBuildInstance]:
"""
Asynchronously streams ModelBuildInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param limit: Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the
limit with the most efficient page size, i.e. min(limit, 1000)
:returns: Generator that will yield up to limit results
"""
limits = self._version.read_limits(limit, page_size)
page = await self.page_async(page_size=limits["page_size"])
return self._version.stream_async(page, limits["limit"])
def list(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[ModelBuildInstance]:
"""
Lists ModelBuildInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param limit: Upper limit for the number of records to return. list() guarantees
never to return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, list() will attempt to read the limit
with the most efficient page size, i.e. min(limit, 1000)
:returns: list that will contain up to limit results
"""
return list(
self.stream(
limit=limit,
page_size=page_size,
)
)
async def list_async(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[ModelBuildInstance]:
"""
Asynchronously lists ModelBuildInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param limit: Upper limit for the number of records to return. list() guarantees
never to return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, list() will attempt to read the limit
with the most efficient page size, i.e. min(limit, 1000)
:returns: list that will contain up to limit results
"""
return [
record
async for record in await self.stream_async(
limit=limit,
page_size=page_size,
)
]
def page(
self,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> ModelBuildPage:
"""
Retrieve a single page of ModelBuildInstance records from the API.
Request is executed immediately
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of ModelBuildInstance
"""
data = values.of(
{
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return ModelBuildPage(self._version, response, self._solution)
async def page_async(
self,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> ModelBuildPage:
"""
Asynchronously retrieve a single page of ModelBuildInstance records from the API.
Request is executed immediately
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of ModelBuildInstance
"""
data = values.of(
{
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = await self._version.page_async(
method="GET", uri=self._uri, params=data
)
return ModelBuildPage(self._version, response, self._solution)
def get_page(self, target_url: str) -> ModelBuildPage:
"""
Retrieve a specific page of ModelBuildInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of ModelBuildInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return ModelBuildPage(self._version, response, self._solution)
async def get_page_async(self, target_url: str) -> ModelBuildPage:
"""
Asynchronously retrieve a specific page of ModelBuildInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of ModelBuildInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return ModelBuildPage(self._version, response, self._solution)
def get(self, sid: str) -> ModelBuildContext:
"""
Constructs a ModelBuildContext
:param sid:
"""
return ModelBuildContext(
self._version, assistant_sid=self._solution["assistant_sid"], sid=sid
)
def __call__(self, sid: str) -> ModelBuildContext:
"""
Constructs a ModelBuildContext
:param sid:
"""
return ModelBuildContext(
self._version, assistant_sid=self._solution["assistant_sid"], sid=sid
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.Understand.ModelBuildList>"
@@ -0,0 +1,715 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Preview
This is the public Twilio REST API.
NOTE: This class is auto generated by OpenAPI Generator.
https://openapi-generator.tech
Do not edit the class manually.
"""
from datetime import datetime
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
from twilio.base import deserialize, values
from twilio.base.instance_context import InstanceContext
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.version import Version
from twilio.base.page import Page
class QueryInstance(InstanceResource):
"""
:ivar account_sid: The unique ID of the Account that created this Query.
:ivar date_created: The date that this resource was created
:ivar date_updated: The date that this resource was last updated
:ivar results: The natural language analysis results which include the Task recognized, the confidence score and a list of identified Fields.
:ivar language: An ISO language-country string of the sample.
:ivar model_build_sid: The unique ID of the Model Build queried.
:ivar query: The end-user's natural language input.
:ivar sample_sid: An optional reference to the Sample created from this query.
:ivar assistant_sid: The unique ID of the parent Assistant.
:ivar sid: A 34 character string that uniquely identifies this resource.
:ivar status: A string that described the query status. The values can be: pending_review, reviewed, discarded
:ivar url:
:ivar source_channel: The communication channel where this end-user input came from
"""
def __init__(
self,
version: Version,
payload: Dict[str, Any],
assistant_sid: str,
sid: Optional[str] = None,
):
super().__init__(version)
self.account_sid: Optional[str] = payload.get("account_sid")
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_created")
)
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_updated")
)
self.results: Optional[Dict[str, object]] = payload.get("results")
self.language: Optional[str] = payload.get("language")
self.model_build_sid: Optional[str] = payload.get("model_build_sid")
self.query: Optional[str] = payload.get("query")
self.sample_sid: Optional[str] = payload.get("sample_sid")
self.assistant_sid: Optional[str] = payload.get("assistant_sid")
self.sid: Optional[str] = payload.get("sid")
self.status: Optional[str] = payload.get("status")
self.url: Optional[str] = payload.get("url")
self.source_channel: Optional[str] = payload.get("source_channel")
self._solution = {
"assistant_sid": assistant_sid,
"sid": sid or self.sid,
}
self._context: Optional[QueryContext] = None
@property
def _proxy(self) -> "QueryContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: QueryContext for this QueryInstance
"""
if self._context is None:
self._context = QueryContext(
self._version,
assistant_sid=self._solution["assistant_sid"],
sid=self._solution["sid"],
)
return self._context
def delete(self) -> bool:
"""
Deletes the QueryInstance
:returns: True if delete succeeds, False otherwise
"""
return self._proxy.delete()
async def delete_async(self) -> bool:
"""
Asynchronous coroutine that deletes the QueryInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._proxy.delete_async()
def fetch(self) -> "QueryInstance":
"""
Fetch the QueryInstance
:returns: The fetched QueryInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "QueryInstance":
"""
Asynchronous coroutine to fetch the QueryInstance
:returns: The fetched QueryInstance
"""
return await self._proxy.fetch_async()
def update(
self,
sample_sid: Union[str, object] = values.unset,
status: Union[str, object] = values.unset,
) -> "QueryInstance":
"""
Update the QueryInstance
:param sample_sid: An optional reference to the Sample created from this query.
:param status: A string that described the query status. The values can be: pending_review, reviewed, discarded
:returns: The updated QueryInstance
"""
return self._proxy.update(
sample_sid=sample_sid,
status=status,
)
async def update_async(
self,
sample_sid: Union[str, object] = values.unset,
status: Union[str, object] = values.unset,
) -> "QueryInstance":
"""
Asynchronous coroutine to update the QueryInstance
:param sample_sid: An optional reference to the Sample created from this query.
:param status: A string that described the query status. The values can be: pending_review, reviewed, discarded
:returns: The updated QueryInstance
"""
return await self._proxy.update_async(
sample_sid=sample_sid,
status=status,
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Preview.Understand.QueryInstance {}>".format(context)
class QueryContext(InstanceContext):
def __init__(self, version: Version, assistant_sid: str, sid: str):
"""
Initialize the QueryContext
:param version: Version that contains the resource
:param assistant_sid: The unique ID of the parent Assistant.
:param sid: A 34 character string that uniquely identifies this resource.
"""
super().__init__(version)
# Path Solution
self._solution = {
"assistant_sid": assistant_sid,
"sid": sid,
}
self._uri = "/Assistants/{assistant_sid}/Queries/{sid}".format(**self._solution)
def delete(self) -> bool:
"""
Deletes the QueryInstance
:returns: True if delete succeeds, False otherwise
"""
return self._version.delete(
method="DELETE",
uri=self._uri,
)
async def delete_async(self) -> bool:
"""
Asynchronous coroutine that deletes the QueryInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._version.delete_async(
method="DELETE",
uri=self._uri,
)
def fetch(self) -> QueryInstance:
"""
Fetch the QueryInstance
:returns: The fetched QueryInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return QueryInstance(
self._version,
payload,
assistant_sid=self._solution["assistant_sid"],
sid=self._solution["sid"],
)
async def fetch_async(self) -> QueryInstance:
"""
Asynchronous coroutine to fetch the QueryInstance
:returns: The fetched QueryInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return QueryInstance(
self._version,
payload,
assistant_sid=self._solution["assistant_sid"],
sid=self._solution["sid"],
)
def update(
self,
sample_sid: Union[str, object] = values.unset,
status: Union[str, object] = values.unset,
) -> QueryInstance:
"""
Update the QueryInstance
:param sample_sid: An optional reference to the Sample created from this query.
:param status: A string that described the query status. The values can be: pending_review, reviewed, discarded
:returns: The updated QueryInstance
"""
data = values.of(
{
"SampleSid": sample_sid,
"Status": status,
}
)
payload = self._version.update(
method="POST",
uri=self._uri,
data=data,
)
return QueryInstance(
self._version,
payload,
assistant_sid=self._solution["assistant_sid"],
sid=self._solution["sid"],
)
async def update_async(
self,
sample_sid: Union[str, object] = values.unset,
status: Union[str, object] = values.unset,
) -> QueryInstance:
"""
Asynchronous coroutine to update the QueryInstance
:param sample_sid: An optional reference to the Sample created from this query.
:param status: A string that described the query status. The values can be: pending_review, reviewed, discarded
:returns: The updated QueryInstance
"""
data = values.of(
{
"SampleSid": sample_sid,
"Status": status,
}
)
payload = await self._version.update_async(
method="POST",
uri=self._uri,
data=data,
)
return QueryInstance(
self._version,
payload,
assistant_sid=self._solution["assistant_sid"],
sid=self._solution["sid"],
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Preview.Understand.QueryContext {}>".format(context)
class QueryPage(Page):
def get_instance(self, payload: Dict[str, Any]) -> QueryInstance:
"""
Build an instance of QueryInstance
:param payload: Payload response from the API
"""
return QueryInstance(
self._version, payload, assistant_sid=self._solution["assistant_sid"]
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.Understand.QueryPage>"
class QueryList(ListResource):
def __init__(self, version: Version, assistant_sid: str):
"""
Initialize the QueryList
:param version: Version that contains the resource
:param assistant_sid: The unique ID of the parent Assistant.
"""
super().__init__(version)
# Path Solution
self._solution = {
"assistant_sid": assistant_sid,
}
self._uri = "/Assistants/{assistant_sid}/Queries".format(**self._solution)
def create(
self,
language: str,
query: str,
tasks: Union[str, object] = values.unset,
model_build: Union[str, object] = values.unset,
field: Union[str, object] = values.unset,
) -> QueryInstance:
"""
Create the QueryInstance
:param language: An ISO language-country string of the sample.
:param query: A user-provided string that uniquely identifies this resource as an alternative to the sid. It can be up to 2048 characters long.
:param tasks: Constraints the query to a set of tasks. Useful when you need to constrain the paths the user can take. Tasks should be comma separated *task-unique-name-1*, *task-unique-name-2*
:param model_build: The Model Build Sid or unique name of the Model Build to be queried.
:param field: Constraints the query to a given Field with an task. Useful when you know the Field you are expecting. It accepts one field in the format *task-unique-name-1*:*field-unique-name*
:returns: The created QueryInstance
"""
data = values.of(
{
"Language": language,
"Query": query,
"Tasks": tasks,
"ModelBuild": model_build,
"Field": field,
}
)
payload = self._version.create(
method="POST",
uri=self._uri,
data=data,
)
return QueryInstance(
self._version, payload, assistant_sid=self._solution["assistant_sid"]
)
async def create_async(
self,
language: str,
query: str,
tasks: Union[str, object] = values.unset,
model_build: Union[str, object] = values.unset,
field: Union[str, object] = values.unset,
) -> QueryInstance:
"""
Asynchronously create the QueryInstance
:param language: An ISO language-country string of the sample.
:param query: A user-provided string that uniquely identifies this resource as an alternative to the sid. It can be up to 2048 characters long.
:param tasks: Constraints the query to a set of tasks. Useful when you need to constrain the paths the user can take. Tasks should be comma separated *task-unique-name-1*, *task-unique-name-2*
:param model_build: The Model Build Sid or unique name of the Model Build to be queried.
:param field: Constraints the query to a given Field with an task. Useful when you know the Field you are expecting. It accepts one field in the format *task-unique-name-1*:*field-unique-name*
:returns: The created QueryInstance
"""
data = values.of(
{
"Language": language,
"Query": query,
"Tasks": tasks,
"ModelBuild": model_build,
"Field": field,
}
)
payload = await self._version.create_async(
method="POST",
uri=self._uri,
data=data,
)
return QueryInstance(
self._version, payload, assistant_sid=self._solution["assistant_sid"]
)
def stream(
self,
language: Union[str, object] = values.unset,
model_build: Union[str, object] = values.unset,
status: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[QueryInstance]:
"""
Streams QueryInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param str language: An ISO language-country string of the sample.
:param str model_build: The Model Build Sid or unique name of the Model Build to be queried.
:param str status: A string that described the query status. The values can be: pending_review, reviewed, discarded
:param limit: Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the
limit with the most efficient page size, i.e. min(limit, 1000)
:returns: Generator that will yield up to limit results
"""
limits = self._version.read_limits(limit, page_size)
page = self.page(
language=language,
model_build=model_build,
status=status,
page_size=limits["page_size"],
)
return self._version.stream(page, limits["limit"])
async def stream_async(
self,
language: Union[str, object] = values.unset,
model_build: Union[str, object] = values.unset,
status: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> AsyncIterator[QueryInstance]:
"""
Asynchronously streams QueryInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param str language: An ISO language-country string of the sample.
:param str model_build: The Model Build Sid or unique name of the Model Build to be queried.
:param str status: A string that described the query status. The values can be: pending_review, reviewed, discarded
:param limit: Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the
limit with the most efficient page size, i.e. min(limit, 1000)
:returns: Generator that will yield up to limit results
"""
limits = self._version.read_limits(limit, page_size)
page = await self.page_async(
language=language,
model_build=model_build,
status=status,
page_size=limits["page_size"],
)
return self._version.stream_async(page, limits["limit"])
def list(
self,
language: Union[str, object] = values.unset,
model_build: Union[str, object] = values.unset,
status: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[QueryInstance]:
"""
Lists QueryInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param str language: An ISO language-country string of the sample.
:param str model_build: The Model Build Sid or unique name of the Model Build to be queried.
:param str status: A string that described the query status. The values can be: pending_review, reviewed, discarded
:param limit: Upper limit for the number of records to return. list() guarantees
never to return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, list() will attempt to read the limit
with the most efficient page size, i.e. min(limit, 1000)
:returns: list that will contain up to limit results
"""
return list(
self.stream(
language=language,
model_build=model_build,
status=status,
limit=limit,
page_size=page_size,
)
)
async def list_async(
self,
language: Union[str, object] = values.unset,
model_build: Union[str, object] = values.unset,
status: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[QueryInstance]:
"""
Asynchronously lists QueryInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param str language: An ISO language-country string of the sample.
:param str model_build: The Model Build Sid or unique name of the Model Build to be queried.
:param str status: A string that described the query status. The values can be: pending_review, reviewed, discarded
:param limit: Upper limit for the number of records to return. list() guarantees
never to return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, list() will attempt to read the limit
with the most efficient page size, i.e. min(limit, 1000)
:returns: list that will contain up to limit results
"""
return [
record
async for record in await self.stream_async(
language=language,
model_build=model_build,
status=status,
limit=limit,
page_size=page_size,
)
]
def page(
self,
language: Union[str, object] = values.unset,
model_build: Union[str, object] = values.unset,
status: Union[str, object] = values.unset,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> QueryPage:
"""
Retrieve a single page of QueryInstance records from the API.
Request is executed immediately
:param language: An ISO language-country string of the sample.
:param model_build: The Model Build Sid or unique name of the Model Build to be queried.
:param status: A string that described the query status. The values can be: pending_review, reviewed, discarded
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of QueryInstance
"""
data = values.of(
{
"Language": language,
"ModelBuild": model_build,
"Status": status,
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return QueryPage(self._version, response, self._solution)
async def page_async(
self,
language: Union[str, object] = values.unset,
model_build: Union[str, object] = values.unset,
status: Union[str, object] = values.unset,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> QueryPage:
"""
Asynchronously retrieve a single page of QueryInstance records from the API.
Request is executed immediately
:param language: An ISO language-country string of the sample.
:param model_build: The Model Build Sid or unique name of the Model Build to be queried.
:param status: A string that described the query status. The values can be: pending_review, reviewed, discarded
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of QueryInstance
"""
data = values.of(
{
"Language": language,
"ModelBuild": model_build,
"Status": status,
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = await self._version.page_async(
method="GET", uri=self._uri, params=data
)
return QueryPage(self._version, response, self._solution)
def get_page(self, target_url: str) -> QueryPage:
"""
Retrieve a specific page of QueryInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of QueryInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return QueryPage(self._version, response, self._solution)
async def get_page_async(self, target_url: str) -> QueryPage:
"""
Asynchronously retrieve a specific page of QueryInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of QueryInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return QueryPage(self._version, response, self._solution)
def get(self, sid: str) -> QueryContext:
"""
Constructs a QueryContext
:param sid: A 34 character string that uniquely identifies this resource.
"""
return QueryContext(
self._version, assistant_sid=self._solution["assistant_sid"], sid=sid
)
def __call__(self, sid: str) -> QueryContext:
"""
Constructs a QueryContext
:param sid: A 34 character string that uniquely identifies this resource.
"""
return QueryContext(
self._version, assistant_sid=self._solution["assistant_sid"], sid=sid
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.Understand.QueryList>"
@@ -0,0 +1,273 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Preview
This is the public Twilio REST API.
NOTE: This class is auto generated by OpenAPI Generator.
https://openapi-generator.tech
Do not edit the class manually.
"""
from typing import Any, Dict, Optional, Union
from twilio.base import serialize, values
from twilio.base.instance_context import InstanceContext
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.version import Version
class StyleSheetInstance(InstanceResource):
"""
:ivar account_sid: The unique ID of the Account that created this Assistant
:ivar assistant_sid: The unique ID of the Assistant
:ivar url:
:ivar data: The JSON style sheet object
"""
def __init__(self, version: Version, payload: Dict[str, Any], assistant_sid: str):
super().__init__(version)
self.account_sid: Optional[str] = payload.get("account_sid")
self.assistant_sid: Optional[str] = payload.get("assistant_sid")
self.url: Optional[str] = payload.get("url")
self.data: Optional[Dict[str, object]] = payload.get("data")
self._solution = {
"assistant_sid": assistant_sid,
}
self._context: Optional[StyleSheetContext] = None
@property
def _proxy(self) -> "StyleSheetContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: StyleSheetContext for this StyleSheetInstance
"""
if self._context is None:
self._context = StyleSheetContext(
self._version,
assistant_sid=self._solution["assistant_sid"],
)
return self._context
def fetch(self) -> "StyleSheetInstance":
"""
Fetch the StyleSheetInstance
:returns: The fetched StyleSheetInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "StyleSheetInstance":
"""
Asynchronous coroutine to fetch the StyleSheetInstance
:returns: The fetched StyleSheetInstance
"""
return await self._proxy.fetch_async()
def update(
self, style_sheet: Union[object, object] = values.unset
) -> "StyleSheetInstance":
"""
Update the StyleSheetInstance
:param style_sheet: The JSON Style sheet string
:returns: The updated StyleSheetInstance
"""
return self._proxy.update(
style_sheet=style_sheet,
)
async def update_async(
self, style_sheet: Union[object, object] = values.unset
) -> "StyleSheetInstance":
"""
Asynchronous coroutine to update the StyleSheetInstance
:param style_sheet: The JSON Style sheet string
:returns: The updated StyleSheetInstance
"""
return await self._proxy.update_async(
style_sheet=style_sheet,
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Preview.Understand.StyleSheetInstance {}>".format(context)
class StyleSheetContext(InstanceContext):
def __init__(self, version: Version, assistant_sid: str):
"""
Initialize the StyleSheetContext
:param version: Version that contains the resource
:param assistant_sid: The unique ID of the Assistant
"""
super().__init__(version)
# Path Solution
self._solution = {
"assistant_sid": assistant_sid,
}
self._uri = "/Assistants/{assistant_sid}/StyleSheet".format(**self._solution)
def fetch(self) -> StyleSheetInstance:
"""
Fetch the StyleSheetInstance
:returns: The fetched StyleSheetInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return StyleSheetInstance(
self._version,
payload,
assistant_sid=self._solution["assistant_sid"],
)
async def fetch_async(self) -> StyleSheetInstance:
"""
Asynchronous coroutine to fetch the StyleSheetInstance
:returns: The fetched StyleSheetInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return StyleSheetInstance(
self._version,
payload,
assistant_sid=self._solution["assistant_sid"],
)
def update(
self, style_sheet: Union[object, object] = values.unset
) -> StyleSheetInstance:
"""
Update the StyleSheetInstance
:param style_sheet: The JSON Style sheet string
:returns: The updated StyleSheetInstance
"""
data = values.of(
{
"StyleSheet": serialize.object(style_sheet),
}
)
payload = self._version.update(
method="POST",
uri=self._uri,
data=data,
)
return StyleSheetInstance(
self._version, payload, assistant_sid=self._solution["assistant_sid"]
)
async def update_async(
self, style_sheet: Union[object, object] = values.unset
) -> StyleSheetInstance:
"""
Asynchronous coroutine to update the StyleSheetInstance
:param style_sheet: The JSON Style sheet string
:returns: The updated StyleSheetInstance
"""
data = values.of(
{
"StyleSheet": serialize.object(style_sheet),
}
)
payload = await self._version.update_async(
method="POST",
uri=self._uri,
data=data,
)
return StyleSheetInstance(
self._version, payload, assistant_sid=self._solution["assistant_sid"]
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Preview.Understand.StyleSheetContext {}>".format(context)
class StyleSheetList(ListResource):
def __init__(self, version: Version, assistant_sid: str):
"""
Initialize the StyleSheetList
:param version: Version that contains the resource
:param assistant_sid: The unique ID of the Assistant
"""
super().__init__(version)
# Path Solution
self._solution = {
"assistant_sid": assistant_sid,
}
def get(self) -> StyleSheetContext:
"""
Constructs a StyleSheetContext
"""
return StyleSheetContext(
self._version, assistant_sid=self._solution["assistant_sid"]
)
def __call__(self) -> StyleSheetContext:
"""
Constructs a StyleSheetContext
"""
return StyleSheetContext(
self._version, assistant_sid=self._solution["assistant_sid"]
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.Understand.StyleSheetList>"
@@ -0,0 +1,760 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Preview
This is the public Twilio REST API.
NOTE: This class is auto generated by OpenAPI Generator.
https://openapi-generator.tech
Do not edit the class manually.
"""
from datetime import datetime
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
from twilio.base import deserialize, serialize, values
from twilio.base.instance_context import InstanceContext
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.version import Version
from twilio.base.page import Page
from twilio.rest.preview.understand.assistant.task.field import FieldList
from twilio.rest.preview.understand.assistant.task.sample import SampleList
from twilio.rest.preview.understand.assistant.task.task_actions import TaskActionsList
from twilio.rest.preview.understand.assistant.task.task_statistics import (
TaskStatisticsList,
)
class TaskInstance(InstanceResource):
"""
:ivar account_sid: The unique ID of the Account that created this Task.
:ivar date_created: The date that this resource was created
:ivar date_updated: The date that this resource was last updated
:ivar friendly_name: A user-provided string that identifies this resource. It is non-unique and can up to 255 characters long.
:ivar links:
:ivar assistant_sid: The unique ID of the Assistant.
:ivar sid: A 34 character string that uniquely identifies this resource.
:ivar unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long.
:ivar actions_url: User-provided HTTP endpoint where from the assistant fetches actions
:ivar url:
"""
def __init__(
self,
version: Version,
payload: Dict[str, Any],
assistant_sid: str,
sid: Optional[str] = None,
):
super().__init__(version)
self.account_sid: Optional[str] = payload.get("account_sid")
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_created")
)
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_updated")
)
self.friendly_name: Optional[str] = payload.get("friendly_name")
self.links: Optional[Dict[str, object]] = payload.get("links")
self.assistant_sid: Optional[str] = payload.get("assistant_sid")
self.sid: Optional[str] = payload.get("sid")
self.unique_name: Optional[str] = payload.get("unique_name")
self.actions_url: Optional[str] = payload.get("actions_url")
self.url: Optional[str] = payload.get("url")
self._solution = {
"assistant_sid": assistant_sid,
"sid": sid or self.sid,
}
self._context: Optional[TaskContext] = None
@property
def _proxy(self) -> "TaskContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: TaskContext for this TaskInstance
"""
if self._context is None:
self._context = TaskContext(
self._version,
assistant_sid=self._solution["assistant_sid"],
sid=self._solution["sid"],
)
return self._context
def delete(self) -> bool:
"""
Deletes the TaskInstance
:returns: True if delete succeeds, False otherwise
"""
return self._proxy.delete()
async def delete_async(self) -> bool:
"""
Asynchronous coroutine that deletes the TaskInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._proxy.delete_async()
def fetch(self) -> "TaskInstance":
"""
Fetch the TaskInstance
:returns: The fetched TaskInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "TaskInstance":
"""
Asynchronous coroutine to fetch the TaskInstance
:returns: The fetched TaskInstance
"""
return await self._proxy.fetch_async()
def update(
self,
friendly_name: Union[str, object] = values.unset,
unique_name: Union[str, object] = values.unset,
actions: Union[object, object] = values.unset,
actions_url: Union[str, object] = values.unset,
) -> "TaskInstance":
"""
Update the TaskInstance
:param friendly_name: A user-provided string that identifies this resource. It is non-unique and can up to 255 characters long.
:param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long.
:param actions: A user-provided JSON object encoded as a string to specify the actions for this task. It is optional and non-unique.
:param actions_url: User-provided HTTP endpoint where from the assistant fetches actions
:returns: The updated TaskInstance
"""
return self._proxy.update(
friendly_name=friendly_name,
unique_name=unique_name,
actions=actions,
actions_url=actions_url,
)
async def update_async(
self,
friendly_name: Union[str, object] = values.unset,
unique_name: Union[str, object] = values.unset,
actions: Union[object, object] = values.unset,
actions_url: Union[str, object] = values.unset,
) -> "TaskInstance":
"""
Asynchronous coroutine to update the TaskInstance
:param friendly_name: A user-provided string that identifies this resource. It is non-unique and can up to 255 characters long.
:param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long.
:param actions: A user-provided JSON object encoded as a string to specify the actions for this task. It is optional and non-unique.
:param actions_url: User-provided HTTP endpoint where from the assistant fetches actions
:returns: The updated TaskInstance
"""
return await self._proxy.update_async(
friendly_name=friendly_name,
unique_name=unique_name,
actions=actions,
actions_url=actions_url,
)
@property
def fields(self) -> FieldList:
"""
Access the fields
"""
return self._proxy.fields
@property
def samples(self) -> SampleList:
"""
Access the samples
"""
return self._proxy.samples
@property
def task_actions(self) -> TaskActionsList:
"""
Access the task_actions
"""
return self._proxy.task_actions
@property
def statistics(self) -> TaskStatisticsList:
"""
Access the statistics
"""
return self._proxy.statistics
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Preview.Understand.TaskInstance {}>".format(context)
class TaskContext(InstanceContext):
def __init__(self, version: Version, assistant_sid: str, sid: str):
"""
Initialize the TaskContext
:param version: Version that contains the resource
:param assistant_sid: The unique ID of the Assistant.
:param sid: A 34 character string that uniquely identifies this resource.
"""
super().__init__(version)
# Path Solution
self._solution = {
"assistant_sid": assistant_sid,
"sid": sid,
}
self._uri = "/Assistants/{assistant_sid}/Tasks/{sid}".format(**self._solution)
self._fields: Optional[FieldList] = None
self._samples: Optional[SampleList] = None
self._task_actions: Optional[TaskActionsList] = None
self._statistics: Optional[TaskStatisticsList] = None
def delete(self) -> bool:
"""
Deletes the TaskInstance
:returns: True if delete succeeds, False otherwise
"""
return self._version.delete(
method="DELETE",
uri=self._uri,
)
async def delete_async(self) -> bool:
"""
Asynchronous coroutine that deletes the TaskInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._version.delete_async(
method="DELETE",
uri=self._uri,
)
def fetch(self) -> TaskInstance:
"""
Fetch the TaskInstance
:returns: The fetched TaskInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return TaskInstance(
self._version,
payload,
assistant_sid=self._solution["assistant_sid"],
sid=self._solution["sid"],
)
async def fetch_async(self) -> TaskInstance:
"""
Asynchronous coroutine to fetch the TaskInstance
:returns: The fetched TaskInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return TaskInstance(
self._version,
payload,
assistant_sid=self._solution["assistant_sid"],
sid=self._solution["sid"],
)
def update(
self,
friendly_name: Union[str, object] = values.unset,
unique_name: Union[str, object] = values.unset,
actions: Union[object, object] = values.unset,
actions_url: Union[str, object] = values.unset,
) -> TaskInstance:
"""
Update the TaskInstance
:param friendly_name: A user-provided string that identifies this resource. It is non-unique and can up to 255 characters long.
:param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long.
:param actions: A user-provided JSON object encoded as a string to specify the actions for this task. It is optional and non-unique.
:param actions_url: User-provided HTTP endpoint where from the assistant fetches actions
:returns: The updated TaskInstance
"""
data = values.of(
{
"FriendlyName": friendly_name,
"UniqueName": unique_name,
"Actions": serialize.object(actions),
"ActionsUrl": actions_url,
}
)
payload = self._version.update(
method="POST",
uri=self._uri,
data=data,
)
return TaskInstance(
self._version,
payload,
assistant_sid=self._solution["assistant_sid"],
sid=self._solution["sid"],
)
async def update_async(
self,
friendly_name: Union[str, object] = values.unset,
unique_name: Union[str, object] = values.unset,
actions: Union[object, object] = values.unset,
actions_url: Union[str, object] = values.unset,
) -> TaskInstance:
"""
Asynchronous coroutine to update the TaskInstance
:param friendly_name: A user-provided string that identifies this resource. It is non-unique and can up to 255 characters long.
:param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long.
:param actions: A user-provided JSON object encoded as a string to specify the actions for this task. It is optional and non-unique.
:param actions_url: User-provided HTTP endpoint where from the assistant fetches actions
:returns: The updated TaskInstance
"""
data = values.of(
{
"FriendlyName": friendly_name,
"UniqueName": unique_name,
"Actions": serialize.object(actions),
"ActionsUrl": actions_url,
}
)
payload = await self._version.update_async(
method="POST",
uri=self._uri,
data=data,
)
return TaskInstance(
self._version,
payload,
assistant_sid=self._solution["assistant_sid"],
sid=self._solution["sid"],
)
@property
def fields(self) -> FieldList:
"""
Access the fields
"""
if self._fields is None:
self._fields = FieldList(
self._version,
self._solution["assistant_sid"],
self._solution["sid"],
)
return self._fields
@property
def samples(self) -> SampleList:
"""
Access the samples
"""
if self._samples is None:
self._samples = SampleList(
self._version,
self._solution["assistant_sid"],
self._solution["sid"],
)
return self._samples
@property
def task_actions(self) -> TaskActionsList:
"""
Access the task_actions
"""
if self._task_actions is None:
self._task_actions = TaskActionsList(
self._version,
self._solution["assistant_sid"],
self._solution["sid"],
)
return self._task_actions
@property
def statistics(self) -> TaskStatisticsList:
"""
Access the statistics
"""
if self._statistics is None:
self._statistics = TaskStatisticsList(
self._version,
self._solution["assistant_sid"],
self._solution["sid"],
)
return self._statistics
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Preview.Understand.TaskContext {}>".format(context)
class TaskPage(Page):
def get_instance(self, payload: Dict[str, Any]) -> TaskInstance:
"""
Build an instance of TaskInstance
:param payload: Payload response from the API
"""
return TaskInstance(
self._version, payload, assistant_sid=self._solution["assistant_sid"]
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.Understand.TaskPage>"
class TaskList(ListResource):
def __init__(self, version: Version, assistant_sid: str):
"""
Initialize the TaskList
:param version: Version that contains the resource
:param assistant_sid: The unique ID of the Assistant.
"""
super().__init__(version)
# Path Solution
self._solution = {
"assistant_sid": assistant_sid,
}
self._uri = "/Assistants/{assistant_sid}/Tasks".format(**self._solution)
def create(
self,
unique_name: str,
friendly_name: Union[str, object] = values.unset,
actions: Union[object, object] = values.unset,
actions_url: Union[str, object] = values.unset,
) -> TaskInstance:
"""
Create the TaskInstance
:param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long.
:param friendly_name: A user-provided string that identifies this resource. It is non-unique and can up to 255 characters long.
:param actions: A user-provided JSON object encoded as a string to specify the actions for this task. It is optional and non-unique.
:param actions_url: User-provided HTTP endpoint where from the assistant fetches actions
:returns: The created TaskInstance
"""
data = values.of(
{
"UniqueName": unique_name,
"FriendlyName": friendly_name,
"Actions": serialize.object(actions),
"ActionsUrl": actions_url,
}
)
payload = self._version.create(
method="POST",
uri=self._uri,
data=data,
)
return TaskInstance(
self._version, payload, assistant_sid=self._solution["assistant_sid"]
)
async def create_async(
self,
unique_name: str,
friendly_name: Union[str, object] = values.unset,
actions: Union[object, object] = values.unset,
actions_url: Union[str, object] = values.unset,
) -> TaskInstance:
"""
Asynchronously create the TaskInstance
:param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long.
:param friendly_name: A user-provided string that identifies this resource. It is non-unique and can up to 255 characters long.
:param actions: A user-provided JSON object encoded as a string to specify the actions for this task. It is optional and non-unique.
:param actions_url: User-provided HTTP endpoint where from the assistant fetches actions
:returns: The created TaskInstance
"""
data = values.of(
{
"UniqueName": unique_name,
"FriendlyName": friendly_name,
"Actions": serialize.object(actions),
"ActionsUrl": actions_url,
}
)
payload = await self._version.create_async(
method="POST",
uri=self._uri,
data=data,
)
return TaskInstance(
self._version, payload, assistant_sid=self._solution["assistant_sid"]
)
def stream(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[TaskInstance]:
"""
Streams TaskInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param limit: Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the
limit with the most efficient page size, i.e. min(limit, 1000)
:returns: Generator that will yield up to limit results
"""
limits = self._version.read_limits(limit, page_size)
page = self.page(page_size=limits["page_size"])
return self._version.stream(page, limits["limit"])
async def stream_async(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> AsyncIterator[TaskInstance]:
"""
Asynchronously streams TaskInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param limit: Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the
limit with the most efficient page size, i.e. min(limit, 1000)
:returns: Generator that will yield up to limit results
"""
limits = self._version.read_limits(limit, page_size)
page = await self.page_async(page_size=limits["page_size"])
return self._version.stream_async(page, limits["limit"])
def list(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[TaskInstance]:
"""
Lists TaskInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param limit: Upper limit for the number of records to return. list() guarantees
never to return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, list() will attempt to read the limit
with the most efficient page size, i.e. min(limit, 1000)
:returns: list that will contain up to limit results
"""
return list(
self.stream(
limit=limit,
page_size=page_size,
)
)
async def list_async(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[TaskInstance]:
"""
Asynchronously lists TaskInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param limit: Upper limit for the number of records to return. list() guarantees
never to return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, list() will attempt to read the limit
with the most efficient page size, i.e. min(limit, 1000)
:returns: list that will contain up to limit results
"""
return [
record
async for record in await self.stream_async(
limit=limit,
page_size=page_size,
)
]
def page(
self,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> TaskPage:
"""
Retrieve a single page of TaskInstance records from the API.
Request is executed immediately
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of TaskInstance
"""
data = values.of(
{
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return TaskPage(self._version, response, self._solution)
async def page_async(
self,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> TaskPage:
"""
Asynchronously retrieve a single page of TaskInstance records from the API.
Request is executed immediately
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of TaskInstance
"""
data = values.of(
{
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = await self._version.page_async(
method="GET", uri=self._uri, params=data
)
return TaskPage(self._version, response, self._solution)
def get_page(self, target_url: str) -> TaskPage:
"""
Retrieve a specific page of TaskInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of TaskInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return TaskPage(self._version, response, self._solution)
async def get_page_async(self, target_url: str) -> TaskPage:
"""
Asynchronously retrieve a specific page of TaskInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of TaskInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return TaskPage(self._version, response, self._solution)
def get(self, sid: str) -> TaskContext:
"""
Constructs a TaskContext
:param sid: A 34 character string that uniquely identifies this resource.
"""
return TaskContext(
self._version, assistant_sid=self._solution["assistant_sid"], sid=sid
)
def __call__(self, sid: str) -> TaskContext:
"""
Constructs a TaskContext
:param sid: A 34 character string that uniquely identifies this resource.
"""
return TaskContext(
self._version, assistant_sid=self._solution["assistant_sid"], sid=sid
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.Understand.TaskList>"
@@ -0,0 +1,549 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Preview
This is the public Twilio REST API.
NOTE: This class is auto generated by OpenAPI Generator.
https://openapi-generator.tech
Do not edit the class manually.
"""
from datetime import datetime
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
from twilio.base import deserialize, values
from twilio.base.instance_context import InstanceContext
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.version import Version
from twilio.base.page import Page
class FieldInstance(InstanceResource):
"""
:ivar account_sid: The unique ID of the Account that created this Field.
:ivar date_created: The date that this resource was created
:ivar date_updated: The date that this resource was last updated
:ivar field_type: The Field Type of this field. It can be any [Built-in Field Type](https://www.twilio.com/docs/assistant/api/built-in-field-types) or the unique_name or sid of a custom Field Type.
:ivar task_sid: The unique ID of the Task associated with this Field.
:ivar assistant_sid: The unique ID of the parent Assistant.
:ivar sid: A 34 character string that uniquely identifies this resource.
:ivar unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long.
:ivar url:
"""
def __init__(
self,
version: Version,
payload: Dict[str, Any],
assistant_sid: str,
task_sid: str,
sid: Optional[str] = None,
):
super().__init__(version)
self.account_sid: Optional[str] = payload.get("account_sid")
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_created")
)
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_updated")
)
self.field_type: Optional[str] = payload.get("field_type")
self.task_sid: Optional[str] = payload.get("task_sid")
self.assistant_sid: Optional[str] = payload.get("assistant_sid")
self.sid: Optional[str] = payload.get("sid")
self.unique_name: Optional[str] = payload.get("unique_name")
self.url: Optional[str] = payload.get("url")
self._solution = {
"assistant_sid": assistant_sid,
"task_sid": task_sid,
"sid": sid or self.sid,
}
self._context: Optional[FieldContext] = None
@property
def _proxy(self) -> "FieldContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: FieldContext for this FieldInstance
"""
if self._context is None:
self._context = FieldContext(
self._version,
assistant_sid=self._solution["assistant_sid"],
task_sid=self._solution["task_sid"],
sid=self._solution["sid"],
)
return self._context
def delete(self) -> bool:
"""
Deletes the FieldInstance
:returns: True if delete succeeds, False otherwise
"""
return self._proxy.delete()
async def delete_async(self) -> bool:
"""
Asynchronous coroutine that deletes the FieldInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._proxy.delete_async()
def fetch(self) -> "FieldInstance":
"""
Fetch the FieldInstance
:returns: The fetched FieldInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "FieldInstance":
"""
Asynchronous coroutine to fetch the FieldInstance
:returns: The fetched FieldInstance
"""
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.Preview.Understand.FieldInstance {}>".format(context)
class FieldContext(InstanceContext):
def __init__(self, version: Version, assistant_sid: str, task_sid: str, sid: str):
"""
Initialize the FieldContext
:param version: Version that contains the resource
:param assistant_sid: The unique ID of the Assistant.
:param task_sid: The unique ID of the Task associated with this Field.
:param sid: A 34 character string that uniquely identifies this resource.
"""
super().__init__(version)
# Path Solution
self._solution = {
"assistant_sid": assistant_sid,
"task_sid": task_sid,
"sid": sid,
}
self._uri = "/Assistants/{assistant_sid}/Tasks/{task_sid}/Fields/{sid}".format(
**self._solution
)
def delete(self) -> bool:
"""
Deletes the FieldInstance
: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 FieldInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._version.delete_async(
method="DELETE",
uri=self._uri,
)
def fetch(self) -> FieldInstance:
"""
Fetch the FieldInstance
:returns: The fetched FieldInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return FieldInstance(
self._version,
payload,
assistant_sid=self._solution["assistant_sid"],
task_sid=self._solution["task_sid"],
sid=self._solution["sid"],
)
async def fetch_async(self) -> FieldInstance:
"""
Asynchronous coroutine to fetch the FieldInstance
:returns: The fetched FieldInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return FieldInstance(
self._version,
payload,
assistant_sid=self._solution["assistant_sid"],
task_sid=self._solution["task_sid"],
sid=self._solution["sid"],
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Preview.Understand.FieldContext {}>".format(context)
class FieldPage(Page):
def get_instance(self, payload: Dict[str, Any]) -> FieldInstance:
"""
Build an instance of FieldInstance
:param payload: Payload response from the API
"""
return FieldInstance(
self._version,
payload,
assistant_sid=self._solution["assistant_sid"],
task_sid=self._solution["task_sid"],
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.Understand.FieldPage>"
class FieldList(ListResource):
def __init__(self, version: Version, assistant_sid: str, task_sid: str):
"""
Initialize the FieldList
:param version: Version that contains the resource
:param assistant_sid: The unique ID of the Assistant.
:param task_sid: The unique ID of the Task associated with this Field.
"""
super().__init__(version)
# Path Solution
self._solution = {
"assistant_sid": assistant_sid,
"task_sid": task_sid,
}
self._uri = "/Assistants/{assistant_sid}/Tasks/{task_sid}/Fields".format(
**self._solution
)
def create(self, field_type: str, unique_name: str) -> FieldInstance:
"""
Create the FieldInstance
:param field_type: The unique name or sid of the FieldType. It can be any [Built-in Field Type](https://www.twilio.com/docs/assistant/api/built-in-field-types) or the unique_name or the Field Type sid of a custom Field Type.
:param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long.
:returns: The created FieldInstance
"""
data = values.of(
{
"FieldType": field_type,
"UniqueName": unique_name,
}
)
payload = self._version.create(
method="POST",
uri=self._uri,
data=data,
)
return FieldInstance(
self._version,
payload,
assistant_sid=self._solution["assistant_sid"],
task_sid=self._solution["task_sid"],
)
async def create_async(self, field_type: str, unique_name: str) -> FieldInstance:
"""
Asynchronously create the FieldInstance
:param field_type: The unique name or sid of the FieldType. It can be any [Built-in Field Type](https://www.twilio.com/docs/assistant/api/built-in-field-types) or the unique_name or the Field Type sid of a custom Field Type.
:param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long.
:returns: The created FieldInstance
"""
data = values.of(
{
"FieldType": field_type,
"UniqueName": unique_name,
}
)
payload = await self._version.create_async(
method="POST",
uri=self._uri,
data=data,
)
return FieldInstance(
self._version,
payload,
assistant_sid=self._solution["assistant_sid"],
task_sid=self._solution["task_sid"],
)
def stream(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[FieldInstance]:
"""
Streams FieldInstance records from the API as a generator stream.
This operation lazily loads 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[FieldInstance]:
"""
Asynchronously streams FieldInstance records from the API as a generator stream.
This operation lazily loads 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[FieldInstance]:
"""
Lists FieldInstance 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[FieldInstance]:
"""
Asynchronously lists FieldInstance 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,
) -> FieldPage:
"""
Retrieve a single page of FieldInstance records from the API.
Request is executed immediately
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of FieldInstance
"""
data = values.of(
{
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return FieldPage(self._version, response, self._solution)
async def page_async(
self,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> FieldPage:
"""
Asynchronously retrieve a single page of FieldInstance records from the API.
Request is executed immediately
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of FieldInstance
"""
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 FieldPage(self._version, response, self._solution)
def get_page(self, target_url: str) -> FieldPage:
"""
Retrieve a specific page of FieldInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of FieldInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return FieldPage(self._version, response, self._solution)
async def get_page_async(self, target_url: str) -> FieldPage:
"""
Asynchronously retrieve a specific page of FieldInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of FieldInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return FieldPage(self._version, response, self._solution)
def get(self, sid: str) -> FieldContext:
"""
Constructs a FieldContext
:param sid: A 34 character string that uniquely identifies this resource.
"""
return FieldContext(
self._version,
assistant_sid=self._solution["assistant_sid"],
task_sid=self._solution["task_sid"],
sid=sid,
)
def __call__(self, sid: str) -> FieldContext:
"""
Constructs a FieldContext
:param sid: A 34 character string that uniquely identifies this resource.
"""
return FieldContext(
self._version,
assistant_sid=self._solution["assistant_sid"],
task_sid=self._solution["task_sid"],
sid=sid,
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.Understand.FieldList>"
@@ -0,0 +1,697 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Preview
This is the public Twilio REST API.
NOTE: This class is auto generated by OpenAPI Generator.
https://openapi-generator.tech
Do not edit the class manually.
"""
from datetime import datetime
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
from twilio.base import deserialize, values
from twilio.base.instance_context import InstanceContext
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.version import Version
from twilio.base.page import Page
class SampleInstance(InstanceResource):
"""
:ivar account_sid: The unique ID of the Account that created this Sample.
:ivar date_created: The date that this resource was created
:ivar date_updated: The date that this resource was last updated
:ivar task_sid: The unique ID of the Task associated with this Sample.
:ivar language: An ISO language-country string of the sample.
:ivar assistant_sid: The unique ID of the Assistant.
:ivar sid: A 34 character string that uniquely identifies this resource.
:ivar tagged_text: The text example of how end-users may express this task. The sample may contain Field tag blocks.
:ivar url:
:ivar source_channel: The communication channel the sample was captured. It can be: *voice*, *sms*, *chat*, *alexa*, *google-assistant*, or *slack*. If not included the value will be null
"""
def __init__(
self,
version: Version,
payload: Dict[str, Any],
assistant_sid: str,
task_sid: str,
sid: Optional[str] = None,
):
super().__init__(version)
self.account_sid: Optional[str] = payload.get("account_sid")
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_created")
)
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_updated")
)
self.task_sid: Optional[str] = payload.get("task_sid")
self.language: Optional[str] = payload.get("language")
self.assistant_sid: Optional[str] = payload.get("assistant_sid")
self.sid: Optional[str] = payload.get("sid")
self.tagged_text: Optional[str] = payload.get("tagged_text")
self.url: Optional[str] = payload.get("url")
self.source_channel: Optional[str] = payload.get("source_channel")
self._solution = {
"assistant_sid": assistant_sid,
"task_sid": task_sid,
"sid": sid or self.sid,
}
self._context: Optional[SampleContext] = None
@property
def _proxy(self) -> "SampleContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: SampleContext for this SampleInstance
"""
if self._context is None:
self._context = SampleContext(
self._version,
assistant_sid=self._solution["assistant_sid"],
task_sid=self._solution["task_sid"],
sid=self._solution["sid"],
)
return self._context
def delete(self) -> bool:
"""
Deletes the SampleInstance
:returns: True if delete succeeds, False otherwise
"""
return self._proxy.delete()
async def delete_async(self) -> bool:
"""
Asynchronous coroutine that deletes the SampleInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._proxy.delete_async()
def fetch(self) -> "SampleInstance":
"""
Fetch the SampleInstance
:returns: The fetched SampleInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "SampleInstance":
"""
Asynchronous coroutine to fetch the SampleInstance
:returns: The fetched SampleInstance
"""
return await self._proxy.fetch_async()
def update(
self,
language: Union[str, object] = values.unset,
tagged_text: Union[str, object] = values.unset,
source_channel: Union[str, object] = values.unset,
) -> "SampleInstance":
"""
Update the SampleInstance
:param language: An ISO language-country string of the sample.
:param tagged_text: The text example of how end-users may express this task. The sample may contain Field tag blocks.
:param source_channel: The communication channel the sample was captured. It can be: *voice*, *sms*, *chat*, *alexa*, *google-assistant*, or *slack*. If not included the value will be null
:returns: The updated SampleInstance
"""
return self._proxy.update(
language=language,
tagged_text=tagged_text,
source_channel=source_channel,
)
async def update_async(
self,
language: Union[str, object] = values.unset,
tagged_text: Union[str, object] = values.unset,
source_channel: Union[str, object] = values.unset,
) -> "SampleInstance":
"""
Asynchronous coroutine to update the SampleInstance
:param language: An ISO language-country string of the sample.
:param tagged_text: The text example of how end-users may express this task. The sample may contain Field tag blocks.
:param source_channel: The communication channel the sample was captured. It can be: *voice*, *sms*, *chat*, *alexa*, *google-assistant*, or *slack*. If not included the value will be null
:returns: The updated SampleInstance
"""
return await self._proxy.update_async(
language=language,
tagged_text=tagged_text,
source_channel=source_channel,
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Preview.Understand.SampleInstance {}>".format(context)
class SampleContext(InstanceContext):
def __init__(self, version: Version, assistant_sid: str, task_sid: str, sid: str):
"""
Initialize the SampleContext
:param version: Version that contains the resource
:param assistant_sid: The unique ID of the Assistant.
:param task_sid: The unique ID of the Task associated with this Sample.
:param sid: A 34 character string that uniquely identifies this resource.
"""
super().__init__(version)
# Path Solution
self._solution = {
"assistant_sid": assistant_sid,
"task_sid": task_sid,
"sid": sid,
}
self._uri = "/Assistants/{assistant_sid}/Tasks/{task_sid}/Samples/{sid}".format(
**self._solution
)
def delete(self) -> bool:
"""
Deletes the SampleInstance
:returns: True if delete succeeds, False otherwise
"""
return self._version.delete(
method="DELETE",
uri=self._uri,
)
async def delete_async(self) -> bool:
"""
Asynchronous coroutine that deletes the SampleInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._version.delete_async(
method="DELETE",
uri=self._uri,
)
def fetch(self) -> SampleInstance:
"""
Fetch the SampleInstance
:returns: The fetched SampleInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return SampleInstance(
self._version,
payload,
assistant_sid=self._solution["assistant_sid"],
task_sid=self._solution["task_sid"],
sid=self._solution["sid"],
)
async def fetch_async(self) -> SampleInstance:
"""
Asynchronous coroutine to fetch the SampleInstance
:returns: The fetched SampleInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return SampleInstance(
self._version,
payload,
assistant_sid=self._solution["assistant_sid"],
task_sid=self._solution["task_sid"],
sid=self._solution["sid"],
)
def update(
self,
language: Union[str, object] = values.unset,
tagged_text: Union[str, object] = values.unset,
source_channel: Union[str, object] = values.unset,
) -> SampleInstance:
"""
Update the SampleInstance
:param language: An ISO language-country string of the sample.
:param tagged_text: The text example of how end-users may express this task. The sample may contain Field tag blocks.
:param source_channel: The communication channel the sample was captured. It can be: *voice*, *sms*, *chat*, *alexa*, *google-assistant*, or *slack*. If not included the value will be null
:returns: The updated SampleInstance
"""
data = values.of(
{
"Language": language,
"TaggedText": tagged_text,
"SourceChannel": source_channel,
}
)
payload = self._version.update(
method="POST",
uri=self._uri,
data=data,
)
return SampleInstance(
self._version,
payload,
assistant_sid=self._solution["assistant_sid"],
task_sid=self._solution["task_sid"],
sid=self._solution["sid"],
)
async def update_async(
self,
language: Union[str, object] = values.unset,
tagged_text: Union[str, object] = values.unset,
source_channel: Union[str, object] = values.unset,
) -> SampleInstance:
"""
Asynchronous coroutine to update the SampleInstance
:param language: An ISO language-country string of the sample.
:param tagged_text: The text example of how end-users may express this task. The sample may contain Field tag blocks.
:param source_channel: The communication channel the sample was captured. It can be: *voice*, *sms*, *chat*, *alexa*, *google-assistant*, or *slack*. If not included the value will be null
:returns: The updated SampleInstance
"""
data = values.of(
{
"Language": language,
"TaggedText": tagged_text,
"SourceChannel": source_channel,
}
)
payload = await self._version.update_async(
method="POST",
uri=self._uri,
data=data,
)
return SampleInstance(
self._version,
payload,
assistant_sid=self._solution["assistant_sid"],
task_sid=self._solution["task_sid"],
sid=self._solution["sid"],
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Preview.Understand.SampleContext {}>".format(context)
class SamplePage(Page):
def get_instance(self, payload: Dict[str, Any]) -> SampleInstance:
"""
Build an instance of SampleInstance
:param payload: Payload response from the API
"""
return SampleInstance(
self._version,
payload,
assistant_sid=self._solution["assistant_sid"],
task_sid=self._solution["task_sid"],
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.Understand.SamplePage>"
class SampleList(ListResource):
def __init__(self, version: Version, assistant_sid: str, task_sid: str):
"""
Initialize the SampleList
:param version: Version that contains the resource
:param assistant_sid: The unique ID of the Assistant.
:param task_sid: The unique ID of the Task associated with this Sample.
"""
super().__init__(version)
# Path Solution
self._solution = {
"assistant_sid": assistant_sid,
"task_sid": task_sid,
}
self._uri = "/Assistants/{assistant_sid}/Tasks/{task_sid}/Samples".format(
**self._solution
)
def create(
self,
language: str,
tagged_text: str,
source_channel: Union[str, object] = values.unset,
) -> SampleInstance:
"""
Create the SampleInstance
:param language: An ISO language-country string of the sample.
:param tagged_text: The text example of how end-users may express this task. The sample may contain Field tag blocks.
:param source_channel: The communication channel the sample was captured. It can be: *voice*, *sms*, *chat*, *alexa*, *google-assistant*, or *slack*. If not included the value will be null
:returns: The created SampleInstance
"""
data = values.of(
{
"Language": language,
"TaggedText": tagged_text,
"SourceChannel": source_channel,
}
)
payload = self._version.create(
method="POST",
uri=self._uri,
data=data,
)
return SampleInstance(
self._version,
payload,
assistant_sid=self._solution["assistant_sid"],
task_sid=self._solution["task_sid"],
)
async def create_async(
self,
language: str,
tagged_text: str,
source_channel: Union[str, object] = values.unset,
) -> SampleInstance:
"""
Asynchronously create the SampleInstance
:param language: An ISO language-country string of the sample.
:param tagged_text: The text example of how end-users may express this task. The sample may contain Field tag blocks.
:param source_channel: The communication channel the sample was captured. It can be: *voice*, *sms*, *chat*, *alexa*, *google-assistant*, or *slack*. If not included the value will be null
:returns: The created SampleInstance
"""
data = values.of(
{
"Language": language,
"TaggedText": tagged_text,
"SourceChannel": source_channel,
}
)
payload = await self._version.create_async(
method="POST",
uri=self._uri,
data=data,
)
return SampleInstance(
self._version,
payload,
assistant_sid=self._solution["assistant_sid"],
task_sid=self._solution["task_sid"],
)
def stream(
self,
language: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[SampleInstance]:
"""
Streams SampleInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param str language: An ISO language-country string of the sample.
:param limit: Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the
limit with the most efficient page size, i.e. min(limit, 1000)
:returns: Generator that will yield up to limit results
"""
limits = self._version.read_limits(limit, page_size)
page = self.page(language=language, page_size=limits["page_size"])
return self._version.stream(page, limits["limit"])
async def stream_async(
self,
language: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> AsyncIterator[SampleInstance]:
"""
Asynchronously streams SampleInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param str language: An ISO language-country string of the sample.
:param limit: Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the
limit with the most efficient page size, i.e. min(limit, 1000)
:returns: Generator that will yield up to limit results
"""
limits = self._version.read_limits(limit, page_size)
page = await self.page_async(language=language, page_size=limits["page_size"])
return self._version.stream_async(page, limits["limit"])
def list(
self,
language: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[SampleInstance]:
"""
Lists SampleInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param str language: An ISO language-country string of the sample.
:param limit: Upper limit for the number of records to return. list() guarantees
never to return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, list() will attempt to read the limit
with the most efficient page size, i.e. min(limit, 1000)
:returns: list that will contain up to limit results
"""
return list(
self.stream(
language=language,
limit=limit,
page_size=page_size,
)
)
async def list_async(
self,
language: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[SampleInstance]:
"""
Asynchronously lists SampleInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param str language: An ISO language-country string of the sample.
:param limit: Upper limit for the number of records to return. list() guarantees
never to return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, list() will attempt to read the limit
with the most efficient page size, i.e. min(limit, 1000)
:returns: list that will contain up to limit results
"""
return [
record
async for record in await self.stream_async(
language=language,
limit=limit,
page_size=page_size,
)
]
def page(
self,
language: Union[str, object] = values.unset,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> SamplePage:
"""
Retrieve a single page of SampleInstance records from the API.
Request is executed immediately
:param language: An ISO language-country string of the sample.
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of SampleInstance
"""
data = values.of(
{
"Language": language,
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return SamplePage(self._version, response, self._solution)
async def page_async(
self,
language: Union[str, object] = values.unset,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> SamplePage:
"""
Asynchronously retrieve a single page of SampleInstance records from the API.
Request is executed immediately
:param language: An ISO language-country string of the sample.
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of SampleInstance
"""
data = values.of(
{
"Language": language,
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = await self._version.page_async(
method="GET", uri=self._uri, params=data
)
return SamplePage(self._version, response, self._solution)
def get_page(self, target_url: str) -> SamplePage:
"""
Retrieve a specific page of SampleInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of SampleInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return SamplePage(self._version, response, self._solution)
async def get_page_async(self, target_url: str) -> SamplePage:
"""
Asynchronously retrieve a specific page of SampleInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of SampleInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return SamplePage(self._version, response, self._solution)
def get(self, sid: str) -> SampleContext:
"""
Constructs a SampleContext
:param sid: A 34 character string that uniquely identifies this resource.
"""
return SampleContext(
self._version,
assistant_sid=self._solution["assistant_sid"],
task_sid=self._solution["task_sid"],
sid=sid,
)
def __call__(self, sid: str) -> SampleContext:
"""
Constructs a SampleContext
:param sid: A 34 character string that uniquely identifies this resource.
"""
return SampleContext(
self._version,
assistant_sid=self._solution["assistant_sid"],
task_sid=self._solution["task_sid"],
sid=sid,
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.Understand.SampleList>"
@@ -0,0 +1,301 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Preview
This is the public Twilio REST API.
NOTE: This class is auto generated by OpenAPI Generator.
https://openapi-generator.tech
Do not edit the class manually.
"""
from typing import Any, Dict, Optional, Union
from twilio.base import serialize, values
from twilio.base.instance_context import InstanceContext
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.version import Version
class TaskActionsInstance(InstanceResource):
"""
:ivar account_sid: The unique ID of the Account that created this Field.
:ivar assistant_sid: The unique ID of the parent Assistant.
:ivar task_sid: The unique ID of the Task.
:ivar url:
:ivar data:
"""
def __init__(
self,
version: Version,
payload: Dict[str, Any],
assistant_sid: str,
task_sid: str,
):
super().__init__(version)
self.account_sid: Optional[str] = payload.get("account_sid")
self.assistant_sid: Optional[str] = payload.get("assistant_sid")
self.task_sid: Optional[str] = payload.get("task_sid")
self.url: Optional[str] = payload.get("url")
self.data: Optional[Dict[str, object]] = payload.get("data")
self._solution = {
"assistant_sid": assistant_sid,
"task_sid": task_sid,
}
self._context: Optional[TaskActionsContext] = None
@property
def _proxy(self) -> "TaskActionsContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: TaskActionsContext for this TaskActionsInstance
"""
if self._context is None:
self._context = TaskActionsContext(
self._version,
assistant_sid=self._solution["assistant_sid"],
task_sid=self._solution["task_sid"],
)
return self._context
def fetch(self) -> "TaskActionsInstance":
"""
Fetch the TaskActionsInstance
:returns: The fetched TaskActionsInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "TaskActionsInstance":
"""
Asynchronous coroutine to fetch the TaskActionsInstance
:returns: The fetched TaskActionsInstance
"""
return await self._proxy.fetch_async()
def update(
self, actions: Union[object, object] = values.unset
) -> "TaskActionsInstance":
"""
Update the TaskActionsInstance
:param actions: The JSON actions that instruct the Assistant how to perform this task.
:returns: The updated TaskActionsInstance
"""
return self._proxy.update(
actions=actions,
)
async def update_async(
self, actions: Union[object, object] = values.unset
) -> "TaskActionsInstance":
"""
Asynchronous coroutine to update the TaskActionsInstance
:param actions: The JSON actions that instruct the Assistant how to perform this task.
:returns: The updated TaskActionsInstance
"""
return await self._proxy.update_async(
actions=actions,
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Preview.Understand.TaskActionsInstance {}>".format(context)
class TaskActionsContext(InstanceContext):
def __init__(self, version: Version, assistant_sid: str, task_sid: str):
"""
Initialize the TaskActionsContext
:param version: Version that contains the resource
:param assistant_sid: The unique ID of the parent Assistant.
:param task_sid: The unique ID of the Task.
"""
super().__init__(version)
# Path Solution
self._solution = {
"assistant_sid": assistant_sid,
"task_sid": task_sid,
}
self._uri = "/Assistants/{assistant_sid}/Tasks/{task_sid}/Actions".format(
**self._solution
)
def fetch(self) -> TaskActionsInstance:
"""
Fetch the TaskActionsInstance
:returns: The fetched TaskActionsInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return TaskActionsInstance(
self._version,
payload,
assistant_sid=self._solution["assistant_sid"],
task_sid=self._solution["task_sid"],
)
async def fetch_async(self) -> TaskActionsInstance:
"""
Asynchronous coroutine to fetch the TaskActionsInstance
:returns: The fetched TaskActionsInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return TaskActionsInstance(
self._version,
payload,
assistant_sid=self._solution["assistant_sid"],
task_sid=self._solution["task_sid"],
)
def update(
self, actions: Union[object, object] = values.unset
) -> TaskActionsInstance:
"""
Update the TaskActionsInstance
:param actions: The JSON actions that instruct the Assistant how to perform this task.
:returns: The updated TaskActionsInstance
"""
data = values.of(
{
"Actions": serialize.object(actions),
}
)
payload = self._version.update(
method="POST",
uri=self._uri,
data=data,
)
return TaskActionsInstance(
self._version,
payload,
assistant_sid=self._solution["assistant_sid"],
task_sid=self._solution["task_sid"],
)
async def update_async(
self, actions: Union[object, object] = values.unset
) -> TaskActionsInstance:
"""
Asynchronous coroutine to update the TaskActionsInstance
:param actions: The JSON actions that instruct the Assistant how to perform this task.
:returns: The updated TaskActionsInstance
"""
data = values.of(
{
"Actions": serialize.object(actions),
}
)
payload = await self._version.update_async(
method="POST",
uri=self._uri,
data=data,
)
return TaskActionsInstance(
self._version,
payload,
assistant_sid=self._solution["assistant_sid"],
task_sid=self._solution["task_sid"],
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Preview.Understand.TaskActionsContext {}>".format(context)
class TaskActionsList(ListResource):
def __init__(self, version: Version, assistant_sid: str, task_sid: str):
"""
Initialize the TaskActionsList
:param version: Version that contains the resource
:param assistant_sid: The unique ID of the parent Assistant.
:param task_sid: The unique ID of the Task.
"""
super().__init__(version)
# Path Solution
self._solution = {
"assistant_sid": assistant_sid,
"task_sid": task_sid,
}
def get(self) -> TaskActionsContext:
"""
Constructs a TaskActionsContext
"""
return TaskActionsContext(
self._version,
assistant_sid=self._solution["assistant_sid"],
task_sid=self._solution["task_sid"],
)
def __call__(self) -> TaskActionsContext:
"""
Constructs a TaskActionsContext
"""
return TaskActionsContext(
self._version,
assistant_sid=self._solution["assistant_sid"],
task_sid=self._solution["task_sid"],
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.Understand.TaskActionsList>"
@@ -0,0 +1,221 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Preview
This is the public Twilio REST API.
NOTE: This class is auto generated by OpenAPI Generator.
https://openapi-generator.tech
Do not edit the class manually.
"""
from typing import Any, Dict, Optional
from twilio.base import deserialize
from twilio.base.instance_context import InstanceContext
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.version import Version
class TaskStatisticsInstance(InstanceResource):
"""
:ivar account_sid: The unique ID of the Account that created this Field.
:ivar assistant_sid: The unique ID of the parent Assistant.
:ivar task_sid: The unique ID of the Task associated with this Field.
:ivar samples_count: The total number of Samples associated with this Task.
:ivar fields_count: The total number of Fields associated with this Task.
:ivar url:
"""
def __init__(
self,
version: Version,
payload: Dict[str, Any],
assistant_sid: str,
task_sid: str,
):
super().__init__(version)
self.account_sid: Optional[str] = payload.get("account_sid")
self.assistant_sid: Optional[str] = payload.get("assistant_sid")
self.task_sid: Optional[str] = payload.get("task_sid")
self.samples_count: Optional[int] = deserialize.integer(
payload.get("samples_count")
)
self.fields_count: Optional[int] = deserialize.integer(
payload.get("fields_count")
)
self.url: Optional[str] = payload.get("url")
self._solution = {
"assistant_sid": assistant_sid,
"task_sid": task_sid,
}
self._context: Optional[TaskStatisticsContext] = None
@property
def _proxy(self) -> "TaskStatisticsContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: TaskStatisticsContext for this TaskStatisticsInstance
"""
if self._context is None:
self._context = TaskStatisticsContext(
self._version,
assistant_sid=self._solution["assistant_sid"],
task_sid=self._solution["task_sid"],
)
return self._context
def fetch(self) -> "TaskStatisticsInstance":
"""
Fetch the TaskStatisticsInstance
:returns: The fetched TaskStatisticsInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "TaskStatisticsInstance":
"""
Asynchronous coroutine to fetch the TaskStatisticsInstance
:returns: The fetched TaskStatisticsInstance
"""
return await self._proxy.fetch_async()
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Preview.Understand.TaskStatisticsInstance {}>".format(context)
class TaskStatisticsContext(InstanceContext):
def __init__(self, version: Version, assistant_sid: str, task_sid: str):
"""
Initialize the TaskStatisticsContext
:param version: Version that contains the resource
:param assistant_sid: The unique ID of the parent Assistant.
:param task_sid: The unique ID of the Task associated with this Field.
"""
super().__init__(version)
# Path Solution
self._solution = {
"assistant_sid": assistant_sid,
"task_sid": task_sid,
}
self._uri = "/Assistants/{assistant_sid}/Tasks/{task_sid}/Statistics".format(
**self._solution
)
def fetch(self) -> TaskStatisticsInstance:
"""
Fetch the TaskStatisticsInstance
:returns: The fetched TaskStatisticsInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return TaskStatisticsInstance(
self._version,
payload,
assistant_sid=self._solution["assistant_sid"],
task_sid=self._solution["task_sid"],
)
async def fetch_async(self) -> TaskStatisticsInstance:
"""
Asynchronous coroutine to fetch the TaskStatisticsInstance
:returns: The fetched TaskStatisticsInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return TaskStatisticsInstance(
self._version,
payload,
assistant_sid=self._solution["assistant_sid"],
task_sid=self._solution["task_sid"],
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Preview.Understand.TaskStatisticsContext {}>".format(context)
class TaskStatisticsList(ListResource):
def __init__(self, version: Version, assistant_sid: str, task_sid: str):
"""
Initialize the TaskStatisticsList
:param version: Version that contains the resource
:param assistant_sid: The unique ID of the parent Assistant.
:param task_sid: The unique ID of the Task associated with this Field.
"""
super().__init__(version)
# Path Solution
self._solution = {
"assistant_sid": assistant_sid,
"task_sid": task_sid,
}
def get(self) -> TaskStatisticsContext:
"""
Constructs a TaskStatisticsContext
"""
return TaskStatisticsContext(
self._version,
assistant_sid=self._solution["assistant_sid"],
task_sid=self._solution["task_sid"],
)
def __call__(self) -> TaskStatisticsContext:
"""
Constructs a TaskStatisticsContext
"""
return TaskStatisticsContext(
self._version,
assistant_sid=self._solution["assistant_sid"],
task_sid=self._solution["task_sid"],
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.Understand.TaskStatisticsList>"
@@ -0,0 +1,58 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Preview
This is the public Twilio REST API.
NOTE: This class is auto generated by OpenAPI Generator.
https://openapi-generator.tech
Do not edit the class manually.
"""
from typing import Optional
from twilio.base.version import Version
from twilio.base.domain import Domain
from twilio.rest.preview.wireless.command import CommandList
from twilio.rest.preview.wireless.rate_plan import RatePlanList
from twilio.rest.preview.wireless.sim import SimList
class Wireless(Version):
def __init__(self, domain: Domain):
"""
Initialize the Wireless version of Preview
:param domain: The Twilio.preview domain
"""
super().__init__(domain, "wireless")
self._commands: Optional[CommandList] = None
self._rate_plans: Optional[RatePlanList] = None
self._sims: Optional[SimList] = None
@property
def commands(self) -> CommandList:
if self._commands is None:
self._commands = CommandList(self)
return self._commands
@property
def rate_plans(self) -> RatePlanList:
if self._rate_plans is None:
self._rate_plans = RatePlanList(self)
return self._rate_plans
@property
def sims(self) -> SimList:
if self._sims is None:
self._sims = SimList(self)
return self._sims
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.Wireless>"
@@ -0,0 +1,572 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Preview
This is the public Twilio REST API.
NOTE: This class is auto generated by OpenAPI Generator.
https://openapi-generator.tech
Do not edit the class manually.
"""
from datetime import datetime
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
from twilio.base import deserialize, values
from twilio.base.instance_context import InstanceContext
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.version import Version
from twilio.base.page import Page
class CommandInstance(InstanceResource):
"""
:ivar sid:
:ivar account_sid:
:ivar device_sid:
:ivar sim_sid:
:ivar command:
:ivar command_mode:
:ivar status:
:ivar direction:
:ivar date_created:
:ivar date_updated:
:ivar url:
"""
def __init__(
self, version: Version, payload: Dict[str, Any], sid: Optional[str] = None
):
super().__init__(version)
self.sid: Optional[str] = payload.get("sid")
self.account_sid: Optional[str] = payload.get("account_sid")
self.device_sid: Optional[str] = payload.get("device_sid")
self.sim_sid: Optional[str] = payload.get("sim_sid")
self.command: Optional[str] = payload.get("command")
self.command_mode: Optional[str] = payload.get("command_mode")
self.status: Optional[str] = payload.get("status")
self.direction: Optional[str] = payload.get("direction")
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_created")
)
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_updated")
)
self.url: Optional[str] = payload.get("url")
self._solution = {
"sid": sid or self.sid,
}
self._context: Optional[CommandContext] = None
@property
def _proxy(self) -> "CommandContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: CommandContext for this CommandInstance
"""
if self._context is None:
self._context = CommandContext(
self._version,
sid=self._solution["sid"],
)
return self._context
def fetch(self) -> "CommandInstance":
"""
Fetch the CommandInstance
:returns: The fetched CommandInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "CommandInstance":
"""
Asynchronous coroutine to fetch the CommandInstance
:returns: The fetched CommandInstance
"""
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.Preview.Wireless.CommandInstance {}>".format(context)
class CommandContext(InstanceContext):
def __init__(self, version: Version, sid: str):
"""
Initialize the CommandContext
:param version: Version that contains the resource
:param sid:
"""
super().__init__(version)
# Path Solution
self._solution = {
"sid": sid,
}
self._uri = "/Commands/{sid}".format(**self._solution)
def fetch(self) -> CommandInstance:
"""
Fetch the CommandInstance
:returns: The fetched CommandInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return CommandInstance(
self._version,
payload,
sid=self._solution["sid"],
)
async def fetch_async(self) -> CommandInstance:
"""
Asynchronous coroutine to fetch the CommandInstance
:returns: The fetched CommandInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return CommandInstance(
self._version,
payload,
sid=self._solution["sid"],
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Preview.Wireless.CommandContext {}>".format(context)
class CommandPage(Page):
def get_instance(self, payload: Dict[str, Any]) -> CommandInstance:
"""
Build an instance of CommandInstance
:param payload: Payload response from the API
"""
return CommandInstance(self._version, payload)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.Wireless.CommandPage>"
class CommandList(ListResource):
def __init__(self, version: Version):
"""
Initialize the CommandList
:param version: Version that contains the resource
"""
super().__init__(version)
self._uri = "/Commands"
def create(
self,
command: str,
device: Union[str, object] = values.unset,
sim: Union[str, object] = values.unset,
callback_method: Union[str, object] = values.unset,
callback_url: Union[str, object] = values.unset,
command_mode: Union[str, object] = values.unset,
include_sid: Union[str, object] = values.unset,
) -> CommandInstance:
"""
Create the CommandInstance
:param command:
:param device:
:param sim:
:param callback_method:
:param callback_url:
:param command_mode:
:param include_sid:
:returns: The created CommandInstance
"""
data = values.of(
{
"Command": command,
"Device": device,
"Sim": sim,
"CallbackMethod": callback_method,
"CallbackUrl": callback_url,
"CommandMode": command_mode,
"IncludeSid": include_sid,
}
)
payload = self._version.create(
method="POST",
uri=self._uri,
data=data,
)
return CommandInstance(self._version, payload)
async def create_async(
self,
command: str,
device: Union[str, object] = values.unset,
sim: Union[str, object] = values.unset,
callback_method: Union[str, object] = values.unset,
callback_url: Union[str, object] = values.unset,
command_mode: Union[str, object] = values.unset,
include_sid: Union[str, object] = values.unset,
) -> CommandInstance:
"""
Asynchronously create the CommandInstance
:param command:
:param device:
:param sim:
:param callback_method:
:param callback_url:
:param command_mode:
:param include_sid:
:returns: The created CommandInstance
"""
data = values.of(
{
"Command": command,
"Device": device,
"Sim": sim,
"CallbackMethod": callback_method,
"CallbackUrl": callback_url,
"CommandMode": command_mode,
"IncludeSid": include_sid,
}
)
payload = await self._version.create_async(
method="POST",
uri=self._uri,
data=data,
)
return CommandInstance(self._version, payload)
def stream(
self,
device: Union[str, object] = values.unset,
sim: Union[str, object] = values.unset,
status: Union[str, object] = values.unset,
direction: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[CommandInstance]:
"""
Streams CommandInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param str device:
:param str sim:
:param str status:
:param str direction:
:param limit: Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the
limit with the most efficient page size, i.e. min(limit, 1000)
:returns: Generator that will yield up to limit results
"""
limits = self._version.read_limits(limit, page_size)
page = self.page(
device=device,
sim=sim,
status=status,
direction=direction,
page_size=limits["page_size"],
)
return self._version.stream(page, limits["limit"])
async def stream_async(
self,
device: Union[str, object] = values.unset,
sim: Union[str, object] = values.unset,
status: Union[str, object] = values.unset,
direction: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> AsyncIterator[CommandInstance]:
"""
Asynchronously streams CommandInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param str device:
:param str sim:
:param str status:
:param str direction:
:param limit: Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the
limit with the most efficient page size, i.e. min(limit, 1000)
:returns: Generator that will yield up to limit results
"""
limits = self._version.read_limits(limit, page_size)
page = await self.page_async(
device=device,
sim=sim,
status=status,
direction=direction,
page_size=limits["page_size"],
)
return self._version.stream_async(page, limits["limit"])
def list(
self,
device: Union[str, object] = values.unset,
sim: Union[str, object] = values.unset,
status: Union[str, object] = values.unset,
direction: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[CommandInstance]:
"""
Lists CommandInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param str device:
:param str sim:
:param str status:
:param str direction:
:param limit: Upper limit for the number of records to return. list() guarantees
never to return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, list() will attempt to read the limit
with the most efficient page size, i.e. min(limit, 1000)
:returns: list that will contain up to limit results
"""
return list(
self.stream(
device=device,
sim=sim,
status=status,
direction=direction,
limit=limit,
page_size=page_size,
)
)
async def list_async(
self,
device: Union[str, object] = values.unset,
sim: Union[str, object] = values.unset,
status: Union[str, object] = values.unset,
direction: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[CommandInstance]:
"""
Asynchronously lists CommandInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param str device:
:param str sim:
:param str status:
:param str direction:
:param limit: Upper limit for the number of records to return. list() guarantees
never to return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, list() will attempt to read the limit
with the most efficient page size, i.e. min(limit, 1000)
:returns: list that will contain up to limit results
"""
return [
record
async for record in await self.stream_async(
device=device,
sim=sim,
status=status,
direction=direction,
limit=limit,
page_size=page_size,
)
]
def page(
self,
device: Union[str, object] = values.unset,
sim: Union[str, object] = values.unset,
status: Union[str, object] = values.unset,
direction: 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,
) -> CommandPage:
"""
Retrieve a single page of CommandInstance records from the API.
Request is executed immediately
:param device:
:param sim:
:param status:
:param direction:
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of CommandInstance
"""
data = values.of(
{
"Device": device,
"Sim": sim,
"Status": status,
"Direction": direction,
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return CommandPage(self._version, response)
async def page_async(
self,
device: Union[str, object] = values.unset,
sim: Union[str, object] = values.unset,
status: Union[str, object] = values.unset,
direction: 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,
) -> CommandPage:
"""
Asynchronously retrieve a single page of CommandInstance records from the API.
Request is executed immediately
:param device:
:param sim:
:param status:
:param direction:
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of CommandInstance
"""
data = values.of(
{
"Device": device,
"Sim": sim,
"Status": status,
"Direction": direction,
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = await self._version.page_async(
method="GET", uri=self._uri, params=data
)
return CommandPage(self._version, response)
def get_page(self, target_url: str) -> CommandPage:
"""
Retrieve a specific page of CommandInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of CommandInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return CommandPage(self._version, response)
async def get_page_async(self, target_url: str) -> CommandPage:
"""
Asynchronously retrieve a specific page of CommandInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of CommandInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return CommandPage(self._version, response)
def get(self, sid: str) -> CommandContext:
"""
Constructs a CommandContext
:param sid:
"""
return CommandContext(self._version, sid=sid)
def __call__(self, sid: str) -> CommandContext:
"""
Constructs a CommandContext
:param sid:
"""
return CommandContext(self._version, sid=sid)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.Wireless.CommandList>"
@@ -0,0 +1,662 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Preview
This is the public Twilio REST API.
NOTE: This class is auto generated by OpenAPI Generator.
https://openapi-generator.tech
Do not edit the class manually.
"""
from datetime import datetime
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
from twilio.base import deserialize, serialize, values
from twilio.base.instance_context import InstanceContext
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.version import Version
from twilio.base.page import Page
class RatePlanInstance(InstanceResource):
"""
:ivar sid:
:ivar unique_name:
:ivar account_sid:
:ivar friendly_name:
:ivar data_enabled:
:ivar data_metering:
:ivar data_limit:
:ivar messaging_enabled:
:ivar voice_enabled:
:ivar national_roaming_enabled:
:ivar international_roaming:
:ivar date_created:
:ivar date_updated:
:ivar url:
"""
def __init__(
self, version: Version, payload: Dict[str, Any], sid: Optional[str] = None
):
super().__init__(version)
self.sid: Optional[str] = payload.get("sid")
self.unique_name: Optional[str] = payload.get("unique_name")
self.account_sid: Optional[str] = payload.get("account_sid")
self.friendly_name: Optional[str] = payload.get("friendly_name")
self.data_enabled: Optional[bool] = payload.get("data_enabled")
self.data_metering: Optional[str] = payload.get("data_metering")
self.data_limit: Optional[int] = deserialize.integer(payload.get("data_limit"))
self.messaging_enabled: Optional[bool] = payload.get("messaging_enabled")
self.voice_enabled: Optional[bool] = payload.get("voice_enabled")
self.national_roaming_enabled: Optional[bool] = payload.get(
"national_roaming_enabled"
)
self.international_roaming: Optional[List[str]] = payload.get(
"international_roaming"
)
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_created")
)
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_updated")
)
self.url: Optional[str] = payload.get("url")
self._solution = {
"sid": sid or self.sid,
}
self._context: Optional[RatePlanContext] = None
@property
def _proxy(self) -> "RatePlanContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: RatePlanContext for this RatePlanInstance
"""
if self._context is None:
self._context = RatePlanContext(
self._version,
sid=self._solution["sid"],
)
return self._context
def delete(self) -> bool:
"""
Deletes the RatePlanInstance
:returns: True if delete succeeds, False otherwise
"""
return self._proxy.delete()
async def delete_async(self) -> bool:
"""
Asynchronous coroutine that deletes the RatePlanInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._proxy.delete_async()
def fetch(self) -> "RatePlanInstance":
"""
Fetch the RatePlanInstance
:returns: The fetched RatePlanInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "RatePlanInstance":
"""
Asynchronous coroutine to fetch the RatePlanInstance
:returns: The fetched RatePlanInstance
"""
return await self._proxy.fetch_async()
def update(
self,
unique_name: Union[str, object] = values.unset,
friendly_name: Union[str, object] = values.unset,
) -> "RatePlanInstance":
"""
Update the RatePlanInstance
:param unique_name:
:param friendly_name:
:returns: The updated RatePlanInstance
"""
return self._proxy.update(
unique_name=unique_name,
friendly_name=friendly_name,
)
async def update_async(
self,
unique_name: Union[str, object] = values.unset,
friendly_name: Union[str, object] = values.unset,
) -> "RatePlanInstance":
"""
Asynchronous coroutine to update the RatePlanInstance
:param unique_name:
:param friendly_name:
:returns: The updated RatePlanInstance
"""
return await self._proxy.update_async(
unique_name=unique_name,
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.Preview.Wireless.RatePlanInstance {}>".format(context)
class RatePlanContext(InstanceContext):
def __init__(self, version: Version, sid: str):
"""
Initialize the RatePlanContext
:param version: Version that contains the resource
:param sid:
"""
super().__init__(version)
# Path Solution
self._solution = {
"sid": sid,
}
self._uri = "/RatePlans/{sid}".format(**self._solution)
def delete(self) -> bool:
"""
Deletes the RatePlanInstance
: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 RatePlanInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._version.delete_async(
method="DELETE",
uri=self._uri,
)
def fetch(self) -> RatePlanInstance:
"""
Fetch the RatePlanInstance
:returns: The fetched RatePlanInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return RatePlanInstance(
self._version,
payload,
sid=self._solution["sid"],
)
async def fetch_async(self) -> RatePlanInstance:
"""
Asynchronous coroutine to fetch the RatePlanInstance
:returns: The fetched RatePlanInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return RatePlanInstance(
self._version,
payload,
sid=self._solution["sid"],
)
def update(
self,
unique_name: Union[str, object] = values.unset,
friendly_name: Union[str, object] = values.unset,
) -> RatePlanInstance:
"""
Update the RatePlanInstance
:param unique_name:
:param friendly_name:
:returns: The updated RatePlanInstance
"""
data = values.of(
{
"UniqueName": unique_name,
"FriendlyName": friendly_name,
}
)
payload = self._version.update(
method="POST",
uri=self._uri,
data=data,
)
return RatePlanInstance(self._version, payload, sid=self._solution["sid"])
async def update_async(
self,
unique_name: Union[str, object] = values.unset,
friendly_name: Union[str, object] = values.unset,
) -> RatePlanInstance:
"""
Asynchronous coroutine to update the RatePlanInstance
:param unique_name:
:param friendly_name:
:returns: The updated RatePlanInstance
"""
data = values.of(
{
"UniqueName": unique_name,
"FriendlyName": friendly_name,
}
)
payload = await self._version.update_async(
method="POST",
uri=self._uri,
data=data,
)
return RatePlanInstance(self._version, payload, sid=self._solution["sid"])
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Preview.Wireless.RatePlanContext {}>".format(context)
class RatePlanPage(Page):
def get_instance(self, payload: Dict[str, Any]) -> RatePlanInstance:
"""
Build an instance of RatePlanInstance
:param payload: Payload response from the API
"""
return RatePlanInstance(self._version, payload)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.Wireless.RatePlanPage>"
class RatePlanList(ListResource):
def __init__(self, version: Version):
"""
Initialize the RatePlanList
:param version: Version that contains the resource
"""
super().__init__(version)
self._uri = "/RatePlans"
def create(
self,
unique_name: Union[str, object] = values.unset,
friendly_name: Union[str, object] = values.unset,
data_enabled: Union[bool, object] = values.unset,
data_limit: Union[int, object] = values.unset,
data_metering: Union[str, object] = values.unset,
messaging_enabled: Union[bool, object] = values.unset,
voice_enabled: Union[bool, object] = values.unset,
commands_enabled: Union[bool, object] = values.unset,
national_roaming_enabled: Union[bool, object] = values.unset,
international_roaming: Union[List[str], object] = values.unset,
) -> RatePlanInstance:
"""
Create the RatePlanInstance
:param unique_name:
:param friendly_name:
:param data_enabled:
:param data_limit:
:param data_metering:
:param messaging_enabled:
:param voice_enabled:
:param commands_enabled:
:param national_roaming_enabled:
:param international_roaming:
:returns: The created RatePlanInstance
"""
data = values.of(
{
"UniqueName": unique_name,
"FriendlyName": friendly_name,
"DataEnabled": data_enabled,
"DataLimit": data_limit,
"DataMetering": data_metering,
"MessagingEnabled": messaging_enabled,
"VoiceEnabled": voice_enabled,
"CommandsEnabled": commands_enabled,
"NationalRoamingEnabled": national_roaming_enabled,
"InternationalRoaming": serialize.map(
international_roaming, lambda e: e
),
}
)
payload = self._version.create(
method="POST",
uri=self._uri,
data=data,
)
return RatePlanInstance(self._version, payload)
async def create_async(
self,
unique_name: Union[str, object] = values.unset,
friendly_name: Union[str, object] = values.unset,
data_enabled: Union[bool, object] = values.unset,
data_limit: Union[int, object] = values.unset,
data_metering: Union[str, object] = values.unset,
messaging_enabled: Union[bool, object] = values.unset,
voice_enabled: Union[bool, object] = values.unset,
commands_enabled: Union[bool, object] = values.unset,
national_roaming_enabled: Union[bool, object] = values.unset,
international_roaming: Union[List[str], object] = values.unset,
) -> RatePlanInstance:
"""
Asynchronously create the RatePlanInstance
:param unique_name:
:param friendly_name:
:param data_enabled:
:param data_limit:
:param data_metering:
:param messaging_enabled:
:param voice_enabled:
:param commands_enabled:
:param national_roaming_enabled:
:param international_roaming:
:returns: The created RatePlanInstance
"""
data = values.of(
{
"UniqueName": unique_name,
"FriendlyName": friendly_name,
"DataEnabled": data_enabled,
"DataLimit": data_limit,
"DataMetering": data_metering,
"MessagingEnabled": messaging_enabled,
"VoiceEnabled": voice_enabled,
"CommandsEnabled": commands_enabled,
"NationalRoamingEnabled": national_roaming_enabled,
"InternationalRoaming": serialize.map(
international_roaming, lambda e: e
),
}
)
payload = await self._version.create_async(
method="POST",
uri=self._uri,
data=data,
)
return RatePlanInstance(self._version, payload)
def stream(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[RatePlanInstance]:
"""
Streams RatePlanInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param limit: Upper limit for the number of records to return. stream()
guarantees to 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[RatePlanInstance]:
"""
Asynchronously streams RatePlanInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param limit: Upper limit for the number of records to return. stream()
guarantees to 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[RatePlanInstance]:
"""
Lists RatePlanInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param limit: Upper limit for the number of records to return. list() guarantees
never 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[RatePlanInstance]:
"""
Asynchronously lists RatePlanInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param limit: Upper limit for the number of records to return. list() guarantees
never 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,
) -> RatePlanPage:
"""
Retrieve a single page of RatePlanInstance 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 RatePlanInstance
"""
data = values.of(
{
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return RatePlanPage(self._version, response)
async def page_async(
self,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> RatePlanPage:
"""
Asynchronously retrieve a single page of RatePlanInstance 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 RatePlanInstance
"""
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 RatePlanPage(self._version, response)
def get_page(self, target_url: str) -> RatePlanPage:
"""
Retrieve a specific page of RatePlanInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of RatePlanInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return RatePlanPage(self._version, response)
async def get_page_async(self, target_url: str) -> RatePlanPage:
"""
Asynchronously retrieve a specific page of RatePlanInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of RatePlanInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return RatePlanPage(self._version, response)
def get(self, sid: str) -> RatePlanContext:
"""
Constructs a RatePlanContext
:param sid:
"""
return RatePlanContext(self._version, sid=sid)
def __call__(self, sid: str) -> RatePlanContext:
"""
Constructs a RatePlanContext
:param sid:
"""
return RatePlanContext(self._version, sid=sid)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.Wireless.RatePlanList>"
@@ -0,0 +1,810 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Preview
This is the public Twilio REST API.
NOTE: This class is auto generated by OpenAPI Generator.
https://openapi-generator.tech
Do not edit the class manually.
"""
from datetime import datetime
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
from twilio.base import deserialize, values
from twilio.base.instance_context import InstanceContext
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.version import Version
from twilio.base.page import Page
from twilio.rest.preview.wireless.sim.usage import UsageList
class SimInstance(InstanceResource):
"""
:ivar sid:
:ivar unique_name:
:ivar account_sid:
:ivar rate_plan_sid:
:ivar friendly_name:
:ivar iccid:
:ivar e_id:
:ivar status:
:ivar commands_callback_url:
:ivar commands_callback_method:
:ivar sms_fallback_method:
:ivar sms_fallback_url:
:ivar sms_method:
:ivar sms_url:
:ivar voice_fallback_method:
:ivar voice_fallback_url:
:ivar voice_method:
:ivar voice_url:
:ivar date_created:
:ivar date_updated:
:ivar url:
:ivar links:
"""
def __init__(
self, version: Version, payload: Dict[str, Any], sid: Optional[str] = None
):
super().__init__(version)
self.sid: Optional[str] = payload.get("sid")
self.unique_name: Optional[str] = payload.get("unique_name")
self.account_sid: Optional[str] = payload.get("account_sid")
self.rate_plan_sid: Optional[str] = payload.get("rate_plan_sid")
self.friendly_name: Optional[str] = payload.get("friendly_name")
self.iccid: Optional[str] = payload.get("iccid")
self.e_id: Optional[str] = payload.get("e_id")
self.status: Optional[str] = payload.get("status")
self.commands_callback_url: Optional[str] = payload.get("commands_callback_url")
self.commands_callback_method: Optional[str] = payload.get(
"commands_callback_method"
)
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.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.date_created: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_created")
)
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_updated")
)
self.url: Optional[str] = payload.get("url")
self.links: Optional[Dict[str, object]] = payload.get("links")
self._solution = {
"sid": sid or self.sid,
}
self._context: Optional[SimContext] = None
@property
def _proxy(self) -> "SimContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: SimContext for this SimInstance
"""
if self._context is None:
self._context = SimContext(
self._version,
sid=self._solution["sid"],
)
return self._context
def fetch(self) -> "SimInstance":
"""
Fetch the SimInstance
:returns: The fetched SimInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "SimInstance":
"""
Asynchronous coroutine to fetch the SimInstance
:returns: The fetched SimInstance
"""
return await self._proxy.fetch_async()
def update(
self,
unique_name: Union[str, object] = values.unset,
callback_method: Union[str, object] = values.unset,
callback_url: Union[str, object] = values.unset,
friendly_name: Union[str, object] = values.unset,
rate_plan: Union[str, object] = values.unset,
status: Union[str, object] = values.unset,
commands_callback_method: Union[str, object] = values.unset,
commands_callback_url: 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,
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,
) -> "SimInstance":
"""
Update the SimInstance
:param unique_name:
:param callback_method:
:param callback_url:
:param friendly_name:
:param rate_plan:
:param status:
:param commands_callback_method:
:param commands_callback_url:
:param sms_fallback_method:
:param sms_fallback_url:
:param sms_method:
:param sms_url:
:param voice_fallback_method:
:param voice_fallback_url:
:param voice_method:
:param voice_url:
:returns: The updated SimInstance
"""
return self._proxy.update(
unique_name=unique_name,
callback_method=callback_method,
callback_url=callback_url,
friendly_name=friendly_name,
rate_plan=rate_plan,
status=status,
commands_callback_method=commands_callback_method,
commands_callback_url=commands_callback_url,
sms_fallback_method=sms_fallback_method,
sms_fallback_url=sms_fallback_url,
sms_method=sms_method,
sms_url=sms_url,
voice_fallback_method=voice_fallback_method,
voice_fallback_url=voice_fallback_url,
voice_method=voice_method,
voice_url=voice_url,
)
async def update_async(
self,
unique_name: Union[str, object] = values.unset,
callback_method: Union[str, object] = values.unset,
callback_url: Union[str, object] = values.unset,
friendly_name: Union[str, object] = values.unset,
rate_plan: Union[str, object] = values.unset,
status: Union[str, object] = values.unset,
commands_callback_method: Union[str, object] = values.unset,
commands_callback_url: 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,
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,
) -> "SimInstance":
"""
Asynchronous coroutine to update the SimInstance
:param unique_name:
:param callback_method:
:param callback_url:
:param friendly_name:
:param rate_plan:
:param status:
:param commands_callback_method:
:param commands_callback_url:
:param sms_fallback_method:
:param sms_fallback_url:
:param sms_method:
:param sms_url:
:param voice_fallback_method:
:param voice_fallback_url:
:param voice_method:
:param voice_url:
:returns: The updated SimInstance
"""
return await self._proxy.update_async(
unique_name=unique_name,
callback_method=callback_method,
callback_url=callback_url,
friendly_name=friendly_name,
rate_plan=rate_plan,
status=status,
commands_callback_method=commands_callback_method,
commands_callback_url=commands_callback_url,
sms_fallback_method=sms_fallback_method,
sms_fallback_url=sms_fallback_url,
sms_method=sms_method,
sms_url=sms_url,
voice_fallback_method=voice_fallback_method,
voice_fallback_url=voice_fallback_url,
voice_method=voice_method,
voice_url=voice_url,
)
@property
def usage(self) -> UsageList:
"""
Access the usage
"""
return self._proxy.usage
def __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.Preview.Wireless.SimInstance {}>".format(context)
class SimContext(InstanceContext):
def __init__(self, version: Version, sid: str):
"""
Initialize the SimContext
:param version: Version that contains the resource
:param sid:
"""
super().__init__(version)
# Path Solution
self._solution = {
"sid": sid,
}
self._uri = "/Sims/{sid}".format(**self._solution)
self._usage: Optional[UsageList] = None
def fetch(self) -> SimInstance:
"""
Fetch the SimInstance
:returns: The fetched SimInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return SimInstance(
self._version,
payload,
sid=self._solution["sid"],
)
async def fetch_async(self) -> SimInstance:
"""
Asynchronous coroutine to fetch the SimInstance
:returns: The fetched SimInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return SimInstance(
self._version,
payload,
sid=self._solution["sid"],
)
def update(
self,
unique_name: Union[str, object] = values.unset,
callback_method: Union[str, object] = values.unset,
callback_url: Union[str, object] = values.unset,
friendly_name: Union[str, object] = values.unset,
rate_plan: Union[str, object] = values.unset,
status: Union[str, object] = values.unset,
commands_callback_method: Union[str, object] = values.unset,
commands_callback_url: 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,
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,
) -> SimInstance:
"""
Update the SimInstance
:param unique_name:
:param callback_method:
:param callback_url:
:param friendly_name:
:param rate_plan:
:param status:
:param commands_callback_method:
:param commands_callback_url:
:param sms_fallback_method:
:param sms_fallback_url:
:param sms_method:
:param sms_url:
:param voice_fallback_method:
:param voice_fallback_url:
:param voice_method:
:param voice_url:
:returns: The updated SimInstance
"""
data = values.of(
{
"UniqueName": unique_name,
"CallbackMethod": callback_method,
"CallbackUrl": callback_url,
"FriendlyName": friendly_name,
"RatePlan": rate_plan,
"Status": status,
"CommandsCallbackMethod": commands_callback_method,
"CommandsCallbackUrl": commands_callback_url,
"SmsFallbackMethod": sms_fallback_method,
"SmsFallbackUrl": sms_fallback_url,
"SmsMethod": sms_method,
"SmsUrl": sms_url,
"VoiceFallbackMethod": voice_fallback_method,
"VoiceFallbackUrl": voice_fallback_url,
"VoiceMethod": voice_method,
"VoiceUrl": voice_url,
}
)
payload = self._version.update(
method="POST",
uri=self._uri,
data=data,
)
return SimInstance(self._version, payload, sid=self._solution["sid"])
async def update_async(
self,
unique_name: Union[str, object] = values.unset,
callback_method: Union[str, object] = values.unset,
callback_url: Union[str, object] = values.unset,
friendly_name: Union[str, object] = values.unset,
rate_plan: Union[str, object] = values.unset,
status: Union[str, object] = values.unset,
commands_callback_method: Union[str, object] = values.unset,
commands_callback_url: 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,
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,
) -> SimInstance:
"""
Asynchronous coroutine to update the SimInstance
:param unique_name:
:param callback_method:
:param callback_url:
:param friendly_name:
:param rate_plan:
:param status:
:param commands_callback_method:
:param commands_callback_url:
:param sms_fallback_method:
:param sms_fallback_url:
:param sms_method:
:param sms_url:
:param voice_fallback_method:
:param voice_fallback_url:
:param voice_method:
:param voice_url:
:returns: The updated SimInstance
"""
data = values.of(
{
"UniqueName": unique_name,
"CallbackMethod": callback_method,
"CallbackUrl": callback_url,
"FriendlyName": friendly_name,
"RatePlan": rate_plan,
"Status": status,
"CommandsCallbackMethod": commands_callback_method,
"CommandsCallbackUrl": commands_callback_url,
"SmsFallbackMethod": sms_fallback_method,
"SmsFallbackUrl": sms_fallback_url,
"SmsMethod": sms_method,
"SmsUrl": sms_url,
"VoiceFallbackMethod": voice_fallback_method,
"VoiceFallbackUrl": voice_fallback_url,
"VoiceMethod": voice_method,
"VoiceUrl": voice_url,
}
)
payload = await self._version.update_async(
method="POST",
uri=self._uri,
data=data,
)
return SimInstance(self._version, payload, sid=self._solution["sid"])
@property
def usage(self) -> UsageList:
"""
Access the usage
"""
if self._usage is None:
self._usage = UsageList(
self._version,
self._solution["sid"],
)
return self._usage
def __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.Preview.Wireless.SimContext {}>".format(context)
class SimPage(Page):
def get_instance(self, payload: Dict[str, Any]) -> SimInstance:
"""
Build an instance of SimInstance
:param payload: Payload response from the API
"""
return SimInstance(self._version, payload)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.Wireless.SimPage>"
class SimList(ListResource):
def __init__(self, version: Version):
"""
Initialize the SimList
:param version: Version that contains the resource
"""
super().__init__(version)
self._uri = "/Sims"
def stream(
self,
status: Union[str, object] = values.unset,
iccid: Union[str, object] = values.unset,
rate_plan: Union[str, object] = values.unset,
e_id: Union[str, object] = values.unset,
sim_registration_code: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[SimInstance]:
"""
Streams SimInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param str status:
:param str iccid:
:param str rate_plan:
:param str e_id:
:param str sim_registration_code:
:param limit: Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the
limit with the most efficient page size, i.e. min(limit, 1000)
:returns: Generator that will yield up to limit results
"""
limits = self._version.read_limits(limit, page_size)
page = self.page(
status=status,
iccid=iccid,
rate_plan=rate_plan,
e_id=e_id,
sim_registration_code=sim_registration_code,
page_size=limits["page_size"],
)
return self._version.stream(page, limits["limit"])
async def stream_async(
self,
status: Union[str, object] = values.unset,
iccid: Union[str, object] = values.unset,
rate_plan: Union[str, object] = values.unset,
e_id: Union[str, object] = values.unset,
sim_registration_code: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> AsyncIterator[SimInstance]:
"""
Asynchronously streams SimInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param str status:
:param str iccid:
:param str rate_plan:
:param str e_id:
:param str sim_registration_code:
:param limit: Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the
limit with the most efficient page size, i.e. min(limit, 1000)
:returns: Generator that will yield up to limit results
"""
limits = self._version.read_limits(limit, page_size)
page = await self.page_async(
status=status,
iccid=iccid,
rate_plan=rate_plan,
e_id=e_id,
sim_registration_code=sim_registration_code,
page_size=limits["page_size"],
)
return self._version.stream_async(page, limits["limit"])
def list(
self,
status: Union[str, object] = values.unset,
iccid: Union[str, object] = values.unset,
rate_plan: Union[str, object] = values.unset,
e_id: Union[str, object] = values.unset,
sim_registration_code: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[SimInstance]:
"""
Lists SimInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param str status:
:param str iccid:
:param str rate_plan:
:param str e_id:
:param str sim_registration_code:
:param limit: Upper limit for the number of records to return. list() guarantees
never to return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, list() will attempt to read the limit
with the most efficient page size, i.e. min(limit, 1000)
:returns: list that will contain up to limit results
"""
return list(
self.stream(
status=status,
iccid=iccid,
rate_plan=rate_plan,
e_id=e_id,
sim_registration_code=sim_registration_code,
limit=limit,
page_size=page_size,
)
)
async def list_async(
self,
status: Union[str, object] = values.unset,
iccid: Union[str, object] = values.unset,
rate_plan: Union[str, object] = values.unset,
e_id: Union[str, object] = values.unset,
sim_registration_code: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[SimInstance]:
"""
Asynchronously lists SimInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param str status:
:param str iccid:
:param str rate_plan:
:param str e_id:
:param str sim_registration_code:
:param limit: Upper limit for the number of records to return. list() guarantees
never to return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, list() will attempt to read the limit
with the most efficient page size, i.e. min(limit, 1000)
:returns: list that will contain up to limit results
"""
return [
record
async for record in await self.stream_async(
status=status,
iccid=iccid,
rate_plan=rate_plan,
e_id=e_id,
sim_registration_code=sim_registration_code,
limit=limit,
page_size=page_size,
)
]
def page(
self,
status: Union[str, object] = values.unset,
iccid: Union[str, object] = values.unset,
rate_plan: Union[str, object] = values.unset,
e_id: Union[str, object] = values.unset,
sim_registration_code: Union[str, object] = values.unset,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> SimPage:
"""
Retrieve a single page of SimInstance records from the API.
Request is executed immediately
:param status:
:param iccid:
:param rate_plan:
:param e_id:
:param sim_registration_code:
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of SimInstance
"""
data = values.of(
{
"Status": status,
"Iccid": iccid,
"RatePlan": rate_plan,
"EId": e_id,
"SimRegistrationCode": sim_registration_code,
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return SimPage(self._version, response)
async def page_async(
self,
status: Union[str, object] = values.unset,
iccid: Union[str, object] = values.unset,
rate_plan: Union[str, object] = values.unset,
e_id: Union[str, object] = values.unset,
sim_registration_code: Union[str, object] = values.unset,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> SimPage:
"""
Asynchronously retrieve a single page of SimInstance records from the API.
Request is executed immediately
:param status:
:param iccid:
:param rate_plan:
:param e_id:
:param sim_registration_code:
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of SimInstance
"""
data = values.of(
{
"Status": status,
"Iccid": iccid,
"RatePlan": rate_plan,
"EId": e_id,
"SimRegistrationCode": sim_registration_code,
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = await self._version.page_async(
method="GET", uri=self._uri, params=data
)
return SimPage(self._version, response)
def get_page(self, target_url: str) -> SimPage:
"""
Retrieve a specific page of SimInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of SimInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return SimPage(self._version, response)
async def get_page_async(self, target_url: str) -> SimPage:
"""
Asynchronously retrieve a specific page of SimInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of SimInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return SimPage(self._version, response)
def get(self, sid: str) -> SimContext:
"""
Constructs a SimContext
:param sid:
"""
return SimContext(self._version, sid=sid)
def __call__(self, sid: str) -> SimContext:
"""
Constructs a SimContext
:param sid:
"""
return SimContext(self._version, sid=sid)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.Wireless.SimList>"
@@ -0,0 +1,239 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Preview
This is the public Twilio REST API.
NOTE: This class is auto generated by OpenAPI Generator.
https://openapi-generator.tech
Do not edit the class manually.
"""
from typing import Any, Dict, Optional, Union
from twilio.base import values
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 UsageInstance(InstanceResource):
"""
:ivar sim_sid:
:ivar sim_unique_name:
:ivar account_sid:
:ivar period:
:ivar commands_usage:
:ivar commands_costs:
:ivar data_usage:
:ivar data_costs:
:ivar url:
"""
def __init__(self, version: Version, payload: Dict[str, Any], sim_sid: str):
super().__init__(version)
self.sim_sid: Optional[str] = payload.get("sim_sid")
self.sim_unique_name: Optional[str] = payload.get("sim_unique_name")
self.account_sid: Optional[str] = payload.get("account_sid")
self.period: Optional[Dict[str, object]] = payload.get("period")
self.commands_usage: Optional[Dict[str, object]] = payload.get("commands_usage")
self.commands_costs: Optional[Dict[str, object]] = payload.get("commands_costs")
self.data_usage: Optional[Dict[str, object]] = payload.get("data_usage")
self.data_costs: Optional[Dict[str, object]] = payload.get("data_costs")
self.url: Optional[str] = payload.get("url")
self._solution = {
"sim_sid": sim_sid,
}
self._context: Optional[UsageContext] = None
@property
def _proxy(self) -> "UsageContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: UsageContext for this UsageInstance
"""
if self._context is None:
self._context = UsageContext(
self._version,
sim_sid=self._solution["sim_sid"],
)
return self._context
def fetch(
self,
end: Union[str, object] = values.unset,
start: Union[str, object] = values.unset,
) -> "UsageInstance":
"""
Fetch the UsageInstance
:param end:
:param start:
:returns: The fetched UsageInstance
"""
return self._proxy.fetch(
end=end,
start=start,
)
async def fetch_async(
self,
end: Union[str, object] = values.unset,
start: Union[str, object] = values.unset,
) -> "UsageInstance":
"""
Asynchronous coroutine to fetch the UsageInstance
:param end:
:param start:
:returns: The fetched UsageInstance
"""
return await self._proxy.fetch_async(
end=end,
start=start,
)
def __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.Preview.Wireless.UsageInstance {}>".format(context)
class UsageContext(InstanceContext):
def __init__(self, version: Version, sim_sid: str):
"""
Initialize the UsageContext
:param version: Version that contains the resource
:param sim_sid:
"""
super().__init__(version)
# Path Solution
self._solution = {
"sim_sid": sim_sid,
}
self._uri = "/Sims/{sim_sid}/Usage".format(**self._solution)
def fetch(
self,
end: Union[str, object] = values.unset,
start: Union[str, object] = values.unset,
) -> UsageInstance:
"""
Fetch the UsageInstance
:param end:
:param start:
:returns: The fetched UsageInstance
"""
data = values.of(
{
"End": end,
"Start": start,
}
)
payload = self._version.fetch(method="GET", uri=self._uri, params=data)
return UsageInstance(
self._version,
payload,
sim_sid=self._solution["sim_sid"],
)
async def fetch_async(
self,
end: Union[str, object] = values.unset,
start: Union[str, object] = values.unset,
) -> UsageInstance:
"""
Asynchronous coroutine to fetch the UsageInstance
:param end:
:param start:
:returns: The fetched UsageInstance
"""
data = values.of(
{
"End": end,
"Start": start,
}
)
payload = await self._version.fetch_async(
method="GET", uri=self._uri, params=data
)
return UsageInstance(
self._version,
payload,
sim_sid=self._solution["sim_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.Preview.Wireless.UsageContext {}>".format(context)
class UsageList(ListResource):
def __init__(self, version: Version, sim_sid: str):
"""
Initialize the UsageList
:param version: Version that contains the resource
:param sim_sid:
"""
super().__init__(version)
# Path Solution
self._solution = {
"sim_sid": sim_sid,
}
def get(self) -> UsageContext:
"""
Constructs a UsageContext
"""
return UsageContext(self._version, sim_sid=self._solution["sim_sid"])
def __call__(self) -> UsageContext:
"""
Constructs a UsageContext
"""
return UsageContext(self._version, sim_sid=self._solution["sim_sid"])
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Preview.Wireless.UsageList>"