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.microvisor.v1 import V1
class MicrovisorBase(Domain):
def __init__(self, twilio: Client):
"""
Initialize the Microvisor Domain
:returns: Domain for Microvisor
"""
super().__init__(twilio, "https://microvisor.twilio.com")
self._v1: Optional[V1] = None
@property
def v1(self) -> V1:
"""
:returns: Versions v1 of Microvisor
"""
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.Microvisor>"
@@ -0,0 +1,43 @@
from warnings import warn
from twilio.rest.microvisor.MicrovisorBase import MicrovisorBase
from twilio.rest.microvisor.v1.account_config import AccountConfigList
from twilio.rest.microvisor.v1.account_secret import AccountSecretList
from twilio.rest.microvisor.v1.app import AppList
from twilio.rest.microvisor.v1.device import DeviceList
class Microvisor(MicrovisorBase):
@property
def account_configs(self) -> AccountConfigList:
warn(
"account_configs is deprecated. Use v1.account_configs instead.",
DeprecationWarning,
stacklevel=2,
)
return self.v1.account_configs
@property
def account_secrets(self) -> AccountSecretList:
warn(
"account_secrets is deprecated. Use v1.account_secrets instead.",
DeprecationWarning,
stacklevel=2,
)
return self.v1.account_secrets
@property
def apps(self) -> AppList:
warn(
"apps is deprecated. Use v1.apps instead.", DeprecationWarning, stacklevel=2
)
return self.v1.apps
@property
def devices(self) -> DeviceList:
warn(
"devices is deprecated. Use v1.devices instead.",
DeprecationWarning,
stacklevel=2,
)
return self.v1.devices
@@ -0,0 +1,66 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Microvisor
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.microvisor.v1.account_config import AccountConfigList
from twilio.rest.microvisor.v1.account_secret import AccountSecretList
from twilio.rest.microvisor.v1.app import AppList
from twilio.rest.microvisor.v1.device import DeviceList
class V1(Version):
def __init__(self, domain: Domain):
"""
Initialize the V1 version of Microvisor
:param domain: The Twilio.microvisor domain
"""
super().__init__(domain, "v1")
self._account_configs: Optional[AccountConfigList] = None
self._account_secrets: Optional[AccountSecretList] = None
self._apps: Optional[AppList] = None
self._devices: Optional[DeviceList] = None
@property
def account_configs(self) -> AccountConfigList:
if self._account_configs is None:
self._account_configs = AccountConfigList(self)
return self._account_configs
@property
def account_secrets(self) -> AccountSecretList:
if self._account_secrets is None:
self._account_secrets = AccountSecretList(self)
return self._account_secrets
@property
def apps(self) -> AppList:
if self._apps is None:
self._apps = AppList(self)
return self._apps
@property
def devices(self) -> DeviceList:
if self._devices is None:
self._devices = DeviceList(self)
return self._devices
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Microvisor.V1>"
@@ -0,0 +1,552 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Microvisor
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 AccountConfigInstance(InstanceResource):
"""
:ivar key: The config key; up to 100 characters.
:ivar date_updated:
:ivar value: The config value; up to 4096 characters.
:ivar url: The absolute URL of the Config.
"""
def __init__(
self, version: Version, payload: Dict[str, Any], key: Optional[str] = None
):
super().__init__(version)
self.key: Optional[str] = payload.get("key")
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_updated")
)
self.value: Optional[str] = payload.get("value")
self.url: Optional[str] = payload.get("url")
self._solution = {
"key": key or self.key,
}
self._context: Optional[AccountConfigContext] = None
@property
def _proxy(self) -> "AccountConfigContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: AccountConfigContext for this AccountConfigInstance
"""
if self._context is None:
self._context = AccountConfigContext(
self._version,
key=self._solution["key"],
)
return self._context
def delete(self) -> bool:
"""
Deletes the AccountConfigInstance
:returns: True if delete succeeds, False otherwise
"""
return self._proxy.delete()
async def delete_async(self) -> bool:
"""
Asynchronous coroutine that deletes the AccountConfigInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._proxy.delete_async()
def fetch(self) -> "AccountConfigInstance":
"""
Fetch the AccountConfigInstance
:returns: The fetched AccountConfigInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "AccountConfigInstance":
"""
Asynchronous coroutine to fetch the AccountConfigInstance
:returns: The fetched AccountConfigInstance
"""
return await self._proxy.fetch_async()
def update(self, value: str) -> "AccountConfigInstance":
"""
Update the AccountConfigInstance
:param value: The config value; up to 4096 characters.
:returns: The updated AccountConfigInstance
"""
return self._proxy.update(
value=value,
)
async def update_async(self, value: str) -> "AccountConfigInstance":
"""
Asynchronous coroutine to update the AccountConfigInstance
:param value: The config value; up to 4096 characters.
:returns: The updated AccountConfigInstance
"""
return await self._proxy.update_async(
value=value,
)
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.Microvisor.V1.AccountConfigInstance {}>".format(context)
class AccountConfigContext(InstanceContext):
def __init__(self, version: Version, key: str):
"""
Initialize the AccountConfigContext
:param version: Version that contains the resource
:param key: The config key; up to 100 characters.
"""
super().__init__(version)
# Path Solution
self._solution = {
"key": key,
}
self._uri = "/Configs/{key}".format(**self._solution)
def delete(self) -> bool:
"""
Deletes the AccountConfigInstance
: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 AccountConfigInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._version.delete_async(
method="DELETE",
uri=self._uri,
)
def fetch(self) -> AccountConfigInstance:
"""
Fetch the AccountConfigInstance
:returns: The fetched AccountConfigInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return AccountConfigInstance(
self._version,
payload,
key=self._solution["key"],
)
async def fetch_async(self) -> AccountConfigInstance:
"""
Asynchronous coroutine to fetch the AccountConfigInstance
:returns: The fetched AccountConfigInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return AccountConfigInstance(
self._version,
payload,
key=self._solution["key"],
)
def update(self, value: str) -> AccountConfigInstance:
"""
Update the AccountConfigInstance
:param value: The config value; up to 4096 characters.
:returns: The updated AccountConfigInstance
"""
data = values.of(
{
"Value": value,
}
)
payload = self._version.update(
method="POST",
uri=self._uri,
data=data,
)
return AccountConfigInstance(self._version, payload, key=self._solution["key"])
async def update_async(self, value: str) -> AccountConfigInstance:
"""
Asynchronous coroutine to update the AccountConfigInstance
:param value: The config value; up to 4096 characters.
:returns: The updated AccountConfigInstance
"""
data = values.of(
{
"Value": value,
}
)
payload = await self._version.update_async(
method="POST",
uri=self._uri,
data=data,
)
return AccountConfigInstance(self._version, payload, key=self._solution["key"])
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Microvisor.V1.AccountConfigContext {}>".format(context)
class AccountConfigPage(Page):
def get_instance(self, payload: Dict[str, Any]) -> AccountConfigInstance:
"""
Build an instance of AccountConfigInstance
:param payload: Payload response from the API
"""
return AccountConfigInstance(self._version, payload)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Microvisor.V1.AccountConfigPage>"
class AccountConfigList(ListResource):
def __init__(self, version: Version):
"""
Initialize the AccountConfigList
:param version: Version that contains the resource
"""
super().__init__(version)
self._uri = "/Configs"
def create(self, key: str, value: str) -> AccountConfigInstance:
"""
Create the AccountConfigInstance
:param key: The config key; up to 100 characters.
:param value: The config value; up to 4096 characters.
:returns: The created AccountConfigInstance
"""
data = values.of(
{
"Key": key,
"Value": value,
}
)
payload = self._version.create(
method="POST",
uri=self._uri,
data=data,
)
return AccountConfigInstance(self._version, payload)
async def create_async(self, key: str, value: str) -> AccountConfigInstance:
"""
Asynchronously create the AccountConfigInstance
:param key: The config key; up to 100 characters.
:param value: The config value; up to 4096 characters.
:returns: The created AccountConfigInstance
"""
data = values.of(
{
"Key": key,
"Value": value,
}
)
payload = await self._version.create_async(
method="POST",
uri=self._uri,
data=data,
)
return AccountConfigInstance(self._version, payload)
def stream(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[AccountConfigInstance]:
"""
Streams AccountConfigInstance 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[AccountConfigInstance]:
"""
Asynchronously streams AccountConfigInstance 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[AccountConfigInstance]:
"""
Lists AccountConfigInstance 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[AccountConfigInstance]:
"""
Asynchronously lists AccountConfigInstance 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,
) -> AccountConfigPage:
"""
Retrieve a single page of AccountConfigInstance 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 AccountConfigInstance
"""
data = values.of(
{
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return AccountConfigPage(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,
) -> AccountConfigPage:
"""
Asynchronously retrieve a single page of AccountConfigInstance 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 AccountConfigInstance
"""
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 AccountConfigPage(self._version, response)
def get_page(self, target_url: str) -> AccountConfigPage:
"""
Retrieve a specific page of AccountConfigInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of AccountConfigInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return AccountConfigPage(self._version, response)
async def get_page_async(self, target_url: str) -> AccountConfigPage:
"""
Asynchronously retrieve a specific page of AccountConfigInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of AccountConfigInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return AccountConfigPage(self._version, response)
def get(self, key: str) -> AccountConfigContext:
"""
Constructs a AccountConfigContext
:param key: The config key; up to 100 characters.
"""
return AccountConfigContext(self._version, key=key)
def __call__(self, key: str) -> AccountConfigContext:
"""
Constructs a AccountConfigContext
:param key: The config key; up to 100 characters.
"""
return AccountConfigContext(self._version, key=key)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Microvisor.V1.AccountConfigList>"
@@ -0,0 +1,550 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Microvisor
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 AccountSecretInstance(InstanceResource):
"""
:ivar key: The secret key; up to 100 characters.
:ivar date_rotated:
:ivar url: The absolute URL of the Secret.
"""
def __init__(
self, version: Version, payload: Dict[str, Any], key: Optional[str] = None
):
super().__init__(version)
self.key: Optional[str] = payload.get("key")
self.date_rotated: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_rotated")
)
self.url: Optional[str] = payload.get("url")
self._solution = {
"key": key or self.key,
}
self._context: Optional[AccountSecretContext] = None
@property
def _proxy(self) -> "AccountSecretContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: AccountSecretContext for this AccountSecretInstance
"""
if self._context is None:
self._context = AccountSecretContext(
self._version,
key=self._solution["key"],
)
return self._context
def delete(self) -> bool:
"""
Deletes the AccountSecretInstance
:returns: True if delete succeeds, False otherwise
"""
return self._proxy.delete()
async def delete_async(self) -> bool:
"""
Asynchronous coroutine that deletes the AccountSecretInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._proxy.delete_async()
def fetch(self) -> "AccountSecretInstance":
"""
Fetch the AccountSecretInstance
:returns: The fetched AccountSecretInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "AccountSecretInstance":
"""
Asynchronous coroutine to fetch the AccountSecretInstance
:returns: The fetched AccountSecretInstance
"""
return await self._proxy.fetch_async()
def update(self, value: str) -> "AccountSecretInstance":
"""
Update the AccountSecretInstance
:param value: The secret value; up to 4096 characters.
:returns: The updated AccountSecretInstance
"""
return self._proxy.update(
value=value,
)
async def update_async(self, value: str) -> "AccountSecretInstance":
"""
Asynchronous coroutine to update the AccountSecretInstance
:param value: The secret value; up to 4096 characters.
:returns: The updated AccountSecretInstance
"""
return await self._proxy.update_async(
value=value,
)
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.Microvisor.V1.AccountSecretInstance {}>".format(context)
class AccountSecretContext(InstanceContext):
def __init__(self, version: Version, key: str):
"""
Initialize the AccountSecretContext
:param version: Version that contains the resource
:param key: The secret key; up to 100 characters.
"""
super().__init__(version)
# Path Solution
self._solution = {
"key": key,
}
self._uri = "/Secrets/{key}".format(**self._solution)
def delete(self) -> bool:
"""
Deletes the AccountSecretInstance
: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 AccountSecretInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._version.delete_async(
method="DELETE",
uri=self._uri,
)
def fetch(self) -> AccountSecretInstance:
"""
Fetch the AccountSecretInstance
:returns: The fetched AccountSecretInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return AccountSecretInstance(
self._version,
payload,
key=self._solution["key"],
)
async def fetch_async(self) -> AccountSecretInstance:
"""
Asynchronous coroutine to fetch the AccountSecretInstance
:returns: The fetched AccountSecretInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return AccountSecretInstance(
self._version,
payload,
key=self._solution["key"],
)
def update(self, value: str) -> AccountSecretInstance:
"""
Update the AccountSecretInstance
:param value: The secret value; up to 4096 characters.
:returns: The updated AccountSecretInstance
"""
data = values.of(
{
"Value": value,
}
)
payload = self._version.update(
method="POST",
uri=self._uri,
data=data,
)
return AccountSecretInstance(self._version, payload, key=self._solution["key"])
async def update_async(self, value: str) -> AccountSecretInstance:
"""
Asynchronous coroutine to update the AccountSecretInstance
:param value: The secret value; up to 4096 characters.
:returns: The updated AccountSecretInstance
"""
data = values.of(
{
"Value": value,
}
)
payload = await self._version.update_async(
method="POST",
uri=self._uri,
data=data,
)
return AccountSecretInstance(self._version, payload, key=self._solution["key"])
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Microvisor.V1.AccountSecretContext {}>".format(context)
class AccountSecretPage(Page):
def get_instance(self, payload: Dict[str, Any]) -> AccountSecretInstance:
"""
Build an instance of AccountSecretInstance
:param payload: Payload response from the API
"""
return AccountSecretInstance(self._version, payload)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Microvisor.V1.AccountSecretPage>"
class AccountSecretList(ListResource):
def __init__(self, version: Version):
"""
Initialize the AccountSecretList
:param version: Version that contains the resource
"""
super().__init__(version)
self._uri = "/Secrets"
def create(self, key: str, value: str) -> AccountSecretInstance:
"""
Create the AccountSecretInstance
:param key: The secret key; up to 100 characters.
:param value: The secret value; up to 4096 characters.
:returns: The created AccountSecretInstance
"""
data = values.of(
{
"Key": key,
"Value": value,
}
)
payload = self._version.create(
method="POST",
uri=self._uri,
data=data,
)
return AccountSecretInstance(self._version, payload)
async def create_async(self, key: str, value: str) -> AccountSecretInstance:
"""
Asynchronously create the AccountSecretInstance
:param key: The secret key; up to 100 characters.
:param value: The secret value; up to 4096 characters.
:returns: The created AccountSecretInstance
"""
data = values.of(
{
"Key": key,
"Value": value,
}
)
payload = await self._version.create_async(
method="POST",
uri=self._uri,
data=data,
)
return AccountSecretInstance(self._version, payload)
def stream(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[AccountSecretInstance]:
"""
Streams AccountSecretInstance 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[AccountSecretInstance]:
"""
Asynchronously streams AccountSecretInstance 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[AccountSecretInstance]:
"""
Lists AccountSecretInstance 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[AccountSecretInstance]:
"""
Asynchronously lists AccountSecretInstance 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,
) -> AccountSecretPage:
"""
Retrieve a single page of AccountSecretInstance 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 AccountSecretInstance
"""
data = values.of(
{
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return AccountSecretPage(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,
) -> AccountSecretPage:
"""
Asynchronously retrieve a single page of AccountSecretInstance 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 AccountSecretInstance
"""
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 AccountSecretPage(self._version, response)
def get_page(self, target_url: str) -> AccountSecretPage:
"""
Retrieve a specific page of AccountSecretInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of AccountSecretInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return AccountSecretPage(self._version, response)
async def get_page_async(self, target_url: str) -> AccountSecretPage:
"""
Asynchronously retrieve a specific page of AccountSecretInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of AccountSecretInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return AccountSecretPage(self._version, response)
def get(self, key: str) -> AccountSecretContext:
"""
Constructs a AccountSecretContext
:param key: The secret key; up to 100 characters.
"""
return AccountSecretContext(self._version, key=key)
def __call__(self, key: str) -> AccountSecretContext:
"""
Constructs a AccountSecretContext
:param key: The secret key; up to 100 characters.
"""
return AccountSecretContext(self._version, key=key)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Microvisor.V1.AccountSecretList>"
@@ -0,0 +1,468 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Microvisor
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.microvisor.v1.app.app_manifest import AppManifestList
class AppInstance(InstanceResource):
"""
:ivar sid: A 34-character string that uniquely identifies this App.
:ivar account_sid: The unique SID identifier of the Account.
:ivar hash: App manifest hash represented as `hash_algorithm:hash_value`.
:ivar unique_name: A developer-defined string that uniquely identifies the App. This value must be unique for all Apps on this Account. The `unique_name` value may be used as an alternative to the `sid` in the URL path to address the resource.
:ivar date_created: The date that this App was created, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
:ivar date_updated: The date that this App was last updated, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
:ivar url: The URL of this 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.account_sid: Optional[str] = payload.get("account_sid")
self.hash: Optional[str] = payload.get("hash")
self.unique_name: Optional[str] = payload.get("unique_name")
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_created")
)
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_updated")
)
self.url: Optional[str] = payload.get("url")
self.links: Optional[Dict[str, object]] = payload.get("links")
self._solution = {
"sid": sid or self.sid,
}
self._context: Optional[AppContext] = None
@property
def _proxy(self) -> "AppContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: AppContext for this AppInstance
"""
if self._context is None:
self._context = AppContext(
self._version,
sid=self._solution["sid"],
)
return self._context
def delete(self) -> bool:
"""
Deletes the AppInstance
:returns: True if delete succeeds, False otherwise
"""
return self._proxy.delete()
async def delete_async(self) -> bool:
"""
Asynchronous coroutine that deletes the AppInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._proxy.delete_async()
def fetch(self) -> "AppInstance":
"""
Fetch the AppInstance
:returns: The fetched AppInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "AppInstance":
"""
Asynchronous coroutine to fetch the AppInstance
:returns: The fetched AppInstance
"""
return await self._proxy.fetch_async()
@property
def app_manifests(self) -> AppManifestList:
"""
Access the app_manifests
"""
return self._proxy.app_manifests
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.Microvisor.V1.AppInstance {}>".format(context)
class AppContext(InstanceContext):
def __init__(self, version: Version, sid: str):
"""
Initialize the AppContext
:param version: Version that contains the resource
:param sid: A 34-character string that uniquely identifies this App.
"""
super().__init__(version)
# Path Solution
self._solution = {
"sid": sid,
}
self._uri = "/Apps/{sid}".format(**self._solution)
self._app_manifests: Optional[AppManifestList] = None
def delete(self) -> bool:
"""
Deletes the AppInstance
: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 AppInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._version.delete_async(
method="DELETE",
uri=self._uri,
)
def fetch(self) -> AppInstance:
"""
Fetch the AppInstance
:returns: The fetched AppInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return AppInstance(
self._version,
payload,
sid=self._solution["sid"],
)
async def fetch_async(self) -> AppInstance:
"""
Asynchronous coroutine to fetch the AppInstance
:returns: The fetched AppInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return AppInstance(
self._version,
payload,
sid=self._solution["sid"],
)
@property
def app_manifests(self) -> AppManifestList:
"""
Access the app_manifests
"""
if self._app_manifests is None:
self._app_manifests = AppManifestList(
self._version,
self._solution["sid"],
)
return self._app_manifests
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.Microvisor.V1.AppContext {}>".format(context)
class AppPage(Page):
def get_instance(self, payload: Dict[str, Any]) -> AppInstance:
"""
Build an instance of AppInstance
:param payload: Payload response from the API
"""
return AppInstance(self._version, payload)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Microvisor.V1.AppPage>"
class AppList(ListResource):
def __init__(self, version: Version):
"""
Initialize the AppList
:param version: Version that contains the resource
"""
super().__init__(version)
self._uri = "/Apps"
def stream(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[AppInstance]:
"""
Streams AppInstance 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[AppInstance]:
"""
Asynchronously streams AppInstance 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[AppInstance]:
"""
Lists AppInstance 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[AppInstance]:
"""
Asynchronously lists AppInstance 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,
) -> AppPage:
"""
Retrieve a single page of AppInstance 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 AppInstance
"""
data = values.of(
{
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return AppPage(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,
) -> AppPage:
"""
Asynchronously retrieve a single page of AppInstance 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 AppInstance
"""
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 AppPage(self._version, response)
def get_page(self, target_url: str) -> AppPage:
"""
Retrieve a specific page of AppInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of AppInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return AppPage(self._version, response)
async def get_page_async(self, target_url: str) -> AppPage:
"""
Asynchronously retrieve a specific page of AppInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of AppInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return AppPage(self._version, response)
def get(self, sid: str) -> AppContext:
"""
Constructs a AppContext
:param sid: A 34-character string that uniquely identifies this App.
"""
return AppContext(self._version, sid=sid)
def __call__(self, sid: str) -> AppContext:
"""
Constructs a AppContext
:param sid: A 34-character string that uniquely identifies this App.
"""
return AppContext(self._version, sid=sid)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Microvisor.V1.AppList>"
@@ -0,0 +1,188 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Microvisor
This is the public Twilio REST API.
NOTE: This class is auto generated by OpenAPI Generator.
https://openapi-generator.tech
Do not edit the class manually.
"""
from typing import Any, Dict, Optional
from twilio.base.instance_context import InstanceContext
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.version import Version
class AppManifestInstance(InstanceResource):
"""
:ivar app_sid: A 34-character string that uniquely identifies this App.
:ivar hash: App manifest hash represented as `hash_algorithm:hash_value`.
:ivar encoded_bytes: The base-64 encoded manifest
:ivar url: The absolute URL of this Manifest.
"""
def __init__(self, version: Version, payload: Dict[str, Any], app_sid: str):
super().__init__(version)
self.app_sid: Optional[str] = payload.get("app_sid")
self.hash: Optional[str] = payload.get("hash")
self.encoded_bytes: Optional[str] = payload.get("encoded_bytes")
self.url: Optional[str] = payload.get("url")
self._solution = {
"app_sid": app_sid,
}
self._context: Optional[AppManifestContext] = None
@property
def _proxy(self) -> "AppManifestContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: AppManifestContext for this AppManifestInstance
"""
if self._context is None:
self._context = AppManifestContext(
self._version,
app_sid=self._solution["app_sid"],
)
return self._context
def fetch(self) -> "AppManifestInstance":
"""
Fetch the AppManifestInstance
:returns: The fetched AppManifestInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "AppManifestInstance":
"""
Asynchronous coroutine to fetch the AppManifestInstance
:returns: The fetched AppManifestInstance
"""
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.Microvisor.V1.AppManifestInstance {}>".format(context)
class AppManifestContext(InstanceContext):
def __init__(self, version: Version, app_sid: str):
"""
Initialize the AppManifestContext
:param version: Version that contains the resource
:param app_sid: A 34-character string that uniquely identifies this App.
"""
super().__init__(version)
# Path Solution
self._solution = {
"app_sid": app_sid,
}
self._uri = "/Apps/{app_sid}/Manifest".format(**self._solution)
def fetch(self) -> AppManifestInstance:
"""
Fetch the AppManifestInstance
:returns: The fetched AppManifestInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return AppManifestInstance(
self._version,
payload,
app_sid=self._solution["app_sid"],
)
async def fetch_async(self) -> AppManifestInstance:
"""
Asynchronous coroutine to fetch the AppManifestInstance
:returns: The fetched AppManifestInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return AppManifestInstance(
self._version,
payload,
app_sid=self._solution["app_sid"],
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Microvisor.V1.AppManifestContext {}>".format(context)
class AppManifestList(ListResource):
def __init__(self, version: Version, app_sid: str):
"""
Initialize the AppManifestList
:param version: Version that contains the resource
:param app_sid: A 34-character string that uniquely identifies this App.
"""
super().__init__(version)
# Path Solution
self._solution = {
"app_sid": app_sid,
}
def get(self) -> AppManifestContext:
"""
Constructs a AppManifestContext
"""
return AppManifestContext(self._version, app_sid=self._solution["app_sid"])
def __call__(self) -> AppManifestContext:
"""
Constructs a AppManifestContext
"""
return AppManifestContext(self._version, app_sid=self._solution["app_sid"])
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Microvisor.V1.AppManifestList>"
@@ -0,0 +1,565 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Microvisor
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.microvisor.v1.device.device_config import DeviceConfigList
from twilio.rest.microvisor.v1.device.device_secret import DeviceSecretList
class DeviceInstance(InstanceResource):
"""
:ivar sid: A 34-character string that uniquely identifies this Device.
:ivar unique_name: A developer-defined string that uniquely identifies the Device. This value must be unique for all Devices on this Account. The `unique_name` value may be used as an alternative to the `sid` in the URL path to address the resource.
:ivar account_sid: The unique SID identifier of the Account.
:ivar app: Information about the target App and the App reported by this Device. Contains the properties `target_sid`, `date_targeted`, `update_status` (one of `up-to-date`, `pending` and `error`), `update_error_code`, `reported_sid` and `date_reported`.
:ivar logging: Object specifying whether application logging is enabled for this Device. Contains the properties `enabled` and `date_expires`.
:ivar date_created: The date that this Device was created, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
:ivar date_updated: The date that this Device was last updated, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
:ivar url: The URL of this resource.
:ivar links: The absolute URLs of related resources.
"""
def __init__(
self, version: Version, payload: Dict[str, Any], sid: Optional[str] = None
):
super().__init__(version)
self.sid: Optional[str] = payload.get("sid")
self.unique_name: Optional[str] = payload.get("unique_name")
self.account_sid: Optional[str] = payload.get("account_sid")
self.app: Optional[Dict[str, object]] = payload.get("app")
self.logging: Optional[Dict[str, object]] = payload.get("logging")
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[DeviceContext] = None
@property
def _proxy(self) -> "DeviceContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: DeviceContext for this DeviceInstance
"""
if self._context is None:
self._context = DeviceContext(
self._version,
sid=self._solution["sid"],
)
return self._context
def fetch(self) -> "DeviceInstance":
"""
Fetch the DeviceInstance
:returns: The fetched DeviceInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "DeviceInstance":
"""
Asynchronous coroutine to fetch the DeviceInstance
:returns: The fetched DeviceInstance
"""
return await self._proxy.fetch_async()
def update(
self,
unique_name: Union[str, object] = values.unset,
target_app: Union[str, object] = values.unset,
logging_enabled: Union[bool, object] = values.unset,
restart_app: Union[bool, object] = values.unset,
) -> "DeviceInstance":
"""
Update the DeviceInstance
:param unique_name: A unique and addressable name to be assigned to this Device by the developer. It may be used in place of the Device SID.
:param target_app: The SID or unique name of the App to be targeted to the Device.
:param logging_enabled: A Boolean flag specifying whether to enable application logging. Logs will be enabled or extended for 24 hours.
:param restart_app: Set to true to restart the App running on the Device.
:returns: The updated DeviceInstance
"""
return self._proxy.update(
unique_name=unique_name,
target_app=target_app,
logging_enabled=logging_enabled,
restart_app=restart_app,
)
async def update_async(
self,
unique_name: Union[str, object] = values.unset,
target_app: Union[str, object] = values.unset,
logging_enabled: Union[bool, object] = values.unset,
restart_app: Union[bool, object] = values.unset,
) -> "DeviceInstance":
"""
Asynchronous coroutine to update the DeviceInstance
:param unique_name: A unique and addressable name to be assigned to this Device by the developer. It may be used in place of the Device SID.
:param target_app: The SID or unique name of the App to be targeted to the Device.
:param logging_enabled: A Boolean flag specifying whether to enable application logging. Logs will be enabled or extended for 24 hours.
:param restart_app: Set to true to restart the App running on the Device.
:returns: The updated DeviceInstance
"""
return await self._proxy.update_async(
unique_name=unique_name,
target_app=target_app,
logging_enabled=logging_enabled,
restart_app=restart_app,
)
@property
def device_configs(self) -> DeviceConfigList:
"""
Access the device_configs
"""
return self._proxy.device_configs
@property
def device_secrets(self) -> DeviceSecretList:
"""
Access the device_secrets
"""
return self._proxy.device_secrets
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.Microvisor.V1.DeviceInstance {}>".format(context)
class DeviceContext(InstanceContext):
def __init__(self, version: Version, sid: str):
"""
Initialize the DeviceContext
:param version: Version that contains the resource
:param sid: A 34-character string that uniquely identifies this Device.
"""
super().__init__(version)
# Path Solution
self._solution = {
"sid": sid,
}
self._uri = "/Devices/{sid}".format(**self._solution)
self._device_configs: Optional[DeviceConfigList] = None
self._device_secrets: Optional[DeviceSecretList] = None
def fetch(self) -> DeviceInstance:
"""
Fetch the DeviceInstance
:returns: The fetched DeviceInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return DeviceInstance(
self._version,
payload,
sid=self._solution["sid"],
)
async def fetch_async(self) -> DeviceInstance:
"""
Asynchronous coroutine to fetch the DeviceInstance
:returns: The fetched DeviceInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return DeviceInstance(
self._version,
payload,
sid=self._solution["sid"],
)
def update(
self,
unique_name: Union[str, object] = values.unset,
target_app: Union[str, object] = values.unset,
logging_enabled: Union[bool, object] = values.unset,
restart_app: Union[bool, object] = values.unset,
) -> DeviceInstance:
"""
Update the DeviceInstance
:param unique_name: A unique and addressable name to be assigned to this Device by the developer. It may be used in place of the Device SID.
:param target_app: The SID or unique name of the App to be targeted to the Device.
:param logging_enabled: A Boolean flag specifying whether to enable application logging. Logs will be enabled or extended for 24 hours.
:param restart_app: Set to true to restart the App running on the Device.
:returns: The updated DeviceInstance
"""
data = values.of(
{
"UniqueName": unique_name,
"TargetApp": target_app,
"LoggingEnabled": logging_enabled,
"RestartApp": restart_app,
}
)
payload = self._version.update(
method="POST",
uri=self._uri,
data=data,
)
return DeviceInstance(self._version, payload, sid=self._solution["sid"])
async def update_async(
self,
unique_name: Union[str, object] = values.unset,
target_app: Union[str, object] = values.unset,
logging_enabled: Union[bool, object] = values.unset,
restart_app: Union[bool, object] = values.unset,
) -> DeviceInstance:
"""
Asynchronous coroutine to update the DeviceInstance
:param unique_name: A unique and addressable name to be assigned to this Device by the developer. It may be used in place of the Device SID.
:param target_app: The SID or unique name of the App to be targeted to the Device.
:param logging_enabled: A Boolean flag specifying whether to enable application logging. Logs will be enabled or extended for 24 hours.
:param restart_app: Set to true to restart the App running on the Device.
:returns: The updated DeviceInstance
"""
data = values.of(
{
"UniqueName": unique_name,
"TargetApp": target_app,
"LoggingEnabled": logging_enabled,
"RestartApp": restart_app,
}
)
payload = await self._version.update_async(
method="POST",
uri=self._uri,
data=data,
)
return DeviceInstance(self._version, payload, sid=self._solution["sid"])
@property
def device_configs(self) -> DeviceConfigList:
"""
Access the device_configs
"""
if self._device_configs is None:
self._device_configs = DeviceConfigList(
self._version,
self._solution["sid"],
)
return self._device_configs
@property
def device_secrets(self) -> DeviceSecretList:
"""
Access the device_secrets
"""
if self._device_secrets is None:
self._device_secrets = DeviceSecretList(
self._version,
self._solution["sid"],
)
return self._device_secrets
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.Microvisor.V1.DeviceContext {}>".format(context)
class DevicePage(Page):
def get_instance(self, payload: Dict[str, Any]) -> DeviceInstance:
"""
Build an instance of DeviceInstance
:param payload: Payload response from the API
"""
return DeviceInstance(self._version, payload)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Microvisor.V1.DevicePage>"
class DeviceList(ListResource):
def __init__(self, version: Version):
"""
Initialize the DeviceList
:param version: Version that contains the resource
"""
super().__init__(version)
self._uri = "/Devices"
def stream(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[DeviceInstance]:
"""
Streams DeviceInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param 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[DeviceInstance]:
"""
Asynchronously streams DeviceInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param 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[DeviceInstance]:
"""
Lists DeviceInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param 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[DeviceInstance]:
"""
Asynchronously lists DeviceInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param 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,
) -> DevicePage:
"""
Retrieve a single page of DeviceInstance 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 DeviceInstance
"""
data = values.of(
{
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return DevicePage(self._version, response)
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,
) -> DevicePage:
"""
Asynchronously retrieve a single page of DeviceInstance 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 DeviceInstance
"""
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 DevicePage(self._version, response)
def get_page(self, target_url: str) -> DevicePage:
"""
Retrieve a specific page of DeviceInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of DeviceInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return DevicePage(self._version, response)
async def get_page_async(self, target_url: str) -> DevicePage:
"""
Asynchronously retrieve a specific page of DeviceInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of DeviceInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return DevicePage(self._version, response)
def get(self, sid: str) -> DeviceContext:
"""
Constructs a DeviceContext
:param sid: A 34-character string that uniquely identifies this Device.
"""
return DeviceContext(self._version, sid=sid)
def __call__(self, sid: str) -> DeviceContext:
"""
Constructs a DeviceContext
:param sid: A 34-character string that uniquely identifies this Device.
"""
return DeviceContext(self._version, sid=sid)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Microvisor.V1.DeviceList>"
@@ -0,0 +1,589 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Microvisor
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 DeviceConfigInstance(InstanceResource):
"""
:ivar device_sid: A 34-character string that uniquely identifies the parent Device.
:ivar key: The config key; up to 100 characters.
:ivar value: The config value; up to 4096 characters.
:ivar date_updated:
:ivar url: The absolute URL of the Config.
"""
def __init__(
self,
version: Version,
payload: Dict[str, Any],
device_sid: str,
key: Optional[str] = None,
):
super().__init__(version)
self.device_sid: Optional[str] = payload.get("device_sid")
self.key: Optional[str] = payload.get("key")
self.value: Optional[str] = payload.get("value")
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_updated")
)
self.url: Optional[str] = payload.get("url")
self._solution = {
"device_sid": device_sid,
"key": key or self.key,
}
self._context: Optional[DeviceConfigContext] = None
@property
def _proxy(self) -> "DeviceConfigContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: DeviceConfigContext for this DeviceConfigInstance
"""
if self._context is None:
self._context = DeviceConfigContext(
self._version,
device_sid=self._solution["device_sid"],
key=self._solution["key"],
)
return self._context
def delete(self) -> bool:
"""
Deletes the DeviceConfigInstance
:returns: True if delete succeeds, False otherwise
"""
return self._proxy.delete()
async def delete_async(self) -> bool:
"""
Asynchronous coroutine that deletes the DeviceConfigInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._proxy.delete_async()
def fetch(self) -> "DeviceConfigInstance":
"""
Fetch the DeviceConfigInstance
:returns: The fetched DeviceConfigInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "DeviceConfigInstance":
"""
Asynchronous coroutine to fetch the DeviceConfigInstance
:returns: The fetched DeviceConfigInstance
"""
return await self._proxy.fetch_async()
def update(self, value: str) -> "DeviceConfigInstance":
"""
Update the DeviceConfigInstance
:param value: The config value; up to 4096 characters.
:returns: The updated DeviceConfigInstance
"""
return self._proxy.update(
value=value,
)
async def update_async(self, value: str) -> "DeviceConfigInstance":
"""
Asynchronous coroutine to update the DeviceConfigInstance
:param value: The config value; up to 4096 characters.
:returns: The updated DeviceConfigInstance
"""
return await self._proxy.update_async(
value=value,
)
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.Microvisor.V1.DeviceConfigInstance {}>".format(context)
class DeviceConfigContext(InstanceContext):
def __init__(self, version: Version, device_sid: str, key: str):
"""
Initialize the DeviceConfigContext
:param version: Version that contains the resource
:param device_sid: A 34-character string that uniquely identifies the Device.
:param key: The config key; up to 100 characters.
"""
super().__init__(version)
# Path Solution
self._solution = {
"device_sid": device_sid,
"key": key,
}
self._uri = "/Devices/{device_sid}/Configs/{key}".format(**self._solution)
def delete(self) -> bool:
"""
Deletes the DeviceConfigInstance
: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 DeviceConfigInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._version.delete_async(
method="DELETE",
uri=self._uri,
)
def fetch(self) -> DeviceConfigInstance:
"""
Fetch the DeviceConfigInstance
:returns: The fetched DeviceConfigInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return DeviceConfigInstance(
self._version,
payload,
device_sid=self._solution["device_sid"],
key=self._solution["key"],
)
async def fetch_async(self) -> DeviceConfigInstance:
"""
Asynchronous coroutine to fetch the DeviceConfigInstance
:returns: The fetched DeviceConfigInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return DeviceConfigInstance(
self._version,
payload,
device_sid=self._solution["device_sid"],
key=self._solution["key"],
)
def update(self, value: str) -> DeviceConfigInstance:
"""
Update the DeviceConfigInstance
:param value: The config value; up to 4096 characters.
:returns: The updated DeviceConfigInstance
"""
data = values.of(
{
"Value": value,
}
)
payload = self._version.update(
method="POST",
uri=self._uri,
data=data,
)
return DeviceConfigInstance(
self._version,
payload,
device_sid=self._solution["device_sid"],
key=self._solution["key"],
)
async def update_async(self, value: str) -> DeviceConfigInstance:
"""
Asynchronous coroutine to update the DeviceConfigInstance
:param value: The config value; up to 4096 characters.
:returns: The updated DeviceConfigInstance
"""
data = values.of(
{
"Value": value,
}
)
payload = await self._version.update_async(
method="POST",
uri=self._uri,
data=data,
)
return DeviceConfigInstance(
self._version,
payload,
device_sid=self._solution["device_sid"],
key=self._solution["key"],
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Microvisor.V1.DeviceConfigContext {}>".format(context)
class DeviceConfigPage(Page):
def get_instance(self, payload: Dict[str, Any]) -> DeviceConfigInstance:
"""
Build an instance of DeviceConfigInstance
:param payload: Payload response from the API
"""
return DeviceConfigInstance(
self._version, payload, device_sid=self._solution["device_sid"]
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Microvisor.V1.DeviceConfigPage>"
class DeviceConfigList(ListResource):
def __init__(self, version: Version, device_sid: str):
"""
Initialize the DeviceConfigList
:param version: Version that contains the resource
:param device_sid: A 34-character string that uniquely identifies the Device.
"""
super().__init__(version)
# Path Solution
self._solution = {
"device_sid": device_sid,
}
self._uri = "/Devices/{device_sid}/Configs".format(**self._solution)
def create(self, key: str, value: str) -> DeviceConfigInstance:
"""
Create the DeviceConfigInstance
:param key: The config key; up to 100 characters.
:param value: The config value; up to 4096 characters.
:returns: The created DeviceConfigInstance
"""
data = values.of(
{
"Key": key,
"Value": value,
}
)
payload = self._version.create(
method="POST",
uri=self._uri,
data=data,
)
return DeviceConfigInstance(
self._version, payload, device_sid=self._solution["device_sid"]
)
async def create_async(self, key: str, value: str) -> DeviceConfigInstance:
"""
Asynchronously create the DeviceConfigInstance
:param key: The config key; up to 100 characters.
:param value: The config value; up to 4096 characters.
:returns: The created DeviceConfigInstance
"""
data = values.of(
{
"Key": key,
"Value": value,
}
)
payload = await self._version.create_async(
method="POST",
uri=self._uri,
data=data,
)
return DeviceConfigInstance(
self._version, payload, device_sid=self._solution["device_sid"]
)
def stream(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[DeviceConfigInstance]:
"""
Streams DeviceConfigInstance 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[DeviceConfigInstance]:
"""
Asynchronously streams DeviceConfigInstance 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[DeviceConfigInstance]:
"""
Lists DeviceConfigInstance 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[DeviceConfigInstance]:
"""
Asynchronously lists DeviceConfigInstance 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,
) -> DeviceConfigPage:
"""
Retrieve a single page of DeviceConfigInstance 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 DeviceConfigInstance
"""
data = values.of(
{
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return DeviceConfigPage(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,
) -> DeviceConfigPage:
"""
Asynchronously retrieve a single page of DeviceConfigInstance 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 DeviceConfigInstance
"""
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 DeviceConfigPage(self._version, response, self._solution)
def get_page(self, target_url: str) -> DeviceConfigPage:
"""
Retrieve a specific page of DeviceConfigInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of DeviceConfigInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return DeviceConfigPage(self._version, response, self._solution)
async def get_page_async(self, target_url: str) -> DeviceConfigPage:
"""
Asynchronously retrieve a specific page of DeviceConfigInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of DeviceConfigInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return DeviceConfigPage(self._version, response, self._solution)
def get(self, key: str) -> DeviceConfigContext:
"""
Constructs a DeviceConfigContext
:param key: The config key; up to 100 characters.
"""
return DeviceConfigContext(
self._version, device_sid=self._solution["device_sid"], key=key
)
def __call__(self, key: str) -> DeviceConfigContext:
"""
Constructs a DeviceConfigContext
:param key: The config key; up to 100 characters.
"""
return DeviceConfigContext(
self._version, device_sid=self._solution["device_sid"], key=key
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Microvisor.V1.DeviceConfigList>"
@@ -0,0 +1,587 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Microvisor
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 DeviceSecretInstance(InstanceResource):
"""
:ivar device_sid: A 34-character string that uniquely identifies the parent Device.
:ivar key: The secret key; up to 100 characters.
:ivar date_rotated:
:ivar url: The absolute URL of the Secret.
"""
def __init__(
self,
version: Version,
payload: Dict[str, Any],
device_sid: str,
key: Optional[str] = None,
):
super().__init__(version)
self.device_sid: Optional[str] = payload.get("device_sid")
self.key: Optional[str] = payload.get("key")
self.date_rotated: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_rotated")
)
self.url: Optional[str] = payload.get("url")
self._solution = {
"device_sid": device_sid,
"key": key or self.key,
}
self._context: Optional[DeviceSecretContext] = None
@property
def _proxy(self) -> "DeviceSecretContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: DeviceSecretContext for this DeviceSecretInstance
"""
if self._context is None:
self._context = DeviceSecretContext(
self._version,
device_sid=self._solution["device_sid"],
key=self._solution["key"],
)
return self._context
def delete(self) -> bool:
"""
Deletes the DeviceSecretInstance
:returns: True if delete succeeds, False otherwise
"""
return self._proxy.delete()
async def delete_async(self) -> bool:
"""
Asynchronous coroutine that deletes the DeviceSecretInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._proxy.delete_async()
def fetch(self) -> "DeviceSecretInstance":
"""
Fetch the DeviceSecretInstance
:returns: The fetched DeviceSecretInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "DeviceSecretInstance":
"""
Asynchronous coroutine to fetch the DeviceSecretInstance
:returns: The fetched DeviceSecretInstance
"""
return await self._proxy.fetch_async()
def update(self, value: str) -> "DeviceSecretInstance":
"""
Update the DeviceSecretInstance
:param value: The secret value; up to 4096 characters.
:returns: The updated DeviceSecretInstance
"""
return self._proxy.update(
value=value,
)
async def update_async(self, value: str) -> "DeviceSecretInstance":
"""
Asynchronous coroutine to update the DeviceSecretInstance
:param value: The secret value; up to 4096 characters.
:returns: The updated DeviceSecretInstance
"""
return await self._proxy.update_async(
value=value,
)
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.Microvisor.V1.DeviceSecretInstance {}>".format(context)
class DeviceSecretContext(InstanceContext):
def __init__(self, version: Version, device_sid: str, key: str):
"""
Initialize the DeviceSecretContext
:param version: Version that contains the resource
:param device_sid: A 34-character string that uniquely identifies the Device.
:param key: The secret key; up to 100 characters.
"""
super().__init__(version)
# Path Solution
self._solution = {
"device_sid": device_sid,
"key": key,
}
self._uri = "/Devices/{device_sid}/Secrets/{key}".format(**self._solution)
def delete(self) -> bool:
"""
Deletes the DeviceSecretInstance
: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 DeviceSecretInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._version.delete_async(
method="DELETE",
uri=self._uri,
)
def fetch(self) -> DeviceSecretInstance:
"""
Fetch the DeviceSecretInstance
:returns: The fetched DeviceSecretInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return DeviceSecretInstance(
self._version,
payload,
device_sid=self._solution["device_sid"],
key=self._solution["key"],
)
async def fetch_async(self) -> DeviceSecretInstance:
"""
Asynchronous coroutine to fetch the DeviceSecretInstance
:returns: The fetched DeviceSecretInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return DeviceSecretInstance(
self._version,
payload,
device_sid=self._solution["device_sid"],
key=self._solution["key"],
)
def update(self, value: str) -> DeviceSecretInstance:
"""
Update the DeviceSecretInstance
:param value: The secret value; up to 4096 characters.
:returns: The updated DeviceSecretInstance
"""
data = values.of(
{
"Value": value,
}
)
payload = self._version.update(
method="POST",
uri=self._uri,
data=data,
)
return DeviceSecretInstance(
self._version,
payload,
device_sid=self._solution["device_sid"],
key=self._solution["key"],
)
async def update_async(self, value: str) -> DeviceSecretInstance:
"""
Asynchronous coroutine to update the DeviceSecretInstance
:param value: The secret value; up to 4096 characters.
:returns: The updated DeviceSecretInstance
"""
data = values.of(
{
"Value": value,
}
)
payload = await self._version.update_async(
method="POST",
uri=self._uri,
data=data,
)
return DeviceSecretInstance(
self._version,
payload,
device_sid=self._solution["device_sid"],
key=self._solution["key"],
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Microvisor.V1.DeviceSecretContext {}>".format(context)
class DeviceSecretPage(Page):
def get_instance(self, payload: Dict[str, Any]) -> DeviceSecretInstance:
"""
Build an instance of DeviceSecretInstance
:param payload: Payload response from the API
"""
return DeviceSecretInstance(
self._version, payload, device_sid=self._solution["device_sid"]
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Microvisor.V1.DeviceSecretPage>"
class DeviceSecretList(ListResource):
def __init__(self, version: Version, device_sid: str):
"""
Initialize the DeviceSecretList
:param version: Version that contains the resource
:param device_sid: A 34-character string that uniquely identifies the Device.
"""
super().__init__(version)
# Path Solution
self._solution = {
"device_sid": device_sid,
}
self._uri = "/Devices/{device_sid}/Secrets".format(**self._solution)
def create(self, key: str, value: str) -> DeviceSecretInstance:
"""
Create the DeviceSecretInstance
:param key: The secret key; up to 100 characters.
:param value: The secret value; up to 4096 characters.
:returns: The created DeviceSecretInstance
"""
data = values.of(
{
"Key": key,
"Value": value,
}
)
payload = self._version.create(
method="POST",
uri=self._uri,
data=data,
)
return DeviceSecretInstance(
self._version, payload, device_sid=self._solution["device_sid"]
)
async def create_async(self, key: str, value: str) -> DeviceSecretInstance:
"""
Asynchronously create the DeviceSecretInstance
:param key: The secret key; up to 100 characters.
:param value: The secret value; up to 4096 characters.
:returns: The created DeviceSecretInstance
"""
data = values.of(
{
"Key": key,
"Value": value,
}
)
payload = await self._version.create_async(
method="POST",
uri=self._uri,
data=data,
)
return DeviceSecretInstance(
self._version, payload, device_sid=self._solution["device_sid"]
)
def stream(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[DeviceSecretInstance]:
"""
Streams DeviceSecretInstance 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[DeviceSecretInstance]:
"""
Asynchronously streams DeviceSecretInstance 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[DeviceSecretInstance]:
"""
Lists DeviceSecretInstance 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[DeviceSecretInstance]:
"""
Asynchronously lists DeviceSecretInstance 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,
) -> DeviceSecretPage:
"""
Retrieve a single page of DeviceSecretInstance 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 DeviceSecretInstance
"""
data = values.of(
{
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return DeviceSecretPage(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,
) -> DeviceSecretPage:
"""
Asynchronously retrieve a single page of DeviceSecretInstance 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 DeviceSecretInstance
"""
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 DeviceSecretPage(self._version, response, self._solution)
def get_page(self, target_url: str) -> DeviceSecretPage:
"""
Retrieve a specific page of DeviceSecretInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of DeviceSecretInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return DeviceSecretPage(self._version, response, self._solution)
async def get_page_async(self, target_url: str) -> DeviceSecretPage:
"""
Asynchronously retrieve a specific page of DeviceSecretInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of DeviceSecretInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return DeviceSecretPage(self._version, response, self._solution)
def get(self, key: str) -> DeviceSecretContext:
"""
Constructs a DeviceSecretContext
:param key: The secret key; up to 100 characters.
"""
return DeviceSecretContext(
self._version, device_sid=self._solution["device_sid"], key=key
)
def __call__(self, key: str) -> DeviceSecretContext:
"""
Constructs a DeviceSecretContext
:param key: The secret key; up to 100 characters.
"""
return DeviceSecretContext(
self._version, device_sid=self._solution["device_sid"], key=key
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Microvisor.V1.DeviceSecretList>"