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.serverless.v1 import V1
class ServerlessBase(Domain):
def __init__(self, twilio: Client):
"""
Initialize the Serverless Domain
:returns: Domain for Serverless
"""
super().__init__(twilio, "https://serverless.twilio.com")
self._v1: Optional[V1] = None
@property
def v1(self) -> V1:
"""
:returns: Versions v1 of Serverless
"""
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.Serverless>"
@@ -0,0 +1,15 @@
from warnings import warn
from twilio.rest.serverless.ServerlessBase import ServerlessBase
from twilio.rest.serverless.v1.service import ServiceList
class Serverless(ServerlessBase):
@property
def services(self) -> ServiceList:
warn(
"services is deprecated. Use v1.services instead.",
DeprecationWarning,
stacklevel=2,
)
return self.v1.services
@@ -0,0 +1,42 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Serverless
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.serverless.v1.service import ServiceList
class V1(Version):
def __init__(self, domain: Domain):
"""
Initialize the V1 version of Serverless
:param domain: The Twilio.serverless domain
"""
super().__init__(domain, "v1")
self._services: Optional[ServiceList] = None
@property
def services(self) -> ServiceList:
if self._services is None:
self._services = ServiceList(self)
return self._services
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Serverless.V1>"
@@ -0,0 +1,709 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Serverless
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.serverless.v1.service.asset import AssetList
from twilio.rest.serverless.v1.service.build import BuildList
from twilio.rest.serverless.v1.service.environment import EnvironmentList
from twilio.rest.serverless.v1.service.function import FunctionList
class ServiceInstance(InstanceResource):
"""
:ivar sid: The unique string that we created to identify the Service resource.
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Service resource.
:ivar friendly_name: The string that you assigned to describe the Service resource.
:ivar unique_name: A user-defined string that uniquely identifies the Service resource. It can be used in place of the Service resource's `sid` in the URL to address the Service resource.
:ivar include_credentials: Whether to inject Account credentials into a function invocation context.
:ivar ui_editable: Whether the Service resource's properties and subresources can be edited via the UI.
:ivar domain_base: The base domain name for this Service, which is a combination of the unique name and a randomly generated string.
:ivar date_created: The date and time in GMT when the Service resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
:ivar date_updated: The date and time in GMT when the Service resource was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
:ivar url: The absolute URL of the Service resource.
:ivar links: The URLs of the Service's nested resources.
"""
def __init__(
self, version: Version, payload: Dict[str, Any], sid: Optional[str] = None
):
super().__init__(version)
self.sid: Optional[str] = payload.get("sid")
self.account_sid: Optional[str] = payload.get("account_sid")
self.friendly_name: Optional[str] = payload.get("friendly_name")
self.unique_name: Optional[str] = payload.get("unique_name")
self.include_credentials: Optional[bool] = payload.get("include_credentials")
self.ui_editable: Optional[bool] = payload.get("ui_editable")
self.domain_base: Optional[str] = payload.get("domain_base")
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[ServiceContext] = None
@property
def _proxy(self) -> "ServiceContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: ServiceContext for this ServiceInstance
"""
if self._context is None:
self._context = ServiceContext(
self._version,
sid=self._solution["sid"],
)
return self._context
def delete(self) -> bool:
"""
Deletes the ServiceInstance
:returns: True if delete succeeds, False otherwise
"""
return self._proxy.delete()
async def delete_async(self) -> bool:
"""
Asynchronous coroutine that deletes the ServiceInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._proxy.delete_async()
def fetch(self) -> "ServiceInstance":
"""
Fetch the ServiceInstance
:returns: The fetched ServiceInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "ServiceInstance":
"""
Asynchronous coroutine to fetch the ServiceInstance
:returns: The fetched ServiceInstance
"""
return await self._proxy.fetch_async()
def update(
self,
include_credentials: Union[bool, object] = values.unset,
friendly_name: Union[str, object] = values.unset,
ui_editable: Union[bool, object] = values.unset,
) -> "ServiceInstance":
"""
Update the ServiceInstance
:param include_credentials: Whether to inject Account credentials into a function invocation context.
:param friendly_name: A descriptive string that you create to describe the Service resource. It can be a maximum of 255 characters.
:param ui_editable: Whether the Service resource's properties and subresources can be edited via the UI. The default value is `false`.
:returns: The updated ServiceInstance
"""
return self._proxy.update(
include_credentials=include_credentials,
friendly_name=friendly_name,
ui_editable=ui_editable,
)
async def update_async(
self,
include_credentials: Union[bool, object] = values.unset,
friendly_name: Union[str, object] = values.unset,
ui_editable: Union[bool, object] = values.unset,
) -> "ServiceInstance":
"""
Asynchronous coroutine to update the ServiceInstance
:param include_credentials: Whether to inject Account credentials into a function invocation context.
:param friendly_name: A descriptive string that you create to describe the Service resource. It can be a maximum of 255 characters.
:param ui_editable: Whether the Service resource's properties and subresources can be edited via the UI. The default value is `false`.
:returns: The updated ServiceInstance
"""
return await self._proxy.update_async(
include_credentials=include_credentials,
friendly_name=friendly_name,
ui_editable=ui_editable,
)
@property
def assets(self) -> AssetList:
"""
Access the assets
"""
return self._proxy.assets
@property
def builds(self) -> BuildList:
"""
Access the builds
"""
return self._proxy.builds
@property
def environments(self) -> EnvironmentList:
"""
Access the environments
"""
return self._proxy.environments
@property
def functions(self) -> FunctionList:
"""
Access the functions
"""
return self._proxy.functions
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.Serverless.V1.ServiceInstance {}>".format(context)
class ServiceContext(InstanceContext):
def __init__(self, version: Version, sid: str):
"""
Initialize the ServiceContext
:param version: Version that contains the resource
:param sid: The `sid` or `unique_name` of the Service resource to update.
"""
super().__init__(version)
# Path Solution
self._solution = {
"sid": sid,
}
self._uri = "/Services/{sid}".format(**self._solution)
self._assets: Optional[AssetList] = None
self._builds: Optional[BuildList] = None
self._environments: Optional[EnvironmentList] = None
self._functions: Optional[FunctionList] = None
def delete(self) -> bool:
"""
Deletes the ServiceInstance
:returns: True if delete succeeds, False otherwise
"""
return self._version.delete(
method="DELETE",
uri=self._uri,
)
async def delete_async(self) -> bool:
"""
Asynchronous coroutine that deletes the ServiceInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._version.delete_async(
method="DELETE",
uri=self._uri,
)
def fetch(self) -> ServiceInstance:
"""
Fetch the ServiceInstance
:returns: The fetched ServiceInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return ServiceInstance(
self._version,
payload,
sid=self._solution["sid"],
)
async def fetch_async(self) -> ServiceInstance:
"""
Asynchronous coroutine to fetch the ServiceInstance
:returns: The fetched ServiceInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return ServiceInstance(
self._version,
payload,
sid=self._solution["sid"],
)
def update(
self,
include_credentials: Union[bool, object] = values.unset,
friendly_name: Union[str, object] = values.unset,
ui_editable: Union[bool, object] = values.unset,
) -> ServiceInstance:
"""
Update the ServiceInstance
:param include_credentials: Whether to inject Account credentials into a function invocation context.
:param friendly_name: A descriptive string that you create to describe the Service resource. It can be a maximum of 255 characters.
:param ui_editable: Whether the Service resource's properties and subresources can be edited via the UI. The default value is `false`.
:returns: The updated ServiceInstance
"""
data = values.of(
{
"IncludeCredentials": include_credentials,
"FriendlyName": friendly_name,
"UiEditable": ui_editable,
}
)
payload = self._version.update(
method="POST",
uri=self._uri,
data=data,
)
return ServiceInstance(self._version, payload, sid=self._solution["sid"])
async def update_async(
self,
include_credentials: Union[bool, object] = values.unset,
friendly_name: Union[str, object] = values.unset,
ui_editable: Union[bool, object] = values.unset,
) -> ServiceInstance:
"""
Asynchronous coroutine to update the ServiceInstance
:param include_credentials: Whether to inject Account credentials into a function invocation context.
:param friendly_name: A descriptive string that you create to describe the Service resource. It can be a maximum of 255 characters.
:param ui_editable: Whether the Service resource's properties and subresources can be edited via the UI. The default value is `false`.
:returns: The updated ServiceInstance
"""
data = values.of(
{
"IncludeCredentials": include_credentials,
"FriendlyName": friendly_name,
"UiEditable": ui_editable,
}
)
payload = await self._version.update_async(
method="POST",
uri=self._uri,
data=data,
)
return ServiceInstance(self._version, payload, sid=self._solution["sid"])
@property
def assets(self) -> AssetList:
"""
Access the assets
"""
if self._assets is None:
self._assets = AssetList(
self._version,
self._solution["sid"],
)
return self._assets
@property
def builds(self) -> BuildList:
"""
Access the builds
"""
if self._builds is None:
self._builds = BuildList(
self._version,
self._solution["sid"],
)
return self._builds
@property
def environments(self) -> EnvironmentList:
"""
Access the environments
"""
if self._environments is None:
self._environments = EnvironmentList(
self._version,
self._solution["sid"],
)
return self._environments
@property
def functions(self) -> FunctionList:
"""
Access the functions
"""
if self._functions is None:
self._functions = FunctionList(
self._version,
self._solution["sid"],
)
return self._functions
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.Serverless.V1.ServiceContext {}>".format(context)
class ServicePage(Page):
def get_instance(self, payload: Dict[str, Any]) -> ServiceInstance:
"""
Build an instance of ServiceInstance
:param payload: Payload response from the API
"""
return ServiceInstance(self._version, payload)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Serverless.V1.ServicePage>"
class ServiceList(ListResource):
def __init__(self, version: Version):
"""
Initialize the ServiceList
:param version: Version that contains the resource
"""
super().__init__(version)
self._uri = "/Services"
def create(
self,
unique_name: str,
friendly_name: str,
include_credentials: Union[bool, object] = values.unset,
ui_editable: Union[bool, object] = values.unset,
) -> ServiceInstance:
"""
Create the ServiceInstance
:param unique_name: A user-defined string that uniquely identifies the Service resource. It can be used as an alternative to the `sid` in the URL path to address the Service resource. This value must be 50 characters or less in length and be unique.
:param friendly_name: A descriptive string that you create to describe the Service resource. It can be a maximum of 255 characters.
:param include_credentials: Whether to inject Account credentials into a function invocation context. The default value is `true`.
:param ui_editable: Whether the Service's properties and subresources can be edited via the UI. The default value is `false`.
:returns: The created ServiceInstance
"""
data = values.of(
{
"UniqueName": unique_name,
"FriendlyName": friendly_name,
"IncludeCredentials": include_credentials,
"UiEditable": ui_editable,
}
)
payload = self._version.create(
method="POST",
uri=self._uri,
data=data,
)
return ServiceInstance(self._version, payload)
async def create_async(
self,
unique_name: str,
friendly_name: str,
include_credentials: Union[bool, object] = values.unset,
ui_editable: Union[bool, object] = values.unset,
) -> ServiceInstance:
"""
Asynchronously create the ServiceInstance
:param unique_name: A user-defined string that uniquely identifies the Service resource. It can be used as an alternative to the `sid` in the URL path to address the Service resource. This value must be 50 characters or less in length and be unique.
:param friendly_name: A descriptive string that you create to describe the Service resource. It can be a maximum of 255 characters.
:param include_credentials: Whether to inject Account credentials into a function invocation context. The default value is `true`.
:param ui_editable: Whether the Service's properties and subresources can be edited via the UI. The default value is `false`.
:returns: The created ServiceInstance
"""
data = values.of(
{
"UniqueName": unique_name,
"FriendlyName": friendly_name,
"IncludeCredentials": include_credentials,
"UiEditable": ui_editable,
}
)
payload = await self._version.create_async(
method="POST",
uri=self._uri,
data=data,
)
return ServiceInstance(self._version, payload)
def stream(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[ServiceInstance]:
"""
Streams ServiceInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param limit: Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the
limit with the most efficient page size, i.e. min(limit, 1000)
:returns: Generator that will yield up to limit results
"""
limits = self._version.read_limits(limit, page_size)
page = self.page(page_size=limits["page_size"])
return self._version.stream(page, limits["limit"])
async def stream_async(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> AsyncIterator[ServiceInstance]:
"""
Asynchronously streams ServiceInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param limit: Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the
limit with the most efficient page size, i.e. min(limit, 1000)
:returns: Generator that will yield up to limit results
"""
limits = self._version.read_limits(limit, page_size)
page = await self.page_async(page_size=limits["page_size"])
return self._version.stream_async(page, limits["limit"])
def list(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[ServiceInstance]:
"""
Lists ServiceInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param limit: Upper limit for the number of records to return. list() guarantees
never to return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, list() will attempt to read the limit
with the most efficient page size, i.e. min(limit, 1000)
:returns: list that will contain up to limit results
"""
return list(
self.stream(
limit=limit,
page_size=page_size,
)
)
async def list_async(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[ServiceInstance]:
"""
Asynchronously lists ServiceInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param limit: Upper limit for the number of records to return. list() guarantees
never to return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, list() will attempt to read the limit
with the most efficient page size, i.e. min(limit, 1000)
:returns: list that will contain up to limit results
"""
return [
record
async for record in await self.stream_async(
limit=limit,
page_size=page_size,
)
]
def page(
self,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> ServicePage:
"""
Retrieve a single page of ServiceInstance records from the API.
Request is executed immediately
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of ServiceInstance
"""
data = values.of(
{
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return ServicePage(self._version, response)
async def page_async(
self,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> ServicePage:
"""
Asynchronously retrieve a single page of ServiceInstance records from the API.
Request is executed immediately
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of ServiceInstance
"""
data = values.of(
{
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = await self._version.page_async(
method="GET", uri=self._uri, params=data
)
return ServicePage(self._version, response)
def get_page(self, target_url: str) -> ServicePage:
"""
Retrieve a specific page of ServiceInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of ServiceInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return ServicePage(self._version, response)
async def get_page_async(self, target_url: str) -> ServicePage:
"""
Asynchronously retrieve a specific page of ServiceInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of ServiceInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return ServicePage(self._version, response)
def get(self, sid: str) -> ServiceContext:
"""
Constructs a ServiceContext
:param sid: The `sid` or `unique_name` of the Service resource to update.
"""
return ServiceContext(self._version, sid=sid)
def __call__(self, sid: str) -> ServiceContext:
"""
Constructs a ServiceContext
:param sid: The `sid` or `unique_name` of the Service resource to update.
"""
return ServiceContext(self._version, sid=sid)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Serverless.V1.ServiceList>"
@@ -0,0 +1,616 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Serverless
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.serverless.v1.service.asset.asset_version import AssetVersionList
class AssetInstance(InstanceResource):
"""
:ivar sid: The unique string that we created to identify the Asset resource.
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Asset resource.
:ivar service_sid: The SID of the Service that the Asset resource is associated with.
:ivar friendly_name: The string that you assigned to describe the Asset resource. It can be a maximum of 255 characters.
:ivar date_created: The date and time in GMT when the Asset resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
:ivar date_updated: The date and time in GMT when the Asset resource was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
:ivar url: The absolute URL of the Asset resource.
:ivar links: The URLs of the Asset resource's nested resources.
"""
def __init__(
self,
version: Version,
payload: Dict[str, Any],
service_sid: str,
sid: Optional[str] = None,
):
super().__init__(version)
self.sid: Optional[str] = payload.get("sid")
self.account_sid: Optional[str] = payload.get("account_sid")
self.service_sid: Optional[str] = payload.get("service_sid")
self.friendly_name: Optional[str] = payload.get("friendly_name")
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_created")
)
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_updated")
)
self.url: Optional[str] = payload.get("url")
self.links: Optional[Dict[str, object]] = payload.get("links")
self._solution = {
"service_sid": service_sid,
"sid": sid or self.sid,
}
self._context: Optional[AssetContext] = None
@property
def _proxy(self) -> "AssetContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: AssetContext for this AssetInstance
"""
if self._context is None:
self._context = AssetContext(
self._version,
service_sid=self._solution["service_sid"],
sid=self._solution["sid"],
)
return self._context
def delete(self) -> bool:
"""
Deletes the AssetInstance
:returns: True if delete succeeds, False otherwise
"""
return self._proxy.delete()
async def delete_async(self) -> bool:
"""
Asynchronous coroutine that deletes the AssetInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._proxy.delete_async()
def fetch(self) -> "AssetInstance":
"""
Fetch the AssetInstance
:returns: The fetched AssetInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "AssetInstance":
"""
Asynchronous coroutine to fetch the AssetInstance
:returns: The fetched AssetInstance
"""
return await self._proxy.fetch_async()
def update(self, friendly_name: str) -> "AssetInstance":
"""
Update the AssetInstance
:param friendly_name: A descriptive string that you create to describe the Asset resource. It can be a maximum of 255 characters.
:returns: The updated AssetInstance
"""
return self._proxy.update(
friendly_name=friendly_name,
)
async def update_async(self, friendly_name: str) -> "AssetInstance":
"""
Asynchronous coroutine to update the AssetInstance
:param friendly_name: A descriptive string that you create to describe the Asset resource. It can be a maximum of 255 characters.
:returns: The updated AssetInstance
"""
return await self._proxy.update_async(
friendly_name=friendly_name,
)
@property
def asset_versions(self) -> AssetVersionList:
"""
Access the asset_versions
"""
return self._proxy.asset_versions
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.Serverless.V1.AssetInstance {}>".format(context)
class AssetContext(InstanceContext):
def __init__(self, version: Version, service_sid: str, sid: str):
"""
Initialize the AssetContext
:param version: Version that contains the resource
:param service_sid: The SID of the Service to update the Asset resource from.
:param sid: The SID that identifies the Asset resource to update.
"""
super().__init__(version)
# Path Solution
self._solution = {
"service_sid": service_sid,
"sid": sid,
}
self._uri = "/Services/{service_sid}/Assets/{sid}".format(**self._solution)
self._asset_versions: Optional[AssetVersionList] = None
def delete(self) -> bool:
"""
Deletes the AssetInstance
: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 AssetInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._version.delete_async(
method="DELETE",
uri=self._uri,
)
def fetch(self) -> AssetInstance:
"""
Fetch the AssetInstance
:returns: The fetched AssetInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return AssetInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
sid=self._solution["sid"],
)
async def fetch_async(self) -> AssetInstance:
"""
Asynchronous coroutine to fetch the AssetInstance
:returns: The fetched AssetInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return AssetInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
sid=self._solution["sid"],
)
def update(self, friendly_name: str) -> AssetInstance:
"""
Update the AssetInstance
:param friendly_name: A descriptive string that you create to describe the Asset resource. It can be a maximum of 255 characters.
:returns: The updated AssetInstance
"""
data = values.of(
{
"FriendlyName": friendly_name,
}
)
payload = self._version.update(
method="POST",
uri=self._uri,
data=data,
)
return AssetInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
sid=self._solution["sid"],
)
async def update_async(self, friendly_name: str) -> AssetInstance:
"""
Asynchronous coroutine to update the AssetInstance
:param friendly_name: A descriptive string that you create to describe the Asset resource. It can be a maximum of 255 characters.
:returns: The updated AssetInstance
"""
data = values.of(
{
"FriendlyName": friendly_name,
}
)
payload = await self._version.update_async(
method="POST",
uri=self._uri,
data=data,
)
return AssetInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
sid=self._solution["sid"],
)
@property
def asset_versions(self) -> AssetVersionList:
"""
Access the asset_versions
"""
if self._asset_versions is None:
self._asset_versions = AssetVersionList(
self._version,
self._solution["service_sid"],
self._solution["sid"],
)
return self._asset_versions
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.Serverless.V1.AssetContext {}>".format(context)
class AssetPage(Page):
def get_instance(self, payload: Dict[str, Any]) -> AssetInstance:
"""
Build an instance of AssetInstance
:param payload: Payload response from the API
"""
return AssetInstance(
self._version, payload, service_sid=self._solution["service_sid"]
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Serverless.V1.AssetPage>"
class AssetList(ListResource):
def __init__(self, version: Version, service_sid: str):
"""
Initialize the AssetList
:param version: Version that contains the resource
:param service_sid: The SID of the Service to read the Asset resources from.
"""
super().__init__(version)
# Path Solution
self._solution = {
"service_sid": service_sid,
}
self._uri = "/Services/{service_sid}/Assets".format(**self._solution)
def create(self, friendly_name: str) -> AssetInstance:
"""
Create the AssetInstance
:param friendly_name: A descriptive string that you create to describe the Asset resource. It can be a maximum of 255 characters.
:returns: The created AssetInstance
"""
data = values.of(
{
"FriendlyName": friendly_name,
}
)
payload = self._version.create(
method="POST",
uri=self._uri,
data=data,
)
return AssetInstance(
self._version, payload, service_sid=self._solution["service_sid"]
)
async def create_async(self, friendly_name: str) -> AssetInstance:
"""
Asynchronously create the AssetInstance
:param friendly_name: A descriptive string that you create to describe the Asset resource. It can be a maximum of 255 characters.
:returns: The created AssetInstance
"""
data = values.of(
{
"FriendlyName": friendly_name,
}
)
payload = await self._version.create_async(
method="POST",
uri=self._uri,
data=data,
)
return AssetInstance(
self._version, payload, service_sid=self._solution["service_sid"]
)
def stream(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[AssetInstance]:
"""
Streams AssetInstance 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[AssetInstance]:
"""
Asynchronously streams AssetInstance 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[AssetInstance]:
"""
Lists AssetInstance 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[AssetInstance]:
"""
Asynchronously lists AssetInstance 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,
) -> AssetPage:
"""
Retrieve a single page of AssetInstance 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 AssetInstance
"""
data = values.of(
{
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return AssetPage(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,
) -> AssetPage:
"""
Asynchronously retrieve a single page of AssetInstance 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 AssetInstance
"""
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 AssetPage(self._version, response, self._solution)
def get_page(self, target_url: str) -> AssetPage:
"""
Retrieve a specific page of AssetInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of AssetInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return AssetPage(self._version, response, self._solution)
async def get_page_async(self, target_url: str) -> AssetPage:
"""
Asynchronously retrieve a specific page of AssetInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of AssetInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return AssetPage(self._version, response, self._solution)
def get(self, sid: str) -> AssetContext:
"""
Constructs a AssetContext
:param sid: The SID that identifies the Asset resource to update.
"""
return AssetContext(
self._version, service_sid=self._solution["service_sid"], sid=sid
)
def __call__(self, sid: str) -> AssetContext:
"""
Constructs a AssetContext
:param sid: The SID that identifies the Asset resource to update.
"""
return AssetContext(
self._version, service_sid=self._solution["service_sid"], sid=sid
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Serverless.V1.AssetList>"
@@ -0,0 +1,451 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Serverless
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 AssetVersionInstance(InstanceResource):
class Visibility(object):
PUBLIC = "public"
PRIVATE = "private"
PROTECTED = "protected"
"""
:ivar sid: The unique string that we created to identify the Asset Version resource.
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Asset Version resource.
:ivar service_sid: The SID of the Service that the Asset Version resource is associated with.
:ivar asset_sid: The SID of the Asset resource that is the parent of the Asset Version.
:ivar path: The URL-friendly string by which the Asset Version can be referenced. It can be a maximum of 255 characters. All paths begin with a forward slash ('/'). If an Asset Version creation request is submitted with a path not containing a leading slash, the path will automatically be prepended with one.
:ivar visibility:
:ivar date_created: The date and time in GMT when the Asset Version resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
:ivar url: The absolute URL of the Asset Version resource.
"""
def __init__(
self,
version: Version,
payload: Dict[str, Any],
service_sid: str,
asset_sid: str,
sid: Optional[str] = None,
):
super().__init__(version)
self.sid: Optional[str] = payload.get("sid")
self.account_sid: Optional[str] = payload.get("account_sid")
self.service_sid: Optional[str] = payload.get("service_sid")
self.asset_sid: Optional[str] = payload.get("asset_sid")
self.path: Optional[str] = payload.get("path")
self.visibility: Optional["AssetVersionInstance.Visibility"] = payload.get(
"visibility"
)
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_created")
)
self.url: Optional[str] = payload.get("url")
self._solution = {
"service_sid": service_sid,
"asset_sid": asset_sid,
"sid": sid or self.sid,
}
self._context: Optional[AssetVersionContext] = None
@property
def _proxy(self) -> "AssetVersionContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: AssetVersionContext for this AssetVersionInstance
"""
if self._context is None:
self._context = AssetVersionContext(
self._version,
service_sid=self._solution["service_sid"],
asset_sid=self._solution["asset_sid"],
sid=self._solution["sid"],
)
return self._context
def fetch(self) -> "AssetVersionInstance":
"""
Fetch the AssetVersionInstance
:returns: The fetched AssetVersionInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "AssetVersionInstance":
"""
Asynchronous coroutine to fetch the AssetVersionInstance
:returns: The fetched AssetVersionInstance
"""
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.Serverless.V1.AssetVersionInstance {}>".format(context)
class AssetVersionContext(InstanceContext):
def __init__(self, version: Version, service_sid: str, asset_sid: str, sid: str):
"""
Initialize the AssetVersionContext
:param version: Version that contains the resource
:param service_sid: The SID of the Service to fetch the Asset Version resource from.
:param asset_sid: The SID of the Asset resource that is the parent of the Asset Version resource to fetch.
:param sid: The SID of the Asset Version resource to fetch.
"""
super().__init__(version)
# Path Solution
self._solution = {
"service_sid": service_sid,
"asset_sid": asset_sid,
"sid": sid,
}
self._uri = "/Services/{service_sid}/Assets/{asset_sid}/Versions/{sid}".format(
**self._solution
)
def fetch(self) -> AssetVersionInstance:
"""
Fetch the AssetVersionInstance
:returns: The fetched AssetVersionInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return AssetVersionInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
asset_sid=self._solution["asset_sid"],
sid=self._solution["sid"],
)
async def fetch_async(self) -> AssetVersionInstance:
"""
Asynchronous coroutine to fetch the AssetVersionInstance
:returns: The fetched AssetVersionInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return AssetVersionInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
asset_sid=self._solution["asset_sid"],
sid=self._solution["sid"],
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Serverless.V1.AssetVersionContext {}>".format(context)
class AssetVersionPage(Page):
def get_instance(self, payload: Dict[str, Any]) -> AssetVersionInstance:
"""
Build an instance of AssetVersionInstance
:param payload: Payload response from the API
"""
return AssetVersionInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
asset_sid=self._solution["asset_sid"],
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Serverless.V1.AssetVersionPage>"
class AssetVersionList(ListResource):
def __init__(self, version: Version, service_sid: str, asset_sid: str):
"""
Initialize the AssetVersionList
:param version: Version that contains the resource
:param service_sid: The SID of the Service to read the Asset Version resource from.
:param asset_sid: The SID of the Asset resource that is the parent of the Asset Version resources to read.
"""
super().__init__(version)
# Path Solution
self._solution = {
"service_sid": service_sid,
"asset_sid": asset_sid,
}
self._uri = "/Services/{service_sid}/Assets/{asset_sid}/Versions".format(
**self._solution
)
def stream(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[AssetVersionInstance]:
"""
Streams AssetVersionInstance 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[AssetVersionInstance]:
"""
Asynchronously streams AssetVersionInstance 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[AssetVersionInstance]:
"""
Lists AssetVersionInstance 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[AssetVersionInstance]:
"""
Asynchronously lists AssetVersionInstance 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,
) -> AssetVersionPage:
"""
Retrieve a single page of AssetVersionInstance 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 AssetVersionInstance
"""
data = values.of(
{
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return AssetVersionPage(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,
) -> AssetVersionPage:
"""
Asynchronously retrieve a single page of AssetVersionInstance 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 AssetVersionInstance
"""
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 AssetVersionPage(self._version, response, self._solution)
def get_page(self, target_url: str) -> AssetVersionPage:
"""
Retrieve a specific page of AssetVersionInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of AssetVersionInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return AssetVersionPage(self._version, response, self._solution)
async def get_page_async(self, target_url: str) -> AssetVersionPage:
"""
Asynchronously retrieve a specific page of AssetVersionInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of AssetVersionInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return AssetVersionPage(self._version, response, self._solution)
def get(self, sid: str) -> AssetVersionContext:
"""
Constructs a AssetVersionContext
:param sid: The SID of the Asset Version resource to fetch.
"""
return AssetVersionContext(
self._version,
service_sid=self._solution["service_sid"],
asset_sid=self._solution["asset_sid"],
sid=sid,
)
def __call__(self, sid: str) -> AssetVersionContext:
"""
Constructs a AssetVersionContext
:param sid: The SID of the Asset Version resource to fetch.
"""
return AssetVersionContext(
self._version,
service_sid=self._solution["service_sid"],
asset_sid=self._solution["asset_sid"],
sid=sid,
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Serverless.V1.AssetVersionList>"
@@ -0,0 +1,551 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Serverless
This is the public Twilio REST API.
NOTE: This class is auto generated by OpenAPI Generator.
https://openapi-generator.tech
Do not edit the class manually.
"""
from datetime import datetime
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
from twilio.base import deserialize, serialize, values
from twilio.base.instance_context import InstanceContext
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.version import Version
from twilio.base.page import Page
from twilio.rest.serverless.v1.service.build.build_status import BuildStatusList
class BuildInstance(InstanceResource):
class Runtime(object):
NODE8 = "node8"
NODE10 = "node10"
NODE12 = "node12"
NODE14 = "node14"
NODE16 = "node16"
class Status(object):
BUILDING = "building"
COMPLETED = "completed"
FAILED = "failed"
"""
:ivar sid: The unique string that we created to identify the Build resource.
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Build resource.
:ivar service_sid: The SID of the Service that the Build resource is associated with.
:ivar status:
:ivar asset_versions: The list of Asset Version resource SIDs that are included in the Build.
:ivar function_versions: The list of Function Version resource SIDs that are included in the Build.
:ivar dependencies: A list of objects that describe the Dependencies included in the Build. Each object contains the `name` and `version` of the dependency.
:ivar runtime:
:ivar date_created: The date and time in GMT when the Build resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
:ivar date_updated: The date and time in GMT when the Build resource was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
:ivar url: The absolute URL of the Build resource.
:ivar links:
"""
def __init__(self, version: Version, payload: Dict[str, Any], service_sid: str, sid: Optional[str] = None):
super().__init__(version)
self.sid: Optional[str] = payload.get("sid")
self.account_sid: Optional[str] = payload.get("account_sid")
self.service_sid: Optional[str] = payload.get("service_sid")
self.status: Optional["BuildInstance.Status"] = payload.get("status")
self.asset_versions: Optional[List[object]] = payload.get("asset_versions")
self.function_versions: Optional[List[object]] = payload.get("function_versions")
self.dependencies: Optional[List[object]] = payload.get("dependencies")
self.runtime: Optional["BuildInstance.Runtime"] = payload.get("runtime")
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 = {
"service_sid": service_sid,
"sid": sid or self.sid,
}
self._context: Optional[BuildContext] = None
@property
def _proxy(self) -> "BuildContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: BuildContext for this BuildInstance
"""
if self._context is None:
self._context = BuildContext(self._version, service_sid=self._solution['service_sid'], sid=self._solution['sid'],)
return self._context
def delete(self) -> bool:
"""
Deletes the BuildInstance
:returns: True if delete succeeds, False otherwise
"""
return self._proxy.delete()
async def delete_async(self) -> bool:
"""
Asynchronous coroutine that deletes the BuildInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._proxy.delete_async()
def fetch(self) -> "BuildInstance":
"""
Fetch the BuildInstance
:returns: The fetched BuildInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "BuildInstance":
"""
Asynchronous coroutine to fetch the BuildInstance
:returns: The fetched BuildInstance
"""
return await self._proxy.fetch_async()
@property
def build_status(self) -> BuildStatusList:
"""
Access the build_status
"""
return self._proxy.build_status
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items())
return '<Twilio.Serverless.V1.BuildInstance {}>'.format(context)
class BuildContext(InstanceContext):
def __init__(self, version: Version, service_sid: str, sid: str):
"""
Initialize the BuildContext
:param version: Version that contains the resource
:param service_sid: The SID of the Service to fetch the Build resource from.
:param sid: The SID of the Build resource to fetch.
"""
super().__init__(version)
# Path Solution
self._solution = {
'service_sid': service_sid,
'sid': sid,
}
self._uri = '/Services/{service_sid}/Builds/{sid}'.format(**self._solution)
self._build_status: Optional[BuildStatusList] = None
def delete(self) -> bool:
"""
Deletes the BuildInstance
: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 BuildInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._version.delete_async(method='DELETE', uri=self._uri,)
def fetch(self) -> BuildInstance:
"""
Fetch the BuildInstance
:returns: The fetched BuildInstance
"""
payload = self._version.fetch(method='GET', uri=self._uri, )
return BuildInstance(
self._version,
payload,
service_sid=self._solution['service_sid'],
sid=self._solution['sid'],
)
async def fetch_async(self) -> BuildInstance:
"""
Asynchronous coroutine to fetch the BuildInstance
:returns: The fetched BuildInstance
"""
payload = await self._version.fetch_async(method='GET', uri=self._uri, )
return BuildInstance(
self._version,
payload,
service_sid=self._solution['service_sid'],
sid=self._solution['sid'],
)
@property
def build_status(self) -> BuildStatusList:
"""
Access the build_status
"""
if self._build_status is None:
self._build_status = BuildStatusList(
self._version,
self._solution['service_sid'],
self._solution['sid'],
)
return self._build_status
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items())
return '<Twilio.Serverless.V1.BuildContext {}>'.format(context)
class BuildPage(Page):
def get_instance(self, payload: Dict[str, Any]) -> BuildInstance:
"""
Build an instance of BuildInstance
:param payload: Payload response from the API
"""
return BuildInstance(self._version, payload, service_sid=self._solution["service_sid"])
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Serverless.V1.BuildPage>"
class BuildList(ListResource):
def __init__(self, version: Version, service_sid: str):
"""
Initialize the BuildList
:param version: Version that contains the resource
:param service_sid: The SID of the Service to read the Build resources from.
"""
super().__init__(version)
# Path Solution
self._solution = { 'service_sid': service_sid, }
self._uri = '/Services/{service_sid}/Builds'.format(**self._solution)
def create(self, asset_versions: Union[List[str], object]=values.unset, function_versions: Union[List[str], object]=values.unset, dependencies: Union[str, object]=values.unset, runtime: Union[str, object]=values.unset) -> BuildInstance:
"""
Create the BuildInstance
:param asset_versions: The list of Asset Version resource SIDs to include in the Build.
:param function_versions: The list of the Function Version resource SIDs to include in the Build.
:param dependencies: A list of objects that describe the Dependencies included in the Build. Each object contains the `name` and `version` of the dependency.
:param runtime: The Runtime version that will be used to run the Build resource when it is deployed.
:returns: The created BuildInstance
"""
data = values.of({
'AssetVersions': serialize.map(asset_versions, lambda e: e),
'FunctionVersions': serialize.map(function_versions, lambda e: e),
'Dependencies': dependencies,
'Runtime': runtime,
})
payload = self._version.create(method='POST', uri=self._uri, data=data,)
return BuildInstance(self._version, payload, service_sid=self._solution['service_sid'])
async def create_async(self, asset_versions: Union[List[str], object]=values.unset, function_versions: Union[List[str], object]=values.unset, dependencies: Union[str, object]=values.unset, runtime: Union[str, object]=values.unset) -> BuildInstance:
"""
Asynchronously create the BuildInstance
:param asset_versions: The list of Asset Version resource SIDs to include in the Build.
:param function_versions: The list of the Function Version resource SIDs to include in the Build.
:param dependencies: A list of objects that describe the Dependencies included in the Build. Each object contains the `name` and `version` of the dependency.
:param runtime: The Runtime version that will be used to run the Build resource when it is deployed.
:returns: The created BuildInstance
"""
data = values.of({
'AssetVersions': serialize.map(asset_versions, lambda e: e),
'FunctionVersions': serialize.map(function_versions, lambda e: e),
'Dependencies': dependencies,
'Runtime': runtime,
})
payload = await self._version.create_async(method='POST', uri=self._uri, data=data,)
return BuildInstance(self._version, payload, service_sid=self._solution['service_sid'])
def stream(self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[BuildInstance]:
"""
Streams BuildInstance 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[BuildInstance]:
"""
Asynchronously streams BuildInstance 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[BuildInstance]:
"""
Lists BuildInstance 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[BuildInstance]:
"""
Asynchronously lists BuildInstance 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,
) -> BuildPage:
"""
Retrieve a single page of BuildInstance 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 BuildInstance
"""
data = values.of({
'PageToken': page_token,
'Page': page_number,
'PageSize': page_size,
})
response = self._version.page(method='GET', uri=self._uri, params=data)
return BuildPage(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,
) -> BuildPage:
"""
Asynchronously retrieve a single page of BuildInstance 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 BuildInstance
"""
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 BuildPage(self._version, response, self._solution)
def get_page(self, target_url: str) -> BuildPage:
"""
Retrieve a specific page of BuildInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of BuildInstance
"""
response = self._version.domain.twilio.request(
'GET',
target_url
)
return BuildPage(self._version, response, self._solution)
async def get_page_async(self, target_url: str) -> BuildPage:
"""
Asynchronously retrieve a specific page of BuildInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of BuildInstance
"""
response = await self._version.domain.twilio.request_async(
'GET',
target_url
)
return BuildPage(self._version, response, self._solution)
def get(self, sid: str) -> BuildContext:
"""
Constructs a BuildContext
:param sid: The SID of the Build resource to fetch.
"""
return BuildContext(self._version, service_sid=self._solution['service_sid'], sid=sid)
def __call__(self, sid: str) -> BuildContext:
"""
Constructs a BuildContext
:param sid: The SID of the Build resource to fetch.
"""
return BuildContext(self._version, service_sid=self._solution['service_sid'], sid=sid)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return '<Twilio.Serverless.V1.BuildList>'
@@ -0,0 +1,207 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Serverless
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 BuildStatusInstance(InstanceResource):
class Status(object):
BUILDING = "building"
COMPLETED = "completed"
FAILED = "failed"
"""
:ivar sid: The unique string that we created to identify the Build resource.
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Build resource.
:ivar service_sid: The SID of the Service that the Build resource is associated with.
:ivar status:
:ivar url: The absolute URL of the Build Status resource.
"""
def __init__(self, version: Version, payload: Dict[str, Any], service_sid: str, sid: str):
super().__init__(version)
self.sid: Optional[str] = payload.get("sid")
self.account_sid: Optional[str] = payload.get("account_sid")
self.service_sid: Optional[str] = payload.get("service_sid")
self.status: Optional["BuildStatusInstance.Status"] = payload.get("status")
self.url: Optional[str] = payload.get("url")
self._solution = {
"service_sid": service_sid,
"sid": sid,
}
self._context: Optional[BuildStatusContext] = None
@property
def _proxy(self) -> "BuildStatusContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: BuildStatusContext for this BuildStatusInstance
"""
if self._context is None:
self._context = BuildStatusContext(self._version, service_sid=self._solution['service_sid'], sid=self._solution['sid'],)
return self._context
def fetch(self) -> "BuildStatusInstance":
"""
Fetch the BuildStatusInstance
:returns: The fetched BuildStatusInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "BuildStatusInstance":
"""
Asynchronous coroutine to fetch the BuildStatusInstance
:returns: The fetched BuildStatusInstance
"""
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.Serverless.V1.BuildStatusInstance {}>'.format(context)
class BuildStatusContext(InstanceContext):
def __init__(self, version: Version, service_sid: str, sid: str):
"""
Initialize the BuildStatusContext
:param version: Version that contains the resource
:param service_sid: The SID of the Service to fetch the Build resource from.
:param sid: The SID of the Build resource to fetch.
"""
super().__init__(version)
# Path Solution
self._solution = {
'service_sid': service_sid,
'sid': sid,
}
self._uri = '/Services/{service_sid}/Builds/{sid}/Status'.format(**self._solution)
def fetch(self) -> BuildStatusInstance:
"""
Fetch the BuildStatusInstance
:returns: The fetched BuildStatusInstance
"""
payload = self._version.fetch(method='GET', uri=self._uri, )
return BuildStatusInstance(
self._version,
payload,
service_sid=self._solution['service_sid'],
sid=self._solution['sid'],
)
async def fetch_async(self) -> BuildStatusInstance:
"""
Asynchronous coroutine to fetch the BuildStatusInstance
:returns: The fetched BuildStatusInstance
"""
payload = await self._version.fetch_async(method='GET', uri=self._uri, )
return BuildStatusInstance(
self._version,
payload,
service_sid=self._solution['service_sid'],
sid=self._solution['sid'],
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items())
return '<Twilio.Serverless.V1.BuildStatusContext {}>'.format(context)
class BuildStatusList(ListResource):
def __init__(self, version: Version, service_sid: str, sid: str):
"""
Initialize the BuildStatusList
:param version: Version that contains the resource
:param service_sid: The SID of the Service to fetch the Build resource from.
:param sid: The SID of the Build resource to fetch.
"""
super().__init__(version)
# Path Solution
self._solution = { 'service_sid': service_sid, 'sid': sid, }
def get(self) -> BuildStatusContext:
"""
Constructs a BuildStatusContext
"""
return BuildStatusContext(self._version, service_sid=self._solution['service_sid'], sid=self._solution['sid'])
def __call__(self) -> BuildStatusContext:
"""
Constructs a BuildStatusContext
"""
return BuildStatusContext(self._version, service_sid=self._solution['service_sid'], sid=self._solution['sid'])
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return '<Twilio.Serverless.V1.BuildStatusList>'
@@ -0,0 +1,598 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Serverless
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.serverless.v1.service.environment.deployment import DeploymentList
from twilio.rest.serverless.v1.service.environment.log import LogList
from twilio.rest.serverless.v1.service.environment.variable import VariableList
class EnvironmentInstance(InstanceResource):
"""
:ivar sid: The unique string that we created to identify the Environment resource.
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Environment resource.
:ivar service_sid: The SID of the Service that the Environment resource is associated with.
:ivar build_sid: The SID of the build deployed in the environment.
:ivar unique_name: A user-defined string that uniquely identifies the Environment resource.
:ivar domain_suffix: A URL-friendly name that represents the environment and forms part of the domain name.
:ivar domain_name: The domain name for all Functions and Assets deployed in the Environment, using the Service unique name, a randomly-generated Service suffix, and an optional Environment domain suffix.
:ivar date_created: The date and time in GMT when the Environment resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
:ivar date_updated: The date and time in GMT when the Environment resource was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
:ivar url: The absolute URL of the Environment resource.
:ivar links: The URLs of the Environment resource's nested resources.
"""
def __init__(
self,
version: Version,
payload: Dict[str, Any],
service_sid: str,
sid: Optional[str] = None,
):
super().__init__(version)
self.sid: Optional[str] = payload.get("sid")
self.account_sid: Optional[str] = payload.get("account_sid")
self.service_sid: Optional[str] = payload.get("service_sid")
self.build_sid: Optional[str] = payload.get("build_sid")
self.unique_name: Optional[str] = payload.get("unique_name")
self.domain_suffix: Optional[str] = payload.get("domain_suffix")
self.domain_name: Optional[str] = payload.get("domain_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 = {
"service_sid": service_sid,
"sid": sid or self.sid,
}
self._context: Optional[EnvironmentContext] = None
@property
def _proxy(self) -> "EnvironmentContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: EnvironmentContext for this EnvironmentInstance
"""
if self._context is None:
self._context = EnvironmentContext(
self._version,
service_sid=self._solution["service_sid"],
sid=self._solution["sid"],
)
return self._context
def delete(self) -> bool:
"""
Deletes the EnvironmentInstance
:returns: True if delete succeeds, False otherwise
"""
return self._proxy.delete()
async def delete_async(self) -> bool:
"""
Asynchronous coroutine that deletes the EnvironmentInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._proxy.delete_async()
def fetch(self) -> "EnvironmentInstance":
"""
Fetch the EnvironmentInstance
:returns: The fetched EnvironmentInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "EnvironmentInstance":
"""
Asynchronous coroutine to fetch the EnvironmentInstance
:returns: The fetched EnvironmentInstance
"""
return await self._proxy.fetch_async()
@property
def deployments(self) -> DeploymentList:
"""
Access the deployments
"""
return self._proxy.deployments
@property
def logs(self) -> LogList:
"""
Access the logs
"""
return self._proxy.logs
@property
def variables(self) -> VariableList:
"""
Access the variables
"""
return self._proxy.variables
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.Serverless.V1.EnvironmentInstance {}>".format(context)
class EnvironmentContext(InstanceContext):
def __init__(self, version: Version, service_sid: str, sid: str):
"""
Initialize the EnvironmentContext
:param version: Version that contains the resource
:param service_sid: The SID of the Service to fetch the Environment resource from.
:param sid: The SID of the Environment resource to fetch.
"""
super().__init__(version)
# Path Solution
self._solution = {
"service_sid": service_sid,
"sid": sid,
}
self._uri = "/Services/{service_sid}/Environments/{sid}".format(
**self._solution
)
self._deployments: Optional[DeploymentList] = None
self._logs: Optional[LogList] = None
self._variables: Optional[VariableList] = None
def delete(self) -> bool:
"""
Deletes the EnvironmentInstance
: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 EnvironmentInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._version.delete_async(
method="DELETE",
uri=self._uri,
)
def fetch(self) -> EnvironmentInstance:
"""
Fetch the EnvironmentInstance
:returns: The fetched EnvironmentInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return EnvironmentInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
sid=self._solution["sid"],
)
async def fetch_async(self) -> EnvironmentInstance:
"""
Asynchronous coroutine to fetch the EnvironmentInstance
:returns: The fetched EnvironmentInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return EnvironmentInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
sid=self._solution["sid"],
)
@property
def deployments(self) -> DeploymentList:
"""
Access the deployments
"""
if self._deployments is None:
self._deployments = DeploymentList(
self._version,
self._solution["service_sid"],
self._solution["sid"],
)
return self._deployments
@property
def logs(self) -> LogList:
"""
Access the logs
"""
if self._logs is None:
self._logs = LogList(
self._version,
self._solution["service_sid"],
self._solution["sid"],
)
return self._logs
@property
def variables(self) -> VariableList:
"""
Access the variables
"""
if self._variables is None:
self._variables = VariableList(
self._version,
self._solution["service_sid"],
self._solution["sid"],
)
return self._variables
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.Serverless.V1.EnvironmentContext {}>".format(context)
class EnvironmentPage(Page):
def get_instance(self, payload: Dict[str, Any]) -> EnvironmentInstance:
"""
Build an instance of EnvironmentInstance
:param payload: Payload response from the API
"""
return EnvironmentInstance(
self._version, payload, service_sid=self._solution["service_sid"]
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Serverless.V1.EnvironmentPage>"
class EnvironmentList(ListResource):
def __init__(self, version: Version, service_sid: str):
"""
Initialize the EnvironmentList
:param version: Version that contains the resource
:param service_sid: The SID of the Service to read the Environment resources from.
"""
super().__init__(version)
# Path Solution
self._solution = {
"service_sid": service_sid,
}
self._uri = "/Services/{service_sid}/Environments".format(**self._solution)
def create(
self, unique_name: str, domain_suffix: Union[str, object] = values.unset
) -> EnvironmentInstance:
"""
Create the EnvironmentInstance
:param unique_name: A user-defined string that uniquely identifies the Environment resource. It can be a maximum of 100 characters.
:param domain_suffix: A URL-friendly name that represents the environment and forms part of the domain name. It can be a maximum of 16 characters.
:returns: The created EnvironmentInstance
"""
data = values.of(
{
"UniqueName": unique_name,
"DomainSuffix": domain_suffix,
}
)
payload = self._version.create(
method="POST",
uri=self._uri,
data=data,
)
return EnvironmentInstance(
self._version, payload, service_sid=self._solution["service_sid"]
)
async def create_async(
self, unique_name: str, domain_suffix: Union[str, object] = values.unset
) -> EnvironmentInstance:
"""
Asynchronously create the EnvironmentInstance
:param unique_name: A user-defined string that uniquely identifies the Environment resource. It can be a maximum of 100 characters.
:param domain_suffix: A URL-friendly name that represents the environment and forms part of the domain name. It can be a maximum of 16 characters.
:returns: The created EnvironmentInstance
"""
data = values.of(
{
"UniqueName": unique_name,
"DomainSuffix": domain_suffix,
}
)
payload = await self._version.create_async(
method="POST",
uri=self._uri,
data=data,
)
return EnvironmentInstance(
self._version, payload, service_sid=self._solution["service_sid"]
)
def stream(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[EnvironmentInstance]:
"""
Streams EnvironmentInstance 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[EnvironmentInstance]:
"""
Asynchronously streams EnvironmentInstance 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[EnvironmentInstance]:
"""
Lists EnvironmentInstance 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[EnvironmentInstance]:
"""
Asynchronously lists EnvironmentInstance 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,
) -> EnvironmentPage:
"""
Retrieve a single page of EnvironmentInstance 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 EnvironmentInstance
"""
data = values.of(
{
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return EnvironmentPage(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,
) -> EnvironmentPage:
"""
Asynchronously retrieve a single page of EnvironmentInstance 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 EnvironmentInstance
"""
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 EnvironmentPage(self._version, response, self._solution)
def get_page(self, target_url: str) -> EnvironmentPage:
"""
Retrieve a specific page of EnvironmentInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of EnvironmentInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return EnvironmentPage(self._version, response, self._solution)
async def get_page_async(self, target_url: str) -> EnvironmentPage:
"""
Asynchronously retrieve a specific page of EnvironmentInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of EnvironmentInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return EnvironmentPage(self._version, response, self._solution)
def get(self, sid: str) -> EnvironmentContext:
"""
Constructs a EnvironmentContext
:param sid: The SID of the Environment resource to fetch.
"""
return EnvironmentContext(
self._version, service_sid=self._solution["service_sid"], sid=sid
)
def __call__(self, sid: str) -> EnvironmentContext:
"""
Constructs a EnvironmentContext
:param sid: The SID of the Environment resource to fetch.
"""
return EnvironmentContext(
self._version, service_sid=self._solution["service_sid"], sid=sid
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Serverless.V1.EnvironmentList>"
@@ -0,0 +1,509 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Serverless
This is the public Twilio REST API.
NOTE: This class is auto generated by OpenAPI Generator.
https://openapi-generator.tech
Do not edit the class manually.
"""
from datetime import datetime
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
from twilio.base import deserialize, values
from twilio.base.instance_context import InstanceContext
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.version import Version
from twilio.base.page import Page
class DeploymentInstance(InstanceResource):
"""
:ivar sid: The unique string that we created to identify the Deployment resource.
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Deployment resource.
:ivar service_sid: The SID of the Service that the Deployment resource is associated with.
:ivar environment_sid: The SID of the Environment for the Deployment.
:ivar build_sid: The SID of the Build for the deployment.
:ivar date_created: The date and time in GMT when the Deployment resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
:ivar date_updated: The date and time in GMT when the Deployment resource was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
:ivar url: The absolute URL of the Deployment resource.
"""
def __init__(
self,
version: Version,
payload: Dict[str, Any],
service_sid: str,
environment_sid: str,
sid: Optional[str] = None,
):
super().__init__(version)
self.sid: Optional[str] = payload.get("sid")
self.account_sid: Optional[str] = payload.get("account_sid")
self.service_sid: Optional[str] = payload.get("service_sid")
self.environment_sid: Optional[str] = payload.get("environment_sid")
self.build_sid: Optional[str] = payload.get("build_sid")
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_created")
)
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_updated")
)
self.url: Optional[str] = payload.get("url")
self._solution = {
"service_sid": service_sid,
"environment_sid": environment_sid,
"sid": sid or self.sid,
}
self._context: Optional[DeploymentContext] = None
@property
def _proxy(self) -> "DeploymentContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: DeploymentContext for this DeploymentInstance
"""
if self._context is None:
self._context = DeploymentContext(
self._version,
service_sid=self._solution["service_sid"],
environment_sid=self._solution["environment_sid"],
sid=self._solution["sid"],
)
return self._context
def fetch(self) -> "DeploymentInstance":
"""
Fetch the DeploymentInstance
:returns: The fetched DeploymentInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "DeploymentInstance":
"""
Asynchronous coroutine to fetch the DeploymentInstance
:returns: The fetched DeploymentInstance
"""
return await self._proxy.fetch_async()
def __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.Serverless.V1.DeploymentInstance {}>".format(context)
class DeploymentContext(InstanceContext):
def __init__(
self, version: Version, service_sid: str, environment_sid: str, sid: str
):
"""
Initialize the DeploymentContext
:param version: Version that contains the resource
:param service_sid: The SID of the Service to fetch the Deployment resource from.
:param environment_sid: The SID of the Environment used by the Deployment to fetch.
:param sid: The SID that identifies the Deployment resource to fetch.
"""
super().__init__(version)
# Path Solution
self._solution = {
"service_sid": service_sid,
"environment_sid": environment_sid,
"sid": sid,
}
self._uri = "/Services/{service_sid}/Environments/{environment_sid}/Deployments/{sid}".format(
**self._solution
)
def fetch(self) -> DeploymentInstance:
"""
Fetch the DeploymentInstance
:returns: The fetched DeploymentInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return DeploymentInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
environment_sid=self._solution["environment_sid"],
sid=self._solution["sid"],
)
async def fetch_async(self) -> DeploymentInstance:
"""
Asynchronous coroutine to fetch the DeploymentInstance
:returns: The fetched DeploymentInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return DeploymentInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
environment_sid=self._solution["environment_sid"],
sid=self._solution["sid"],
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Serverless.V1.DeploymentContext {}>".format(context)
class DeploymentPage(Page):
def get_instance(self, payload: Dict[str, Any]) -> DeploymentInstance:
"""
Build an instance of DeploymentInstance
:param payload: Payload response from the API
"""
return DeploymentInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
environment_sid=self._solution["environment_sid"],
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Serverless.V1.DeploymentPage>"
class DeploymentList(ListResource):
def __init__(self, version: Version, service_sid: str, environment_sid: str):
"""
Initialize the DeploymentList
:param version: Version that contains the resource
:param service_sid: The SID of the Service to read the Deployment resources from.
:param environment_sid: The SID of the Environment used by the Deployment resources to read.
"""
super().__init__(version)
# Path Solution
self._solution = {
"service_sid": service_sid,
"environment_sid": environment_sid,
}
self._uri = (
"/Services/{service_sid}/Environments/{environment_sid}/Deployments".format(
**self._solution
)
)
def create(
self, build_sid: Union[str, object] = values.unset
) -> DeploymentInstance:
"""
Create the DeploymentInstance
:param build_sid: The SID of the Build for the Deployment.
:returns: The created DeploymentInstance
"""
data = values.of(
{
"BuildSid": build_sid,
}
)
payload = self._version.create(
method="POST",
uri=self._uri,
data=data,
)
return DeploymentInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
environment_sid=self._solution["environment_sid"],
)
async def create_async(
self, build_sid: Union[str, object] = values.unset
) -> DeploymentInstance:
"""
Asynchronously create the DeploymentInstance
:param build_sid: The SID of the Build for the Deployment.
:returns: The created DeploymentInstance
"""
data = values.of(
{
"BuildSid": build_sid,
}
)
payload = await self._version.create_async(
method="POST",
uri=self._uri,
data=data,
)
return DeploymentInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
environment_sid=self._solution["environment_sid"],
)
def stream(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[DeploymentInstance]:
"""
Streams DeploymentInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param limit: Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the
limit with the most efficient page size, i.e. min(limit, 1000)
:returns: Generator that will yield up to limit results
"""
limits = self._version.read_limits(limit, page_size)
page = self.page(page_size=limits["page_size"])
return self._version.stream(page, limits["limit"])
async def stream_async(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> AsyncIterator[DeploymentInstance]:
"""
Asynchronously streams DeploymentInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param limit: Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the
limit with the most efficient page size, i.e. min(limit, 1000)
:returns: Generator that will yield up to limit results
"""
limits = self._version.read_limits(limit, page_size)
page = await self.page_async(page_size=limits["page_size"])
return self._version.stream_async(page, limits["limit"])
def list(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[DeploymentInstance]:
"""
Lists DeploymentInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param limit: Upper limit for the number of records to return. list() guarantees
never to return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, list() will attempt to read the limit
with the most efficient page size, i.e. min(limit, 1000)
:returns: list that will contain up to limit results
"""
return list(
self.stream(
limit=limit,
page_size=page_size,
)
)
async def list_async(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[DeploymentInstance]:
"""
Asynchronously lists DeploymentInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param limit: Upper limit for the number of records to return. list() guarantees
never to return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, list() will attempt to read the limit
with the most efficient page size, i.e. min(limit, 1000)
:returns: list that will contain up to limit results
"""
return [
record
async for record in await self.stream_async(
limit=limit,
page_size=page_size,
)
]
def page(
self,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> DeploymentPage:
"""
Retrieve a single page of DeploymentInstance records from the API.
Request is executed immediately
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of DeploymentInstance
"""
data = values.of(
{
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return DeploymentPage(self._version, response, self._solution)
async def page_async(
self,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> DeploymentPage:
"""
Asynchronously retrieve a single page of DeploymentInstance records from the API.
Request is executed immediately
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of DeploymentInstance
"""
data = values.of(
{
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = await self._version.page_async(
method="GET", uri=self._uri, params=data
)
return DeploymentPage(self._version, response, self._solution)
def get_page(self, target_url: str) -> DeploymentPage:
"""
Retrieve a specific page of DeploymentInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of DeploymentInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return DeploymentPage(self._version, response, self._solution)
async def get_page_async(self, target_url: str) -> DeploymentPage:
"""
Asynchronously retrieve a specific page of DeploymentInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of DeploymentInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return DeploymentPage(self._version, response, self._solution)
def get(self, sid: str) -> DeploymentContext:
"""
Constructs a DeploymentContext
:param sid: The SID that identifies the Deployment resource to fetch.
"""
return DeploymentContext(
self._version,
service_sid=self._solution["service_sid"],
environment_sid=self._solution["environment_sid"],
sid=sid,
)
def __call__(self, sid: str) -> DeploymentContext:
"""
Constructs a DeploymentContext
:param sid: The SID that identifies the Deployment resource to fetch.
"""
return DeploymentContext(
self._version,
service_sid=self._solution["service_sid"],
environment_sid=self._solution["environment_sid"],
sid=sid,
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Serverless.V1.DeploymentList>"
@@ -0,0 +1,521 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Serverless
This is the public Twilio REST API.
NOTE: This class is auto generated by OpenAPI Generator.
https://openapi-generator.tech
Do not edit the class manually.
"""
from datetime import datetime
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
from twilio.base import deserialize, serialize, values
from twilio.base.instance_context import InstanceContext
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.version import Version
from twilio.base.page import Page
class LogInstance(InstanceResource):
class Level(object):
INFO = "info"
WARN = "warn"
ERROR = "error"
"""
:ivar sid: The unique string that we created to identify the Log resource.
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Log resource.
:ivar service_sid: The SID of the Service that the Log resource is associated with.
:ivar environment_sid: The SID of the environment in which the log occurred.
:ivar build_sid: The SID of the build that corresponds to the log.
:ivar deployment_sid: The SID of the deployment that corresponds to the log.
:ivar function_sid: The SID of the function whose invocation produced the log.
:ivar request_sid: The SID of the request associated with the log.
:ivar level:
:ivar message: The log message.
:ivar date_created: The date and time in GMT when the Log resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
:ivar url: The absolute URL of the Log resource.
"""
def __init__(
self,
version: Version,
payload: Dict[str, Any],
service_sid: str,
environment_sid: str,
sid: Optional[str] = None,
):
super().__init__(version)
self.sid: Optional[str] = payload.get("sid")
self.account_sid: Optional[str] = payload.get("account_sid")
self.service_sid: Optional[str] = payload.get("service_sid")
self.environment_sid: Optional[str] = payload.get("environment_sid")
self.build_sid: Optional[str] = payload.get("build_sid")
self.deployment_sid: Optional[str] = payload.get("deployment_sid")
self.function_sid: Optional[str] = payload.get("function_sid")
self.request_sid: Optional[str] = payload.get("request_sid")
self.level: Optional["LogInstance.Level"] = payload.get("level")
self.message: Optional[str] = payload.get("message")
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_created")
)
self.url: Optional[str] = payload.get("url")
self._solution = {
"service_sid": service_sid,
"environment_sid": environment_sid,
"sid": sid or self.sid,
}
self._context: Optional[LogContext] = None
@property
def _proxy(self) -> "LogContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: LogContext for this LogInstance
"""
if self._context is None:
self._context = LogContext(
self._version,
service_sid=self._solution["service_sid"],
environment_sid=self._solution["environment_sid"],
sid=self._solution["sid"],
)
return self._context
def fetch(self) -> "LogInstance":
"""
Fetch the LogInstance
:returns: The fetched LogInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "LogInstance":
"""
Asynchronous coroutine to fetch the LogInstance
:returns: The fetched LogInstance
"""
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.Serverless.V1.LogInstance {}>".format(context)
class LogContext(InstanceContext):
def __init__(
self, version: Version, service_sid: str, environment_sid: str, sid: str
):
"""
Initialize the LogContext
:param version: Version that contains the resource
:param service_sid: The SID of the Service to fetch the Log resource from.
:param environment_sid: The SID of the environment with the Log resource to fetch.
:param sid: The SID of the Log resource to fetch.
"""
super().__init__(version)
# Path Solution
self._solution = {
"service_sid": service_sid,
"environment_sid": environment_sid,
"sid": sid,
}
self._uri = (
"/Services/{service_sid}/Environments/{environment_sid}/Logs/{sid}".format(
**self._solution
)
)
def fetch(self) -> LogInstance:
"""
Fetch the LogInstance
:returns: The fetched LogInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return LogInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
environment_sid=self._solution["environment_sid"],
sid=self._solution["sid"],
)
async def fetch_async(self) -> LogInstance:
"""
Asynchronous coroutine to fetch the LogInstance
:returns: The fetched LogInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return LogInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
environment_sid=self._solution["environment_sid"],
sid=self._solution["sid"],
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Serverless.V1.LogContext {}>".format(context)
class LogPage(Page):
def get_instance(self, payload: Dict[str, Any]) -> LogInstance:
"""
Build an instance of LogInstance
:param payload: Payload response from the API
"""
return LogInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
environment_sid=self._solution["environment_sid"],
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Serverless.V1.LogPage>"
class LogList(ListResource):
def __init__(self, version: Version, service_sid: str, environment_sid: str):
"""
Initialize the LogList
:param version: Version that contains the resource
:param service_sid: The SID of the Service to read the Log resource from.
:param environment_sid: The SID of the environment with the Log resources to read.
"""
super().__init__(version)
# Path Solution
self._solution = {
"service_sid": service_sid,
"environment_sid": environment_sid,
}
self._uri = (
"/Services/{service_sid}/Environments/{environment_sid}/Logs".format(
**self._solution
)
)
def stream(
self,
function_sid: Union[str, object] = values.unset,
start_date: Union[datetime, object] = values.unset,
end_date: Union[datetime, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[LogInstance]:
"""
Streams LogInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param str function_sid: The SID of the function whose invocation produced the Log resources to read.
:param datetime start_date: The date/time (in GMT, ISO 8601) after which the Log resources must have been created. Defaults to 1 day prior to current date/time.
:param datetime end_date: The date/time (in GMT, ISO 8601) before which the Log resources must have been created. Defaults to current date/time.
:param limit: Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the
limit with the most efficient page size, i.e. min(limit, 1000)
:returns: Generator that will yield up to limit results
"""
limits = self._version.read_limits(limit, page_size)
page = self.page(
function_sid=function_sid,
start_date=start_date,
end_date=end_date,
page_size=limits["page_size"],
)
return self._version.stream(page, limits["limit"])
async def stream_async(
self,
function_sid: Union[str, object] = values.unset,
start_date: Union[datetime, object] = values.unset,
end_date: Union[datetime, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> AsyncIterator[LogInstance]:
"""
Asynchronously streams LogInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param str function_sid: The SID of the function whose invocation produced the Log resources to read.
:param datetime start_date: The date/time (in GMT, ISO 8601) after which the Log resources must have been created. Defaults to 1 day prior to current date/time.
:param datetime end_date: The date/time (in GMT, ISO 8601) before which the Log resources must have been created. Defaults to current date/time.
:param limit: Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the
limit with the most efficient page size, i.e. min(limit, 1000)
:returns: Generator that will yield up to limit results
"""
limits = self._version.read_limits(limit, page_size)
page = await self.page_async(
function_sid=function_sid,
start_date=start_date,
end_date=end_date,
page_size=limits["page_size"],
)
return self._version.stream_async(page, limits["limit"])
def list(
self,
function_sid: Union[str, object] = values.unset,
start_date: Union[datetime, object] = values.unset,
end_date: Union[datetime, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[LogInstance]:
"""
Lists LogInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param str function_sid: The SID of the function whose invocation produced the Log resources to read.
:param datetime start_date: The date/time (in GMT, ISO 8601) after which the Log resources must have been created. Defaults to 1 day prior to current date/time.
:param datetime end_date: The date/time (in GMT, ISO 8601) before which the Log resources must have been created. Defaults to current date/time.
:param limit: Upper limit for the number of records to return. list() guarantees
never to return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, list() will attempt to read the limit
with the most efficient page size, i.e. min(limit, 1000)
:returns: list that will contain up to limit results
"""
return list(
self.stream(
function_sid=function_sid,
start_date=start_date,
end_date=end_date,
limit=limit,
page_size=page_size,
)
)
async def list_async(
self,
function_sid: Union[str, object] = values.unset,
start_date: Union[datetime, object] = values.unset,
end_date: Union[datetime, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[LogInstance]:
"""
Asynchronously lists LogInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param str function_sid: The SID of the function whose invocation produced the Log resources to read.
:param datetime start_date: The date/time (in GMT, ISO 8601) after which the Log resources must have been created. Defaults to 1 day prior to current date/time.
:param datetime end_date: The date/time (in GMT, ISO 8601) before which the Log resources must have been created. Defaults to current date/time.
:param limit: Upper limit for the number of records to return. list() guarantees
never to return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, list() will attempt to read the limit
with the most efficient page size, i.e. min(limit, 1000)
:returns: list that will contain up to limit results
"""
return [
record
async for record in await self.stream_async(
function_sid=function_sid,
start_date=start_date,
end_date=end_date,
limit=limit,
page_size=page_size,
)
]
def page(
self,
function_sid: Union[str, object] = values.unset,
start_date: Union[datetime, object] = values.unset,
end_date: Union[datetime, object] = values.unset,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> LogPage:
"""
Retrieve a single page of LogInstance records from the API.
Request is executed immediately
:param function_sid: The SID of the function whose invocation produced the Log resources to read.
:param start_date: The date/time (in GMT, ISO 8601) after which the Log resources must have been created. Defaults to 1 day prior to current date/time.
:param end_date: The date/time (in GMT, ISO 8601) before which the Log resources must have been created. Defaults to current date/time.
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of LogInstance
"""
data = values.of(
{
"FunctionSid": function_sid,
"StartDate": serialize.iso8601_datetime(start_date),
"EndDate": serialize.iso8601_datetime(end_date),
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return LogPage(self._version, response, self._solution)
async def page_async(
self,
function_sid: Union[str, object] = values.unset,
start_date: Union[datetime, object] = values.unset,
end_date: Union[datetime, object] = values.unset,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> LogPage:
"""
Asynchronously retrieve a single page of LogInstance records from the API.
Request is executed immediately
:param function_sid: The SID of the function whose invocation produced the Log resources to read.
:param start_date: The date/time (in GMT, ISO 8601) after which the Log resources must have been created. Defaults to 1 day prior to current date/time.
:param end_date: The date/time (in GMT, ISO 8601) before which the Log resources must have been created. Defaults to current date/time.
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of LogInstance
"""
data = values.of(
{
"FunctionSid": function_sid,
"StartDate": serialize.iso8601_datetime(start_date),
"EndDate": serialize.iso8601_datetime(end_date),
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = await self._version.page_async(
method="GET", uri=self._uri, params=data
)
return LogPage(self._version, response, self._solution)
def get_page(self, target_url: str) -> LogPage:
"""
Retrieve a specific page of LogInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of LogInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return LogPage(self._version, response, self._solution)
async def get_page_async(self, target_url: str) -> LogPage:
"""
Asynchronously retrieve a specific page of LogInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of LogInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return LogPage(self._version, response, self._solution)
def get(self, sid: str) -> LogContext:
"""
Constructs a LogContext
:param sid: The SID of the Log resource to fetch.
"""
return LogContext(
self._version,
service_sid=self._solution["service_sid"],
environment_sid=self._solution["environment_sid"],
sid=sid,
)
def __call__(self, sid: str) -> LogContext:
"""
Constructs a LogContext
:param sid: The SID of the Log resource to fetch.
"""
return LogContext(
self._version,
service_sid=self._solution["service_sid"],
environment_sid=self._solution["environment_sid"],
sid=sid,
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Serverless.V1.LogList>"
@@ -0,0 +1,657 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Serverless
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 VariableInstance(InstanceResource):
"""
:ivar sid: The unique string that we created to identify the Variable resource.
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Variable resource.
:ivar service_sid: The SID of the Service that the Variable resource is associated with.
:ivar environment_sid: The SID of the Environment in which the Variable exists.
:ivar key: A string by which the Variable resource can be referenced.
:ivar value: A string that contains the actual value of the Variable.
:ivar date_created: The date and time in GMT when the Variable resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
:ivar date_updated: The date and time in GMT when the Variable resource was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
:ivar url: The absolute URL of the Variable resource.
"""
def __init__(
self,
version: Version,
payload: Dict[str, Any],
service_sid: str,
environment_sid: str,
sid: Optional[str] = None,
):
super().__init__(version)
self.sid: Optional[str] = payload.get("sid")
self.account_sid: Optional[str] = payload.get("account_sid")
self.service_sid: Optional[str] = payload.get("service_sid")
self.environment_sid: Optional[str] = payload.get("environment_sid")
self.key: Optional[str] = payload.get("key")
self.value: Optional[str] = payload.get("value")
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_created")
)
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_updated")
)
self.url: Optional[str] = payload.get("url")
self._solution = {
"service_sid": service_sid,
"environment_sid": environment_sid,
"sid": sid or self.sid,
}
self._context: Optional[VariableContext] = None
@property
def _proxy(self) -> "VariableContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: VariableContext for this VariableInstance
"""
if self._context is None:
self._context = VariableContext(
self._version,
service_sid=self._solution["service_sid"],
environment_sid=self._solution["environment_sid"],
sid=self._solution["sid"],
)
return self._context
def delete(self) -> bool:
"""
Deletes the VariableInstance
:returns: True if delete succeeds, False otherwise
"""
return self._proxy.delete()
async def delete_async(self) -> bool:
"""
Asynchronous coroutine that deletes the VariableInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._proxy.delete_async()
def fetch(self) -> "VariableInstance":
"""
Fetch the VariableInstance
:returns: The fetched VariableInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "VariableInstance":
"""
Asynchronous coroutine to fetch the VariableInstance
:returns: The fetched VariableInstance
"""
return await self._proxy.fetch_async()
def update(
self,
key: Union[str, object] = values.unset,
value: Union[str, object] = values.unset,
) -> "VariableInstance":
"""
Update the VariableInstance
:param key: A string by which the Variable resource can be referenced. It can be a maximum of 128 characters.
:param value: A string that contains the actual value of the Variable. It can be a maximum of 450 bytes in size.
:returns: The updated VariableInstance
"""
return self._proxy.update(
key=key,
value=value,
)
async def update_async(
self,
key: Union[str, object] = values.unset,
value: Union[str, object] = values.unset,
) -> "VariableInstance":
"""
Asynchronous coroutine to update the VariableInstance
:param key: A string by which the Variable resource can be referenced. It can be a maximum of 128 characters.
:param value: A string that contains the actual value of the Variable. It can be a maximum of 450 bytes in size.
:returns: The updated VariableInstance
"""
return await self._proxy.update_async(
key=key,
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.Serverless.V1.VariableInstance {}>".format(context)
class VariableContext(InstanceContext):
def __init__(
self, version: Version, service_sid: str, environment_sid: str, sid: str
):
"""
Initialize the VariableContext
:param version: Version that contains the resource
:param service_sid: The SID of the Service to update the Variable resource under.
:param environment_sid: The SID of the Environment with the Variable resource to update.
:param sid: The SID of the Variable resource to update.
"""
super().__init__(version)
# Path Solution
self._solution = {
"service_sid": service_sid,
"environment_sid": environment_sid,
"sid": sid,
}
self._uri = "/Services/{service_sid}/Environments/{environment_sid}/Variables/{sid}".format(
**self._solution
)
def delete(self) -> bool:
"""
Deletes the VariableInstance
: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 VariableInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._version.delete_async(
method="DELETE",
uri=self._uri,
)
def fetch(self) -> VariableInstance:
"""
Fetch the VariableInstance
:returns: The fetched VariableInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return VariableInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
environment_sid=self._solution["environment_sid"],
sid=self._solution["sid"],
)
async def fetch_async(self) -> VariableInstance:
"""
Asynchronous coroutine to fetch the VariableInstance
:returns: The fetched VariableInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return VariableInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
environment_sid=self._solution["environment_sid"],
sid=self._solution["sid"],
)
def update(
self,
key: Union[str, object] = values.unset,
value: Union[str, object] = values.unset,
) -> VariableInstance:
"""
Update the VariableInstance
:param key: A string by which the Variable resource can be referenced. It can be a maximum of 128 characters.
:param value: A string that contains the actual value of the Variable. It can be a maximum of 450 bytes in size.
:returns: The updated VariableInstance
"""
data = values.of(
{
"Key": key,
"Value": value,
}
)
payload = self._version.update(
method="POST",
uri=self._uri,
data=data,
)
return VariableInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
environment_sid=self._solution["environment_sid"],
sid=self._solution["sid"],
)
async def update_async(
self,
key: Union[str, object] = values.unset,
value: Union[str, object] = values.unset,
) -> VariableInstance:
"""
Asynchronous coroutine to update the VariableInstance
:param key: A string by which the Variable resource can be referenced. It can be a maximum of 128 characters.
:param value: A string that contains the actual value of the Variable. It can be a maximum of 450 bytes in size.
:returns: The updated VariableInstance
"""
data = values.of(
{
"Key": key,
"Value": value,
}
)
payload = await self._version.update_async(
method="POST",
uri=self._uri,
data=data,
)
return VariableInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
environment_sid=self._solution["environment_sid"],
sid=self._solution["sid"],
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Serverless.V1.VariableContext {}>".format(context)
class VariablePage(Page):
def get_instance(self, payload: Dict[str, Any]) -> VariableInstance:
"""
Build an instance of VariableInstance
:param payload: Payload response from the API
"""
return VariableInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
environment_sid=self._solution["environment_sid"],
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Serverless.V1.VariablePage>"
class VariableList(ListResource):
def __init__(self, version: Version, service_sid: str, environment_sid: str):
"""
Initialize the VariableList
:param version: Version that contains the resource
:param service_sid: The SID of the Service to read the Variable resources from.
:param environment_sid: The SID of the Environment with the Variable resources to read.
"""
super().__init__(version)
# Path Solution
self._solution = {
"service_sid": service_sid,
"environment_sid": environment_sid,
}
self._uri = (
"/Services/{service_sid}/Environments/{environment_sid}/Variables".format(
**self._solution
)
)
def create(self, key: str, value: str) -> VariableInstance:
"""
Create the VariableInstance
:param key: A string by which the Variable resource can be referenced. It can be a maximum of 128 characters.
:param value: A string that contains the actual value of the Variable. It can be a maximum of 450 bytes in size.
:returns: The created VariableInstance
"""
data = values.of(
{
"Key": key,
"Value": value,
}
)
payload = self._version.create(
method="POST",
uri=self._uri,
data=data,
)
return VariableInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
environment_sid=self._solution["environment_sid"],
)
async def create_async(self, key: str, value: str) -> VariableInstance:
"""
Asynchronously create the VariableInstance
:param key: A string by which the Variable resource can be referenced. It can be a maximum of 128 characters.
:param value: A string that contains the actual value of the Variable. It can be a maximum of 450 bytes in size.
:returns: The created VariableInstance
"""
data = values.of(
{
"Key": key,
"Value": value,
}
)
payload = await self._version.create_async(
method="POST",
uri=self._uri,
data=data,
)
return VariableInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
environment_sid=self._solution["environment_sid"],
)
def stream(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[VariableInstance]:
"""
Streams VariableInstance 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[VariableInstance]:
"""
Asynchronously streams VariableInstance 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[VariableInstance]:
"""
Lists VariableInstance 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[VariableInstance]:
"""
Asynchronously lists VariableInstance 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,
) -> VariablePage:
"""
Retrieve a single page of VariableInstance 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 VariableInstance
"""
data = values.of(
{
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return VariablePage(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,
) -> VariablePage:
"""
Asynchronously retrieve a single page of VariableInstance 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 VariableInstance
"""
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 VariablePage(self._version, response, self._solution)
def get_page(self, target_url: str) -> VariablePage:
"""
Retrieve a specific page of VariableInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of VariableInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return VariablePage(self._version, response, self._solution)
async def get_page_async(self, target_url: str) -> VariablePage:
"""
Asynchronously retrieve a specific page of VariableInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of VariableInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return VariablePage(self._version, response, self._solution)
def get(self, sid: str) -> VariableContext:
"""
Constructs a VariableContext
:param sid: The SID of the Variable resource to update.
"""
return VariableContext(
self._version,
service_sid=self._solution["service_sid"],
environment_sid=self._solution["environment_sid"],
sid=sid,
)
def __call__(self, sid: str) -> VariableContext:
"""
Constructs a VariableContext
:param sid: The SID of the Variable resource to update.
"""
return VariableContext(
self._version,
service_sid=self._solution["service_sid"],
environment_sid=self._solution["environment_sid"],
sid=sid,
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Serverless.V1.VariableList>"
@@ -0,0 +1,618 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Serverless
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.serverless.v1.service.function.function_version import (
FunctionVersionList,
)
class FunctionInstance(InstanceResource):
"""
:ivar sid: The unique string that we created to identify the Function resource.
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Function resource.
:ivar service_sid: The SID of the Service that the Function resource is associated with.
:ivar friendly_name: The string that you assigned to describe the Function resource. It can be a maximum of 255 characters.
:ivar date_created: The date and time in GMT when the Function resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
:ivar date_updated: The date and time in GMT when the Function resource was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
:ivar url: The absolute URL of the Function resource.
:ivar links: The URLs of nested resources of the Function resource.
"""
def __init__(
self,
version: Version,
payload: Dict[str, Any],
service_sid: str,
sid: Optional[str] = None,
):
super().__init__(version)
self.sid: Optional[str] = payload.get("sid")
self.account_sid: Optional[str] = payload.get("account_sid")
self.service_sid: Optional[str] = payload.get("service_sid")
self.friendly_name: Optional[str] = payload.get("friendly_name")
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_created")
)
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_updated")
)
self.url: Optional[str] = payload.get("url")
self.links: Optional[Dict[str, object]] = payload.get("links")
self._solution = {
"service_sid": service_sid,
"sid": sid or self.sid,
}
self._context: Optional[FunctionContext] = None
@property
def _proxy(self) -> "FunctionContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: FunctionContext for this FunctionInstance
"""
if self._context is None:
self._context = FunctionContext(
self._version,
service_sid=self._solution["service_sid"],
sid=self._solution["sid"],
)
return self._context
def delete(self) -> bool:
"""
Deletes the FunctionInstance
:returns: True if delete succeeds, False otherwise
"""
return self._proxy.delete()
async def delete_async(self) -> bool:
"""
Asynchronous coroutine that deletes the FunctionInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._proxy.delete_async()
def fetch(self) -> "FunctionInstance":
"""
Fetch the FunctionInstance
:returns: The fetched FunctionInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "FunctionInstance":
"""
Asynchronous coroutine to fetch the FunctionInstance
:returns: The fetched FunctionInstance
"""
return await self._proxy.fetch_async()
def update(self, friendly_name: str) -> "FunctionInstance":
"""
Update the FunctionInstance
:param friendly_name: A descriptive string that you create to describe the Function resource. It can be a maximum of 255 characters.
:returns: The updated FunctionInstance
"""
return self._proxy.update(
friendly_name=friendly_name,
)
async def update_async(self, friendly_name: str) -> "FunctionInstance":
"""
Asynchronous coroutine to update the FunctionInstance
:param friendly_name: A descriptive string that you create to describe the Function resource. It can be a maximum of 255 characters.
:returns: The updated FunctionInstance
"""
return await self._proxy.update_async(
friendly_name=friendly_name,
)
@property
def function_versions(self) -> FunctionVersionList:
"""
Access the function_versions
"""
return self._proxy.function_versions
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.Serverless.V1.FunctionInstance {}>".format(context)
class FunctionContext(InstanceContext):
def __init__(self, version: Version, service_sid: str, sid: str):
"""
Initialize the FunctionContext
:param version: Version that contains the resource
:param service_sid: The SID of the Service to update the Function resource from.
:param sid: The SID of the Function resource to update.
"""
super().__init__(version)
# Path Solution
self._solution = {
"service_sid": service_sid,
"sid": sid,
}
self._uri = "/Services/{service_sid}/Functions/{sid}".format(**self._solution)
self._function_versions: Optional[FunctionVersionList] = None
def delete(self) -> bool:
"""
Deletes the FunctionInstance
: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 FunctionInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._version.delete_async(
method="DELETE",
uri=self._uri,
)
def fetch(self) -> FunctionInstance:
"""
Fetch the FunctionInstance
:returns: The fetched FunctionInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return FunctionInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
sid=self._solution["sid"],
)
async def fetch_async(self) -> FunctionInstance:
"""
Asynchronous coroutine to fetch the FunctionInstance
:returns: The fetched FunctionInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return FunctionInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
sid=self._solution["sid"],
)
def update(self, friendly_name: str) -> FunctionInstance:
"""
Update the FunctionInstance
:param friendly_name: A descriptive string that you create to describe the Function resource. It can be a maximum of 255 characters.
:returns: The updated FunctionInstance
"""
data = values.of(
{
"FriendlyName": friendly_name,
}
)
payload = self._version.update(
method="POST",
uri=self._uri,
data=data,
)
return FunctionInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
sid=self._solution["sid"],
)
async def update_async(self, friendly_name: str) -> FunctionInstance:
"""
Asynchronous coroutine to update the FunctionInstance
:param friendly_name: A descriptive string that you create to describe the Function resource. It can be a maximum of 255 characters.
:returns: The updated FunctionInstance
"""
data = values.of(
{
"FriendlyName": friendly_name,
}
)
payload = await self._version.update_async(
method="POST",
uri=self._uri,
data=data,
)
return FunctionInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
sid=self._solution["sid"],
)
@property
def function_versions(self) -> FunctionVersionList:
"""
Access the function_versions
"""
if self._function_versions is None:
self._function_versions = FunctionVersionList(
self._version,
self._solution["service_sid"],
self._solution["sid"],
)
return self._function_versions
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.Serverless.V1.FunctionContext {}>".format(context)
class FunctionPage(Page):
def get_instance(self, payload: Dict[str, Any]) -> FunctionInstance:
"""
Build an instance of FunctionInstance
:param payload: Payload response from the API
"""
return FunctionInstance(
self._version, payload, service_sid=self._solution["service_sid"]
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Serverless.V1.FunctionPage>"
class FunctionList(ListResource):
def __init__(self, version: Version, service_sid: str):
"""
Initialize the FunctionList
:param version: Version that contains the resource
:param service_sid: The SID of the Service to read the Function resources from.
"""
super().__init__(version)
# Path Solution
self._solution = {
"service_sid": service_sid,
}
self._uri = "/Services/{service_sid}/Functions".format(**self._solution)
def create(self, friendly_name: str) -> FunctionInstance:
"""
Create the FunctionInstance
:param friendly_name: A descriptive string that you create to describe the Function resource. It can be a maximum of 255 characters.
:returns: The created FunctionInstance
"""
data = values.of(
{
"FriendlyName": friendly_name,
}
)
payload = self._version.create(
method="POST",
uri=self._uri,
data=data,
)
return FunctionInstance(
self._version, payload, service_sid=self._solution["service_sid"]
)
async def create_async(self, friendly_name: str) -> FunctionInstance:
"""
Asynchronously create the FunctionInstance
:param friendly_name: A descriptive string that you create to describe the Function resource. It can be a maximum of 255 characters.
:returns: The created FunctionInstance
"""
data = values.of(
{
"FriendlyName": friendly_name,
}
)
payload = await self._version.create_async(
method="POST",
uri=self._uri,
data=data,
)
return FunctionInstance(
self._version, payload, service_sid=self._solution["service_sid"]
)
def stream(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[FunctionInstance]:
"""
Streams FunctionInstance 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[FunctionInstance]:
"""
Asynchronously streams FunctionInstance 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[FunctionInstance]:
"""
Lists FunctionInstance 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[FunctionInstance]:
"""
Asynchronously lists FunctionInstance 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,
) -> FunctionPage:
"""
Retrieve a single page of FunctionInstance 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 FunctionInstance
"""
data = values.of(
{
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return FunctionPage(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,
) -> FunctionPage:
"""
Asynchronously retrieve a single page of FunctionInstance 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 FunctionInstance
"""
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 FunctionPage(self._version, response, self._solution)
def get_page(self, target_url: str) -> FunctionPage:
"""
Retrieve a specific page of FunctionInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of FunctionInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return FunctionPage(self._version, response, self._solution)
async def get_page_async(self, target_url: str) -> FunctionPage:
"""
Asynchronously retrieve a specific page of FunctionInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of FunctionInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return FunctionPage(self._version, response, self._solution)
def get(self, sid: str) -> FunctionContext:
"""
Constructs a FunctionContext
:param sid: The SID of the Function resource to update.
"""
return FunctionContext(
self._version, service_sid=self._solution["service_sid"], sid=sid
)
def __call__(self, sid: str) -> FunctionContext:
"""
Constructs a FunctionContext
:param sid: The SID of the Function resource to update.
"""
return FunctionContext(
self._version, service_sid=self._solution["service_sid"], sid=sid
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Serverless.V1.FunctionList>"
@@ -0,0 +1,481 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Serverless
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.serverless.v1.service.function.function_version.function_version_content import (
FunctionVersionContentList,
)
class FunctionVersionInstance(InstanceResource):
class Visibility(object):
PUBLIC = "public"
PRIVATE = "private"
PROTECTED = "protected"
"""
:ivar sid: The unique string that we created to identify the Function Version resource.
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Function Version resource.
:ivar service_sid: The SID of the Service that the Function Version resource is associated with.
:ivar function_sid: The SID of the Function resource that is the parent of the Function Version resource.
:ivar path: The URL-friendly string by which the Function Version resource can be referenced. It can be a maximum of 255 characters. All paths begin with a forward slash ('/'). If a Function Version creation request is submitted with a path not containing a leading slash, the path will automatically be prepended with one.
:ivar visibility:
:ivar date_created: The date and time in GMT when the Function Version resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
:ivar url: The absolute URL of the Function Version resource.
:ivar links:
"""
def __init__(
self,
version: Version,
payload: Dict[str, Any],
service_sid: str,
function_sid: str,
sid: Optional[str] = None,
):
super().__init__(version)
self.sid: Optional[str] = payload.get("sid")
self.account_sid: Optional[str] = payload.get("account_sid")
self.service_sid: Optional[str] = payload.get("service_sid")
self.function_sid: Optional[str] = payload.get("function_sid")
self.path: Optional[str] = payload.get("path")
self.visibility: Optional["FunctionVersionInstance.Visibility"] = payload.get(
"visibility"
)
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_created")
)
self.url: Optional[str] = payload.get("url")
self.links: Optional[Dict[str, object]] = payload.get("links")
self._solution = {
"service_sid": service_sid,
"function_sid": function_sid,
"sid": sid or self.sid,
}
self._context: Optional[FunctionVersionContext] = None
@property
def _proxy(self) -> "FunctionVersionContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: FunctionVersionContext for this FunctionVersionInstance
"""
if self._context is None:
self._context = FunctionVersionContext(
self._version,
service_sid=self._solution["service_sid"],
function_sid=self._solution["function_sid"],
sid=self._solution["sid"],
)
return self._context
def fetch(self) -> "FunctionVersionInstance":
"""
Fetch the FunctionVersionInstance
:returns: The fetched FunctionVersionInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "FunctionVersionInstance":
"""
Asynchronous coroutine to fetch the FunctionVersionInstance
:returns: The fetched FunctionVersionInstance
"""
return await self._proxy.fetch_async()
@property
def function_version_content(self) -> FunctionVersionContentList:
"""
Access the function_version_content
"""
return self._proxy.function_version_content
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.Serverless.V1.FunctionVersionInstance {}>".format(context)
class FunctionVersionContext(InstanceContext):
def __init__(self, version: Version, service_sid: str, function_sid: str, sid: str):
"""
Initialize the FunctionVersionContext
:param version: Version that contains the resource
:param service_sid: The SID of the Service to fetch the Function Version resource from.
:param function_sid: The SID of the function that is the parent of the Function Version resource to fetch.
:param sid: The SID of the Function Version resource to fetch.
"""
super().__init__(version)
# Path Solution
self._solution = {
"service_sid": service_sid,
"function_sid": function_sid,
"sid": sid,
}
self._uri = (
"/Services/{service_sid}/Functions/{function_sid}/Versions/{sid}".format(
**self._solution
)
)
self._function_version_content: Optional[FunctionVersionContentList] = None
def fetch(self) -> FunctionVersionInstance:
"""
Fetch the FunctionVersionInstance
:returns: The fetched FunctionVersionInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return FunctionVersionInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
function_sid=self._solution["function_sid"],
sid=self._solution["sid"],
)
async def fetch_async(self) -> FunctionVersionInstance:
"""
Asynchronous coroutine to fetch the FunctionVersionInstance
:returns: The fetched FunctionVersionInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return FunctionVersionInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
function_sid=self._solution["function_sid"],
sid=self._solution["sid"],
)
@property
def function_version_content(self) -> FunctionVersionContentList:
"""
Access the function_version_content
"""
if self._function_version_content is None:
self._function_version_content = FunctionVersionContentList(
self._version,
self._solution["service_sid"],
self._solution["function_sid"],
self._solution["sid"],
)
return self._function_version_content
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.Serverless.V1.FunctionVersionContext {}>".format(context)
class FunctionVersionPage(Page):
def get_instance(self, payload: Dict[str, Any]) -> FunctionVersionInstance:
"""
Build an instance of FunctionVersionInstance
:param payload: Payload response from the API
"""
return FunctionVersionInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
function_sid=self._solution["function_sid"],
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Serverless.V1.FunctionVersionPage>"
class FunctionVersionList(ListResource):
def __init__(self, version: Version, service_sid: str, function_sid: str):
"""
Initialize the FunctionVersionList
:param version: Version that contains the resource
:param service_sid: The SID of the Service to read the Function Version resources from.
:param function_sid: The SID of the function that is the parent of the Function Version resources to read.
"""
super().__init__(version)
# Path Solution
self._solution = {
"service_sid": service_sid,
"function_sid": function_sid,
}
self._uri = "/Services/{service_sid}/Functions/{function_sid}/Versions".format(
**self._solution
)
def stream(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[FunctionVersionInstance]:
"""
Streams FunctionVersionInstance 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[FunctionVersionInstance]:
"""
Asynchronously streams FunctionVersionInstance 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[FunctionVersionInstance]:
"""
Lists FunctionVersionInstance 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[FunctionVersionInstance]:
"""
Asynchronously lists FunctionVersionInstance 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,
) -> FunctionVersionPage:
"""
Retrieve a single page of FunctionVersionInstance 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 FunctionVersionInstance
"""
data = values.of(
{
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return FunctionVersionPage(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,
) -> FunctionVersionPage:
"""
Asynchronously retrieve a single page of FunctionVersionInstance 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 FunctionVersionInstance
"""
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 FunctionVersionPage(self._version, response, self._solution)
def get_page(self, target_url: str) -> FunctionVersionPage:
"""
Retrieve a specific page of FunctionVersionInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of FunctionVersionInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return FunctionVersionPage(self._version, response, self._solution)
async def get_page_async(self, target_url: str) -> FunctionVersionPage:
"""
Asynchronously retrieve a specific page of FunctionVersionInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of FunctionVersionInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return FunctionVersionPage(self._version, response, self._solution)
def get(self, sid: str) -> FunctionVersionContext:
"""
Constructs a FunctionVersionContext
:param sid: The SID of the Function Version resource to fetch.
"""
return FunctionVersionContext(
self._version,
service_sid=self._solution["service_sid"],
function_sid=self._solution["function_sid"],
sid=sid,
)
def __call__(self, sid: str) -> FunctionVersionContext:
"""
Constructs a FunctionVersionContext
:param sid: The SID of the Function Version resource to fetch.
"""
return FunctionVersionContext(
self._version,
service_sid=self._solution["service_sid"],
function_sid=self._solution["function_sid"],
sid=sid,
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Serverless.V1.FunctionVersionList>"
@@ -0,0 +1,229 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Serverless
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 FunctionVersionContentInstance(InstanceResource):
"""
:ivar sid: The unique string that we created to identify the Function Version resource.
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Function Version resource.
:ivar service_sid: The SID of the Service that the Function Version resource is associated with.
:ivar function_sid: The SID of the Function that is the parent of the Function Version.
:ivar content: The content of the Function Version resource.
:ivar url:
"""
def __init__(
self,
version: Version,
payload: Dict[str, Any],
service_sid: str,
function_sid: str,
sid: str,
):
super().__init__(version)
self.sid: Optional[str] = payload.get("sid")
self.account_sid: Optional[str] = payload.get("account_sid")
self.service_sid: Optional[str] = payload.get("service_sid")
self.function_sid: Optional[str] = payload.get("function_sid")
self.content: Optional[str] = payload.get("content")
self.url: Optional[str] = payload.get("url")
self._solution = {
"service_sid": service_sid,
"function_sid": function_sid,
"sid": sid,
}
self._context: Optional[FunctionVersionContentContext] = None
@property
def _proxy(self) -> "FunctionVersionContentContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: FunctionVersionContentContext for this FunctionVersionContentInstance
"""
if self._context is None:
self._context = FunctionVersionContentContext(
self._version,
service_sid=self._solution["service_sid"],
function_sid=self._solution["function_sid"],
sid=self._solution["sid"],
)
return self._context
def fetch(self) -> "FunctionVersionContentInstance":
"""
Fetch the FunctionVersionContentInstance
:returns: The fetched FunctionVersionContentInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "FunctionVersionContentInstance":
"""
Asynchronous coroutine to fetch the FunctionVersionContentInstance
:returns: The fetched FunctionVersionContentInstance
"""
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.Serverless.V1.FunctionVersionContentInstance {}>".format(
context
)
class FunctionVersionContentContext(InstanceContext):
def __init__(self, version: Version, service_sid: str, function_sid: str, sid: str):
"""
Initialize the FunctionVersionContentContext
:param version: Version that contains the resource
:param service_sid: The SID of the Service to fetch the Function Version content from.
:param function_sid: The SID of the Function that is the parent of the Function Version content to fetch.
:param sid: The SID of the Function Version content to fetch.
"""
super().__init__(version)
# Path Solution
self._solution = {
"service_sid": service_sid,
"function_sid": function_sid,
"sid": sid,
}
self._uri = "/Services/{service_sid}/Functions/{function_sid}/Versions/{sid}/Content".format(
**self._solution
)
def fetch(self) -> FunctionVersionContentInstance:
"""
Fetch the FunctionVersionContentInstance
:returns: The fetched FunctionVersionContentInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return FunctionVersionContentInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
function_sid=self._solution["function_sid"],
sid=self._solution["sid"],
)
async def fetch_async(self) -> FunctionVersionContentInstance:
"""
Asynchronous coroutine to fetch the FunctionVersionContentInstance
:returns: The fetched FunctionVersionContentInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return FunctionVersionContentInstance(
self._version,
payload,
service_sid=self._solution["service_sid"],
function_sid=self._solution["function_sid"],
sid=self._solution["sid"],
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Serverless.V1.FunctionVersionContentContext {}>".format(context)
class FunctionVersionContentList(ListResource):
def __init__(self, version: Version, service_sid: str, function_sid: str, sid: str):
"""
Initialize the FunctionVersionContentList
:param version: Version that contains the resource
:param service_sid: The SID of the Service to fetch the Function Version content from.
:param function_sid: The SID of the Function that is the parent of the Function Version content to fetch.
:param sid: The SID of the Function Version content to fetch.
"""
super().__init__(version)
# Path Solution
self._solution = {
"service_sid": service_sid,
"function_sid": function_sid,
"sid": sid,
}
def get(self) -> FunctionVersionContentContext:
"""
Constructs a FunctionVersionContentContext
"""
return FunctionVersionContentContext(
self._version,
service_sid=self._solution["service_sid"],
function_sid=self._solution["function_sid"],
sid=self._solution["sid"],
)
def __call__(self) -> FunctionVersionContentContext:
"""
Constructs a FunctionVersionContentContext
"""
return FunctionVersionContentContext(
self._version,
service_sid=self._solution["service_sid"],
function_sid=self._solution["function_sid"],
sid=self._solution["sid"],
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Serverless.V1.FunctionVersionContentList>"