Initial commit: Email alerts application
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
from typing import Optional
|
||||
|
||||
from twilio.base.domain import Domain
|
||||
from twilio.rest import Client
|
||||
from twilio.rest.wireless.v1 import V1
|
||||
|
||||
|
||||
class WirelessBase(Domain):
|
||||
def __init__(self, twilio: Client):
|
||||
"""
|
||||
Initialize the Wireless Domain
|
||||
|
||||
:returns: Domain for Wireless
|
||||
"""
|
||||
super().__init__(twilio, "https://wireless.twilio.com")
|
||||
self._v1: Optional[V1] = None
|
||||
|
||||
@property
|
||||
def v1(self) -> V1:
|
||||
"""
|
||||
:returns: Versions v1 of Wireless
|
||||
"""
|
||||
if self._v1 is None:
|
||||
self._v1 = V1(self)
|
||||
return self._v1
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Wireless>"
|
||||
@@ -0,0 +1,43 @@
|
||||
from warnings import warn
|
||||
|
||||
from twilio.rest.wireless.WirelessBase import WirelessBase
|
||||
from twilio.rest.wireless.v1.command import CommandList
|
||||
from twilio.rest.wireless.v1.rate_plan import RatePlanList
|
||||
from twilio.rest.wireless.v1.sim import SimList
|
||||
from twilio.rest.wireless.v1.usage_record import UsageRecordList
|
||||
|
||||
|
||||
class Wireless(WirelessBase):
|
||||
@property
|
||||
def usage_records(self) -> UsageRecordList:
|
||||
warn(
|
||||
"usage_records is deprecated. Use v1.usage_records instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.v1.usage_records
|
||||
|
||||
@property
|
||||
def commands(self) -> CommandList:
|
||||
warn(
|
||||
"commands is deprecated. Use v1.commands instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.v1.commands
|
||||
|
||||
@property
|
||||
def rate_plans(self) -> RatePlanList:
|
||||
warn(
|
||||
"rate_plans is deprecated. Use v1.rate_plans instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.v1.rate_plans
|
||||
|
||||
@property
|
||||
def sims(self) -> SimList:
|
||||
warn(
|
||||
"sims is deprecated. Use v1.sims instead.", DeprecationWarning, stacklevel=2
|
||||
)
|
||||
return self.v1.sims
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -0,0 +1,66 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Wireless
|
||||
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.wireless.v1.command import CommandList
|
||||
from twilio.rest.wireless.v1.rate_plan import RatePlanList
|
||||
from twilio.rest.wireless.v1.sim import SimList
|
||||
from twilio.rest.wireless.v1.usage_record import UsageRecordList
|
||||
|
||||
|
||||
class V1(Version):
|
||||
def __init__(self, domain: Domain):
|
||||
"""
|
||||
Initialize the V1 version of Wireless
|
||||
|
||||
:param domain: The Twilio.wireless domain
|
||||
"""
|
||||
super().__init__(domain, "v1")
|
||||
self._commands: Optional[CommandList] = None
|
||||
self._rate_plans: Optional[RatePlanList] = None
|
||||
self._sims: Optional[SimList] = None
|
||||
self._usage_records: Optional[UsageRecordList] = 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
|
||||
|
||||
@property
|
||||
def usage_records(self) -> UsageRecordList:
|
||||
if self._usage_records is None:
|
||||
self._usage_records = UsageRecordList(self)
|
||||
return self._usage_records
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Wireless.V1>"
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -0,0 +1,638 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Wireless
|
||||
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):
|
||||
class CommandMode(object):
|
||||
TEXT = "text"
|
||||
BINARY = "binary"
|
||||
|
||||
class Direction(object):
|
||||
FROM_SIM = "from_sim"
|
||||
TO_SIM = "to_sim"
|
||||
|
||||
class Status(object):
|
||||
QUEUED = "queued"
|
||||
SENT = "sent"
|
||||
DELIVERED = "delivered"
|
||||
RECEIVED = "received"
|
||||
FAILED = "failed"
|
||||
|
||||
class Transport(object):
|
||||
SMS = "sms"
|
||||
IP = "ip"
|
||||
|
||||
"""
|
||||
:ivar sid: The unique string that we created to identify the Command resource.
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Command resource.
|
||||
:ivar sim_sid: The SID of the [Sim resource](https://www.twilio.com/docs/iot/wireless/api/sim-resource) that the Command was sent to or from.
|
||||
:ivar command: The message being sent to or from the SIM. For text mode messages, this can be up to 160 characters. For binary mode messages, this is a series of up to 140 bytes of data encoded using base64.
|
||||
:ivar command_mode:
|
||||
:ivar transport:
|
||||
:ivar delivery_receipt_requested: Whether to request a delivery receipt.
|
||||
:ivar status:
|
||||
:ivar direction:
|
||||
:ivar date_created: The date and time in GMT when the resource was created specified in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format.
|
||||
:ivar date_updated: The date and time in GMT when the resource was last updated specified in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format.
|
||||
:ivar url: The absolute URL of the resource.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self, version: Version, payload: Dict[str, Any], sid: Optional[str] = None
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.sim_sid: Optional[str] = payload.get("sim_sid")
|
||||
self.command: Optional[str] = payload.get("command")
|
||||
self.command_mode: Optional["CommandInstance.CommandMode"] = payload.get(
|
||||
"command_mode"
|
||||
)
|
||||
self.transport: Optional["CommandInstance.Transport"] = payload.get("transport")
|
||||
self.delivery_receipt_requested: Optional[bool] = payload.get(
|
||||
"delivery_receipt_requested"
|
||||
)
|
||||
self.status: Optional["CommandInstance.Status"] = payload.get("status")
|
||||
self.direction: Optional["CommandInstance.Direction"] = 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 delete(self) -> bool:
|
||||
"""
|
||||
Deletes the CommandInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the CommandInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
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.Wireless.V1.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: The SID of the Command resource to fetch.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Commands/{sid}".format(**self._solution)
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the CommandInstance
|
||||
|
||||
|
||||
: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 CommandInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
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.Wireless.V1.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.Wireless.V1.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,
|
||||
sim: Union[str, object] = values.unset,
|
||||
callback_method: Union[str, object] = values.unset,
|
||||
callback_url: Union[str, object] = values.unset,
|
||||
command_mode: Union["CommandInstance.CommandMode", object] = values.unset,
|
||||
include_sid: Union[str, object] = values.unset,
|
||||
delivery_receipt_requested: Union[bool, object] = values.unset,
|
||||
) -> CommandInstance:
|
||||
"""
|
||||
Create the CommandInstance
|
||||
|
||||
:param command: The message body of the Command. Can be plain text in text mode or a Base64 encoded byte string in binary mode.
|
||||
:param sim: The `sid` or `unique_name` of the [SIM](https://www.twilio.com/docs/iot/wireless/api/sim-resource) to send the Command to.
|
||||
:param callback_method: The HTTP method we use to call `callback_url`. Can be: `POST` or `GET`, and the default is `POST`.
|
||||
:param callback_url: The URL we call using the `callback_url` when the Command has finished sending, whether the command was delivered or it failed.
|
||||
:param command_mode:
|
||||
:param include_sid: Whether to include the SID of the command in the message body. Can be: `none`, `start`, or `end`, and the default behavior is `none`. When sending a Command to a SIM in text mode, we can automatically include the SID of the Command in the message body, which could be used to ensure that the device does not process the same Command more than once. A value of `start` will prepend the message with the Command SID, and `end` will append it to the end, separating the Command SID from the message body with a space. The length of the Command SID is included in the 160 character limit so the SMS body must be 128 characters or less before the Command SID is included.
|
||||
:param delivery_receipt_requested: Whether to request delivery receipt from the recipient. For Commands that request delivery receipt, the Command state transitions to 'delivered' once the server has received a delivery receipt from the device. The default value is `true`.
|
||||
|
||||
:returns: The created CommandInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Command": command,
|
||||
"Sim": sim,
|
||||
"CallbackMethod": callback_method,
|
||||
"CallbackUrl": callback_url,
|
||||
"CommandMode": command_mode,
|
||||
"IncludeSid": include_sid,
|
||||
"DeliveryReceiptRequested": delivery_receipt_requested,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return CommandInstance(self._version, payload)
|
||||
|
||||
async def create_async(
|
||||
self,
|
||||
command: str,
|
||||
sim: Union[str, object] = values.unset,
|
||||
callback_method: Union[str, object] = values.unset,
|
||||
callback_url: Union[str, object] = values.unset,
|
||||
command_mode: Union["CommandInstance.CommandMode", object] = values.unset,
|
||||
include_sid: Union[str, object] = values.unset,
|
||||
delivery_receipt_requested: Union[bool, object] = values.unset,
|
||||
) -> CommandInstance:
|
||||
"""
|
||||
Asynchronously create the CommandInstance
|
||||
|
||||
:param command: The message body of the Command. Can be plain text in text mode or a Base64 encoded byte string in binary mode.
|
||||
:param sim: The `sid` or `unique_name` of the [SIM](https://www.twilio.com/docs/iot/wireless/api/sim-resource) to send the Command to.
|
||||
:param callback_method: The HTTP method we use to call `callback_url`. Can be: `POST` or `GET`, and the default is `POST`.
|
||||
:param callback_url: The URL we call using the `callback_url` when the Command has finished sending, whether the command was delivered or it failed.
|
||||
:param command_mode:
|
||||
:param include_sid: Whether to include the SID of the command in the message body. Can be: `none`, `start`, or `end`, and the default behavior is `none`. When sending a Command to a SIM in text mode, we can automatically include the SID of the Command in the message body, which could be used to ensure that the device does not process the same Command more than once. A value of `start` will prepend the message with the Command SID, and `end` will append it to the end, separating the Command SID from the message body with a space. The length of the Command SID is included in the 160 character limit so the SMS body must be 128 characters or less before the Command SID is included.
|
||||
:param delivery_receipt_requested: Whether to request delivery receipt from the recipient. For Commands that request delivery receipt, the Command state transitions to 'delivered' once the server has received a delivery receipt from the device. The default value is `true`.
|
||||
|
||||
:returns: The created CommandInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Command": command,
|
||||
"Sim": sim,
|
||||
"CallbackMethod": callback_method,
|
||||
"CallbackUrl": callback_url,
|
||||
"CommandMode": command_mode,
|
||||
"IncludeSid": include_sid,
|
||||
"DeliveryReceiptRequested": delivery_receipt_requested,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return CommandInstance(self._version, payload)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
sim: Union[str, object] = values.unset,
|
||||
status: Union["CommandInstance.Status", object] = values.unset,
|
||||
direction: Union["CommandInstance.Direction", object] = values.unset,
|
||||
transport: Union["CommandInstance.Transport", 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 sim: The `sid` or `unique_name` of the [Sim resources](https://www.twilio.com/docs/iot/wireless/api/sim-resource) to read.
|
||||
:param "CommandInstance.Status" status: The status of the resources to read. Can be: `queued`, `sent`, `delivered`, `received`, or `failed`.
|
||||
:param "CommandInstance.Direction" direction: Only return Commands with this direction value.
|
||||
:param "CommandInstance.Transport" transport: Only return Commands with this transport value. Can be: `sms` or `ip`.
|
||||
: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(
|
||||
sim=sim,
|
||||
status=status,
|
||||
direction=direction,
|
||||
transport=transport,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
sim: Union[str, object] = values.unset,
|
||||
status: Union["CommandInstance.Status", object] = values.unset,
|
||||
direction: Union["CommandInstance.Direction", object] = values.unset,
|
||||
transport: Union["CommandInstance.Transport", 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 sim: The `sid` or `unique_name` of the [Sim resources](https://www.twilio.com/docs/iot/wireless/api/sim-resource) to read.
|
||||
:param "CommandInstance.Status" status: The status of the resources to read. Can be: `queued`, `sent`, `delivered`, `received`, or `failed`.
|
||||
:param "CommandInstance.Direction" direction: Only return Commands with this direction value.
|
||||
:param "CommandInstance.Transport" transport: Only return Commands with this transport value. Can be: `sms` or `ip`.
|
||||
: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(
|
||||
sim=sim,
|
||||
status=status,
|
||||
direction=direction,
|
||||
transport=transport,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
sim: Union[str, object] = values.unset,
|
||||
status: Union["CommandInstance.Status", object] = values.unset,
|
||||
direction: Union["CommandInstance.Direction", object] = values.unset,
|
||||
transport: Union["CommandInstance.Transport", 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 sim: The `sid` or `unique_name` of the [Sim resources](https://www.twilio.com/docs/iot/wireless/api/sim-resource) to read.
|
||||
:param "CommandInstance.Status" status: The status of the resources to read. Can be: `queued`, `sent`, `delivered`, `received`, or `failed`.
|
||||
:param "CommandInstance.Direction" direction: Only return Commands with this direction value.
|
||||
:param "CommandInstance.Transport" transport: Only return Commands with this transport value. Can be: `sms` or `ip`.
|
||||
: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(
|
||||
sim=sim,
|
||||
status=status,
|
||||
direction=direction,
|
||||
transport=transport,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
sim: Union[str, object] = values.unset,
|
||||
status: Union["CommandInstance.Status", object] = values.unset,
|
||||
direction: Union["CommandInstance.Direction", object] = values.unset,
|
||||
transport: Union["CommandInstance.Transport", 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 sim: The `sid` or `unique_name` of the [Sim resources](https://www.twilio.com/docs/iot/wireless/api/sim-resource) to read.
|
||||
:param "CommandInstance.Status" status: The status of the resources to read. Can be: `queued`, `sent`, `delivered`, `received`, or `failed`.
|
||||
:param "CommandInstance.Direction" direction: Only return Commands with this direction value.
|
||||
:param "CommandInstance.Transport" transport: Only return Commands with this transport value. Can be: `sms` or `ip`.
|
||||
: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(
|
||||
sim=sim,
|
||||
status=status,
|
||||
direction=direction,
|
||||
transport=transport,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
sim: Union[str, object] = values.unset,
|
||||
status: Union["CommandInstance.Status", object] = values.unset,
|
||||
direction: Union["CommandInstance.Direction", object] = values.unset,
|
||||
transport: Union["CommandInstance.Transport", 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 sim: The `sid` or `unique_name` of the [Sim resources](https://www.twilio.com/docs/iot/wireless/api/sim-resource) to read.
|
||||
:param status: The status of the resources to read. Can be: `queued`, `sent`, `delivered`, `received`, or `failed`.
|
||||
:param direction: Only return Commands with this direction value.
|
||||
:param transport: Only return Commands with this transport value. Can be: `sms` or `ip`.
|
||||
: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(
|
||||
{
|
||||
"Sim": sim,
|
||||
"Status": status,
|
||||
"Direction": direction,
|
||||
"Transport": transport,
|
||||
"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,
|
||||
sim: Union[str, object] = values.unset,
|
||||
status: Union["CommandInstance.Status", object] = values.unset,
|
||||
direction: Union["CommandInstance.Direction", object] = values.unset,
|
||||
transport: Union["CommandInstance.Transport", 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 sim: The `sid` or `unique_name` of the [Sim resources](https://www.twilio.com/docs/iot/wireless/api/sim-resource) to read.
|
||||
:param status: The status of the resources to read. Can be: `queued`, `sent`, `delivered`, `received`, or `failed`.
|
||||
:param direction: Only return Commands with this direction value.
|
||||
:param transport: Only return Commands with this transport value. Can be: `sms` or `ip`.
|
||||
: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(
|
||||
{
|
||||
"Sim": sim,
|
||||
"Status": status,
|
||||
"Direction": direction,
|
||||
"Transport": transport,
|
||||
"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: The SID of the Command resource to fetch.
|
||||
"""
|
||||
return CommandContext(self._version, sid=sid)
|
||||
|
||||
def __call__(self, sid: str) -> CommandContext:
|
||||
"""
|
||||
Constructs a CommandContext
|
||||
|
||||
:param sid: The SID of the Command resource to fetch.
|
||||
"""
|
||||
return CommandContext(self._version, sid=sid)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Wireless.V1.CommandList>"
|
||||
@@ -0,0 +1,676 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Wireless
|
||||
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: The unique string that we created to identify the RatePlan resource.
|
||||
:ivar unique_name: An application-defined string that uniquely identifies the resource. It can be used in place of the resource's `sid` in the URL to address the resource.
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the RatePlan resource.
|
||||
:ivar friendly_name: The string that you assigned to describe the resource.
|
||||
:ivar data_enabled: Whether SIMs can use GPRS/3G/4G/LTE data connectivity.
|
||||
:ivar data_metering: The model used to meter data usage. Can be: `payg` and `quota-1`, `quota-10`, and `quota-50`. Learn more about the available [data metering models](https://www.twilio.com/docs/iot/wireless/api/rateplan-resource#payg-vs-quota-data-plans).
|
||||
:ivar data_limit: The total data usage (download and upload combined) in Megabytes that the Network allows during one month on the home network (T-Mobile USA). The metering period begins the day of activation and ends on the same day in the following month. Can be up to 2TB.
|
||||
:ivar messaging_enabled: Whether SIMs can make, send, and receive SMS using [Commands](https://www.twilio.com/docs/iot/wireless/api/command-resource).
|
||||
:ivar voice_enabled: Deprecated. Whether SIMs can make and receive voice calls.
|
||||
:ivar national_roaming_enabled: Whether SIMs can roam on networks other than the home network (T-Mobile USA) in the United States. See [national roaming](https://www.twilio.com/docs/iot/wireless/api/rateplan-resource#national-roaming).
|
||||
:ivar national_roaming_data_limit: The total data usage (download and upload combined) in Megabytes that the Network allows during one month on non-home networks in the United States. The metering period begins the day of activation and ends on the same day in the following month. Can be up to 2TB.
|
||||
:ivar international_roaming: The list of services that SIMs capable of using GPRS/3G/4G/LTE data connectivity can use outside of the United States. Can contain: `data` and `messaging`.
|
||||
:ivar international_roaming_data_limit: The total data usage (download and upload combined) in Megabytes that the Network allows during one month when roaming outside the United States. Can be up to 2TB.
|
||||
:ivar date_created: The date and time in GMT when the resource was created specified in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format.
|
||||
:ivar date_updated: The date and time in GMT when the resource was last updated specified in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format.
|
||||
:ivar url: The absolute URL of the resource.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self, version: Version, payload: Dict[str, Any], sid: Optional[str] = None
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.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.national_roaming_data_limit: Optional[int] = deserialize.integer(
|
||||
payload.get("national_roaming_data_limit")
|
||||
)
|
||||
self.international_roaming: Optional[List[str]] = payload.get(
|
||||
"international_roaming"
|
||||
)
|
||||
self.international_roaming_data_limit: Optional[int] = deserialize.integer(
|
||||
payload.get("international_roaming_data_limit")
|
||||
)
|
||||
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: An application-defined string that uniquely identifies the resource. It can be used in place of the resource's `sid` in the URL to address the resource.
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It does not have to be unique.
|
||||
|
||||
: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: An application-defined string that uniquely identifies the resource. It can be used in place of the resource's `sid` in the URL to address the resource.
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It does not have to be unique.
|
||||
|
||||
: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.Wireless.V1.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: The SID of the RatePlan resource to update.
|
||||
"""
|
||||
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: An application-defined string that uniquely identifies the resource. It can be used in place of the resource's `sid` in the URL to address the resource.
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It does not have to be unique.
|
||||
|
||||
: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: An application-defined string that uniquely identifies the resource. It can be used in place of the resource's `sid` in the URL to address the resource.
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It does not have to be unique.
|
||||
|
||||
: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.Wireless.V1.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.Wireless.V1.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,
|
||||
national_roaming_enabled: Union[bool, object] = values.unset,
|
||||
international_roaming: Union[List[str], object] = values.unset,
|
||||
national_roaming_data_limit: Union[int, object] = values.unset,
|
||||
international_roaming_data_limit: Union[int, object] = values.unset,
|
||||
) -> RatePlanInstance:
|
||||
"""
|
||||
Create the RatePlanInstance
|
||||
|
||||
:param unique_name: An application-defined string that uniquely identifies the resource. It can be used in place of the resource's `sid` in the URL to address the resource.
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It does not have to be unique.
|
||||
:param data_enabled: Whether SIMs can use GPRS/3G/4G/LTE data connectivity.
|
||||
:param data_limit: The total data usage (download and upload combined) in Megabytes that the Network allows during one month on the home network (T-Mobile USA). The metering period begins the day of activation and ends on the same day in the following month. Can be up to 2TB and the default value is `1000`.
|
||||
:param data_metering: The model used to meter data usage. Can be: `payg` and `quota-1`, `quota-10`, and `quota-50`. Learn more about the available [data metering models](https://www.twilio.com/docs/iot/wireless/api/rateplan-resource#payg-vs-quota-data-plans).
|
||||
:param messaging_enabled: Whether SIMs can make, send, and receive SMS using [Commands](https://www.twilio.com/docs/iot/wireless/api/command-resource).
|
||||
:param voice_enabled: Deprecated.
|
||||
:param national_roaming_enabled: Whether SIMs can roam on networks other than the home network (T-Mobile USA) in the United States. See [national roaming](https://www.twilio.com/docs/iot/wireless/api/rateplan-resource#national-roaming).
|
||||
:param international_roaming: The list of services that SIMs capable of using GPRS/3G/4G/LTE data connectivity can use outside of the United States. Can contain: `data` and `messaging`.
|
||||
:param national_roaming_data_limit: The total data usage (download and upload combined) in Megabytes that the Network allows during one month on non-home networks in the United States. The metering period begins the day of activation and ends on the same day in the following month. Can be up to 2TB. See [national roaming](https://www.twilio.com/docs/iot/wireless/api/rateplan-resource#national-roaming) for more info.
|
||||
:param international_roaming_data_limit: The total data usage (download and upload combined) in Megabytes that the Network allows during one month when roaming outside the United States. Can be up to 2TB.
|
||||
|
||||
: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,
|
||||
"NationalRoamingEnabled": national_roaming_enabled,
|
||||
"InternationalRoaming": serialize.map(
|
||||
international_roaming, lambda e: e
|
||||
),
|
||||
"NationalRoamingDataLimit": national_roaming_data_limit,
|
||||
"InternationalRoamingDataLimit": international_roaming_data_limit,
|
||||
}
|
||||
)
|
||||
|
||||
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,
|
||||
national_roaming_enabled: Union[bool, object] = values.unset,
|
||||
international_roaming: Union[List[str], object] = values.unset,
|
||||
national_roaming_data_limit: Union[int, object] = values.unset,
|
||||
international_roaming_data_limit: Union[int, object] = values.unset,
|
||||
) -> RatePlanInstance:
|
||||
"""
|
||||
Asynchronously create the RatePlanInstance
|
||||
|
||||
:param unique_name: An application-defined string that uniquely identifies the resource. It can be used in place of the resource's `sid` in the URL to address the resource.
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It does not have to be unique.
|
||||
:param data_enabled: Whether SIMs can use GPRS/3G/4G/LTE data connectivity.
|
||||
:param data_limit: The total data usage (download and upload combined) in Megabytes that the Network allows during one month on the home network (T-Mobile USA). The metering period begins the day of activation and ends on the same day in the following month. Can be up to 2TB and the default value is `1000`.
|
||||
:param data_metering: The model used to meter data usage. Can be: `payg` and `quota-1`, `quota-10`, and `quota-50`. Learn more about the available [data metering models](https://www.twilio.com/docs/iot/wireless/api/rateplan-resource#payg-vs-quota-data-plans).
|
||||
:param messaging_enabled: Whether SIMs can make, send, and receive SMS using [Commands](https://www.twilio.com/docs/iot/wireless/api/command-resource).
|
||||
:param voice_enabled: Deprecated.
|
||||
:param national_roaming_enabled: Whether SIMs can roam on networks other than the home network (T-Mobile USA) in the United States. See [national roaming](https://www.twilio.com/docs/iot/wireless/api/rateplan-resource#national-roaming).
|
||||
:param international_roaming: The list of services that SIMs capable of using GPRS/3G/4G/LTE data connectivity can use outside of the United States. Can contain: `data` and `messaging`.
|
||||
:param national_roaming_data_limit: The total data usage (download and upload combined) in Megabytes that the Network allows during one month on non-home networks in the United States. The metering period begins the day of activation and ends on the same day in the following month. Can be up to 2TB. See [national roaming](https://www.twilio.com/docs/iot/wireless/api/rateplan-resource#national-roaming) for more info.
|
||||
:param international_roaming_data_limit: The total data usage (download and upload combined) in Megabytes that the Network allows during one month when roaming outside the United States. Can be up to 2TB.
|
||||
|
||||
: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,
|
||||
"NationalRoamingEnabled": national_roaming_enabled,
|
||||
"InternationalRoaming": serialize.map(
|
||||
international_roaming, lambda e: e
|
||||
),
|
||||
"NationalRoamingDataLimit": national_roaming_data_limit,
|
||||
"InternationalRoamingDataLimit": international_roaming_data_limit,
|
||||
}
|
||||
)
|
||||
|
||||
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: The SID of the RatePlan resource to update.
|
||||
"""
|
||||
return RatePlanContext(self._version, sid=sid)
|
||||
|
||||
def __call__(self, sid: str) -> RatePlanContext:
|
||||
"""
|
||||
Constructs a RatePlanContext
|
||||
|
||||
:param sid: The SID of the RatePlan resource to update.
|
||||
"""
|
||||
return RatePlanContext(self._version, sid=sid)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Wireless.V1.RatePlanList>"
|
||||
@@ -0,0 +1,915 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Wireless
|
||||
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.wireless.v1.sim.data_session import DataSessionList
|
||||
from twilio.rest.wireless.v1.sim.usage_record import UsageRecordList
|
||||
|
||||
|
||||
class SimInstance(InstanceResource):
|
||||
class ResetStatus(object):
|
||||
RESETTING = "resetting"
|
||||
|
||||
class Status(object):
|
||||
NEW = "new"
|
||||
READY = "ready"
|
||||
ACTIVE = "active"
|
||||
SUSPENDED = "suspended"
|
||||
DEACTIVATED = "deactivated"
|
||||
CANCELED = "canceled"
|
||||
SCHEDULED = "scheduled"
|
||||
UPDATING = "updating"
|
||||
|
||||
"""
|
||||
:ivar sid: The unique string that we created to identify the Sim resource.
|
||||
:ivar unique_name: An application-defined string that uniquely identifies the resource. It can be used in place of the resource's `sid` in the URL to address the resource.
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) to which the Sim resource belongs.
|
||||
:ivar rate_plan_sid: The SID of the [RatePlan resource](https://www.twilio.com/docs/iot/wireless/api/rateplan-resource) to which the Sim resource is assigned.
|
||||
:ivar friendly_name: The string that you assigned to describe the Sim resource.
|
||||
:ivar iccid: The [ICCID](https://en.wikipedia.org/wiki/SIM_card#ICCID) associated with the SIM.
|
||||
:ivar e_id: Deprecated.
|
||||
:ivar status:
|
||||
:ivar reset_status:
|
||||
:ivar commands_callback_url: The URL we call using the `commands_callback_method` when the SIM originates a machine-to-machine [Command](https://www.twilio.com/docs/iot/wireless/api/command-resource). Your server should respond with an HTTP status code in the 200 range; any response body will be ignored.
|
||||
:ivar commands_callback_method: The HTTP method we use to call `commands_callback_url`. Can be: `POST` or `GET`. Default is `POST`.
|
||||
:ivar sms_fallback_method: Deprecated.
|
||||
:ivar sms_fallback_url: Deprecated.
|
||||
:ivar sms_method: Deprecated.
|
||||
:ivar sms_url: Deprecated.
|
||||
:ivar voice_fallback_method: Deprecated. The HTTP method we use to call `voice_fallback_url`. Can be: `GET` or `POST`. Default is `POST`.
|
||||
:ivar voice_fallback_url: Deprecated. The URL we call using the `voice_fallback_method` when an error occurs while retrieving or executing the TwiML requested from `voice_url`.
|
||||
:ivar voice_method: Deprecated. The HTTP method we use to call `voice_url`. Can be: `GET` or `POST`. Default is `POST`.
|
||||
:ivar voice_url: Deprecated. The URL we call using the `voice_method` when the SIM-connected device makes a voice call.
|
||||
:ivar date_created: The date and time in GMT when the resource was created specified in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format.
|
||||
:ivar date_updated: The date and time in GMT when the Sim resource was last updated specified in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format.
|
||||
:ivar url: The absolute URL of the resource.
|
||||
:ivar links: The URLs of related subresources.
|
||||
:ivar ip_address: Deprecated.
|
||||
"""
|
||||
|
||||
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["SimInstance.Status"] = payload.get("status")
|
||||
self.reset_status: Optional["SimInstance.ResetStatus"] = payload.get(
|
||||
"reset_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.ip_address: Optional[str] = payload.get("ip_address")
|
||||
|
||||
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 delete(self) -> bool:
|
||||
"""
|
||||
Deletes the SimInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the SimInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
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["SimInstance.Status", 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,
|
||||
reset_status: Union["SimInstance.ResetStatus", object] = values.unset,
|
||||
account_sid: Union[str, object] = values.unset,
|
||||
) -> "SimInstance":
|
||||
"""
|
||||
Update the SimInstance
|
||||
|
||||
:param unique_name: An application-defined string that uniquely identifies the resource. It can be used in place of the `sid` in the URL path to address the resource.
|
||||
:param callback_method: The HTTP method we should use to call `callback_url`. Can be: `POST` or `GET`. The default is `POST`.
|
||||
:param callback_url: The URL we should call using the `callback_url` when the SIM has finished updating. When the SIM transitions from `new` to `ready` or from any status to `deactivated`, we call this URL when the status changes to an intermediate status (`ready` or `deactivated`) and again when the status changes to its final status (`active` or `canceled`).
|
||||
:param friendly_name: A descriptive string that you create to describe the Sim resource. It does not need to be unique.
|
||||
:param rate_plan: The SID or unique name of the [RatePlan resource](https://www.twilio.com/docs/iot/wireless/api/rateplan-resource) to which the Sim resource should be assigned.
|
||||
:param status:
|
||||
:param commands_callback_method: The HTTP method we should use to call `commands_callback_url`. Can be: `POST` or `GET`. The default is `POST`.
|
||||
:param commands_callback_url: The URL we should call using the `commands_callback_method` when the SIM sends a [Command](https://www.twilio.com/docs/iot/wireless/api/command-resource). Your server should respond with an HTTP status code in the 200 range; any response body is ignored.
|
||||
:param sms_fallback_method: The HTTP method we should use to call `sms_fallback_url`. Can be: `GET` or `POST`. Default is `POST`.
|
||||
:param sms_fallback_url: The URL we should call using the `sms_fallback_method` when an error occurs while retrieving or executing the TwiML requested from `sms_url`.
|
||||
:param sms_method: The HTTP method we should use to call `sms_url`. Can be: `GET` or `POST`. Default is `POST`.
|
||||
:param sms_url: The URL we should call using the `sms_method` when the SIM-connected device sends an SMS message that is not a [Command](https://www.twilio.com/docs/iot/wireless/api/command-resource).
|
||||
:param voice_fallback_method: Deprecated.
|
||||
:param voice_fallback_url: Deprecated.
|
||||
:param voice_method: Deprecated.
|
||||
:param voice_url: Deprecated.
|
||||
:param reset_status:
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) to which the Sim resource should belong. The Account SID can only be that of the requesting Account or that of a [Subaccount](https://www.twilio.com/docs/iam/api/subaccounts) of the requesting Account. Only valid when the Sim resource's status is `new`. For more information, see the [Move SIMs between Subaccounts documentation](https://www.twilio.com/docs/iot/wireless/api/sim-resource#move-sims-between-subaccounts).
|
||||
|
||||
: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,
|
||||
reset_status=reset_status,
|
||||
account_sid=account_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["SimInstance.Status", 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,
|
||||
reset_status: Union["SimInstance.ResetStatus", object] = values.unset,
|
||||
account_sid: Union[str, object] = values.unset,
|
||||
) -> "SimInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the SimInstance
|
||||
|
||||
:param unique_name: An application-defined string that uniquely identifies the resource. It can be used in place of the `sid` in the URL path to address the resource.
|
||||
:param callback_method: The HTTP method we should use to call `callback_url`. Can be: `POST` or `GET`. The default is `POST`.
|
||||
:param callback_url: The URL we should call using the `callback_url` when the SIM has finished updating. When the SIM transitions from `new` to `ready` or from any status to `deactivated`, we call this URL when the status changes to an intermediate status (`ready` or `deactivated`) and again when the status changes to its final status (`active` or `canceled`).
|
||||
:param friendly_name: A descriptive string that you create to describe the Sim resource. It does not need to be unique.
|
||||
:param rate_plan: The SID or unique name of the [RatePlan resource](https://www.twilio.com/docs/iot/wireless/api/rateplan-resource) to which the Sim resource should be assigned.
|
||||
:param status:
|
||||
:param commands_callback_method: The HTTP method we should use to call `commands_callback_url`. Can be: `POST` or `GET`. The default is `POST`.
|
||||
:param commands_callback_url: The URL we should call using the `commands_callback_method` when the SIM sends a [Command](https://www.twilio.com/docs/iot/wireless/api/command-resource). Your server should respond with an HTTP status code in the 200 range; any response body is ignored.
|
||||
:param sms_fallback_method: The HTTP method we should use to call `sms_fallback_url`. Can be: `GET` or `POST`. Default is `POST`.
|
||||
:param sms_fallback_url: The URL we should call using the `sms_fallback_method` when an error occurs while retrieving or executing the TwiML requested from `sms_url`.
|
||||
:param sms_method: The HTTP method we should use to call `sms_url`. Can be: `GET` or `POST`. Default is `POST`.
|
||||
:param sms_url: The URL we should call using the `sms_method` when the SIM-connected device sends an SMS message that is not a [Command](https://www.twilio.com/docs/iot/wireless/api/command-resource).
|
||||
:param voice_fallback_method: Deprecated.
|
||||
:param voice_fallback_url: Deprecated.
|
||||
:param voice_method: Deprecated.
|
||||
:param voice_url: Deprecated.
|
||||
:param reset_status:
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) to which the Sim resource should belong. The Account SID can only be that of the requesting Account or that of a [Subaccount](https://www.twilio.com/docs/iam/api/subaccounts) of the requesting Account. Only valid when the Sim resource's status is `new`. For more information, see the [Move SIMs between Subaccounts documentation](https://www.twilio.com/docs/iot/wireless/api/sim-resource#move-sims-between-subaccounts).
|
||||
|
||||
: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,
|
||||
reset_status=reset_status,
|
||||
account_sid=account_sid,
|
||||
)
|
||||
|
||||
@property
|
||||
def data_sessions(self) -> DataSessionList:
|
||||
"""
|
||||
Access the data_sessions
|
||||
"""
|
||||
return self._proxy.data_sessions
|
||||
|
||||
@property
|
||||
def usage_records(self) -> UsageRecordList:
|
||||
"""
|
||||
Access the usage_records
|
||||
"""
|
||||
return self._proxy.usage_records
|
||||
|
||||
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.Wireless.V1.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: The SID or the `unique_name` of the Sim resource to update.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Sims/{sid}".format(**self._solution)
|
||||
|
||||
self._data_sessions: Optional[DataSessionList] = None
|
||||
self._usage_records: Optional[UsageRecordList] = None
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the SimInstance
|
||||
|
||||
|
||||
: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 SimInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
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["SimInstance.Status", 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,
|
||||
reset_status: Union["SimInstance.ResetStatus", object] = values.unset,
|
||||
account_sid: Union[str, object] = values.unset,
|
||||
) -> SimInstance:
|
||||
"""
|
||||
Update the SimInstance
|
||||
|
||||
:param unique_name: An application-defined string that uniquely identifies the resource. It can be used in place of the `sid` in the URL path to address the resource.
|
||||
:param callback_method: The HTTP method we should use to call `callback_url`. Can be: `POST` or `GET`. The default is `POST`.
|
||||
:param callback_url: The URL we should call using the `callback_url` when the SIM has finished updating. When the SIM transitions from `new` to `ready` or from any status to `deactivated`, we call this URL when the status changes to an intermediate status (`ready` or `deactivated`) and again when the status changes to its final status (`active` or `canceled`).
|
||||
:param friendly_name: A descriptive string that you create to describe the Sim resource. It does not need to be unique.
|
||||
:param rate_plan: The SID or unique name of the [RatePlan resource](https://www.twilio.com/docs/iot/wireless/api/rateplan-resource) to which the Sim resource should be assigned.
|
||||
:param status:
|
||||
:param commands_callback_method: The HTTP method we should use to call `commands_callback_url`. Can be: `POST` or `GET`. The default is `POST`.
|
||||
:param commands_callback_url: The URL we should call using the `commands_callback_method` when the SIM sends a [Command](https://www.twilio.com/docs/iot/wireless/api/command-resource). Your server should respond with an HTTP status code in the 200 range; any response body is ignored.
|
||||
:param sms_fallback_method: The HTTP method we should use to call `sms_fallback_url`. Can be: `GET` or `POST`. Default is `POST`.
|
||||
:param sms_fallback_url: The URL we should call using the `sms_fallback_method` when an error occurs while retrieving or executing the TwiML requested from `sms_url`.
|
||||
:param sms_method: The HTTP method we should use to call `sms_url`. Can be: `GET` or `POST`. Default is `POST`.
|
||||
:param sms_url: The URL we should call using the `sms_method` when the SIM-connected device sends an SMS message that is not a [Command](https://www.twilio.com/docs/iot/wireless/api/command-resource).
|
||||
:param voice_fallback_method: Deprecated.
|
||||
:param voice_fallback_url: Deprecated.
|
||||
:param voice_method: Deprecated.
|
||||
:param voice_url: Deprecated.
|
||||
:param reset_status:
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) to which the Sim resource should belong. The Account SID can only be that of the requesting Account or that of a [Subaccount](https://www.twilio.com/docs/iam/api/subaccounts) of the requesting Account. Only valid when the Sim resource's status is `new`. For more information, see the [Move SIMs between Subaccounts documentation](https://www.twilio.com/docs/iot/wireless/api/sim-resource#move-sims-between-subaccounts).
|
||||
|
||||
: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,
|
||||
"ResetStatus": reset_status,
|
||||
"AccountSid": account_sid,
|
||||
}
|
||||
)
|
||||
|
||||
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["SimInstance.Status", 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,
|
||||
reset_status: Union["SimInstance.ResetStatus", object] = values.unset,
|
||||
account_sid: Union[str, object] = values.unset,
|
||||
) -> SimInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the SimInstance
|
||||
|
||||
:param unique_name: An application-defined string that uniquely identifies the resource. It can be used in place of the `sid` in the URL path to address the resource.
|
||||
:param callback_method: The HTTP method we should use to call `callback_url`. Can be: `POST` or `GET`. The default is `POST`.
|
||||
:param callback_url: The URL we should call using the `callback_url` when the SIM has finished updating. When the SIM transitions from `new` to `ready` or from any status to `deactivated`, we call this URL when the status changes to an intermediate status (`ready` or `deactivated`) and again when the status changes to its final status (`active` or `canceled`).
|
||||
:param friendly_name: A descriptive string that you create to describe the Sim resource. It does not need to be unique.
|
||||
:param rate_plan: The SID or unique name of the [RatePlan resource](https://www.twilio.com/docs/iot/wireless/api/rateplan-resource) to which the Sim resource should be assigned.
|
||||
:param status:
|
||||
:param commands_callback_method: The HTTP method we should use to call `commands_callback_url`. Can be: `POST` or `GET`. The default is `POST`.
|
||||
:param commands_callback_url: The URL we should call using the `commands_callback_method` when the SIM sends a [Command](https://www.twilio.com/docs/iot/wireless/api/command-resource). Your server should respond with an HTTP status code in the 200 range; any response body is ignored.
|
||||
:param sms_fallback_method: The HTTP method we should use to call `sms_fallback_url`. Can be: `GET` or `POST`. Default is `POST`.
|
||||
:param sms_fallback_url: The URL we should call using the `sms_fallback_method` when an error occurs while retrieving or executing the TwiML requested from `sms_url`.
|
||||
:param sms_method: The HTTP method we should use to call `sms_url`. Can be: `GET` or `POST`. Default is `POST`.
|
||||
:param sms_url: The URL we should call using the `sms_method` when the SIM-connected device sends an SMS message that is not a [Command](https://www.twilio.com/docs/iot/wireless/api/command-resource).
|
||||
:param voice_fallback_method: Deprecated.
|
||||
:param voice_fallback_url: Deprecated.
|
||||
:param voice_method: Deprecated.
|
||||
:param voice_url: Deprecated.
|
||||
:param reset_status:
|
||||
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) to which the Sim resource should belong. The Account SID can only be that of the requesting Account or that of a [Subaccount](https://www.twilio.com/docs/iam/api/subaccounts) of the requesting Account. Only valid when the Sim resource's status is `new`. For more information, see the [Move SIMs between Subaccounts documentation](https://www.twilio.com/docs/iot/wireless/api/sim-resource#move-sims-between-subaccounts).
|
||||
|
||||
: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,
|
||||
"ResetStatus": reset_status,
|
||||
"AccountSid": account_sid,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return SimInstance(self._version, payload, sid=self._solution["sid"])
|
||||
|
||||
@property
|
||||
def data_sessions(self) -> DataSessionList:
|
||||
"""
|
||||
Access the data_sessions
|
||||
"""
|
||||
if self._data_sessions is None:
|
||||
self._data_sessions = DataSessionList(
|
||||
self._version,
|
||||
self._solution["sid"],
|
||||
)
|
||||
return self._data_sessions
|
||||
|
||||
@property
|
||||
def usage_records(self) -> UsageRecordList:
|
||||
"""
|
||||
Access the usage_records
|
||||
"""
|
||||
if self._usage_records is None:
|
||||
self._usage_records = UsageRecordList(
|
||||
self._version,
|
||||
self._solution["sid"],
|
||||
)
|
||||
return self._usage_records
|
||||
|
||||
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.Wireless.V1.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.Wireless.V1.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["SimInstance.Status", 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 "SimInstance.Status" status: Only return Sim resources with this status.
|
||||
:param str iccid: Only return Sim resources with this ICCID. This will return a list with a maximum size of 1.
|
||||
:param str rate_plan: The SID or unique name of a [RatePlan resource](https://www.twilio.com/docs/iot/wireless/api/rateplan-resource). Only return Sim resources assigned to this RatePlan resource.
|
||||
:param str e_id: Deprecated.
|
||||
:param str sim_registration_code: Only return Sim resources with this registration code. This will return a list with a maximum size of 1.
|
||||
: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["SimInstance.Status", 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 "SimInstance.Status" status: Only return Sim resources with this status.
|
||||
:param str iccid: Only return Sim resources with this ICCID. This will return a list with a maximum size of 1.
|
||||
:param str rate_plan: The SID or unique name of a [RatePlan resource](https://www.twilio.com/docs/iot/wireless/api/rateplan-resource). Only return Sim resources assigned to this RatePlan resource.
|
||||
:param str e_id: Deprecated.
|
||||
:param str sim_registration_code: Only return Sim resources with this registration code. This will return a list with a maximum size of 1.
|
||||
: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["SimInstance.Status", 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 "SimInstance.Status" status: Only return Sim resources with this status.
|
||||
:param str iccid: Only return Sim resources with this ICCID. This will return a list with a maximum size of 1.
|
||||
:param str rate_plan: The SID or unique name of a [RatePlan resource](https://www.twilio.com/docs/iot/wireless/api/rateplan-resource). Only return Sim resources assigned to this RatePlan resource.
|
||||
:param str e_id: Deprecated.
|
||||
:param str sim_registration_code: Only return Sim resources with this registration code. This will return a list with a maximum size of 1.
|
||||
: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["SimInstance.Status", 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 "SimInstance.Status" status: Only return Sim resources with this status.
|
||||
:param str iccid: Only return Sim resources with this ICCID. This will return a list with a maximum size of 1.
|
||||
:param str rate_plan: The SID or unique name of a [RatePlan resource](https://www.twilio.com/docs/iot/wireless/api/rateplan-resource). Only return Sim resources assigned to this RatePlan resource.
|
||||
:param str e_id: Deprecated.
|
||||
:param str sim_registration_code: Only return Sim resources with this registration code. This will return a list with a maximum size of 1.
|
||||
: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["SimInstance.Status", 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: Only return Sim resources with this status.
|
||||
:param iccid: Only return Sim resources with this ICCID. This will return a list with a maximum size of 1.
|
||||
:param rate_plan: The SID or unique name of a [RatePlan resource](https://www.twilio.com/docs/iot/wireless/api/rateplan-resource). Only return Sim resources assigned to this RatePlan resource.
|
||||
:param e_id: Deprecated.
|
||||
:param sim_registration_code: Only return Sim resources with this registration code. This will return a list with a maximum size of 1.
|
||||
: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["SimInstance.Status", 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: Only return Sim resources with this status.
|
||||
:param iccid: Only return Sim resources with this ICCID. This will return a list with a maximum size of 1.
|
||||
:param rate_plan: The SID or unique name of a [RatePlan resource](https://www.twilio.com/docs/iot/wireless/api/rateplan-resource). Only return Sim resources assigned to this RatePlan resource.
|
||||
:param e_id: Deprecated.
|
||||
:param sim_registration_code: Only return Sim resources with this registration code. This will return a list with a maximum size of 1.
|
||||
: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: The SID or the `unique_name` of the Sim resource to update.
|
||||
"""
|
||||
return SimContext(self._version, sid=sid)
|
||||
|
||||
def __call__(self, sid: str) -> SimContext:
|
||||
"""
|
||||
Constructs a SimContext
|
||||
|
||||
:param sid: The SID or the `unique_name` of the Sim resource to update.
|
||||
"""
|
||||
return SimContext(self._version, sid=sid)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Wireless.V1.SimList>"
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -0,0 +1,317 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Wireless
|
||||
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 DataSessionInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar sid: The unique string that we created to identify the DataSession resource.
|
||||
:ivar sim_sid: The SID of the [Sim resource](https://www.twilio.com/docs/iot/wireless/api/sim-resource) that the Data Session is for.
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the DataSession resource.
|
||||
:ivar radio_link: The generation of wireless technology that the device was using.
|
||||
:ivar operator_mcc: The 'mobile country code' is the unique ID of the home country where the Data Session took place. See: [MCC/MNC lookup](http://mcc-mnc.com/).
|
||||
:ivar operator_mnc: The 'mobile network code' is the unique ID specific to the mobile operator network where the Data Session took place.
|
||||
:ivar operator_country: The three letter country code representing where the device's Data Session took place. This is determined by looking up the `operator_mcc`.
|
||||
:ivar operator_name: The friendly name of the mobile operator network that the [SIM](https://www.twilio.com/docs/iot/wireless/api/sim-resource)-connected device is attached to. This is determined by looking up the `operator_mnc`.
|
||||
:ivar cell_id: The unique ID of the cellular tower that the device was attached to at the moment when the Data Session was last updated.
|
||||
:ivar cell_location_estimate: An object that describes the estimated location in latitude and longitude where the device's Data Session took place. The location is derived from the `cell_id` when the Data Session was last updated. See [Cell Location Estimate Object](https://www.twilio.com/docs/iot/wireless/api/datasession-resource#cell-location-estimate-object).
|
||||
:ivar packets_uploaded: The number of packets uploaded by the device between the `start` time and when the Data Session was last updated.
|
||||
:ivar packets_downloaded: The number of packets downloaded by the device between the `start` time and when the Data Session was last updated.
|
||||
:ivar last_updated: The date that the resource was last updated, given as GMT in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format.
|
||||
:ivar start: The date that the Data Session started, given as GMT in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format.
|
||||
:ivar end: The date that the record ended, given as GMT in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format.
|
||||
:ivar imei: The 'international mobile equipment identity' is the unique ID of the device using the SIM to connect. An IMEI is a 15-digit string: 14 digits for the device identifier plus a check digit calculated using the Luhn formula.
|
||||
"""
|
||||
|
||||
def __init__(self, version: Version, payload: Dict[str, Any], sim_sid: str):
|
||||
super().__init__(version)
|
||||
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.sim_sid: Optional[str] = payload.get("sim_sid")
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.radio_link: Optional[str] = payload.get("radio_link")
|
||||
self.operator_mcc: Optional[str] = payload.get("operator_mcc")
|
||||
self.operator_mnc: Optional[str] = payload.get("operator_mnc")
|
||||
self.operator_country: Optional[str] = payload.get("operator_country")
|
||||
self.operator_name: Optional[str] = payload.get("operator_name")
|
||||
self.cell_id: Optional[str] = payload.get("cell_id")
|
||||
self.cell_location_estimate: Optional[Dict[str, object]] = payload.get(
|
||||
"cell_location_estimate"
|
||||
)
|
||||
self.packets_uploaded: Optional[int] = deserialize.integer(
|
||||
payload.get("packets_uploaded")
|
||||
)
|
||||
self.packets_downloaded: Optional[int] = deserialize.integer(
|
||||
payload.get("packets_downloaded")
|
||||
)
|
||||
self.last_updated: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("last_updated")
|
||||
)
|
||||
self.start: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("start")
|
||||
)
|
||||
self.end: Optional[datetime] = deserialize.iso8601_datetime(payload.get("end"))
|
||||
self.imei: Optional[str] = payload.get("imei")
|
||||
|
||||
self._solution = {
|
||||
"sim_sid": 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.Wireless.V1.DataSessionInstance {}>".format(context)
|
||||
|
||||
|
||||
class DataSessionPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> DataSessionInstance:
|
||||
"""
|
||||
Build an instance of DataSessionInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return DataSessionInstance(
|
||||
self._version, payload, sim_sid=self._solution["sim_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Wireless.V1.DataSessionPage>"
|
||||
|
||||
|
||||
class DataSessionList(ListResource):
|
||||
def __init__(self, version: Version, sim_sid: str):
|
||||
"""
|
||||
Initialize the DataSessionList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param sim_sid: The SID of the [Sim resource](https://www.twilio.com/docs/iot/wireless/api/sim-resource) with the Data Sessions to read.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"sim_sid": sim_sid,
|
||||
}
|
||||
self._uri = "/Sims/{sim_sid}/DataSessions".format(**self._solution)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[DataSessionInstance]:
|
||||
"""
|
||||
Streams DataSessionInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param 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[DataSessionInstance]:
|
||||
"""
|
||||
Asynchronously streams DataSessionInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param 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[DataSessionInstance]:
|
||||
"""
|
||||
Lists DataSessionInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param 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[DataSessionInstance]:
|
||||
"""
|
||||
Asynchronously lists DataSessionInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param 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,
|
||||
) -> DataSessionPage:
|
||||
"""
|
||||
Retrieve a single page of DataSessionInstance 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 DataSessionInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return DataSessionPage(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,
|
||||
) -> DataSessionPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of DataSessionInstance 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 DataSessionInstance
|
||||
"""
|
||||
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 DataSessionPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> DataSessionPage:
|
||||
"""
|
||||
Retrieve a specific page of DataSessionInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of DataSessionInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return DataSessionPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> DataSessionPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of DataSessionInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of DataSessionInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return DataSessionPage(self._version, response, self._solution)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Wireless.V1.DataSessionList>"
|
||||
@@ -0,0 +1,341 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Wireless
|
||||
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 serialize, 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 UsageRecordInstance(InstanceResource):
|
||||
class Granularity(object):
|
||||
HOURLY = "hourly"
|
||||
DAILY = "daily"
|
||||
ALL = "all"
|
||||
|
||||
"""
|
||||
:ivar sim_sid: The SID of the [Sim resource](https://www.twilio.com/docs/iot/wireless/api/sim-resource) that this Usage Record is for.
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the UsageRecord resource.
|
||||
:ivar period: The time period for which the usage is reported. Contains `start` and `end` datetime values given as GMT in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format.
|
||||
:ivar commands: An object that describes the SIM's usage of Commands during the specified period. See [Commands Usage Object](https://www.twilio.com/docs/iot/wireless/api/sim-usagerecord-resource#commands-usage-object).
|
||||
:ivar data: An object that describes the SIM's data usage during the specified period. See [Data Usage Object](https://www.twilio.com/docs/iot/wireless/api/sim-usagerecord-resource#data-usage-object).
|
||||
"""
|
||||
|
||||
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.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.period: Optional[Dict[str, object]] = payload.get("period")
|
||||
self.commands: Optional[Dict[str, object]] = payload.get("commands")
|
||||
self.data: Optional[Dict[str, object]] = payload.get("data")
|
||||
|
||||
self._solution = {
|
||||
"sim_sid": 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.Wireless.V1.UsageRecordInstance {}>".format(context)
|
||||
|
||||
|
||||
class UsageRecordPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> UsageRecordInstance:
|
||||
"""
|
||||
Build an instance of UsageRecordInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return UsageRecordInstance(
|
||||
self._version, payload, sim_sid=self._solution["sim_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Wireless.V1.UsageRecordPage>"
|
||||
|
||||
|
||||
class UsageRecordList(ListResource):
|
||||
def __init__(self, version: Version, sim_sid: str):
|
||||
"""
|
||||
Initialize the UsageRecordList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param sim_sid: The SID of the [Sim resource](https://www.twilio.com/docs/iot/wireless/api/sim-resource) to read the usage from.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"sim_sid": sim_sid,
|
||||
}
|
||||
self._uri = "/Sims/{sim_sid}/UsageRecords".format(**self._solution)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
end: Union[datetime, object] = values.unset,
|
||||
start: Union[datetime, object] = values.unset,
|
||||
granularity: Union["UsageRecordInstance.Granularity", object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[UsageRecordInstance]:
|
||||
"""
|
||||
Streams UsageRecordInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param datetime end: Only include usage that occurred on or before this date, specified in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html). The default is the current time.
|
||||
:param datetime start: Only include usage that has occurred on or after this date, specified in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html). The default is one month before the `end` parameter value.
|
||||
:param "UsageRecordInstance.Granularity" granularity: How to summarize the usage by time. Can be: `daily`, `hourly`, or `all`. The default is `all`. A value of `all` returns one Usage Record that describes the usage for the entire period.
|
||||
: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(
|
||||
end=end, start=start, granularity=granularity, page_size=limits["page_size"]
|
||||
)
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
end: Union[datetime, object] = values.unset,
|
||||
start: Union[datetime, object] = values.unset,
|
||||
granularity: Union["UsageRecordInstance.Granularity", object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[UsageRecordInstance]:
|
||||
"""
|
||||
Asynchronously streams UsageRecordInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param datetime end: Only include usage that occurred on or before this date, specified in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html). The default is the current time.
|
||||
:param datetime start: Only include usage that has occurred on or after this date, specified in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html). The default is one month before the `end` parameter value.
|
||||
:param "UsageRecordInstance.Granularity" granularity: How to summarize the usage by time. Can be: `daily`, `hourly`, or `all`. The default is `all`. A value of `all` returns one Usage Record that describes the usage for the entire period.
|
||||
: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(
|
||||
end=end, start=start, granularity=granularity, page_size=limits["page_size"]
|
||||
)
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
end: Union[datetime, object] = values.unset,
|
||||
start: Union[datetime, object] = values.unset,
|
||||
granularity: Union["UsageRecordInstance.Granularity", object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[UsageRecordInstance]:
|
||||
"""
|
||||
Lists UsageRecordInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param datetime end: Only include usage that occurred on or before this date, specified in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html). The default is the current time.
|
||||
:param datetime start: Only include usage that has occurred on or after this date, specified in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html). The default is one month before the `end` parameter value.
|
||||
:param "UsageRecordInstance.Granularity" granularity: How to summarize the usage by time. Can be: `daily`, `hourly`, or `all`. The default is `all`. A value of `all` returns one Usage Record that describes the usage for the entire period.
|
||||
: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(
|
||||
end=end,
|
||||
start=start,
|
||||
granularity=granularity,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
end: Union[datetime, object] = values.unset,
|
||||
start: Union[datetime, object] = values.unset,
|
||||
granularity: Union["UsageRecordInstance.Granularity", object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[UsageRecordInstance]:
|
||||
"""
|
||||
Asynchronously lists UsageRecordInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param datetime end: Only include usage that occurred on or before this date, specified in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html). The default is the current time.
|
||||
:param datetime start: Only include usage that has occurred on or after this date, specified in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html). The default is one month before the `end` parameter value.
|
||||
:param "UsageRecordInstance.Granularity" granularity: How to summarize the usage by time. Can be: `daily`, `hourly`, or `all`. The default is `all`. A value of `all` returns one Usage Record that describes the usage for the entire period.
|
||||
: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(
|
||||
end=end,
|
||||
start=start,
|
||||
granularity=granularity,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
end: Union[datetime, object] = values.unset,
|
||||
start: Union[datetime, object] = values.unset,
|
||||
granularity: Union["UsageRecordInstance.Granularity", object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> UsageRecordPage:
|
||||
"""
|
||||
Retrieve a single page of UsageRecordInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param end: Only include usage that occurred on or before this date, specified in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html). The default is the current time.
|
||||
:param start: Only include usage that has occurred on or after this date, specified in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html). The default is one month before the `end` parameter value.
|
||||
:param granularity: How to summarize the usage by time. Can be: `daily`, `hourly`, or `all`. The default is `all`. A value of `all` returns one Usage Record that describes the usage for the entire period.
|
||||
: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 UsageRecordInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"End": serialize.iso8601_datetime(end),
|
||||
"Start": serialize.iso8601_datetime(start),
|
||||
"Granularity": granularity,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return UsageRecordPage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
end: Union[datetime, object] = values.unset,
|
||||
start: Union[datetime, object] = values.unset,
|
||||
granularity: Union["UsageRecordInstance.Granularity", object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> UsageRecordPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of UsageRecordInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param end: Only include usage that occurred on or before this date, specified in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html). The default is the current time.
|
||||
:param start: Only include usage that has occurred on or after this date, specified in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html). The default is one month before the `end` parameter value.
|
||||
:param granularity: How to summarize the usage by time. Can be: `daily`, `hourly`, or `all`. The default is `all`. A value of `all` returns one Usage Record that describes the usage for the entire period.
|
||||
: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 UsageRecordInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"End": serialize.iso8601_datetime(end),
|
||||
"Start": serialize.iso8601_datetime(start),
|
||||
"Granularity": granularity,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return UsageRecordPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> UsageRecordPage:
|
||||
"""
|
||||
Retrieve a specific page of UsageRecordInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of UsageRecordInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return UsageRecordPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> UsageRecordPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of UsageRecordInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of UsageRecordInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return UsageRecordPage(self._version, response, self._solution)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Wireless.V1.UsageRecordList>"
|
||||
@@ -0,0 +1,328 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Wireless
|
||||
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 serialize, 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 UsageRecordInstance(InstanceResource):
|
||||
class Granularity(object):
|
||||
HOURLY = "hourly"
|
||||
DAILY = "daily"
|
||||
ALL = "all"
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the AccountUsageRecord resource.
|
||||
:ivar period: The time period for which usage is reported. Contains `start` and `end` properties that describe the period using GMT date-time values specified in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format.
|
||||
:ivar commands: An object that describes the aggregated Commands usage for all SIMs during the specified period. See [Commands Usage Object](https://www.twilio.com/docs/iot/wireless/api/account-usagerecord-resource#commands-usage-object).
|
||||
:ivar data: An object that describes the aggregated Data usage for all SIMs over the period. See [Data Usage Object](https://www.twilio.com/docs/iot/wireless/api/account-usagerecord-resource#data-usage-object).
|
||||
"""
|
||||
|
||||
def __init__(self, version: Version, payload: Dict[str, Any]):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.period: Optional[Dict[str, object]] = payload.get("period")
|
||||
self.commands: Optional[Dict[str, object]] = payload.get("commands")
|
||||
self.data: Optional[Dict[str, object]] = payload.get("data")
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
|
||||
return "<Twilio.Wireless.V1.UsageRecordInstance>"
|
||||
|
||||
|
||||
class UsageRecordPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> UsageRecordInstance:
|
||||
"""
|
||||
Build an instance of UsageRecordInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return UsageRecordInstance(self._version, payload)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Wireless.V1.UsageRecordPage>"
|
||||
|
||||
|
||||
class UsageRecordList(ListResource):
|
||||
def __init__(self, version: Version):
|
||||
"""
|
||||
Initialize the UsageRecordList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
self._uri = "/UsageRecords"
|
||||
|
||||
def stream(
|
||||
self,
|
||||
end: Union[datetime, object] = values.unset,
|
||||
start: Union[datetime, object] = values.unset,
|
||||
granularity: Union["UsageRecordInstance.Granularity", object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[UsageRecordInstance]:
|
||||
"""
|
||||
Streams UsageRecordInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param datetime end: Only include usage that has occurred on or before this date. Format is [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html).
|
||||
:param datetime start: Only include usage that has occurred on or after this date. Format is [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html).
|
||||
:param "UsageRecordInstance.Granularity" granularity: How to summarize the usage by time. Can be: `daily`, `hourly`, or `all`. A value of `all` returns one Usage Record that describes the usage for the entire period.
|
||||
: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(
|
||||
end=end, start=start, granularity=granularity, page_size=limits["page_size"]
|
||||
)
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
end: Union[datetime, object] = values.unset,
|
||||
start: Union[datetime, object] = values.unset,
|
||||
granularity: Union["UsageRecordInstance.Granularity", object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[UsageRecordInstance]:
|
||||
"""
|
||||
Asynchronously streams UsageRecordInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param datetime end: Only include usage that has occurred on or before this date. Format is [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html).
|
||||
:param datetime start: Only include usage that has occurred on or after this date. Format is [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html).
|
||||
:param "UsageRecordInstance.Granularity" granularity: How to summarize the usage by time. Can be: `daily`, `hourly`, or `all`. A value of `all` returns one Usage Record that describes the usage for the entire period.
|
||||
: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(
|
||||
end=end, start=start, granularity=granularity, page_size=limits["page_size"]
|
||||
)
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
end: Union[datetime, object] = values.unset,
|
||||
start: Union[datetime, object] = values.unset,
|
||||
granularity: Union["UsageRecordInstance.Granularity", object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[UsageRecordInstance]:
|
||||
"""
|
||||
Lists UsageRecordInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param datetime end: Only include usage that has occurred on or before this date. Format is [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html).
|
||||
:param datetime start: Only include usage that has occurred on or after this date. Format is [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html).
|
||||
:param "UsageRecordInstance.Granularity" granularity: How to summarize the usage by time. Can be: `daily`, `hourly`, or `all`. A value of `all` returns one Usage Record that describes the usage for the entire period.
|
||||
: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(
|
||||
end=end,
|
||||
start=start,
|
||||
granularity=granularity,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
end: Union[datetime, object] = values.unset,
|
||||
start: Union[datetime, object] = values.unset,
|
||||
granularity: Union["UsageRecordInstance.Granularity", object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[UsageRecordInstance]:
|
||||
"""
|
||||
Asynchronously lists UsageRecordInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param datetime end: Only include usage that has occurred on or before this date. Format is [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html).
|
||||
:param datetime start: Only include usage that has occurred on or after this date. Format is [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html).
|
||||
:param "UsageRecordInstance.Granularity" granularity: How to summarize the usage by time. Can be: `daily`, `hourly`, or `all`. A value of `all` returns one Usage Record that describes the usage for the entire period.
|
||||
: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(
|
||||
end=end,
|
||||
start=start,
|
||||
granularity=granularity,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
end: Union[datetime, object] = values.unset,
|
||||
start: Union[datetime, object] = values.unset,
|
||||
granularity: Union["UsageRecordInstance.Granularity", object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> UsageRecordPage:
|
||||
"""
|
||||
Retrieve a single page of UsageRecordInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param end: Only include usage that has occurred on or before this date. Format is [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html).
|
||||
:param start: Only include usage that has occurred on or after this date. Format is [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html).
|
||||
:param granularity: How to summarize the usage by time. Can be: `daily`, `hourly`, or `all`. A value of `all` returns one Usage Record that describes the usage for the entire period.
|
||||
: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 UsageRecordInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"End": serialize.iso8601_datetime(end),
|
||||
"Start": serialize.iso8601_datetime(start),
|
||||
"Granularity": granularity,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return UsageRecordPage(self._version, response)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
end: Union[datetime, object] = values.unset,
|
||||
start: Union[datetime, object] = values.unset,
|
||||
granularity: Union["UsageRecordInstance.Granularity", object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> UsageRecordPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of UsageRecordInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param end: Only include usage that has occurred on or before this date. Format is [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html).
|
||||
:param start: Only include usage that has occurred on or after this date. Format is [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html).
|
||||
:param granularity: How to summarize the usage by time. Can be: `daily`, `hourly`, or `all`. A value of `all` returns one Usage Record that describes the usage for the entire period.
|
||||
: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 UsageRecordInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"End": serialize.iso8601_datetime(end),
|
||||
"Start": serialize.iso8601_datetime(start),
|
||||
"Granularity": granularity,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return UsageRecordPage(self._version, response)
|
||||
|
||||
def get_page(self, target_url: str) -> UsageRecordPage:
|
||||
"""
|
||||
Retrieve a specific page of UsageRecordInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of UsageRecordInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return UsageRecordPage(self._version, response)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> UsageRecordPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of UsageRecordInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of UsageRecordInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return UsageRecordPage(self._version, response)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Wireless.V1.UsageRecordList>"
|
||||
Reference in New Issue
Block a user