Initial commit: Email alerts application

This commit is contained in:
Iyeoluwa Akinrinola
2025-07-25 11:31:36 +01:00
commit adfb625ae9
6322 changed files with 2882826 additions and 0 deletions
@@ -0,0 +1,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.supersim.v1 import V1
class SupersimBase(Domain):
def __init__(self, twilio: Client):
"""
Initialize the Supersim Domain
:returns: Domain for Supersim
"""
super().__init__(twilio, "https://supersim.twilio.com")
self._v1: Optional[V1] = None
@property
def v1(self) -> V1:
"""
:returns: Versions v1 of Supersim
"""
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.Supersim>"
@@ -0,0 +1,93 @@
from warnings import warn
from twilio.rest.supersim.SupersimBase import SupersimBase
from twilio.rest.supersim.v1.esim_profile import EsimProfileList
from twilio.rest.supersim.v1.fleet import FleetList
from twilio.rest.supersim.v1.ip_command import IpCommandList
from twilio.rest.supersim.v1.network import NetworkList
from twilio.rest.supersim.v1.network_access_profile import NetworkAccessProfileList
from twilio.rest.supersim.v1.settings_update import SettingsUpdateList
from twilio.rest.supersim.v1.sim import SimList
from twilio.rest.supersim.v1.sms_command import SmsCommandList
from twilio.rest.supersim.v1.usage_record import UsageRecordList
class Supersim(SupersimBase):
@property
def esim_profiles(self) -> EsimProfileList:
warn(
"esim_profiles is deprecated. Use v1.esim_profiles instead.",
DeprecationWarning,
stacklevel=2,
)
return self.v1.esim_profiles
@property
def fleets(self) -> FleetList:
warn(
"fleets is deprecated. Use v1.fleets instead.",
DeprecationWarning,
stacklevel=2,
)
return self.v1.fleets
@property
def ip_commands(self) -> IpCommandList:
warn(
"ip_commands is deprecated. Use v1.ip_commands instead.",
DeprecationWarning,
stacklevel=2,
)
return self.v1.ip_commands
@property
def networks(self) -> NetworkList:
warn(
"networks is deprecated. Use v1.networks instead.",
DeprecationWarning,
stacklevel=2,
)
return self.v1.networks
@property
def network_access_profiles(self) -> NetworkAccessProfileList:
warn(
"network_access_profiles is deprecated. Use v1.network_access_profiles instead.",
DeprecationWarning,
stacklevel=2,
)
return self.v1.network_access_profiles
@property
def settings_updates(self) -> SettingsUpdateList:
warn(
"settings_updates is deprecated. Use v1.settings_updates instead.",
DeprecationWarning,
stacklevel=2,
)
return self.v1.settings_updates
@property
def sims(self) -> SimList:
warn(
"sims is deprecated. Use v1.sims instead.", DeprecationWarning, stacklevel=2
)
return self.v1.sims
@property
def sms_commands(self) -> SmsCommandList:
warn(
"sms_commands is deprecated. Use v1.sms_commands instead.",
DeprecationWarning,
stacklevel=2,
)
return self.v1.sms_commands
@property
def usage_records(self) -> UsageRecordList:
warn(
"usage_records is deprecated. Use v1.usage_records instead.",
DeprecationWarning,
stacklevel=2,
)
return self.v1.usage_records
@@ -0,0 +1,106 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Supersim
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.supersim.v1.esim_profile import EsimProfileList
from twilio.rest.supersim.v1.fleet import FleetList
from twilio.rest.supersim.v1.ip_command import IpCommandList
from twilio.rest.supersim.v1.network import NetworkList
from twilio.rest.supersim.v1.network_access_profile import NetworkAccessProfileList
from twilio.rest.supersim.v1.settings_update import SettingsUpdateList
from twilio.rest.supersim.v1.sim import SimList
from twilio.rest.supersim.v1.sms_command import SmsCommandList
from twilio.rest.supersim.v1.usage_record import UsageRecordList
class V1(Version):
def __init__(self, domain: Domain):
"""
Initialize the V1 version of Supersim
:param domain: The Twilio.supersim domain
"""
super().__init__(domain, "v1")
self._esim_profiles: Optional[EsimProfileList] = None
self._fleets: Optional[FleetList] = None
self._ip_commands: Optional[IpCommandList] = None
self._networks: Optional[NetworkList] = None
self._network_access_profiles: Optional[NetworkAccessProfileList] = None
self._settings_updates: Optional[SettingsUpdateList] = None
self._sims: Optional[SimList] = None
self._sms_commands: Optional[SmsCommandList] = None
self._usage_records: Optional[UsageRecordList] = None
@property
def esim_profiles(self) -> EsimProfileList:
if self._esim_profiles is None:
self._esim_profiles = EsimProfileList(self)
return self._esim_profiles
@property
def fleets(self) -> FleetList:
if self._fleets is None:
self._fleets = FleetList(self)
return self._fleets
@property
def ip_commands(self) -> IpCommandList:
if self._ip_commands is None:
self._ip_commands = IpCommandList(self)
return self._ip_commands
@property
def networks(self) -> NetworkList:
if self._networks is None:
self._networks = NetworkList(self)
return self._networks
@property
def network_access_profiles(self) -> NetworkAccessProfileList:
if self._network_access_profiles is None:
self._network_access_profiles = NetworkAccessProfileList(self)
return self._network_access_profiles
@property
def settings_updates(self) -> SettingsUpdateList:
if self._settings_updates is None:
self._settings_updates = SettingsUpdateList(self)
return self._settings_updates
@property
def sims(self) -> SimList:
if self._sims is None:
self._sims = SimList(self)
return self._sims
@property
def sms_commands(self) -> SmsCommandList:
if self._sms_commands is None:
self._sms_commands = SmsCommandList(self)
return self._sms_commands
@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.Supersim.V1>"
@@ -0,0 +1,543 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Supersim
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 EsimProfileInstance(InstanceResource):
class Status(object):
NEW = "new"
RESERVING = "reserving"
AVAILABLE = "available"
DOWNLOADED = "downloaded"
INSTALLED = "installed"
FAILED = "failed"
"""
:ivar sid: The unique string that we created to identify the eSIM Profile resource.
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) to which the eSIM Profile resource belongs.
:ivar iccid: The [ICCID](https://en.wikipedia.org/wiki/Subscriber_identity_module#ICCID) associated with the Sim resource.
:ivar sim_sid: The SID of the [Sim](https://www.twilio.com/docs/iot/wireless/api/sim-resource) resource that this eSIM Profile controls.
:ivar status:
:ivar eid: Identifier of the eUICC that can claim the eSIM Profile.
:ivar smdp_plus_address: Address of the SM-DP+ server from which the Profile will be downloaded. The URL will appear once the eSIM Profile reaches the status `available`.
:ivar matching_id: Unique identifier of the eSIM profile that can be used to identify and download the eSIM profile from the SM-DP+ server. Populated if `generate_matching_id` is set to `true` when creating the eSIM profile reservation.
:ivar activation_code: Combined machine-readable activation code for acquiring an eSIM Profile with the Activation Code download method. Can be used in a QR code to download an eSIM profile.
:ivar error_code: Code indicating the failure if the download of the SIM Profile failed and the eSIM Profile is in `failed` state.
:ivar error_message: Error message describing the failure if the download of the SIM Profile failed and the eSIM Profile is in `failed` state.
:ivar date_created: The date and time in GMT when the resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
:ivar date_updated: The date and time in GMT when the resource was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
:ivar url: The absolute URL of the eSIM Profile 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.iccid: Optional[str] = payload.get("iccid")
self.sim_sid: Optional[str] = payload.get("sim_sid")
self.status: Optional["EsimProfileInstance.Status"] = payload.get("status")
self.eid: Optional[str] = payload.get("eid")
self.smdp_plus_address: Optional[str] = payload.get("smdp_plus_address")
self.matching_id: Optional[str] = payload.get("matching_id")
self.activation_code: Optional[str] = payload.get("activation_code")
self.error_code: Optional[str] = payload.get("error_code")
self.error_message: Optional[str] = payload.get("error_message")
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[EsimProfileContext] = None
@property
def _proxy(self) -> "EsimProfileContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: EsimProfileContext for this EsimProfileInstance
"""
if self._context is None:
self._context = EsimProfileContext(
self._version,
sid=self._solution["sid"],
)
return self._context
def fetch(self) -> "EsimProfileInstance":
"""
Fetch the EsimProfileInstance
:returns: The fetched EsimProfileInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "EsimProfileInstance":
"""
Asynchronous coroutine to fetch the EsimProfileInstance
:returns: The fetched EsimProfileInstance
"""
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.Supersim.V1.EsimProfileInstance {}>".format(context)
class EsimProfileContext(InstanceContext):
def __init__(self, version: Version, sid: str):
"""
Initialize the EsimProfileContext
:param version: Version that contains the resource
:param sid: The SID of the eSIM Profile resource to fetch.
"""
super().__init__(version)
# Path Solution
self._solution = {
"sid": sid,
}
self._uri = "/ESimProfiles/{sid}".format(**self._solution)
def fetch(self) -> EsimProfileInstance:
"""
Fetch the EsimProfileInstance
:returns: The fetched EsimProfileInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return EsimProfileInstance(
self._version,
payload,
sid=self._solution["sid"],
)
async def fetch_async(self) -> EsimProfileInstance:
"""
Asynchronous coroutine to fetch the EsimProfileInstance
:returns: The fetched EsimProfileInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return EsimProfileInstance(
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.Supersim.V1.EsimProfileContext {}>".format(context)
class EsimProfilePage(Page):
def get_instance(self, payload: Dict[str, Any]) -> EsimProfileInstance:
"""
Build an instance of EsimProfileInstance
:param payload: Payload response from the API
"""
return EsimProfileInstance(self._version, payload)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Supersim.V1.EsimProfilePage>"
class EsimProfileList(ListResource):
def __init__(self, version: Version):
"""
Initialize the EsimProfileList
:param version: Version that contains the resource
"""
super().__init__(version)
self._uri = "/ESimProfiles"
def create(
self,
callback_url: Union[str, object] = values.unset,
callback_method: Union[str, object] = values.unset,
generate_matching_id: Union[bool, object] = values.unset,
eid: Union[str, object] = values.unset,
) -> EsimProfileInstance:
"""
Create the EsimProfileInstance
:param callback_url: The URL we should call using the `callback_method` when the status of the eSIM Profile changes. At this stage of the eSIM Profile pilot, the a request to the URL will only be called when the ESimProfile resource changes from `reserving` to `available`.
:param callback_method: The HTTP method we should use to call `callback_url`. Can be: `GET` or `POST` and the default is POST.
:param generate_matching_id: When set to `true`, a value for `Eid` does not need to be provided. Instead, when the eSIM profile is reserved, a matching ID will be generated and returned via the `matching_id` property. This identifies the specific eSIM profile that can be used by any capable device to claim and download the profile.
:param eid: Identifier of the eUICC that will claim the eSIM Profile.
:returns: The created EsimProfileInstance
"""
data = values.of(
{
"CallbackUrl": callback_url,
"CallbackMethod": callback_method,
"GenerateMatchingId": generate_matching_id,
"Eid": eid,
}
)
payload = self._version.create(
method="POST",
uri=self._uri,
data=data,
)
return EsimProfileInstance(self._version, payload)
async def create_async(
self,
callback_url: Union[str, object] = values.unset,
callback_method: Union[str, object] = values.unset,
generate_matching_id: Union[bool, object] = values.unset,
eid: Union[str, object] = values.unset,
) -> EsimProfileInstance:
"""
Asynchronously create the EsimProfileInstance
:param callback_url: The URL we should call using the `callback_method` when the status of the eSIM Profile changes. At this stage of the eSIM Profile pilot, the a request to the URL will only be called when the ESimProfile resource changes from `reserving` to `available`.
:param callback_method: The HTTP method we should use to call `callback_url`. Can be: `GET` or `POST` and the default is POST.
:param generate_matching_id: When set to `true`, a value for `Eid` does not need to be provided. Instead, when the eSIM profile is reserved, a matching ID will be generated and returned via the `matching_id` property. This identifies the specific eSIM profile that can be used by any capable device to claim and download the profile.
:param eid: Identifier of the eUICC that will claim the eSIM Profile.
:returns: The created EsimProfileInstance
"""
data = values.of(
{
"CallbackUrl": callback_url,
"CallbackMethod": callback_method,
"GenerateMatchingId": generate_matching_id,
"Eid": eid,
}
)
payload = await self._version.create_async(
method="POST",
uri=self._uri,
data=data,
)
return EsimProfileInstance(self._version, payload)
def stream(
self,
eid: Union[str, object] = values.unset,
sim_sid: Union[str, object] = values.unset,
status: Union["EsimProfileInstance.Status", object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[EsimProfileInstance]:
"""
Streams EsimProfileInstance 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 eid: List the eSIM Profiles that have been associated with an EId.
:param str sim_sid: Find the eSIM Profile resource related to a [Sim](https://www.twilio.com/docs/iot/wireless/api/sim-resource) resource by providing the SIM SID. Will always return an array with either 1 or 0 records.
:param &quot;EsimProfileInstance.Status&quot; status: List the eSIM Profiles that are in a given status.
: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(
eid=eid, sim_sid=sim_sid, status=status, page_size=limits["page_size"]
)
return self._version.stream(page, limits["limit"])
async def stream_async(
self,
eid: Union[str, object] = values.unset,
sim_sid: Union[str, object] = values.unset,
status: Union["EsimProfileInstance.Status", object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> AsyncIterator[EsimProfileInstance]:
"""
Asynchronously streams EsimProfileInstance 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 eid: List the eSIM Profiles that have been associated with an EId.
:param str sim_sid: Find the eSIM Profile resource related to a [Sim](https://www.twilio.com/docs/iot/wireless/api/sim-resource) resource by providing the SIM SID. Will always return an array with either 1 or 0 records.
:param &quot;EsimProfileInstance.Status&quot; status: List the eSIM Profiles that are in a given status.
: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(
eid=eid, sim_sid=sim_sid, status=status, page_size=limits["page_size"]
)
return self._version.stream_async(page, limits["limit"])
def list(
self,
eid: Union[str, object] = values.unset,
sim_sid: Union[str, object] = values.unset,
status: Union["EsimProfileInstance.Status", object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[EsimProfileInstance]:
"""
Lists EsimProfileInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param str eid: List the eSIM Profiles that have been associated with an EId.
:param str sim_sid: Find the eSIM Profile resource related to a [Sim](https://www.twilio.com/docs/iot/wireless/api/sim-resource) resource by providing the SIM SID. Will always return an array with either 1 or 0 records.
:param &quot;EsimProfileInstance.Status&quot; status: List the eSIM Profiles that are in a given status.
: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(
eid=eid,
sim_sid=sim_sid,
status=status,
limit=limit,
page_size=page_size,
)
)
async def list_async(
self,
eid: Union[str, object] = values.unset,
sim_sid: Union[str, object] = values.unset,
status: Union["EsimProfileInstance.Status", object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[EsimProfileInstance]:
"""
Asynchronously lists EsimProfileInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param str eid: List the eSIM Profiles that have been associated with an EId.
:param str sim_sid: Find the eSIM Profile resource related to a [Sim](https://www.twilio.com/docs/iot/wireless/api/sim-resource) resource by providing the SIM SID. Will always return an array with either 1 or 0 records.
:param &quot;EsimProfileInstance.Status&quot; status: List the eSIM Profiles that are in a given status.
: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(
eid=eid,
sim_sid=sim_sid,
status=status,
limit=limit,
page_size=page_size,
)
]
def page(
self,
eid: Union[str, object] = values.unset,
sim_sid: Union[str, object] = values.unset,
status: Union["EsimProfileInstance.Status", object] = values.unset,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> EsimProfilePage:
"""
Retrieve a single page of EsimProfileInstance records from the API.
Request is executed immediately
:param eid: List the eSIM Profiles that have been associated with an EId.
:param sim_sid: Find the eSIM Profile resource related to a [Sim](https://www.twilio.com/docs/iot/wireless/api/sim-resource) resource by providing the SIM SID. Will always return an array with either 1 or 0 records.
:param status: List the eSIM Profiles that are in a given status.
: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 EsimProfileInstance
"""
data = values.of(
{
"Eid": eid,
"SimSid": sim_sid,
"Status": status,
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return EsimProfilePage(self._version, response)
async def page_async(
self,
eid: Union[str, object] = values.unset,
sim_sid: Union[str, object] = values.unset,
status: Union["EsimProfileInstance.Status", object] = values.unset,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> EsimProfilePage:
"""
Asynchronously retrieve a single page of EsimProfileInstance records from the API.
Request is executed immediately
:param eid: List the eSIM Profiles that have been associated with an EId.
:param sim_sid: Find the eSIM Profile resource related to a [Sim](https://www.twilio.com/docs/iot/wireless/api/sim-resource) resource by providing the SIM SID. Will always return an array with either 1 or 0 records.
:param status: List the eSIM Profiles that are in a given status.
: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 EsimProfileInstance
"""
data = values.of(
{
"Eid": eid,
"SimSid": sim_sid,
"Status": status,
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = await self._version.page_async(
method="GET", uri=self._uri, params=data
)
return EsimProfilePage(self._version, response)
def get_page(self, target_url: str) -> EsimProfilePage:
"""
Retrieve a specific page of EsimProfileInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of EsimProfileInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return EsimProfilePage(self._version, response)
async def get_page_async(self, target_url: str) -> EsimProfilePage:
"""
Asynchronously retrieve a specific page of EsimProfileInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of EsimProfileInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return EsimProfilePage(self._version, response)
def get(self, sid: str) -> EsimProfileContext:
"""
Constructs a EsimProfileContext
:param sid: The SID of the eSIM Profile resource to fetch.
"""
return EsimProfileContext(self._version, sid=sid)
def __call__(self, sid: str) -> EsimProfileContext:
"""
Constructs a EsimProfileContext
:param sid: The SID of the eSIM Profile resource to fetch.
"""
return EsimProfileContext(self._version, sid=sid)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Supersim.V1.EsimProfileList>"
@@ -0,0 +1,694 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Supersim
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 FleetInstance(InstanceResource):
class DataMetering(object):
PAYG = "payg"
"""
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Fleet resource.
:ivar sid: The unique string that we created to identify the Fleet 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 date_created: The date and time in GMT when the resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
:ivar date_updated: The date and time in GMT when the resource was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
:ivar url: The absolute URL of the Fleet resource.
:ivar data_enabled: Defines whether SIMs in the Fleet are capable of using 2G/3G/4G/LTE/CAT-M data connectivity. Defaults to `true`.
:ivar data_limit: The total data usage (download and upload combined) in Megabytes that each Super SIM assigned to the Fleet can consume during a billing period (normally one month). Value must be between 1MB (1) and 2TB (2,000,000). Defaults to 250MB.
:ivar data_metering:
:ivar sms_commands_enabled: Defines whether SIMs in the Fleet are capable of sending and receiving machine-to-machine SMS via Commands. Defaults to `false`.
:ivar sms_commands_url: The URL that will receive a webhook when a Super SIM in the Fleet is used to send an SMS from your device to the SMS Commands number. Your server should respond with an HTTP status code in the 200 range; any response body will be ignored.
:ivar sms_commands_method: A string representing the HTTP method to use when making a request to `sms_commands_url`. Can be one of `POST` or `GET`. Defaults to `POST`.
:ivar network_access_profile_sid: The SID of the Network Access Profile that controls which cellular networks the Fleet's SIMs can connect to.
:ivar ip_commands_url: The URL that will receive a webhook when a Super SIM in the Fleet is used to send an IP Command from your device to a special IP address. Your server should respond with an HTTP status code in the 200 range; any response body will be ignored.
:ivar ip_commands_method: A string representing the HTTP method to use when making a request to `ip_commands_url`. Can be one of `POST` or `GET`. Defaults to `POST`.
"""
def __init__(
self, version: Version, payload: Dict[str, Any], sid: Optional[str] = None
):
super().__init__(version)
self.account_sid: Optional[str] = payload.get("account_sid")
self.sid: Optional[str] = payload.get("sid")
self.unique_name: Optional[str] = payload.get("unique_name")
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_created")
)
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_updated")
)
self.url: Optional[str] = payload.get("url")
self.data_enabled: Optional[bool] = payload.get("data_enabled")
self.data_limit: Optional[int] = deserialize.integer(payload.get("data_limit"))
self.data_metering: Optional["FleetInstance.DataMetering"] = payload.get(
"data_metering"
)
self.sms_commands_enabled: Optional[bool] = payload.get("sms_commands_enabled")
self.sms_commands_url: Optional[str] = payload.get("sms_commands_url")
self.sms_commands_method: Optional[str] = payload.get("sms_commands_method")
self.network_access_profile_sid: Optional[str] = payload.get(
"network_access_profile_sid"
)
self.ip_commands_url: Optional[str] = payload.get("ip_commands_url")
self.ip_commands_method: Optional[str] = payload.get("ip_commands_method")
self._solution = {
"sid": sid or self.sid,
}
self._context: Optional[FleetContext] = None
@property
def _proxy(self) -> "FleetContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: FleetContext for this FleetInstance
"""
if self._context is None:
self._context = FleetContext(
self._version,
sid=self._solution["sid"],
)
return self._context
def fetch(self) -> "FleetInstance":
"""
Fetch the FleetInstance
:returns: The fetched FleetInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "FleetInstance":
"""
Asynchronous coroutine to fetch the FleetInstance
:returns: The fetched FleetInstance
"""
return await self._proxy.fetch_async()
def update(
self,
unique_name: Union[str, object] = values.unset,
network_access_profile: Union[str, object] = values.unset,
ip_commands_url: Union[str, object] = values.unset,
ip_commands_method: Union[str, object] = values.unset,
sms_commands_url: Union[str, object] = values.unset,
sms_commands_method: Union[str, object] = values.unset,
data_limit: Union[int, object] = values.unset,
) -> "FleetInstance":
"""
Update the FleetInstance
: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 network_access_profile: The SID or unique name of the Network Access Profile that will control which cellular networks the Fleet's SIMs can connect to.
:param ip_commands_url: The URL that will receive a webhook when a Super SIM in the Fleet is used to send an IP Command from your device to a special IP address. Your server should respond with an HTTP status code in the 200 range; any response body will be ignored.
:param ip_commands_method: A string representing the HTTP method to use when making a request to `ip_commands_url`. Can be one of `POST` or `GET`. Defaults to `POST`.
:param sms_commands_url: The URL that will receive a webhook when a Super SIM in the Fleet is used to send an SMS from your device to the SMS Commands number. Your server should respond with an HTTP status code in the 200 range; any response body will be ignored.
:param sms_commands_method: A string representing the HTTP method to use when making a request to `sms_commands_url`. Can be one of `POST` or `GET`. Defaults to `POST`.
:param data_limit: The total data usage (download and upload combined) in Megabytes that each Super SIM assigned to the Fleet can consume during a billing period (normally one month). Value must be between 1MB (1) and 2TB (2,000,000). Defaults to 1GB (1,000).
:returns: The updated FleetInstance
"""
return self._proxy.update(
unique_name=unique_name,
network_access_profile=network_access_profile,
ip_commands_url=ip_commands_url,
ip_commands_method=ip_commands_method,
sms_commands_url=sms_commands_url,
sms_commands_method=sms_commands_method,
data_limit=data_limit,
)
async def update_async(
self,
unique_name: Union[str, object] = values.unset,
network_access_profile: Union[str, object] = values.unset,
ip_commands_url: Union[str, object] = values.unset,
ip_commands_method: Union[str, object] = values.unset,
sms_commands_url: Union[str, object] = values.unset,
sms_commands_method: Union[str, object] = values.unset,
data_limit: Union[int, object] = values.unset,
) -> "FleetInstance":
"""
Asynchronous coroutine to update the FleetInstance
: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 network_access_profile: The SID or unique name of the Network Access Profile that will control which cellular networks the Fleet's SIMs can connect to.
:param ip_commands_url: The URL that will receive a webhook when a Super SIM in the Fleet is used to send an IP Command from your device to a special IP address. Your server should respond with an HTTP status code in the 200 range; any response body will be ignored.
:param ip_commands_method: A string representing the HTTP method to use when making a request to `ip_commands_url`. Can be one of `POST` or `GET`. Defaults to `POST`.
:param sms_commands_url: The URL that will receive a webhook when a Super SIM in the Fleet is used to send an SMS from your device to the SMS Commands number. Your server should respond with an HTTP status code in the 200 range; any response body will be ignored.
:param sms_commands_method: A string representing the HTTP method to use when making a request to `sms_commands_url`. Can be one of `POST` or `GET`. Defaults to `POST`.
:param data_limit: The total data usage (download and upload combined) in Megabytes that each Super SIM assigned to the Fleet can consume during a billing period (normally one month). Value must be between 1MB (1) and 2TB (2,000,000). Defaults to 1GB (1,000).
:returns: The updated FleetInstance
"""
return await self._proxy.update_async(
unique_name=unique_name,
network_access_profile=network_access_profile,
ip_commands_url=ip_commands_url,
ip_commands_method=ip_commands_method,
sms_commands_url=sms_commands_url,
sms_commands_method=sms_commands_method,
data_limit=data_limit,
)
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.Supersim.V1.FleetInstance {}>".format(context)
class FleetContext(InstanceContext):
def __init__(self, version: Version, sid: str):
"""
Initialize the FleetContext
:param version: Version that contains the resource
:param sid: The SID of the Fleet resource to update.
"""
super().__init__(version)
# Path Solution
self._solution = {
"sid": sid,
}
self._uri = "/Fleets/{sid}".format(**self._solution)
def fetch(self) -> FleetInstance:
"""
Fetch the FleetInstance
:returns: The fetched FleetInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return FleetInstance(
self._version,
payload,
sid=self._solution["sid"],
)
async def fetch_async(self) -> FleetInstance:
"""
Asynchronous coroutine to fetch the FleetInstance
:returns: The fetched FleetInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return FleetInstance(
self._version,
payload,
sid=self._solution["sid"],
)
def update(
self,
unique_name: Union[str, object] = values.unset,
network_access_profile: Union[str, object] = values.unset,
ip_commands_url: Union[str, object] = values.unset,
ip_commands_method: Union[str, object] = values.unset,
sms_commands_url: Union[str, object] = values.unset,
sms_commands_method: Union[str, object] = values.unset,
data_limit: Union[int, object] = values.unset,
) -> FleetInstance:
"""
Update the FleetInstance
: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 network_access_profile: The SID or unique name of the Network Access Profile that will control which cellular networks the Fleet's SIMs can connect to.
:param ip_commands_url: The URL that will receive a webhook when a Super SIM in the Fleet is used to send an IP Command from your device to a special IP address. Your server should respond with an HTTP status code in the 200 range; any response body will be ignored.
:param ip_commands_method: A string representing the HTTP method to use when making a request to `ip_commands_url`. Can be one of `POST` or `GET`. Defaults to `POST`.
:param sms_commands_url: The URL that will receive a webhook when a Super SIM in the Fleet is used to send an SMS from your device to the SMS Commands number. Your server should respond with an HTTP status code in the 200 range; any response body will be ignored.
:param sms_commands_method: A string representing the HTTP method to use when making a request to `sms_commands_url`. Can be one of `POST` or `GET`. Defaults to `POST`.
:param data_limit: The total data usage (download and upload combined) in Megabytes that each Super SIM assigned to the Fleet can consume during a billing period (normally one month). Value must be between 1MB (1) and 2TB (2,000,000). Defaults to 1GB (1,000).
:returns: The updated FleetInstance
"""
data = values.of(
{
"UniqueName": unique_name,
"NetworkAccessProfile": network_access_profile,
"IpCommandsUrl": ip_commands_url,
"IpCommandsMethod": ip_commands_method,
"SmsCommandsUrl": sms_commands_url,
"SmsCommandsMethod": sms_commands_method,
"DataLimit": data_limit,
}
)
payload = self._version.update(
method="POST",
uri=self._uri,
data=data,
)
return FleetInstance(self._version, payload, sid=self._solution["sid"])
async def update_async(
self,
unique_name: Union[str, object] = values.unset,
network_access_profile: Union[str, object] = values.unset,
ip_commands_url: Union[str, object] = values.unset,
ip_commands_method: Union[str, object] = values.unset,
sms_commands_url: Union[str, object] = values.unset,
sms_commands_method: Union[str, object] = values.unset,
data_limit: Union[int, object] = values.unset,
) -> FleetInstance:
"""
Asynchronous coroutine to update the FleetInstance
: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 network_access_profile: The SID or unique name of the Network Access Profile that will control which cellular networks the Fleet's SIMs can connect to.
:param ip_commands_url: The URL that will receive a webhook when a Super SIM in the Fleet is used to send an IP Command from your device to a special IP address. Your server should respond with an HTTP status code in the 200 range; any response body will be ignored.
:param ip_commands_method: A string representing the HTTP method to use when making a request to `ip_commands_url`. Can be one of `POST` or `GET`. Defaults to `POST`.
:param sms_commands_url: The URL that will receive a webhook when a Super SIM in the Fleet is used to send an SMS from your device to the SMS Commands number. Your server should respond with an HTTP status code in the 200 range; any response body will be ignored.
:param sms_commands_method: A string representing the HTTP method to use when making a request to `sms_commands_url`. Can be one of `POST` or `GET`. Defaults to `POST`.
:param data_limit: The total data usage (download and upload combined) in Megabytes that each Super SIM assigned to the Fleet can consume during a billing period (normally one month). Value must be between 1MB (1) and 2TB (2,000,000). Defaults to 1GB (1,000).
:returns: The updated FleetInstance
"""
data = values.of(
{
"UniqueName": unique_name,
"NetworkAccessProfile": network_access_profile,
"IpCommandsUrl": ip_commands_url,
"IpCommandsMethod": ip_commands_method,
"SmsCommandsUrl": sms_commands_url,
"SmsCommandsMethod": sms_commands_method,
"DataLimit": data_limit,
}
)
payload = await self._version.update_async(
method="POST",
uri=self._uri,
data=data,
)
return FleetInstance(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.Supersim.V1.FleetContext {}>".format(context)
class FleetPage(Page):
def get_instance(self, payload: Dict[str, Any]) -> FleetInstance:
"""
Build an instance of FleetInstance
:param payload: Payload response from the API
"""
return FleetInstance(self._version, payload)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Supersim.V1.FleetPage>"
class FleetList(ListResource):
def __init__(self, version: Version):
"""
Initialize the FleetList
:param version: Version that contains the resource
"""
super().__init__(version)
self._uri = "/Fleets"
def create(
self,
network_access_profile: str,
unique_name: Union[str, object] = values.unset,
data_enabled: Union[bool, object] = values.unset,
data_limit: Union[int, object] = values.unset,
ip_commands_url: Union[str, object] = values.unset,
ip_commands_method: Union[str, object] = values.unset,
sms_commands_enabled: Union[bool, object] = values.unset,
sms_commands_url: Union[str, object] = values.unset,
sms_commands_method: Union[str, object] = values.unset,
) -> FleetInstance:
"""
Create the FleetInstance
:param network_access_profile: The SID or unique name of the Network Access Profile that will control which cellular networks the Fleet's SIMs can connect to.
: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 data_enabled: Defines whether SIMs in the Fleet are capable of using 2G/3G/4G/LTE/CAT-M data connectivity. Defaults to `true`.
:param data_limit: The total data usage (download and upload combined) in Megabytes that each Super SIM assigned to the Fleet can consume during a billing period (normally one month). Value must be between 1MB (1) and 2TB (2,000,000). Defaults to 1GB (1,000).
:param ip_commands_url: The URL that will receive a webhook when a Super SIM in the Fleet is used to send an IP Command from your device to a special IP address. Your server should respond with an HTTP status code in the 200 range; any response body will be ignored.
:param ip_commands_method: A string representing the HTTP method to use when making a request to `ip_commands_url`. Can be one of `POST` or `GET`. Defaults to `POST`.
:param sms_commands_enabled: Defines whether SIMs in the Fleet are capable of sending and receiving machine-to-machine SMS via Commands. Defaults to `true`.
:param sms_commands_url: The URL that will receive a webhook when a Super SIM in the Fleet is used to send an SMS from your device to the SMS Commands number. Your server should respond with an HTTP status code in the 200 range; any response body will be ignored.
:param sms_commands_method: A string representing the HTTP method to use when making a request to `sms_commands_url`. Can be one of `POST` or `GET`. Defaults to `POST`.
:returns: The created FleetInstance
"""
data = values.of(
{
"NetworkAccessProfile": network_access_profile,
"UniqueName": unique_name,
"DataEnabled": data_enabled,
"DataLimit": data_limit,
"IpCommandsUrl": ip_commands_url,
"IpCommandsMethod": ip_commands_method,
"SmsCommandsEnabled": sms_commands_enabled,
"SmsCommandsUrl": sms_commands_url,
"SmsCommandsMethod": sms_commands_method,
}
)
payload = self._version.create(
method="POST",
uri=self._uri,
data=data,
)
return FleetInstance(self._version, payload)
async def create_async(
self,
network_access_profile: str,
unique_name: Union[str, object] = values.unset,
data_enabled: Union[bool, object] = values.unset,
data_limit: Union[int, object] = values.unset,
ip_commands_url: Union[str, object] = values.unset,
ip_commands_method: Union[str, object] = values.unset,
sms_commands_enabled: Union[bool, object] = values.unset,
sms_commands_url: Union[str, object] = values.unset,
sms_commands_method: Union[str, object] = values.unset,
) -> FleetInstance:
"""
Asynchronously create the FleetInstance
:param network_access_profile: The SID or unique name of the Network Access Profile that will control which cellular networks the Fleet's SIMs can connect to.
: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 data_enabled: Defines whether SIMs in the Fleet are capable of using 2G/3G/4G/LTE/CAT-M data connectivity. Defaults to `true`.
:param data_limit: The total data usage (download and upload combined) in Megabytes that each Super SIM assigned to the Fleet can consume during a billing period (normally one month). Value must be between 1MB (1) and 2TB (2,000,000). Defaults to 1GB (1,000).
:param ip_commands_url: The URL that will receive a webhook when a Super SIM in the Fleet is used to send an IP Command from your device to a special IP address. Your server should respond with an HTTP status code in the 200 range; any response body will be ignored.
:param ip_commands_method: A string representing the HTTP method to use when making a request to `ip_commands_url`. Can be one of `POST` or `GET`. Defaults to `POST`.
:param sms_commands_enabled: Defines whether SIMs in the Fleet are capable of sending and receiving machine-to-machine SMS via Commands. Defaults to `true`.
:param sms_commands_url: The URL that will receive a webhook when a Super SIM in the Fleet is used to send an SMS from your device to the SMS Commands number. Your server should respond with an HTTP status code in the 200 range; any response body will be ignored.
:param sms_commands_method: A string representing the HTTP method to use when making a request to `sms_commands_url`. Can be one of `POST` or `GET`. Defaults to `POST`.
:returns: The created FleetInstance
"""
data = values.of(
{
"NetworkAccessProfile": network_access_profile,
"UniqueName": unique_name,
"DataEnabled": data_enabled,
"DataLimit": data_limit,
"IpCommandsUrl": ip_commands_url,
"IpCommandsMethod": ip_commands_method,
"SmsCommandsEnabled": sms_commands_enabled,
"SmsCommandsUrl": sms_commands_url,
"SmsCommandsMethod": sms_commands_method,
}
)
payload = await self._version.create_async(
method="POST",
uri=self._uri,
data=data,
)
return FleetInstance(self._version, payload)
def stream(
self,
network_access_profile: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[FleetInstance]:
"""
Streams FleetInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param str network_access_profile: The SID or unique name of the Network Access Profile that controls which cellular networks the Fleet's SIMs can connect to.
: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(
network_access_profile=network_access_profile, page_size=limits["page_size"]
)
return self._version.stream(page, limits["limit"])
async def stream_async(
self,
network_access_profile: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> AsyncIterator[FleetInstance]:
"""
Asynchronously streams FleetInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param str network_access_profile: The SID or unique name of the Network Access Profile that controls which cellular networks the Fleet's SIMs can connect to.
: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(
network_access_profile=network_access_profile, page_size=limits["page_size"]
)
return self._version.stream_async(page, limits["limit"])
def list(
self,
network_access_profile: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[FleetInstance]:
"""
Lists FleetInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param str network_access_profile: The SID or unique name of the Network Access Profile that controls which cellular networks the Fleet's SIMs can connect to.
: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(
network_access_profile=network_access_profile,
limit=limit,
page_size=page_size,
)
)
async def list_async(
self,
network_access_profile: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[FleetInstance]:
"""
Asynchronously lists FleetInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param str network_access_profile: The SID or unique name of the Network Access Profile that controls which cellular networks the Fleet's SIMs can connect to.
: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(
network_access_profile=network_access_profile,
limit=limit,
page_size=page_size,
)
]
def page(
self,
network_access_profile: 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,
) -> FleetPage:
"""
Retrieve a single page of FleetInstance records from the API.
Request is executed immediately
:param network_access_profile: The SID or unique name of the Network Access Profile that controls which cellular networks the Fleet's SIMs can connect to.
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of FleetInstance
"""
data = values.of(
{
"NetworkAccessProfile": network_access_profile,
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return FleetPage(self._version, response)
async def page_async(
self,
network_access_profile: 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,
) -> FleetPage:
"""
Asynchronously retrieve a single page of FleetInstance records from the API.
Request is executed immediately
:param network_access_profile: The SID or unique name of the Network Access Profile that controls which cellular networks the Fleet's SIMs can connect to.
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of FleetInstance
"""
data = values.of(
{
"NetworkAccessProfile": network_access_profile,
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = await self._version.page_async(
method="GET", uri=self._uri, params=data
)
return FleetPage(self._version, response)
def get_page(self, target_url: str) -> FleetPage:
"""
Retrieve a specific page of FleetInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of FleetInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return FleetPage(self._version, response)
async def get_page_async(self, target_url: str) -> FleetPage:
"""
Asynchronously retrieve a specific page of FleetInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of FleetInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return FleetPage(self._version, response)
def get(self, sid: str) -> FleetContext:
"""
Constructs a FleetContext
:param sid: The SID of the Fleet resource to update.
"""
return FleetContext(self._version, sid=sid)
def __call__(self, sid: str) -> FleetContext:
"""
Constructs a FleetContext
:param sid: The SID of the Fleet resource to update.
"""
return FleetContext(self._version, sid=sid)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Supersim.V1.FleetList>"
@@ -0,0 +1,589 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Supersim
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 IpCommandInstance(InstanceResource):
class Direction(object):
TO_SIM = "to_sim"
FROM_SIM = "from_sim"
class PayloadType(object):
TEXT = "text"
BINARY = "binary"
class Status(object):
QUEUED = "queued"
SENT = "sent"
RECEIVED = "received"
FAILED = "failed"
"""
:ivar sid: The unique string that we created to identify the IP Command resource.
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the IP Command resource.
:ivar sim_sid: The SID of the [Super SIM](https://www.twilio.com/docs/iot/supersim/api/sim-resource) that this IP Command was sent to or from.
:ivar sim_iccid: The [ICCID](https://en.wikipedia.org/wiki/Subscriber_identity_module#ICCID) of the [Super SIM](https://www.twilio.com/docs/iot/supersim/api/sim-resource) that this IP Command was sent to or from.
:ivar status:
:ivar direction:
:ivar device_ip: The IP address of the device that the IP Command was sent to or received from. For an IP Command sent to a Super SIM, `device_ip` starts out as `null`, and once the IP Command is “sent”, the `device_ip` will be filled out. An IP Command sent from a Super SIM have its `device_ip` always set.
:ivar device_port: For an IP Command sent to a Super SIM, it would be the destination port of the IP message. For an IP Command sent from a Super SIM, it would be the source port of the IP message.
:ivar payload_type:
:ivar payload: The payload that is carried in the IP/UDP message. The payload can be encoded in either text or binary format. For text payload, UTF-8 encoding must be used. For an IP Command sent to a Super SIM, the payload is appended to the IP/UDP message “as is”. The payload should not exceed 1300 bytes. For an IP Command sent from a Super SIM, the payload from the received IP/UDP message is extracted and sent in binary encoding. For an IP Command sent from a Super SIM, the payload should not exceed 1300 bytes. If it is larger than 1300 bytes, there might be fragmentation on the upstream and the message may appear truncated.
:ivar date_created: The date and time in GMT when the resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
:ivar date_updated: The date and time in GMT when the resource was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
:ivar url: The absolute URL of the IP Command 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.sim_iccid: Optional[str] = payload.get("sim_iccid")
self.status: Optional["IpCommandInstance.Status"] = payload.get("status")
self.direction: Optional["IpCommandInstance.Direction"] = payload.get(
"direction"
)
self.device_ip: Optional[str] = payload.get("device_ip")
self.device_port: Optional[int] = deserialize.integer(
payload.get("device_port")
)
self.payload_type: Optional["IpCommandInstance.PayloadType"] = payload.get(
"payload_type"
)
self.payload: Optional[str] = payload.get("payload")
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[IpCommandContext] = None
@property
def _proxy(self) -> "IpCommandContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: IpCommandContext for this IpCommandInstance
"""
if self._context is None:
self._context = IpCommandContext(
self._version,
sid=self._solution["sid"],
)
return self._context
def fetch(self) -> "IpCommandInstance":
"""
Fetch the IpCommandInstance
:returns: The fetched IpCommandInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "IpCommandInstance":
"""
Asynchronous coroutine to fetch the IpCommandInstance
:returns: The fetched IpCommandInstance
"""
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.Supersim.V1.IpCommandInstance {}>".format(context)
class IpCommandContext(InstanceContext):
def __init__(self, version: Version, sid: str):
"""
Initialize the IpCommandContext
:param version: Version that contains the resource
:param sid: The SID of the IP Command resource to fetch.
"""
super().__init__(version)
# Path Solution
self._solution = {
"sid": sid,
}
self._uri = "/IpCommands/{sid}".format(**self._solution)
def fetch(self) -> IpCommandInstance:
"""
Fetch the IpCommandInstance
:returns: The fetched IpCommandInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return IpCommandInstance(
self._version,
payload,
sid=self._solution["sid"],
)
async def fetch_async(self) -> IpCommandInstance:
"""
Asynchronous coroutine to fetch the IpCommandInstance
:returns: The fetched IpCommandInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return IpCommandInstance(
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.Supersim.V1.IpCommandContext {}>".format(context)
class IpCommandPage(Page):
def get_instance(self, payload: Dict[str, Any]) -> IpCommandInstance:
"""
Build an instance of IpCommandInstance
:param payload: Payload response from the API
"""
return IpCommandInstance(self._version, payload)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Supersim.V1.IpCommandPage>"
class IpCommandList(ListResource):
def __init__(self, version: Version):
"""
Initialize the IpCommandList
:param version: Version that contains the resource
"""
super().__init__(version)
self._uri = "/IpCommands"
def create(
self,
sim: str,
payload: str,
device_port: int,
payload_type: Union["IpCommandInstance.PayloadType", object] = values.unset,
callback_url: Union[str, object] = values.unset,
callback_method: Union[str, object] = values.unset,
) -> IpCommandInstance:
"""
Create the IpCommandInstance
:param sim: The `sid` or `unique_name` of the [Super SIM](https://www.twilio.com/docs/iot/supersim/api/sim-resource) to send the IP Command to.
:param payload: The data that will be sent to the device. The payload cannot exceed 1300 bytes. If the PayloadType is set to text, the payload is encoded in UTF-8. If PayloadType is set to binary, the payload is encoded in Base64.
:param device_port: The device port to which the IP Command will be sent.
:param payload_type:
:param callback_url: The URL we should call using the `callback_method` after we have sent the IP Command.
:param callback_method: The HTTP method we should use to call `callback_url`. Can be `GET` or `POST`, and the default is `POST`.
:returns: The created IpCommandInstance
"""
data = values.of(
{
"Sim": sim,
"Payload": payload,
"DevicePort": device_port,
"PayloadType": payload_type,
"CallbackUrl": callback_url,
"CallbackMethod": callback_method,
}
)
payload = self._version.create(
method="POST",
uri=self._uri,
data=data,
)
return IpCommandInstance(self._version, payload)
async def create_async(
self,
sim: str,
payload: str,
device_port: int,
payload_type: Union["IpCommandInstance.PayloadType", object] = values.unset,
callback_url: Union[str, object] = values.unset,
callback_method: Union[str, object] = values.unset,
) -> IpCommandInstance:
"""
Asynchronously create the IpCommandInstance
:param sim: The `sid` or `unique_name` of the [Super SIM](https://www.twilio.com/docs/iot/supersim/api/sim-resource) to send the IP Command to.
:param payload: The data that will be sent to the device. The payload cannot exceed 1300 bytes. If the PayloadType is set to text, the payload is encoded in UTF-8. If PayloadType is set to binary, the payload is encoded in Base64.
:param device_port: The device port to which the IP Command will be sent.
:param payload_type:
:param callback_url: The URL we should call using the `callback_method` after we have sent the IP Command.
:param callback_method: The HTTP method we should use to call `callback_url`. Can be `GET` or `POST`, and the default is `POST`.
:returns: The created IpCommandInstance
"""
data = values.of(
{
"Sim": sim,
"Payload": payload,
"DevicePort": device_port,
"PayloadType": payload_type,
"CallbackUrl": callback_url,
"CallbackMethod": callback_method,
}
)
payload = await self._version.create_async(
method="POST",
uri=self._uri,
data=data,
)
return IpCommandInstance(self._version, payload)
def stream(
self,
sim: Union[str, object] = values.unset,
sim_iccid: Union[str, object] = values.unset,
status: Union["IpCommandInstance.Status", object] = values.unset,
direction: Union["IpCommandInstance.Direction", object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[IpCommandInstance]:
"""
Streams IpCommandInstance 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 resource that IP Command was sent to or from.
:param str sim_iccid: The ICCID of the Sim resource that IP Command was sent to or from.
:param &quot;IpCommandInstance.Status&quot; status: The status of the IP Command. Can be: `queued`, `sent`, `received` or `failed`. See the [IP Command Status Values](https://www.twilio.com/docs/iot/supersim/api/ipcommand-resource#status-values) for a description of each.
:param &quot;IpCommandInstance.Direction&quot; direction: The direction of the IP Command. Can be `to_sim` or `from_sim`. The value of `to_sim` is synonymous with the term `mobile terminated`, and `from_sim` is synonymous with the term `mobile originated`.
: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,
sim_iccid=sim_iccid,
status=status,
direction=direction,
page_size=limits["page_size"],
)
return self._version.stream(page, limits["limit"])
async def stream_async(
self,
sim: Union[str, object] = values.unset,
sim_iccid: Union[str, object] = values.unset,
status: Union["IpCommandInstance.Status", object] = values.unset,
direction: Union["IpCommandInstance.Direction", object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> AsyncIterator[IpCommandInstance]:
"""
Asynchronously streams IpCommandInstance 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 resource that IP Command was sent to or from.
:param str sim_iccid: The ICCID of the Sim resource that IP Command was sent to or from.
:param &quot;IpCommandInstance.Status&quot; status: The status of the IP Command. Can be: `queued`, `sent`, `received` or `failed`. See the [IP Command Status Values](https://www.twilio.com/docs/iot/supersim/api/ipcommand-resource#status-values) for a description of each.
:param &quot;IpCommandInstance.Direction&quot; direction: The direction of the IP Command. Can be `to_sim` or `from_sim`. The value of `to_sim` is synonymous with the term `mobile terminated`, and `from_sim` is synonymous with the term `mobile originated`.
: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,
sim_iccid=sim_iccid,
status=status,
direction=direction,
page_size=limits["page_size"],
)
return self._version.stream_async(page, limits["limit"])
def list(
self,
sim: Union[str, object] = values.unset,
sim_iccid: Union[str, object] = values.unset,
status: Union["IpCommandInstance.Status", object] = values.unset,
direction: Union["IpCommandInstance.Direction", object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[IpCommandInstance]:
"""
Lists IpCommandInstance 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 resource that IP Command was sent to or from.
:param str sim_iccid: The ICCID of the Sim resource that IP Command was sent to or from.
:param &quot;IpCommandInstance.Status&quot; status: The status of the IP Command. Can be: `queued`, `sent`, `received` or `failed`. See the [IP Command Status Values](https://www.twilio.com/docs/iot/supersim/api/ipcommand-resource#status-values) for a description of each.
:param &quot;IpCommandInstance.Direction&quot; direction: The direction of the IP Command. Can be `to_sim` or `from_sim`. The value of `to_sim` is synonymous with the term `mobile terminated`, and `from_sim` is synonymous with the term `mobile originated`.
: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,
sim_iccid=sim_iccid,
status=status,
direction=direction,
limit=limit,
page_size=page_size,
)
)
async def list_async(
self,
sim: Union[str, object] = values.unset,
sim_iccid: Union[str, object] = values.unset,
status: Union["IpCommandInstance.Status", object] = values.unset,
direction: Union["IpCommandInstance.Direction", object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[IpCommandInstance]:
"""
Asynchronously lists IpCommandInstance 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 resource that IP Command was sent to or from.
:param str sim_iccid: The ICCID of the Sim resource that IP Command was sent to or from.
:param &quot;IpCommandInstance.Status&quot; status: The status of the IP Command. Can be: `queued`, `sent`, `received` or `failed`. See the [IP Command Status Values](https://www.twilio.com/docs/iot/supersim/api/ipcommand-resource#status-values) for a description of each.
:param &quot;IpCommandInstance.Direction&quot; direction: The direction of the IP Command. Can be `to_sim` or `from_sim`. The value of `to_sim` is synonymous with the term `mobile terminated`, and `from_sim` is synonymous with the term `mobile originated`.
: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,
sim_iccid=sim_iccid,
status=status,
direction=direction,
limit=limit,
page_size=page_size,
)
]
def page(
self,
sim: Union[str, object] = values.unset,
sim_iccid: Union[str, object] = values.unset,
status: Union["IpCommandInstance.Status", object] = values.unset,
direction: Union["IpCommandInstance.Direction", object] = values.unset,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> IpCommandPage:
"""
Retrieve a single page of IpCommandInstance records from the API.
Request is executed immediately
:param sim: The SID or unique name of the Sim resource that IP Command was sent to or from.
:param sim_iccid: The ICCID of the Sim resource that IP Command was sent to or from.
:param status: The status of the IP Command. Can be: `queued`, `sent`, `received` or `failed`. See the [IP Command Status Values](https://www.twilio.com/docs/iot/supersim/api/ipcommand-resource#status-values) for a description of each.
:param direction: The direction of the IP Command. Can be `to_sim` or `from_sim`. The value of `to_sim` is synonymous with the term `mobile terminated`, and `from_sim` is synonymous with the term `mobile originated`.
: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 IpCommandInstance
"""
data = values.of(
{
"Sim": sim,
"SimIccid": sim_iccid,
"Status": status,
"Direction": direction,
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return IpCommandPage(self._version, response)
async def page_async(
self,
sim: Union[str, object] = values.unset,
sim_iccid: Union[str, object] = values.unset,
status: Union["IpCommandInstance.Status", object] = values.unset,
direction: Union["IpCommandInstance.Direction", object] = values.unset,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> IpCommandPage:
"""
Asynchronously retrieve a single page of IpCommandInstance records from the API.
Request is executed immediately
:param sim: The SID or unique name of the Sim resource that IP Command was sent to or from.
:param sim_iccid: The ICCID of the Sim resource that IP Command was sent to or from.
:param status: The status of the IP Command. Can be: `queued`, `sent`, `received` or `failed`. See the [IP Command Status Values](https://www.twilio.com/docs/iot/supersim/api/ipcommand-resource#status-values) for a description of each.
:param direction: The direction of the IP Command. Can be `to_sim` or `from_sim`. The value of `to_sim` is synonymous with the term `mobile terminated`, and `from_sim` is synonymous with the term `mobile originated`.
: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 IpCommandInstance
"""
data = values.of(
{
"Sim": sim,
"SimIccid": sim_iccid,
"Status": status,
"Direction": direction,
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = await self._version.page_async(
method="GET", uri=self._uri, params=data
)
return IpCommandPage(self._version, response)
def get_page(self, target_url: str) -> IpCommandPage:
"""
Retrieve a specific page of IpCommandInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of IpCommandInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return IpCommandPage(self._version, response)
async def get_page_async(self, target_url: str) -> IpCommandPage:
"""
Asynchronously retrieve a specific page of IpCommandInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of IpCommandInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return IpCommandPage(self._version, response)
def get(self, sid: str) -> IpCommandContext:
"""
Constructs a IpCommandContext
:param sid: The SID of the IP Command resource to fetch.
"""
return IpCommandContext(self._version, sid=sid)
def __call__(self, sid: str) -> IpCommandContext:
"""
Constructs a IpCommandContext
:param sid: The SID of the IP Command resource to fetch.
"""
return IpCommandContext(self._version, sid=sid)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Supersim.V1.IpCommandList>"
@@ -0,0 +1,445 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Supersim
This is the public Twilio REST API.
NOTE: This class is auto generated by OpenAPI Generator.
https://openapi-generator.tech
Do not edit the class manually.
"""
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
from twilio.base import values
from twilio.base.instance_context import InstanceContext
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.version import Version
from twilio.base.page import Page
class NetworkInstance(InstanceResource):
"""
:ivar sid: The unique string that we created to identify the Network resource.
:ivar friendly_name: A human readable identifier of this resource.
:ivar url: The absolute URL of the Network resource.
:ivar iso_country: The [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the Network resource.
:ivar identifiers: Array of objects identifying the [MCC-MNCs](https://en.wikipedia.org/wiki/Mobile_country_code) that are included in the Network 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.friendly_name: Optional[str] = payload.get("friendly_name")
self.url: Optional[str] = payload.get("url")
self.iso_country: Optional[str] = payload.get("iso_country")
self.identifiers: Optional[List[object]] = payload.get("identifiers")
self._solution = {
"sid": sid or self.sid,
}
self._context: Optional[NetworkContext] = None
@property
def _proxy(self) -> "NetworkContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: NetworkContext for this NetworkInstance
"""
if self._context is None:
self._context = NetworkContext(
self._version,
sid=self._solution["sid"],
)
return self._context
def fetch(self) -> "NetworkInstance":
"""
Fetch the NetworkInstance
:returns: The fetched NetworkInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "NetworkInstance":
"""
Asynchronous coroutine to fetch the NetworkInstance
:returns: The fetched NetworkInstance
"""
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.Supersim.V1.NetworkInstance {}>".format(context)
class NetworkContext(InstanceContext):
def __init__(self, version: Version, sid: str):
"""
Initialize the NetworkContext
:param version: Version that contains the resource
:param sid: The SID of the Network resource to fetch.
"""
super().__init__(version)
# Path Solution
self._solution = {
"sid": sid,
}
self._uri = "/Networks/{sid}".format(**self._solution)
def fetch(self) -> NetworkInstance:
"""
Fetch the NetworkInstance
:returns: The fetched NetworkInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return NetworkInstance(
self._version,
payload,
sid=self._solution["sid"],
)
async def fetch_async(self) -> NetworkInstance:
"""
Asynchronous coroutine to fetch the NetworkInstance
:returns: The fetched NetworkInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return NetworkInstance(
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.Supersim.V1.NetworkContext {}>".format(context)
class NetworkPage(Page):
def get_instance(self, payload: Dict[str, Any]) -> NetworkInstance:
"""
Build an instance of NetworkInstance
:param payload: Payload response from the API
"""
return NetworkInstance(self._version, payload)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Supersim.V1.NetworkPage>"
class NetworkList(ListResource):
def __init__(self, version: Version):
"""
Initialize the NetworkList
:param version: Version that contains the resource
"""
super().__init__(version)
self._uri = "/Networks"
def stream(
self,
iso_country: Union[str, object] = values.unset,
mcc: Union[str, object] = values.unset,
mnc: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[NetworkInstance]:
"""
Streams NetworkInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param str iso_country: The [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the Network resources to read.
:param str mcc: The 'mobile country code' of a country. Network resources with this `mcc` in their `identifiers` will be read.
:param str mnc: The 'mobile network code' of a mobile operator network. Network resources with this `mnc` in their `identifiers` will be read.
:param limit: Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the
limit with the most efficient page size, i.e. min(limit, 1000)
:returns: Generator that will yield up to limit results
"""
limits = self._version.read_limits(limit, page_size)
page = self.page(
iso_country=iso_country, mcc=mcc, mnc=mnc, page_size=limits["page_size"]
)
return self._version.stream(page, limits["limit"])
async def stream_async(
self,
iso_country: Union[str, object] = values.unset,
mcc: Union[str, object] = values.unset,
mnc: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> AsyncIterator[NetworkInstance]:
"""
Asynchronously streams NetworkInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param str iso_country: The [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the Network resources to read.
:param str mcc: The 'mobile country code' of a country. Network resources with this `mcc` in their `identifiers` will be read.
:param str mnc: The 'mobile network code' of a mobile operator network. Network resources with this `mnc` in their `identifiers` will be read.
:param limit: Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the
limit with the most efficient page size, i.e. min(limit, 1000)
:returns: Generator that will yield up to limit results
"""
limits = self._version.read_limits(limit, page_size)
page = await self.page_async(
iso_country=iso_country, mcc=mcc, mnc=mnc, page_size=limits["page_size"]
)
return self._version.stream_async(page, limits["limit"])
def list(
self,
iso_country: Union[str, object] = values.unset,
mcc: Union[str, object] = values.unset,
mnc: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[NetworkInstance]:
"""
Lists NetworkInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param str iso_country: The [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the Network resources to read.
:param str mcc: The 'mobile country code' of a country. Network resources with this `mcc` in their `identifiers` will be read.
:param str mnc: The 'mobile network code' of a mobile operator network. Network resources with this `mnc` in their `identifiers` will be read.
:param limit: Upper limit for the number of records to return. list() guarantees
never to return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, list() will attempt to read the limit
with the most efficient page size, i.e. min(limit, 1000)
:returns: list that will contain up to limit results
"""
return list(
self.stream(
iso_country=iso_country,
mcc=mcc,
mnc=mnc,
limit=limit,
page_size=page_size,
)
)
async def list_async(
self,
iso_country: Union[str, object] = values.unset,
mcc: Union[str, object] = values.unset,
mnc: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[NetworkInstance]:
"""
Asynchronously lists NetworkInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param str iso_country: The [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the Network resources to read.
:param str mcc: The 'mobile country code' of a country. Network resources with this `mcc` in their `identifiers` will be read.
:param str mnc: The 'mobile network code' of a mobile operator network. Network resources with this `mnc` in their `identifiers` will be read.
:param limit: Upper limit for the number of records to return. list() guarantees
never to return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, list() will attempt to read the limit
with the most efficient page size, i.e. min(limit, 1000)
:returns: list that will contain up to limit results
"""
return [
record
async for record in await self.stream_async(
iso_country=iso_country,
mcc=mcc,
mnc=mnc,
limit=limit,
page_size=page_size,
)
]
def page(
self,
iso_country: Union[str, object] = values.unset,
mcc: Union[str, object] = values.unset,
mnc: 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,
) -> NetworkPage:
"""
Retrieve a single page of NetworkInstance records from the API.
Request is executed immediately
:param iso_country: The [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the Network resources to read.
:param mcc: The 'mobile country code' of a country. Network resources with this `mcc` in their `identifiers` will be read.
:param mnc: The 'mobile network code' of a mobile operator network. Network resources with this `mnc` in their `identifiers` will be read.
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of NetworkInstance
"""
data = values.of(
{
"IsoCountry": iso_country,
"Mcc": mcc,
"Mnc": mnc,
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return NetworkPage(self._version, response)
async def page_async(
self,
iso_country: Union[str, object] = values.unset,
mcc: Union[str, object] = values.unset,
mnc: 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,
) -> NetworkPage:
"""
Asynchronously retrieve a single page of NetworkInstance records from the API.
Request is executed immediately
:param iso_country: The [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the Network resources to read.
:param mcc: The 'mobile country code' of a country. Network resources with this `mcc` in their `identifiers` will be read.
:param mnc: The 'mobile network code' of a mobile operator network. Network resources with this `mnc` in their `identifiers` will be read.
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of NetworkInstance
"""
data = values.of(
{
"IsoCountry": iso_country,
"Mcc": mcc,
"Mnc": mnc,
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = await self._version.page_async(
method="GET", uri=self._uri, params=data
)
return NetworkPage(self._version, response)
def get_page(self, target_url: str) -> NetworkPage:
"""
Retrieve a specific page of NetworkInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of NetworkInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return NetworkPage(self._version, response)
async def get_page_async(self, target_url: str) -> NetworkPage:
"""
Asynchronously retrieve a specific page of NetworkInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of NetworkInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return NetworkPage(self._version, response)
def get(self, sid: str) -> NetworkContext:
"""
Constructs a NetworkContext
:param sid: The SID of the Network resource to fetch.
"""
return NetworkContext(self._version, sid=sid)
def __call__(self, sid: str) -> NetworkContext:
"""
Constructs a NetworkContext
:param sid: The SID of the Network resource to fetch.
"""
return NetworkContext(self._version, sid=sid)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Supersim.V1.NetworkList>"
@@ -0,0 +1,562 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Supersim
This is the public Twilio REST API.
NOTE: This class is auto generated by OpenAPI Generator.
https://openapi-generator.tech
Do not edit the class manually.
"""
from datetime import datetime
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
from twilio.base import deserialize, serialize, values
from twilio.base.instance_context import InstanceContext
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.version import Version
from twilio.base.page import Page
from twilio.rest.supersim.v1.network_access_profile.network_access_profile_network import (
NetworkAccessProfileNetworkList,
)
class NetworkAccessProfileInstance(InstanceResource):
"""
:ivar sid: The unique string that identifies the Network Access Profile 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 the Network Access Profile belongs to.
:ivar date_created: The date and time in GMT when the resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
:ivar date_updated: The date and time in GMT when the resource was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
:ivar url: The absolute URL of the Network Access Profile resource.
:ivar links:
"""
def __init__(
self, version: Version, payload: Dict[str, Any], sid: Optional[str] = None
):
super().__init__(version)
self.sid: Optional[str] = payload.get("sid")
self.unique_name: Optional[str] = payload.get("unique_name")
self.account_sid: Optional[str] = payload.get("account_sid")
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_created")
)
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_updated")
)
self.url: Optional[str] = payload.get("url")
self.links: Optional[Dict[str, object]] = payload.get("links")
self._solution = {
"sid": sid or self.sid,
}
self._context: Optional[NetworkAccessProfileContext] = None
@property
def _proxy(self) -> "NetworkAccessProfileContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: NetworkAccessProfileContext for this NetworkAccessProfileInstance
"""
if self._context is None:
self._context = NetworkAccessProfileContext(
self._version,
sid=self._solution["sid"],
)
return self._context
def fetch(self) -> "NetworkAccessProfileInstance":
"""
Fetch the NetworkAccessProfileInstance
:returns: The fetched NetworkAccessProfileInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "NetworkAccessProfileInstance":
"""
Asynchronous coroutine to fetch the NetworkAccessProfileInstance
:returns: The fetched NetworkAccessProfileInstance
"""
return await self._proxy.fetch_async()
def update(
self, unique_name: Union[str, object] = values.unset
) -> "NetworkAccessProfileInstance":
"""
Update the NetworkAccessProfileInstance
:param unique_name: The new unique name of the Network Access Profile.
:returns: The updated NetworkAccessProfileInstance
"""
return self._proxy.update(
unique_name=unique_name,
)
async def update_async(
self, unique_name: Union[str, object] = values.unset
) -> "NetworkAccessProfileInstance":
"""
Asynchronous coroutine to update the NetworkAccessProfileInstance
:param unique_name: The new unique name of the Network Access Profile.
:returns: The updated NetworkAccessProfileInstance
"""
return await self._proxy.update_async(
unique_name=unique_name,
)
@property
def networks(self) -> NetworkAccessProfileNetworkList:
"""
Access the networks
"""
return self._proxy.networks
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.Supersim.V1.NetworkAccessProfileInstance {}>".format(context)
class NetworkAccessProfileContext(InstanceContext):
def __init__(self, version: Version, sid: str):
"""
Initialize the NetworkAccessProfileContext
:param version: Version that contains the resource
:param sid: The SID of the Network Access Profile to update.
"""
super().__init__(version)
# Path Solution
self._solution = {
"sid": sid,
}
self._uri = "/NetworkAccessProfiles/{sid}".format(**self._solution)
self._networks: Optional[NetworkAccessProfileNetworkList] = None
def fetch(self) -> NetworkAccessProfileInstance:
"""
Fetch the NetworkAccessProfileInstance
:returns: The fetched NetworkAccessProfileInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return NetworkAccessProfileInstance(
self._version,
payload,
sid=self._solution["sid"],
)
async def fetch_async(self) -> NetworkAccessProfileInstance:
"""
Asynchronous coroutine to fetch the NetworkAccessProfileInstance
:returns: The fetched NetworkAccessProfileInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return NetworkAccessProfileInstance(
self._version,
payload,
sid=self._solution["sid"],
)
def update(
self, unique_name: Union[str, object] = values.unset
) -> NetworkAccessProfileInstance:
"""
Update the NetworkAccessProfileInstance
:param unique_name: The new unique name of the Network Access Profile.
:returns: The updated NetworkAccessProfileInstance
"""
data = values.of(
{
"UniqueName": unique_name,
}
)
payload = self._version.update(
method="POST",
uri=self._uri,
data=data,
)
return NetworkAccessProfileInstance(
self._version, payload, sid=self._solution["sid"]
)
async def update_async(
self, unique_name: Union[str, object] = values.unset
) -> NetworkAccessProfileInstance:
"""
Asynchronous coroutine to update the NetworkAccessProfileInstance
:param unique_name: The new unique name of the Network Access Profile.
:returns: The updated NetworkAccessProfileInstance
"""
data = values.of(
{
"UniqueName": unique_name,
}
)
payload = await self._version.update_async(
method="POST",
uri=self._uri,
data=data,
)
return NetworkAccessProfileInstance(
self._version, payload, sid=self._solution["sid"]
)
@property
def networks(self) -> NetworkAccessProfileNetworkList:
"""
Access the networks
"""
if self._networks is None:
self._networks = NetworkAccessProfileNetworkList(
self._version,
self._solution["sid"],
)
return self._networks
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.Supersim.V1.NetworkAccessProfileContext {}>".format(context)
class NetworkAccessProfilePage(Page):
def get_instance(self, payload: Dict[str, Any]) -> NetworkAccessProfileInstance:
"""
Build an instance of NetworkAccessProfileInstance
:param payload: Payload response from the API
"""
return NetworkAccessProfileInstance(self._version, payload)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Supersim.V1.NetworkAccessProfilePage>"
class NetworkAccessProfileList(ListResource):
def __init__(self, version: Version):
"""
Initialize the NetworkAccessProfileList
:param version: Version that contains the resource
"""
super().__init__(version)
self._uri = "/NetworkAccessProfiles"
def create(
self,
unique_name: Union[str, object] = values.unset,
networks: Union[List[str], object] = values.unset,
) -> NetworkAccessProfileInstance:
"""
Create the NetworkAccessProfileInstance
: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 networks: List of Network SIDs that this Network Access Profile will allow connections to.
:returns: The created NetworkAccessProfileInstance
"""
data = values.of(
{
"UniqueName": unique_name,
"Networks": serialize.map(networks, lambda e: e),
}
)
payload = self._version.create(
method="POST",
uri=self._uri,
data=data,
)
return NetworkAccessProfileInstance(self._version, payload)
async def create_async(
self,
unique_name: Union[str, object] = values.unset,
networks: Union[List[str], object] = values.unset,
) -> NetworkAccessProfileInstance:
"""
Asynchronously create the NetworkAccessProfileInstance
: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 networks: List of Network SIDs that this Network Access Profile will allow connections to.
:returns: The created NetworkAccessProfileInstance
"""
data = values.of(
{
"UniqueName": unique_name,
"Networks": serialize.map(networks, lambda e: e),
}
)
payload = await self._version.create_async(
method="POST",
uri=self._uri,
data=data,
)
return NetworkAccessProfileInstance(self._version, payload)
def stream(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[NetworkAccessProfileInstance]:
"""
Streams NetworkAccessProfileInstance 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[NetworkAccessProfileInstance]:
"""
Asynchronously streams NetworkAccessProfileInstance 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[NetworkAccessProfileInstance]:
"""
Lists NetworkAccessProfileInstance 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[NetworkAccessProfileInstance]:
"""
Asynchronously lists NetworkAccessProfileInstance 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,
) -> NetworkAccessProfilePage:
"""
Retrieve a single page of NetworkAccessProfileInstance 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 NetworkAccessProfileInstance
"""
data = values.of(
{
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return NetworkAccessProfilePage(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,
) -> NetworkAccessProfilePage:
"""
Asynchronously retrieve a single page of NetworkAccessProfileInstance 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 NetworkAccessProfileInstance
"""
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 NetworkAccessProfilePage(self._version, response)
def get_page(self, target_url: str) -> NetworkAccessProfilePage:
"""
Retrieve a specific page of NetworkAccessProfileInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of NetworkAccessProfileInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return NetworkAccessProfilePage(self._version, response)
async def get_page_async(self, target_url: str) -> NetworkAccessProfilePage:
"""
Asynchronously retrieve a specific page of NetworkAccessProfileInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of NetworkAccessProfileInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return NetworkAccessProfilePage(self._version, response)
def get(self, sid: str) -> NetworkAccessProfileContext:
"""
Constructs a NetworkAccessProfileContext
:param sid: The SID of the Network Access Profile to update.
"""
return NetworkAccessProfileContext(self._version, sid=sid)
def __call__(self, sid: str) -> NetworkAccessProfileContext:
"""
Constructs a NetworkAccessProfileContext
:param sid: The SID of the Network Access Profile to update.
"""
return NetworkAccessProfileContext(self._version, sid=sid)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Supersim.V1.NetworkAccessProfileList>"
@@ -0,0 +1,532 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Supersim
This is the public Twilio REST API.
NOTE: This class is auto generated by OpenAPI Generator.
https://openapi-generator.tech
Do not edit the class manually.
"""
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
from twilio.base import values
from twilio.base.instance_context import InstanceContext
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.version import Version
from twilio.base.page import Page
class NetworkAccessProfileNetworkInstance(InstanceResource):
"""
:ivar sid: The unique string that identifies the Network resource.
:ivar network_access_profile_sid: The unique string that identifies the Network resource's Network Access Profile resource.
:ivar friendly_name: A human readable identifier of the Network this resource refers to.
:ivar iso_country: The [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the Network resource.
:ivar identifiers: Array of objects identifying the [MCC-MNCs](https://en.wikipedia.org/wiki/Mobile_country_code) that are included in the Network resource.
:ivar url: The absolute URL of the Network resource.
"""
def __init__(
self,
version: Version,
payload: Dict[str, Any],
network_access_profile_sid: str,
sid: Optional[str] = None,
):
super().__init__(version)
self.sid: Optional[str] = payload.get("sid")
self.network_access_profile_sid: Optional[str] = payload.get(
"network_access_profile_sid"
)
self.friendly_name: Optional[str] = payload.get("friendly_name")
self.iso_country: Optional[str] = payload.get("iso_country")
self.identifiers: Optional[List[object]] = payload.get("identifiers")
self.url: Optional[str] = payload.get("url")
self._solution = {
"network_access_profile_sid": network_access_profile_sid,
"sid": sid or self.sid,
}
self._context: Optional[NetworkAccessProfileNetworkContext] = None
@property
def _proxy(self) -> "NetworkAccessProfileNetworkContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: NetworkAccessProfileNetworkContext for this NetworkAccessProfileNetworkInstance
"""
if self._context is None:
self._context = NetworkAccessProfileNetworkContext(
self._version,
network_access_profile_sid=self._solution["network_access_profile_sid"],
sid=self._solution["sid"],
)
return self._context
def delete(self) -> bool:
"""
Deletes the NetworkAccessProfileNetworkInstance
:returns: True if delete succeeds, False otherwise
"""
return self._proxy.delete()
async def delete_async(self) -> bool:
"""
Asynchronous coroutine that deletes the NetworkAccessProfileNetworkInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._proxy.delete_async()
def fetch(self) -> "NetworkAccessProfileNetworkInstance":
"""
Fetch the NetworkAccessProfileNetworkInstance
:returns: The fetched NetworkAccessProfileNetworkInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "NetworkAccessProfileNetworkInstance":
"""
Asynchronous coroutine to fetch the NetworkAccessProfileNetworkInstance
:returns: The fetched NetworkAccessProfileNetworkInstance
"""
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.Supersim.V1.NetworkAccessProfileNetworkInstance {}>".format(
context
)
class NetworkAccessProfileNetworkContext(InstanceContext):
def __init__(self, version: Version, network_access_profile_sid: str, sid: str):
"""
Initialize the NetworkAccessProfileNetworkContext
:param version: Version that contains the resource
:param network_access_profile_sid: The unique string that identifies the Network Access Profile resource.
:param sid: The SID of the Network resource to fetch.
"""
super().__init__(version)
# Path Solution
self._solution = {
"network_access_profile_sid": network_access_profile_sid,
"sid": sid,
}
self._uri = (
"/NetworkAccessProfiles/{network_access_profile_sid}/Networks/{sid}".format(
**self._solution
)
)
def delete(self) -> bool:
"""
Deletes the NetworkAccessProfileNetworkInstance
: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 NetworkAccessProfileNetworkInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._version.delete_async(
method="DELETE",
uri=self._uri,
)
def fetch(self) -> NetworkAccessProfileNetworkInstance:
"""
Fetch the NetworkAccessProfileNetworkInstance
:returns: The fetched NetworkAccessProfileNetworkInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return NetworkAccessProfileNetworkInstance(
self._version,
payload,
network_access_profile_sid=self._solution["network_access_profile_sid"],
sid=self._solution["sid"],
)
async def fetch_async(self) -> NetworkAccessProfileNetworkInstance:
"""
Asynchronous coroutine to fetch the NetworkAccessProfileNetworkInstance
:returns: The fetched NetworkAccessProfileNetworkInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return NetworkAccessProfileNetworkInstance(
self._version,
payload,
network_access_profile_sid=self._solution["network_access_profile_sid"],
sid=self._solution["sid"],
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Supersim.V1.NetworkAccessProfileNetworkContext {}>".format(
context
)
class NetworkAccessProfileNetworkPage(Page):
def get_instance(
self, payload: Dict[str, Any]
) -> NetworkAccessProfileNetworkInstance:
"""
Build an instance of NetworkAccessProfileNetworkInstance
:param payload: Payload response from the API
"""
return NetworkAccessProfileNetworkInstance(
self._version,
payload,
network_access_profile_sid=self._solution["network_access_profile_sid"],
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Supersim.V1.NetworkAccessProfileNetworkPage>"
class NetworkAccessProfileNetworkList(ListResource):
def __init__(self, version: Version, network_access_profile_sid: str):
"""
Initialize the NetworkAccessProfileNetworkList
:param version: Version that contains the resource
:param network_access_profile_sid: The unique string that identifies the Network Access Profile resource.
"""
super().__init__(version)
# Path Solution
self._solution = {
"network_access_profile_sid": network_access_profile_sid,
}
self._uri = (
"/NetworkAccessProfiles/{network_access_profile_sid}/Networks".format(
**self._solution
)
)
def create(self, network: str) -> NetworkAccessProfileNetworkInstance:
"""
Create the NetworkAccessProfileNetworkInstance
:param network: The SID of the Network resource to be added to the Network Access Profile resource.
:returns: The created NetworkAccessProfileNetworkInstance
"""
data = values.of(
{
"Network": network,
}
)
payload = self._version.create(
method="POST",
uri=self._uri,
data=data,
)
return NetworkAccessProfileNetworkInstance(
self._version,
payload,
network_access_profile_sid=self._solution["network_access_profile_sid"],
)
async def create_async(self, network: str) -> NetworkAccessProfileNetworkInstance:
"""
Asynchronously create the NetworkAccessProfileNetworkInstance
:param network: The SID of the Network resource to be added to the Network Access Profile resource.
:returns: The created NetworkAccessProfileNetworkInstance
"""
data = values.of(
{
"Network": network,
}
)
payload = await self._version.create_async(
method="POST",
uri=self._uri,
data=data,
)
return NetworkAccessProfileNetworkInstance(
self._version,
payload,
network_access_profile_sid=self._solution["network_access_profile_sid"],
)
def stream(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[NetworkAccessProfileNetworkInstance]:
"""
Streams NetworkAccessProfileNetworkInstance 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[NetworkAccessProfileNetworkInstance]:
"""
Asynchronously streams NetworkAccessProfileNetworkInstance 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[NetworkAccessProfileNetworkInstance]:
"""
Lists NetworkAccessProfileNetworkInstance 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[NetworkAccessProfileNetworkInstance]:
"""
Asynchronously lists NetworkAccessProfileNetworkInstance 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,
) -> NetworkAccessProfileNetworkPage:
"""
Retrieve a single page of NetworkAccessProfileNetworkInstance 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 NetworkAccessProfileNetworkInstance
"""
data = values.of(
{
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return NetworkAccessProfileNetworkPage(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,
) -> NetworkAccessProfileNetworkPage:
"""
Asynchronously retrieve a single page of NetworkAccessProfileNetworkInstance 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 NetworkAccessProfileNetworkInstance
"""
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 NetworkAccessProfileNetworkPage(self._version, response, self._solution)
def get_page(self, target_url: str) -> NetworkAccessProfileNetworkPage:
"""
Retrieve a specific page of NetworkAccessProfileNetworkInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of NetworkAccessProfileNetworkInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return NetworkAccessProfileNetworkPage(self._version, response, self._solution)
async def get_page_async(self, target_url: str) -> NetworkAccessProfileNetworkPage:
"""
Asynchronously retrieve a specific page of NetworkAccessProfileNetworkInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of NetworkAccessProfileNetworkInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return NetworkAccessProfileNetworkPage(self._version, response, self._solution)
def get(self, sid: str) -> NetworkAccessProfileNetworkContext:
"""
Constructs a NetworkAccessProfileNetworkContext
:param sid: The SID of the Network resource to fetch.
"""
return NetworkAccessProfileNetworkContext(
self._version,
network_access_profile_sid=self._solution["network_access_profile_sid"],
sid=sid,
)
def __call__(self, sid: str) -> NetworkAccessProfileNetworkContext:
"""
Constructs a NetworkAccessProfileNetworkContext
:param sid: The SID of the Network resource to fetch.
"""
return NetworkAccessProfileNetworkContext(
self._version,
network_access_profile_sid=self._solution["network_access_profile_sid"],
sid=sid,
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Supersim.V1.NetworkAccessProfileNetworkList>"
@@ -0,0 +1,325 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Supersim
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 SettingsUpdateInstance(InstanceResource):
class Status(object):
SCHEDULED = "scheduled"
IN_PROGRESS = "in-progress"
SUCCESSFUL = "successful"
FAILED = "failed"
"""
:ivar sid: The unique identifier of this Settings Update.
:ivar iccid: The [ICCID](https://en.wikipedia.org/wiki/SIM_card#ICCID) associated with the SIM.
:ivar sim_sid: The SID of the Super SIM to which this Settings Update was applied.
:ivar status:
:ivar packages: Array containing the different Settings Packages that will be applied to the SIM after the update completes. Each object within the array indicates the name and the version of the Settings Package that will be on the SIM if the update is successful.
:ivar date_completed: The time, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format, when the update successfully completed and the new settings were applied to the SIM.
:ivar date_created: The date that this Settings Update was created, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
:ivar date_updated: The date that this Settings Update was updated, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
"""
def __init__(self, version: Version, payload: Dict[str, Any]):
super().__init__(version)
self.sid: Optional[str] = payload.get("sid")
self.iccid: Optional[str] = payload.get("iccid")
self.sim_sid: Optional[str] = payload.get("sim_sid")
self.status: Optional["SettingsUpdateInstance.Status"] = payload.get("status")
self.packages: Optional[List[object]] = payload.get("packages")
self.date_completed: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_completed")
)
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_created")
)
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_updated")
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Supersim.V1.SettingsUpdateInstance>"
class SettingsUpdatePage(Page):
def get_instance(self, payload: Dict[str, Any]) -> SettingsUpdateInstance:
"""
Build an instance of SettingsUpdateInstance
:param payload: Payload response from the API
"""
return SettingsUpdateInstance(self._version, payload)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Supersim.V1.SettingsUpdatePage>"
class SettingsUpdateList(ListResource):
def __init__(self, version: Version):
"""
Initialize the SettingsUpdateList
:param version: Version that contains the resource
"""
super().__init__(version)
self._uri = "/SettingsUpdates"
def stream(
self,
sim: Union[str, object] = values.unset,
status: Union["SettingsUpdateInstance.Status", object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[SettingsUpdateInstance]:
"""
Streams SettingsUpdateInstance 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: Filter the Settings Updates by a Super SIM's SID or UniqueName.
:param &quot;SettingsUpdateInstance.Status&quot; status: Filter the Settings Updates by status. Can be `scheduled`, `in-progress`, `successful`, or `failed`.
: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, 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["SettingsUpdateInstance.Status", object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> AsyncIterator[SettingsUpdateInstance]:
"""
Asynchronously streams SettingsUpdateInstance 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: Filter the Settings Updates by a Super SIM's SID or UniqueName.
:param &quot;SettingsUpdateInstance.Status&quot; status: Filter the Settings Updates by status. Can be `scheduled`, `in-progress`, `successful`, or `failed`.
: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, page_size=limits["page_size"]
)
return self._version.stream_async(page, limits["limit"])
def list(
self,
sim: Union[str, object] = values.unset,
status: Union["SettingsUpdateInstance.Status", object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[SettingsUpdateInstance]:
"""
Lists SettingsUpdateInstance 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: Filter the Settings Updates by a Super SIM's SID or UniqueName.
:param &quot;SettingsUpdateInstance.Status&quot; status: Filter the Settings Updates by status. Can be `scheduled`, `in-progress`, `successful`, or `failed`.
: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,
limit=limit,
page_size=page_size,
)
)
async def list_async(
self,
sim: Union[str, object] = values.unset,
status: Union["SettingsUpdateInstance.Status", object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[SettingsUpdateInstance]:
"""
Asynchronously lists SettingsUpdateInstance 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: Filter the Settings Updates by a Super SIM's SID or UniqueName.
:param &quot;SettingsUpdateInstance.Status&quot; status: Filter the Settings Updates by status. Can be `scheduled`, `in-progress`, `successful`, or `failed`.
: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,
limit=limit,
page_size=page_size,
)
]
def page(
self,
sim: Union[str, object] = values.unset,
status: Union["SettingsUpdateInstance.Status", object] = values.unset,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> SettingsUpdatePage:
"""
Retrieve a single page of SettingsUpdateInstance records from the API.
Request is executed immediately
:param sim: Filter the Settings Updates by a Super SIM's SID or UniqueName.
:param status: Filter the Settings Updates by status. Can be `scheduled`, `in-progress`, `successful`, or `failed`.
: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 SettingsUpdateInstance
"""
data = values.of(
{
"Sim": sim,
"Status": status,
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return SettingsUpdatePage(self._version, response)
async def page_async(
self,
sim: Union[str, object] = values.unset,
status: Union["SettingsUpdateInstance.Status", object] = values.unset,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> SettingsUpdatePage:
"""
Asynchronously retrieve a single page of SettingsUpdateInstance records from the API.
Request is executed immediately
:param sim: Filter the Settings Updates by a Super SIM's SID or UniqueName.
:param status: Filter the Settings Updates by status. Can be `scheduled`, `in-progress`, `successful`, or `failed`.
: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 SettingsUpdateInstance
"""
data = values.of(
{
"Sim": sim,
"Status": status,
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = await self._version.page_async(
method="GET", uri=self._uri, params=data
)
return SettingsUpdatePage(self._version, response)
def get_page(self, target_url: str) -> SettingsUpdatePage:
"""
Retrieve a specific page of SettingsUpdateInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of SettingsUpdateInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return SettingsUpdatePage(self._version, response)
async def get_page_async(self, target_url: str) -> SettingsUpdatePage:
"""
Asynchronously retrieve a specific page of SettingsUpdateInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of SettingsUpdateInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return SettingsUpdatePage(self._version, response)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Supersim.V1.SettingsUpdateList>"
@@ -0,0 +1,702 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Supersim
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.supersim.v1.sim.billing_period import BillingPeriodList
from twilio.rest.supersim.v1.sim.sim_ip_address import SimIpAddressList
class SimInstance(InstanceResource):
class Status(object):
NEW = "new"
READY = "ready"
ACTIVE = "active"
INACTIVE = "inactive"
SCHEDULED = "scheduled"
class StatusUpdate(object):
READY = "ready"
ACTIVE = "active"
INACTIVE = "inactive"
"""
:ivar sid: The unique string that identifies 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) that the Super SIM belongs to.
:ivar iccid: The [ICCID](https://en.wikipedia.org/wiki/Subscriber_identity_module#ICCID) associated with the SIM.
:ivar status:
:ivar fleet_sid: The unique ID of the Fleet configured for this SIM.
:ivar date_created: The date and time in GMT when the resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
:ivar date_updated: The date and time in GMT when the resource was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
:ivar url: The absolute URL of the Sim Resource.
:ivar links:
"""
def __init__(
self, version: Version, payload: Dict[str, Any], sid: Optional[str] = None
):
super().__init__(version)
self.sid: Optional[str] = payload.get("sid")
self.unique_name: Optional[str] = payload.get("unique_name")
self.account_sid: Optional[str] = payload.get("account_sid")
self.iccid: Optional[str] = payload.get("iccid")
self.status: Optional["SimInstance.Status"] = payload.get("status")
self.fleet_sid: Optional[str] = payload.get("fleet_sid")
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_created")
)
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_updated")
)
self.url: Optional[str] = payload.get("url")
self.links: Optional[Dict[str, object]] = payload.get("links")
self._solution = {
"sid": sid or self.sid,
}
self._context: Optional[SimContext] = None
@property
def _proxy(self) -> "SimContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: SimContext for this SimInstance
"""
if self._context is None:
self._context = SimContext(
self._version,
sid=self._solution["sid"],
)
return self._context
def fetch(self) -> "SimInstance":
"""
Fetch the SimInstance
:returns: The fetched SimInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "SimInstance":
"""
Asynchronous coroutine to fetch the SimInstance
:returns: The fetched SimInstance
"""
return await self._proxy.fetch_async()
def update(
self,
unique_name: Union[str, object] = values.unset,
status: Union["SimInstance.StatusUpdate", object] = values.unset,
fleet: Union[str, object] = values.unset,
callback_url: Union[str, object] = values.unset,
callback_method: Union[str, 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 resource's `sid` in the URL to address the resource.
:param status:
:param fleet: The SID or unique name of the Fleet to which the SIM resource should be assigned.
:param callback_url: The URL we should call using the `callback_method` after an asynchronous update has finished.
:param callback_method: The HTTP method we should use to call `callback_url`. Can be: `GET` or `POST` and the default is POST.
:param account_sid: The SID of the Account to which the Sim resource should belong. The Account SID can only be that of the requesting Account or that of a Subaccount of the requesting Account. Only valid when the Sim resource's status is new.
:returns: The updated SimInstance
"""
return self._proxy.update(
unique_name=unique_name,
status=status,
fleet=fleet,
callback_url=callback_url,
callback_method=callback_method,
account_sid=account_sid,
)
async def update_async(
self,
unique_name: Union[str, object] = values.unset,
status: Union["SimInstance.StatusUpdate", object] = values.unset,
fleet: Union[str, object] = values.unset,
callback_url: Union[str, object] = values.unset,
callback_method: Union[str, 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 resource's `sid` in the URL to address the resource.
:param status:
:param fleet: The SID or unique name of the Fleet to which the SIM resource should be assigned.
:param callback_url: The URL we should call using the `callback_method` after an asynchronous update has finished.
:param callback_method: The HTTP method we should use to call `callback_url`. Can be: `GET` or `POST` and the default is POST.
:param account_sid: The SID of the Account to which the Sim resource should belong. The Account SID can only be that of the requesting Account or that of a Subaccount of the requesting Account. Only valid when the Sim resource's status is new.
:returns: The updated SimInstance
"""
return await self._proxy.update_async(
unique_name=unique_name,
status=status,
fleet=fleet,
callback_url=callback_url,
callback_method=callback_method,
account_sid=account_sid,
)
@property
def billing_periods(self) -> BillingPeriodList:
"""
Access the billing_periods
"""
return self._proxy.billing_periods
@property
def sim_ip_addresses(self) -> SimIpAddressList:
"""
Access the sim_ip_addresses
"""
return self._proxy.sim_ip_addresses
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.Supersim.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 of the Sim resource to update.
"""
super().__init__(version)
# Path Solution
self._solution = {
"sid": sid,
}
self._uri = "/Sims/{sid}".format(**self._solution)
self._billing_periods: Optional[BillingPeriodList] = None
self._sim_ip_addresses: Optional[SimIpAddressList] = None
def fetch(self) -> SimInstance:
"""
Fetch the SimInstance
:returns: The fetched SimInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return SimInstance(
self._version,
payload,
sid=self._solution["sid"],
)
async def fetch_async(self) -> SimInstance:
"""
Asynchronous coroutine to fetch the SimInstance
:returns: The fetched SimInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return SimInstance(
self._version,
payload,
sid=self._solution["sid"],
)
def update(
self,
unique_name: Union[str, object] = values.unset,
status: Union["SimInstance.StatusUpdate", object] = values.unset,
fleet: Union[str, object] = values.unset,
callback_url: Union[str, object] = values.unset,
callback_method: Union[str, 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 resource's `sid` in the URL to address the resource.
:param status:
:param fleet: The SID or unique name of the Fleet to which the SIM resource should be assigned.
:param callback_url: The URL we should call using the `callback_method` after an asynchronous update has finished.
:param callback_method: The HTTP method we should use to call `callback_url`. Can be: `GET` or `POST` and the default is POST.
:param account_sid: The SID of the Account to which the Sim resource should belong. The Account SID can only be that of the requesting Account or that of a Subaccount of the requesting Account. Only valid when the Sim resource's status is new.
:returns: The updated SimInstance
"""
data = values.of(
{
"UniqueName": unique_name,
"Status": status,
"Fleet": fleet,
"CallbackUrl": callback_url,
"CallbackMethod": callback_method,
"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,
status: Union["SimInstance.StatusUpdate", object] = values.unset,
fleet: Union[str, object] = values.unset,
callback_url: Union[str, object] = values.unset,
callback_method: Union[str, 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 resource's `sid` in the URL to address the resource.
:param status:
:param fleet: The SID or unique name of the Fleet to which the SIM resource should be assigned.
:param callback_url: The URL we should call using the `callback_method` after an asynchronous update has finished.
:param callback_method: The HTTP method we should use to call `callback_url`. Can be: `GET` or `POST` and the default is POST.
:param account_sid: The SID of the Account to which the Sim resource should belong. The Account SID can only be that of the requesting Account or that of a Subaccount of the requesting Account. Only valid when the Sim resource's status is new.
:returns: The updated SimInstance
"""
data = values.of(
{
"UniqueName": unique_name,
"Status": status,
"Fleet": fleet,
"CallbackUrl": callback_url,
"CallbackMethod": callback_method,
"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 billing_periods(self) -> BillingPeriodList:
"""
Access the billing_periods
"""
if self._billing_periods is None:
self._billing_periods = BillingPeriodList(
self._version,
self._solution["sid"],
)
return self._billing_periods
@property
def sim_ip_addresses(self) -> SimIpAddressList:
"""
Access the sim_ip_addresses
"""
if self._sim_ip_addresses is None:
self._sim_ip_addresses = SimIpAddressList(
self._version,
self._solution["sid"],
)
return self._sim_ip_addresses
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.Supersim.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.Supersim.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 create(self, iccid: str, registration_code: str) -> SimInstance:
"""
Create the SimInstance
:param iccid: The [ICCID](https://en.wikipedia.org/wiki/Subscriber_identity_module#ICCID) of the Super SIM to be added to your Account.
:param registration_code: The 10-digit code required to claim the Super SIM for your Account.
:returns: The created SimInstance
"""
data = values.of(
{
"Iccid": iccid,
"RegistrationCode": registration_code,
}
)
payload = self._version.create(
method="POST",
uri=self._uri,
data=data,
)
return SimInstance(self._version, payload)
async def create_async(self, iccid: str, registration_code: str) -> SimInstance:
"""
Asynchronously create the SimInstance
:param iccid: The [ICCID](https://en.wikipedia.org/wiki/Subscriber_identity_module#ICCID) of the Super SIM to be added to your Account.
:param registration_code: The 10-digit code required to claim the Super SIM for your Account.
:returns: The created SimInstance
"""
data = values.of(
{
"Iccid": iccid,
"RegistrationCode": registration_code,
}
)
payload = await self._version.create_async(
method="POST",
uri=self._uri,
data=data,
)
return SimInstance(self._version, payload)
def stream(
self,
status: Union["SimInstance.Status", object] = values.unset,
fleet: Union[str, object] = values.unset,
iccid: 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 &quot;SimInstance.Status&quot; status: The status of the Sim resources to read. Can be `new`, `ready`, `active`, `inactive`, or `scheduled`.
:param str fleet: The SID or unique name of the Fleet to which a list of Sims are assigned.
:param str iccid: The [ICCID](https://en.wikipedia.org/wiki/Subscriber_identity_module#ICCID) associated with a Super SIM to filter the list by. Passing this parameter will always return a list containing zero or one SIMs.
: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, fleet=fleet, iccid=iccid, page_size=limits["page_size"]
)
return self._version.stream(page, limits["limit"])
async def stream_async(
self,
status: Union["SimInstance.Status", object] = values.unset,
fleet: Union[str, object] = values.unset,
iccid: 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 &quot;SimInstance.Status&quot; status: The status of the Sim resources to read. Can be `new`, `ready`, `active`, `inactive`, or `scheduled`.
:param str fleet: The SID or unique name of the Fleet to which a list of Sims are assigned.
:param str iccid: The [ICCID](https://en.wikipedia.org/wiki/Subscriber_identity_module#ICCID) associated with a Super SIM to filter the list by. Passing this parameter will always return a list containing zero or one SIMs.
: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, fleet=fleet, iccid=iccid, page_size=limits["page_size"]
)
return self._version.stream_async(page, limits["limit"])
def list(
self,
status: Union["SimInstance.Status", object] = values.unset,
fleet: Union[str, object] = values.unset,
iccid: 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 &quot;SimInstance.Status&quot; status: The status of the Sim resources to read. Can be `new`, `ready`, `active`, `inactive`, or `scheduled`.
:param str fleet: The SID or unique name of the Fleet to which a list of Sims are assigned.
:param str iccid: The [ICCID](https://en.wikipedia.org/wiki/Subscriber_identity_module#ICCID) associated with a Super SIM to filter the list by. Passing this parameter will always return a list containing zero or one SIMs.
: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,
fleet=fleet,
iccid=iccid,
limit=limit,
page_size=page_size,
)
)
async def list_async(
self,
status: Union["SimInstance.Status", object] = values.unset,
fleet: Union[str, object] = values.unset,
iccid: 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 &quot;SimInstance.Status&quot; status: The status of the Sim resources to read. Can be `new`, `ready`, `active`, `inactive`, or `scheduled`.
:param str fleet: The SID or unique name of the Fleet to which a list of Sims are assigned.
:param str iccid: The [ICCID](https://en.wikipedia.org/wiki/Subscriber_identity_module#ICCID) associated with a Super SIM to filter the list by. Passing this parameter will always return a list containing zero or one SIMs.
: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,
fleet=fleet,
iccid=iccid,
limit=limit,
page_size=page_size,
)
]
def page(
self,
status: Union["SimInstance.Status", object] = values.unset,
fleet: Union[str, object] = values.unset,
iccid: 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: The status of the Sim resources to read. Can be `new`, `ready`, `active`, `inactive`, or `scheduled`.
:param fleet: The SID or unique name of the Fleet to which a list of Sims are assigned.
:param iccid: The [ICCID](https://en.wikipedia.org/wiki/Subscriber_identity_module#ICCID) associated with a Super SIM to filter the list by. Passing this parameter will always return a list containing zero or one SIMs.
: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,
"Fleet": fleet,
"Iccid": iccid,
"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,
fleet: Union[str, object] = values.unset,
iccid: 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: The status of the Sim resources to read. Can be `new`, `ready`, `active`, `inactive`, or `scheduled`.
:param fleet: The SID or unique name of the Fleet to which a list of Sims are assigned.
:param iccid: The [ICCID](https://en.wikipedia.org/wiki/Subscriber_identity_module#ICCID) associated with a Super SIM to filter the list by. Passing this parameter will always return a list containing zero or one SIMs.
: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,
"Fleet": fleet,
"Iccid": iccid,
"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 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 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.Supersim.V1.SimList>"
@@ -0,0 +1,304 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Supersim
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 BillingPeriodInstance(InstanceResource):
class BpType(object):
READY = "ready"
ACTIVE = "active"
"""
:ivar sid: The SID of the Billing Period.
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) the Super SIM belongs to.
:ivar sim_sid: The SID of the Super SIM the Billing Period belongs to.
:ivar start_time: The start time of the Billing Period specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
:ivar end_time: The end time of the Billing Period specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
:ivar period_type:
:ivar date_created: The date and time in GMT when the resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
:ivar date_updated: The date and time in GMT when the resource was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
"""
def __init__(self, version: Version, payload: Dict[str, Any], sim_sid: str):
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.start_time: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("start_time")
)
self.end_time: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("end_time")
)
self.period_type: Optional["BillingPeriodInstance.BpType"] = payload.get(
"period_type"
)
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_created")
)
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_updated")
)
self._solution = {
"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.Supersim.V1.BillingPeriodInstance {}>".format(context)
class BillingPeriodPage(Page):
def get_instance(self, payload: Dict[str, Any]) -> BillingPeriodInstance:
"""
Build an instance of BillingPeriodInstance
:param payload: Payload response from the API
"""
return BillingPeriodInstance(
self._version, payload, sim_sid=self._solution["sim_sid"]
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Supersim.V1.BillingPeriodPage>"
class BillingPeriodList(ListResource):
def __init__(self, version: Version, sim_sid: str):
"""
Initialize the BillingPeriodList
:param version: Version that contains the resource
:param sim_sid: The SID of the Super SIM to list Billing Periods for.
"""
super().__init__(version)
# Path Solution
self._solution = {
"sim_sid": sim_sid,
}
self._uri = "/Sims/{sim_sid}/BillingPeriods".format(**self._solution)
def stream(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[BillingPeriodInstance]:
"""
Streams BillingPeriodInstance 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[BillingPeriodInstance]:
"""
Asynchronously streams BillingPeriodInstance 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[BillingPeriodInstance]:
"""
Lists BillingPeriodInstance 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[BillingPeriodInstance]:
"""
Asynchronously lists BillingPeriodInstance 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,
) -> BillingPeriodPage:
"""
Retrieve a single page of BillingPeriodInstance 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 BillingPeriodInstance
"""
data = values.of(
{
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return BillingPeriodPage(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,
) -> BillingPeriodPage:
"""
Asynchronously retrieve a single page of BillingPeriodInstance 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 BillingPeriodInstance
"""
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 BillingPeriodPage(self._version, response, self._solution)
def get_page(self, target_url: str) -> BillingPeriodPage:
"""
Retrieve a specific page of BillingPeriodInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of BillingPeriodInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return BillingPeriodPage(self._version, response, self._solution)
async def get_page_async(self, target_url: str) -> BillingPeriodPage:
"""
Asynchronously retrieve a specific page of BillingPeriodInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of BillingPeriodInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return BillingPeriodPage(self._version, response, self._solution)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Supersim.V1.BillingPeriodList>"
@@ -0,0 +1,283 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Supersim
This is the public Twilio REST API.
NOTE: This class is auto generated by OpenAPI Generator.
https://openapi-generator.tech
Do not edit the class manually.
"""
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
from twilio.base import values
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.version import Version
from twilio.base.page import Page
class SimIpAddressInstance(InstanceResource):
class IpAddressVersion(object):
IPV4 = "IPv4"
IPV6 = "IPv6"
"""
:ivar ip_address: IP address assigned to the given Super SIM
:ivar ip_address_version:
"""
def __init__(self, version: Version, payload: Dict[str, Any], sim_sid: str):
super().__init__(version)
self.ip_address: Optional[str] = payload.get("ip_address")
self.ip_address_version: Optional[
"SimIpAddressInstance.IpAddressVersion"
] = payload.get("ip_address_version")
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.Supersim.V1.SimIpAddressInstance {}>".format(context)
class SimIpAddressPage(Page):
def get_instance(self, payload: Dict[str, Any]) -> SimIpAddressInstance:
"""
Build an instance of SimIpAddressInstance
:param payload: Payload response from the API
"""
return SimIpAddressInstance(
self._version, payload, sim_sid=self._solution["sim_sid"]
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Supersim.V1.SimIpAddressPage>"
class SimIpAddressList(ListResource):
def __init__(self, version: Version, sim_sid: str):
"""
Initialize the SimIpAddressList
:param version: Version that contains the resource
:param sim_sid: The SID of the Super SIM to list IP Addresses for.
"""
super().__init__(version)
# Path Solution
self._solution = {
"sim_sid": sim_sid,
}
self._uri = "/Sims/{sim_sid}/IpAddresses".format(**self._solution)
def stream(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[SimIpAddressInstance]:
"""
Streams SimIpAddressInstance 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[SimIpAddressInstance]:
"""
Asynchronously streams SimIpAddressInstance 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[SimIpAddressInstance]:
"""
Lists SimIpAddressInstance 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[SimIpAddressInstance]:
"""
Asynchronously lists SimIpAddressInstance 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,
) -> SimIpAddressPage:
"""
Retrieve a single page of SimIpAddressInstance 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 SimIpAddressInstance
"""
data = values.of(
{
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return SimIpAddressPage(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,
) -> SimIpAddressPage:
"""
Asynchronously retrieve a single page of SimIpAddressInstance 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 SimIpAddressInstance
"""
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 SimIpAddressPage(self._version, response, self._solution)
def get_page(self, target_url: str) -> SimIpAddressPage:
"""
Retrieve a specific page of SimIpAddressInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of SimIpAddressInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return SimIpAddressPage(self._version, response, self._solution)
async def get_page_async(self, target_url: str) -> SimIpAddressPage:
"""
Asynchronously retrieve a specific page of SimIpAddressInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of SimIpAddressInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return SimIpAddressPage(self._version, response, self._solution)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Supersim.V1.SimIpAddressList>"
@@ -0,0 +1,538 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Supersim
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 SmsCommandInstance(InstanceResource):
class Direction(object):
TO_SIM = "to_sim"
FROM_SIM = "from_sim"
class Status(object):
QUEUED = "queued"
SENT = "sent"
DELIVERED = "delivered"
RECEIVED = "received"
FAILED = "failed"
"""
:ivar sid: The unique string that we created to identify the SMS Command resource.
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the SMS Command resource.
:ivar sim_sid: The SID of the [SIM](https://www.twilio.com/docs/iot/supersim/api/sim-resource) that this SMS Command was sent to or from.
:ivar payload: The message body of the SMS Command sent to or from the SIM. For text mode messages, this can be up to 160 characters.
:ivar status:
:ivar direction:
:ivar date_created: The date and time in GMT when the resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
:ivar date_updated: The date and time in GMT when the resource was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
:ivar url: The absolute URL of the SMS Command 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.payload: Optional[str] = payload.get("payload")
self.status: Optional["SmsCommandInstance.Status"] = payload.get("status")
self.direction: Optional["SmsCommandInstance.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[SmsCommandContext] = None
@property
def _proxy(self) -> "SmsCommandContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: SmsCommandContext for this SmsCommandInstance
"""
if self._context is None:
self._context = SmsCommandContext(
self._version,
sid=self._solution["sid"],
)
return self._context
def fetch(self) -> "SmsCommandInstance":
"""
Fetch the SmsCommandInstance
:returns: The fetched SmsCommandInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "SmsCommandInstance":
"""
Asynchronous coroutine to fetch the SmsCommandInstance
:returns: The fetched SmsCommandInstance
"""
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.Supersim.V1.SmsCommandInstance {}>".format(context)
class SmsCommandContext(InstanceContext):
def __init__(self, version: Version, sid: str):
"""
Initialize the SmsCommandContext
:param version: Version that contains the resource
:param sid: The SID of the SMS Command resource to fetch.
"""
super().__init__(version)
# Path Solution
self._solution = {
"sid": sid,
}
self._uri = "/SmsCommands/{sid}".format(**self._solution)
def fetch(self) -> SmsCommandInstance:
"""
Fetch the SmsCommandInstance
:returns: The fetched SmsCommandInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return SmsCommandInstance(
self._version,
payload,
sid=self._solution["sid"],
)
async def fetch_async(self) -> SmsCommandInstance:
"""
Asynchronous coroutine to fetch the SmsCommandInstance
:returns: The fetched SmsCommandInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return SmsCommandInstance(
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.Supersim.V1.SmsCommandContext {}>".format(context)
class SmsCommandPage(Page):
def get_instance(self, payload: Dict[str, Any]) -> SmsCommandInstance:
"""
Build an instance of SmsCommandInstance
:param payload: Payload response from the API
"""
return SmsCommandInstance(self._version, payload)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Supersim.V1.SmsCommandPage>"
class SmsCommandList(ListResource):
def __init__(self, version: Version):
"""
Initialize the SmsCommandList
:param version: Version that contains the resource
"""
super().__init__(version)
self._uri = "/SmsCommands"
def create(
self,
sim: str,
payload: str,
callback_method: Union[str, object] = values.unset,
callback_url: Union[str, object] = values.unset,
) -> SmsCommandInstance:
"""
Create the SmsCommandInstance
:param sim: The `sid` or `unique_name` of the [SIM](https://www.twilio.com/docs/iot/supersim/api/sim-resource) to send the SMS Command to.
:param payload: The message body of the SMS Command.
:param callback_method: The HTTP method we should use to call `callback_url`. Can be: `GET` or `POST` and the default is POST.
:param callback_url: The URL we should call using the `callback_method` after we have sent the command.
:returns: The created SmsCommandInstance
"""
data = values.of(
{
"Sim": sim,
"Payload": payload,
"CallbackMethod": callback_method,
"CallbackUrl": callback_url,
}
)
payload = self._version.create(
method="POST",
uri=self._uri,
data=data,
)
return SmsCommandInstance(self._version, payload)
async def create_async(
self,
sim: str,
payload: str,
callback_method: Union[str, object] = values.unset,
callback_url: Union[str, object] = values.unset,
) -> SmsCommandInstance:
"""
Asynchronously create the SmsCommandInstance
:param sim: The `sid` or `unique_name` of the [SIM](https://www.twilio.com/docs/iot/supersim/api/sim-resource) to send the SMS Command to.
:param payload: The message body of the SMS Command.
:param callback_method: The HTTP method we should use to call `callback_url`. Can be: `GET` or `POST` and the default is POST.
:param callback_url: The URL we should call using the `callback_method` after we have sent the command.
:returns: The created SmsCommandInstance
"""
data = values.of(
{
"Sim": sim,
"Payload": payload,
"CallbackMethod": callback_method,
"CallbackUrl": callback_url,
}
)
payload = await self._version.create_async(
method="POST",
uri=self._uri,
data=data,
)
return SmsCommandInstance(self._version, payload)
def stream(
self,
sim: Union[str, object] = values.unset,
status: Union["SmsCommandInstance.Status", object] = values.unset,
direction: Union["SmsCommandInstance.Direction", object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[SmsCommandInstance]:
"""
Streams SmsCommandInstance 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 resource that SMS Command was sent to or from.
:param &quot;SmsCommandInstance.Status&quot; status: The status of the SMS Command. Can be: `queued`, `sent`, `delivered`, `received` or `failed`. See the [SMS Command Status Values](https://www.twilio.com/docs/iot/supersim/api/smscommand-resource#status-values) for a description of each.
:param &quot;SmsCommandInstance.Direction&quot; direction: The direction of the SMS Command. Can be `to_sim` or `from_sim`. The value of `to_sim` is synonymous with the term `mobile terminated`, and `from_sim` is synonymous with the term `mobile originated`.
: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, 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["SmsCommandInstance.Status", object] = values.unset,
direction: Union["SmsCommandInstance.Direction", object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> AsyncIterator[SmsCommandInstance]:
"""
Asynchronously streams SmsCommandInstance 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 resource that SMS Command was sent to or from.
:param &quot;SmsCommandInstance.Status&quot; status: The status of the SMS Command. Can be: `queued`, `sent`, `delivered`, `received` or `failed`. See the [SMS Command Status Values](https://www.twilio.com/docs/iot/supersim/api/smscommand-resource#status-values) for a description of each.
:param &quot;SmsCommandInstance.Direction&quot; direction: The direction of the SMS Command. Can be `to_sim` or `from_sim`. The value of `to_sim` is synonymous with the term `mobile terminated`, and `from_sim` is synonymous with the term `mobile originated`.
: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, page_size=limits["page_size"]
)
return self._version.stream_async(page, limits["limit"])
def list(
self,
sim: Union[str, object] = values.unset,
status: Union["SmsCommandInstance.Status", object] = values.unset,
direction: Union["SmsCommandInstance.Direction", object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[SmsCommandInstance]:
"""
Lists SmsCommandInstance 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 resource that SMS Command was sent to or from.
:param &quot;SmsCommandInstance.Status&quot; status: The status of the SMS Command. Can be: `queued`, `sent`, `delivered`, `received` or `failed`. See the [SMS Command Status Values](https://www.twilio.com/docs/iot/supersim/api/smscommand-resource#status-values) for a description of each.
:param &quot;SmsCommandInstance.Direction&quot; direction: The direction of the SMS Command. Can be `to_sim` or `from_sim`. The value of `to_sim` is synonymous with the term `mobile terminated`, and `from_sim` is synonymous with the term `mobile originated`.
: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,
limit=limit,
page_size=page_size,
)
)
async def list_async(
self,
sim: Union[str, object] = values.unset,
status: Union["SmsCommandInstance.Status", object] = values.unset,
direction: Union["SmsCommandInstance.Direction", object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[SmsCommandInstance]:
"""
Asynchronously lists SmsCommandInstance 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 resource that SMS Command was sent to or from.
:param &quot;SmsCommandInstance.Status&quot; status: The status of the SMS Command. Can be: `queued`, `sent`, `delivered`, `received` or `failed`. See the [SMS Command Status Values](https://www.twilio.com/docs/iot/supersim/api/smscommand-resource#status-values) for a description of each.
:param &quot;SmsCommandInstance.Direction&quot; direction: The direction of the SMS Command. Can be `to_sim` or `from_sim`. The value of `to_sim` is synonymous with the term `mobile terminated`, and `from_sim` is synonymous with the term `mobile originated`.
: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,
limit=limit,
page_size=page_size,
)
]
def page(
self,
sim: Union[str, object] = values.unset,
status: Union["SmsCommandInstance.Status", object] = values.unset,
direction: Union["SmsCommandInstance.Direction", object] = values.unset,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> SmsCommandPage:
"""
Retrieve a single page of SmsCommandInstance records from the API.
Request is executed immediately
:param sim: The SID or unique name of the Sim resource that SMS Command was sent to or from.
:param status: The status of the SMS Command. Can be: `queued`, `sent`, `delivered`, `received` or `failed`. See the [SMS Command Status Values](https://www.twilio.com/docs/iot/supersim/api/smscommand-resource#status-values) for a description of each.
:param direction: The direction of the SMS Command. Can be `to_sim` or `from_sim`. The value of `to_sim` is synonymous with the term `mobile terminated`, and `from_sim` is synonymous with the term `mobile originated`.
: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 SmsCommandInstance
"""
data = values.of(
{
"Sim": sim,
"Status": status,
"Direction": direction,
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return SmsCommandPage(self._version, response)
async def page_async(
self,
sim: Union[str, object] = values.unset,
status: Union["SmsCommandInstance.Status", object] = values.unset,
direction: Union["SmsCommandInstance.Direction", object] = values.unset,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> SmsCommandPage:
"""
Asynchronously retrieve a single page of SmsCommandInstance records from the API.
Request is executed immediately
:param sim: The SID or unique name of the Sim resource that SMS Command was sent to or from.
:param status: The status of the SMS Command. Can be: `queued`, `sent`, `delivered`, `received` or `failed`. See the [SMS Command Status Values](https://www.twilio.com/docs/iot/supersim/api/smscommand-resource#status-values) for a description of each.
:param direction: The direction of the SMS Command. Can be `to_sim` or `from_sim`. The value of `to_sim` is synonymous with the term `mobile terminated`, and `from_sim` is synonymous with the term `mobile originated`.
: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 SmsCommandInstance
"""
data = values.of(
{
"Sim": sim,
"Status": status,
"Direction": direction,
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = await self._version.page_async(
method="GET", uri=self._uri, params=data
)
return SmsCommandPage(self._version, response)
def get_page(self, target_url: str) -> SmsCommandPage:
"""
Retrieve a specific page of SmsCommandInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of SmsCommandInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return SmsCommandPage(self._version, response)
async def get_page_async(self, target_url: str) -> SmsCommandPage:
"""
Asynchronously retrieve a specific page of SmsCommandInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of SmsCommandInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return SmsCommandPage(self._version, response)
def get(self, sid: str) -> SmsCommandContext:
"""
Constructs a SmsCommandContext
:param sid: The SID of the SMS Command resource to fetch.
"""
return SmsCommandContext(self._version, sid=sid)
def __call__(self, sid: str) -> SmsCommandContext:
"""
Constructs a SmsCommandContext
:param sid: The SID of the SMS Command resource to fetch.
"""
return SmsCommandContext(self._version, sid=sid)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Supersim.V1.SmsCommandList>"
@@ -0,0 +1,446 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Supersim
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_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):
HOUR = "hour"
DAY = "day"
ALL = "all"
class Group(object):
SIM = "sim"
FLEET = "fleet"
NETWORK = "network"
ISOCOUNTRY = "isoCountry"
"""
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that incurred the usage.
:ivar sim_sid: SID of a Sim resource to which the UsageRecord belongs. Value will only be present when either a value for the `Sim` query parameter is provided or when UsageRecords are grouped by `sim`. Otherwise, the value will be `null`.
:ivar network_sid: SID of the Network resource the usage occurred on. Value will only be present when either a value for the `Network` query parameter is provided or when UsageRecords are grouped by `network`. Otherwise, the value will be `null`.
:ivar fleet_sid: SID of the Fleet resource the usage occurred on. Value will only be present when either a value for the `Fleet` query parameter is provided or when UsageRecords are grouped by `fleet`. Otherwise, the value will be `null`.
:ivar iso_country: Alpha-2 ISO Country Code that the usage occurred in. Value will only be present when either a value for the `IsoCountry` query parameter is provided or when UsageRecords are grouped by `isoCountry`. Otherwise, the value will be `null`.
:ivar period: The time period for which the usage is reported. The period is represented as a pair of `start_time` and `end_time` timestamps specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
:ivar data_upload: Total data uploaded in bytes, aggregated by the query parameters.
:ivar data_download: Total data downloaded in bytes, aggregated by the query parameters.
:ivar data_total: Total of data_upload and data_download.
:ivar data_total_billed: Total amount in the `billed_unit` that was charged for the data uploaded or downloaded. Will return 0 for usage prior to February 1, 2022. Value may be 0 despite `data_total` being greater than 0 if the data usage is still being processed by Twilio's billing system. Refer to [Data Usage Processing](https://www.twilio.com/docs/iot/supersim/api/usage-record-resource#data-usage-processing) for more details.
:ivar billed_unit: The currency in which the billed amounts are measured, specified in the 3 letter ISO 4127 format (e.g. `USD`, `EUR`, `JPY`). This can be null when data_toal_billed is 0 and we do not yet have billing information for the corresponding data usage. Refer to [Data Usage Processing](https://www.twilio.com/docs/iot/supersim/api/usage-record-resource#data-usage-processing) for more details.
"""
def __init__(self, version: Version, payload: Dict[str, Any]):
super().__init__(version)
self.account_sid: Optional[str] = payload.get("account_sid")
self.sim_sid: Optional[str] = payload.get("sim_sid")
self.network_sid: Optional[str] = payload.get("network_sid")
self.fleet_sid: Optional[str] = payload.get("fleet_sid")
self.iso_country: Optional[str] = payload.get("iso_country")
self.period: Optional[Dict[str, object]] = payload.get("period")
self.data_upload: Optional[int] = payload.get("data_upload")
self.data_download: Optional[int] = payload.get("data_download")
self.data_total: Optional[int] = payload.get("data_total")
self.data_total_billed: Optional[float] = deserialize.decimal(
payload.get("data_total_billed")
)
self.billed_unit: Optional[str] = payload.get("billed_unit")
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Supersim.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.Supersim.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,
sim: Union[str, object] = values.unset,
fleet: Union[str, object] = values.unset,
network: Union[str, object] = values.unset,
iso_country: Union[str, object] = values.unset,
group: Union["UsageRecordInstance.Group", object] = values.unset,
granularity: Union["UsageRecordInstance.Granularity", object] = values.unset,
start_time: Union[datetime, object] = values.unset,
end_time: Union[datetime, 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 str sim: SID or unique name of a Sim resource. Only show UsageRecords representing usage incurred by this Super SIM.
:param str fleet: SID or unique name of a Fleet resource. Only show UsageRecords representing usage for Super SIMs belonging to this Fleet resource at the time the usage occurred.
:param str network: SID of a Network resource. Only show UsageRecords representing usage on this network.
:param str iso_country: Alpha-2 ISO Country Code. Only show UsageRecords representing usage in this country.
:param &quot;UsageRecordInstance.Group&quot; group: Dimension over which to aggregate usage records. Can be: `sim`, `fleet`, `network`, `isoCountry`. Default is to not aggregate across any of these dimensions, UsageRecords will be aggregated into the time buckets described by the `Granularity` parameter.
:param &quot;UsageRecordInstance.Granularity&quot; granularity: Time-based grouping that UsageRecords should be aggregated by. Can be: `hour`, `day`, or `all`. Default is `all`. `all` returns one UsageRecord that describes the usage for the entire period.
:param datetime start_time: Only include usage that occurred at or after this time, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. Default is one month before the `end_time`.
:param datetime end_time: Only include usage that occurred before this time (exclusive), specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. Default is the current time.
: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,
fleet=fleet,
network=network,
iso_country=iso_country,
group=group,
granularity=granularity,
start_time=start_time,
end_time=end_time,
page_size=limits["page_size"],
)
return self._version.stream(page, limits["limit"])
async def stream_async(
self,
sim: Union[str, object] = values.unset,
fleet: Union[str, object] = values.unset,
network: Union[str, object] = values.unset,
iso_country: Union[str, object] = values.unset,
group: Union["UsageRecordInstance.Group", object] = values.unset,
granularity: Union["UsageRecordInstance.Granularity", object] = values.unset,
start_time: Union[datetime, object] = values.unset,
end_time: Union[datetime, 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 str sim: SID or unique name of a Sim resource. Only show UsageRecords representing usage incurred by this Super SIM.
:param str fleet: SID or unique name of a Fleet resource. Only show UsageRecords representing usage for Super SIMs belonging to this Fleet resource at the time the usage occurred.
:param str network: SID of a Network resource. Only show UsageRecords representing usage on this network.
:param str iso_country: Alpha-2 ISO Country Code. Only show UsageRecords representing usage in this country.
:param &quot;UsageRecordInstance.Group&quot; group: Dimension over which to aggregate usage records. Can be: `sim`, `fleet`, `network`, `isoCountry`. Default is to not aggregate across any of these dimensions, UsageRecords will be aggregated into the time buckets described by the `Granularity` parameter.
:param &quot;UsageRecordInstance.Granularity&quot; granularity: Time-based grouping that UsageRecords should be aggregated by. Can be: `hour`, `day`, or `all`. Default is `all`. `all` returns one UsageRecord that describes the usage for the entire period.
:param datetime start_time: Only include usage that occurred at or after this time, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. Default is one month before the `end_time`.
:param datetime end_time: Only include usage that occurred before this time (exclusive), specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. Default is the current time.
: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,
fleet=fleet,
network=network,
iso_country=iso_country,
group=group,
granularity=granularity,
start_time=start_time,
end_time=end_time,
page_size=limits["page_size"],
)
return self._version.stream_async(page, limits["limit"])
def list(
self,
sim: Union[str, object] = values.unset,
fleet: Union[str, object] = values.unset,
network: Union[str, object] = values.unset,
iso_country: Union[str, object] = values.unset,
group: Union["UsageRecordInstance.Group", object] = values.unset,
granularity: Union["UsageRecordInstance.Granularity", object] = values.unset,
start_time: Union[datetime, object] = values.unset,
end_time: Union[datetime, 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 str sim: SID or unique name of a Sim resource. Only show UsageRecords representing usage incurred by this Super SIM.
:param str fleet: SID or unique name of a Fleet resource. Only show UsageRecords representing usage for Super SIMs belonging to this Fleet resource at the time the usage occurred.
:param str network: SID of a Network resource. Only show UsageRecords representing usage on this network.
:param str iso_country: Alpha-2 ISO Country Code. Only show UsageRecords representing usage in this country.
:param &quot;UsageRecordInstance.Group&quot; group: Dimension over which to aggregate usage records. Can be: `sim`, `fleet`, `network`, `isoCountry`. Default is to not aggregate across any of these dimensions, UsageRecords will be aggregated into the time buckets described by the `Granularity` parameter.
:param &quot;UsageRecordInstance.Granularity&quot; granularity: Time-based grouping that UsageRecords should be aggregated by. Can be: `hour`, `day`, or `all`. Default is `all`. `all` returns one UsageRecord that describes the usage for the entire period.
:param datetime start_time: Only include usage that occurred at or after this time, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. Default is one month before the `end_time`.
:param datetime end_time: Only include usage that occurred before this time (exclusive), specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. Default is the current time.
: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,
fleet=fleet,
network=network,
iso_country=iso_country,
group=group,
granularity=granularity,
start_time=start_time,
end_time=end_time,
limit=limit,
page_size=page_size,
)
)
async def list_async(
self,
sim: Union[str, object] = values.unset,
fleet: Union[str, object] = values.unset,
network: Union[str, object] = values.unset,
iso_country: Union[str, object] = values.unset,
group: Union["UsageRecordInstance.Group", object] = values.unset,
granularity: Union["UsageRecordInstance.Granularity", object] = values.unset,
start_time: Union[datetime, object] = values.unset,
end_time: Union[datetime, 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 str sim: SID or unique name of a Sim resource. Only show UsageRecords representing usage incurred by this Super SIM.
:param str fleet: SID or unique name of a Fleet resource. Only show UsageRecords representing usage for Super SIMs belonging to this Fleet resource at the time the usage occurred.
:param str network: SID of a Network resource. Only show UsageRecords representing usage on this network.
:param str iso_country: Alpha-2 ISO Country Code. Only show UsageRecords representing usage in this country.
:param &quot;UsageRecordInstance.Group&quot; group: Dimension over which to aggregate usage records. Can be: `sim`, `fleet`, `network`, `isoCountry`. Default is to not aggregate across any of these dimensions, UsageRecords will be aggregated into the time buckets described by the `Granularity` parameter.
:param &quot;UsageRecordInstance.Granularity&quot; granularity: Time-based grouping that UsageRecords should be aggregated by. Can be: `hour`, `day`, or `all`. Default is `all`. `all` returns one UsageRecord that describes the usage for the entire period.
:param datetime start_time: Only include usage that occurred at or after this time, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. Default is one month before the `end_time`.
:param datetime end_time: Only include usage that occurred before this time (exclusive), specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. Default is the current time.
: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,
fleet=fleet,
network=network,
iso_country=iso_country,
group=group,
granularity=granularity,
start_time=start_time,
end_time=end_time,
limit=limit,
page_size=page_size,
)
]
def page(
self,
sim: Union[str, object] = values.unset,
fleet: Union[str, object] = values.unset,
network: Union[str, object] = values.unset,
iso_country: Union[str, object] = values.unset,
group: Union["UsageRecordInstance.Group", object] = values.unset,
granularity: Union["UsageRecordInstance.Granularity", object] = values.unset,
start_time: Union[datetime, object] = values.unset,
end_time: Union[datetime, object] = values.unset,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> UsageRecordPage:
"""
Retrieve a single page of UsageRecordInstance records from the API.
Request is executed immediately
:param sim: SID or unique name of a Sim resource. Only show UsageRecords representing usage incurred by this Super SIM.
:param fleet: SID or unique name of a Fleet resource. Only show UsageRecords representing usage for Super SIMs belonging to this Fleet resource at the time the usage occurred.
:param network: SID of a Network resource. Only show UsageRecords representing usage on this network.
:param iso_country: Alpha-2 ISO Country Code. Only show UsageRecords representing usage in this country.
:param group: Dimension over which to aggregate usage records. Can be: `sim`, `fleet`, `network`, `isoCountry`. Default is to not aggregate across any of these dimensions, UsageRecords will be aggregated into the time buckets described by the `Granularity` parameter.
:param granularity: Time-based grouping that UsageRecords should be aggregated by. Can be: `hour`, `day`, or `all`. Default is `all`. `all` returns one UsageRecord that describes the usage for the entire period.
:param start_time: Only include usage that occurred at or after this time, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. Default is one month before the `end_time`.
:param end_time: Only include usage that occurred before this time (exclusive), specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. Default is the current time.
: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(
{
"Sim": sim,
"Fleet": fleet,
"Network": network,
"IsoCountry": iso_country,
"Group": group,
"Granularity": granularity,
"StartTime": serialize.iso8601_datetime(start_time),
"EndTime": serialize.iso8601_datetime(end_time),
"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,
sim: Union[str, object] = values.unset,
fleet: Union[str, object] = values.unset,
network: Union[str, object] = values.unset,
iso_country: Union[str, object] = values.unset,
group: Union["UsageRecordInstance.Group", object] = values.unset,
granularity: Union["UsageRecordInstance.Granularity", object] = values.unset,
start_time: Union[datetime, object] = values.unset,
end_time: Union[datetime, object] = values.unset,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> UsageRecordPage:
"""
Asynchronously retrieve a single page of UsageRecordInstance records from the API.
Request is executed immediately
:param sim: SID or unique name of a Sim resource. Only show UsageRecords representing usage incurred by this Super SIM.
:param fleet: SID or unique name of a Fleet resource. Only show UsageRecords representing usage for Super SIMs belonging to this Fleet resource at the time the usage occurred.
:param network: SID of a Network resource. Only show UsageRecords representing usage on this network.
:param iso_country: Alpha-2 ISO Country Code. Only show UsageRecords representing usage in this country.
:param group: Dimension over which to aggregate usage records. Can be: `sim`, `fleet`, `network`, `isoCountry`. Default is to not aggregate across any of these dimensions, UsageRecords will be aggregated into the time buckets described by the `Granularity` parameter.
:param granularity: Time-based grouping that UsageRecords should be aggregated by. Can be: `hour`, `day`, or `all`. Default is `all`. `all` returns one UsageRecord that describes the usage for the entire period.
:param start_time: Only include usage that occurred at or after this time, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. Default is one month before the `end_time`.
:param end_time: Only include usage that occurred before this time (exclusive), specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. Default is the current time.
: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(
{
"Sim": sim,
"Fleet": fleet,
"Network": network,
"IsoCountry": iso_country,
"Group": group,
"Granularity": granularity,
"StartTime": serialize.iso8601_datetime(start_time),
"EndTime": serialize.iso8601_datetime(end_time),
"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.Supersim.V1.UsageRecordList>"