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.events.v1 import V1
class EventsBase(Domain):
def __init__(self, twilio: Client):
"""
Initialize the Events Domain
:returns: Domain for Events
"""
super().__init__(twilio, "https://events.twilio.com")
self._v1: Optional[V1] = None
@property
def v1(self) -> V1:
"""
:returns: Versions v1 of Events
"""
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.Events>"
@@ -0,0 +1,45 @@
from warnings import warn
from twilio.rest.events.EventsBase import EventsBase
from twilio.rest.events.v1.event_type import EventTypeList
from twilio.rest.events.v1.schema import SchemaList
from twilio.rest.events.v1.sink import SinkList
from twilio.rest.events.v1.subscription import SubscriptionList
class Events(EventsBase):
@property
def event_types(self) -> EventTypeList:
warn(
"event_types is deprecated. Use v1.event_types instead.",
DeprecationWarning,
stacklevel=2,
)
return self.v1.event_types
@property
def schemas(self) -> SchemaList:
warn(
"schemas is deprecated. Use v1.schemas instead.",
DeprecationWarning,
stacklevel=2,
)
return self.v1.schemas
@property
def sinks(self) -> SinkList:
warn(
"sinks is deprecated. Use v1.sinks instead.",
DeprecationWarning,
stacklevel=2,
)
return self.v1.sinks
@property
def subscriptions(self) -> SubscriptionList:
warn(
"subscriptions is deprecated. Use v1.subscriptions instead.",
DeprecationWarning,
stacklevel=2,
)
return self.v1.subscriptions
@@ -0,0 +1,66 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Events
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.events.v1.event_type import EventTypeList
from twilio.rest.events.v1.schema import SchemaList
from twilio.rest.events.v1.sink import SinkList
from twilio.rest.events.v1.subscription import SubscriptionList
class V1(Version):
def __init__(self, domain: Domain):
"""
Initialize the V1 version of Events
:param domain: The Twilio.events domain
"""
super().__init__(domain, "v1")
self._event_types: Optional[EventTypeList] = None
self._schemas: Optional[SchemaList] = None
self._sinks: Optional[SinkList] = None
self._subscriptions: Optional[SubscriptionList] = None
@property
def event_types(self) -> EventTypeList:
if self._event_types is None:
self._event_types = EventTypeList(self)
return self._event_types
@property
def schemas(self) -> SchemaList:
if self._schemas is None:
self._schemas = SchemaList(self)
return self._schemas
@property
def sinks(self) -> SinkList:
if self._sinks is None:
self._sinks = SinkList(self)
return self._sinks
@property
def subscriptions(self) -> SubscriptionList:
if self._subscriptions is None:
self._subscriptions = SubscriptionList(self)
return self._subscriptions
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Events.V1>"
@@ -0,0 +1,418 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Events
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 EventTypeInstance(InstanceResource):
"""
:ivar type: A string that uniquely identifies this Event Type.
:ivar schema_id: A string that uniquely identifies the Schema this Event Type adheres to.
:ivar date_created: The date that this Event Type was created, given in ISO 8601 format.
:ivar date_updated: The date that this Event Type was updated, given in ISO 8601 format.
:ivar description: A human readable description for this Event Type.
:ivar url: The URL of this resource.
:ivar links:
"""
def __init__(
self, version: Version, payload: Dict[str, Any], type: Optional[str] = None
):
super().__init__(version)
self.type: Optional[str] = payload.get("type")
self.schema_id: Optional[str] = payload.get("schema_id")
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.description: Optional[str] = payload.get("description")
self.url: Optional[str] = payload.get("url")
self.links: Optional[Dict[str, object]] = payload.get("links")
self._solution = {
"type": type or self.type,
}
self._context: Optional[EventTypeContext] = None
@property
def _proxy(self) -> "EventTypeContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: EventTypeContext for this EventTypeInstance
"""
if self._context is None:
self._context = EventTypeContext(
self._version,
type=self._solution["type"],
)
return self._context
def fetch(self) -> "EventTypeInstance":
"""
Fetch the EventTypeInstance
:returns: The fetched EventTypeInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "EventTypeInstance":
"""
Asynchronous coroutine to fetch the EventTypeInstance
:returns: The fetched EventTypeInstance
"""
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.Events.V1.EventTypeInstance {}>".format(context)
class EventTypeContext(InstanceContext):
def __init__(self, version: Version, type: str):
"""
Initialize the EventTypeContext
:param version: Version that contains the resource
:param type: A string that uniquely identifies this Event Type.
"""
super().__init__(version)
# Path Solution
self._solution = {
"type": type,
}
self._uri = "/Types/{type}".format(**self._solution)
def fetch(self) -> EventTypeInstance:
"""
Fetch the EventTypeInstance
:returns: The fetched EventTypeInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return EventTypeInstance(
self._version,
payload,
type=self._solution["type"],
)
async def fetch_async(self) -> EventTypeInstance:
"""
Asynchronous coroutine to fetch the EventTypeInstance
:returns: The fetched EventTypeInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return EventTypeInstance(
self._version,
payload,
type=self._solution["type"],
)
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.Events.V1.EventTypeContext {}>".format(context)
class EventTypePage(Page):
def get_instance(self, payload: Dict[str, Any]) -> EventTypeInstance:
"""
Build an instance of EventTypeInstance
:param payload: Payload response from the API
"""
return EventTypeInstance(self._version, payload)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Events.V1.EventTypePage>"
class EventTypeList(ListResource):
def __init__(self, version: Version):
"""
Initialize the EventTypeList
:param version: Version that contains the resource
"""
super().__init__(version)
self._uri = "/Types"
def stream(
self,
schema_id: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[EventTypeInstance]:
"""
Streams EventTypeInstance 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 schema_id: A string parameter filtering the results to return only the Event Types using a given schema.
: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(schema_id=schema_id, page_size=limits["page_size"])
return self._version.stream(page, limits["limit"])
async def stream_async(
self,
schema_id: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> AsyncIterator[EventTypeInstance]:
"""
Asynchronously streams EventTypeInstance 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 schema_id: A string parameter filtering the results to return only the Event Types using a given schema.
: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(schema_id=schema_id, page_size=limits["page_size"])
return self._version.stream_async(page, limits["limit"])
def list(
self,
schema_id: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[EventTypeInstance]:
"""
Lists EventTypeInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param str schema_id: A string parameter filtering the results to return only the Event Types using a given schema.
: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(
schema_id=schema_id,
limit=limit,
page_size=page_size,
)
)
async def list_async(
self,
schema_id: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[EventTypeInstance]:
"""
Asynchronously lists EventTypeInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param str schema_id: A string parameter filtering the results to return only the Event Types using a given schema.
: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(
schema_id=schema_id,
limit=limit,
page_size=page_size,
)
]
def page(
self,
schema_id: Union[str, object] = values.unset,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> EventTypePage:
"""
Retrieve a single page of EventTypeInstance records from the API.
Request is executed immediately
:param schema_id: A string parameter filtering the results to return only the Event Types using a given schema.
: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 EventTypeInstance
"""
data = values.of(
{
"SchemaId": schema_id,
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return EventTypePage(self._version, response)
async def page_async(
self,
schema_id: Union[str, object] = values.unset,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> EventTypePage:
"""
Asynchronously retrieve a single page of EventTypeInstance records from the API.
Request is executed immediately
:param schema_id: A string parameter filtering the results to return only the Event Types using a given schema.
: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 EventTypeInstance
"""
data = values.of(
{
"SchemaId": schema_id,
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = await self._version.page_async(
method="GET", uri=self._uri, params=data
)
return EventTypePage(self._version, response)
def get_page(self, target_url: str) -> EventTypePage:
"""
Retrieve a specific page of EventTypeInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of EventTypeInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return EventTypePage(self._version, response)
async def get_page_async(self, target_url: str) -> EventTypePage:
"""
Asynchronously retrieve a specific page of EventTypeInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of EventTypeInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return EventTypePage(self._version, response)
def get(self, type: str) -> EventTypeContext:
"""
Constructs a EventTypeContext
:param type: A string that uniquely identifies this Event Type.
"""
return EventTypeContext(self._version, type=type)
def __call__(self, type: str) -> EventTypeContext:
"""
Constructs a EventTypeContext
:param type: A string that uniquely identifies this Event Type.
"""
return EventTypeContext(self._version, type=type)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Events.V1.EventTypeList>"
@@ -0,0 +1,217 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Events
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, Optional
from twilio.base import deserialize
from twilio.base.instance_context import InstanceContext
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.version import Version
from twilio.rest.events.v1.schema.schema_version import SchemaVersionList
class SchemaInstance(InstanceResource):
"""
:ivar id: The unique identifier of the schema. Each schema can have multiple versions, that share the same id.
:ivar url: The URL of this resource.
:ivar links: Contains a dictionary of URL links to nested resources of this schema.
:ivar latest_version_date_created: The date that the latest schema version was created, given in ISO 8601 format.
:ivar latest_version: The latest version published of this schema.
"""
def __init__(
self, version: Version, payload: Dict[str, Any], id: Optional[str] = None
):
super().__init__(version)
self.id: Optional[str] = payload.get("id")
self.url: Optional[str] = payload.get("url")
self.links: Optional[Dict[str, object]] = payload.get("links")
self.latest_version_date_created: Optional[
datetime
] = deserialize.iso8601_datetime(payload.get("latest_version_date_created"))
self.latest_version: Optional[int] = deserialize.integer(
payload.get("latest_version")
)
self._solution = {
"id": id or self.id,
}
self._context: Optional[SchemaContext] = None
@property
def _proxy(self) -> "SchemaContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: SchemaContext for this SchemaInstance
"""
if self._context is None:
self._context = SchemaContext(
self._version,
id=self._solution["id"],
)
return self._context
def fetch(self) -> "SchemaInstance":
"""
Fetch the SchemaInstance
:returns: The fetched SchemaInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "SchemaInstance":
"""
Asynchronous coroutine to fetch the SchemaInstance
:returns: The fetched SchemaInstance
"""
return await self._proxy.fetch_async()
@property
def versions(self) -> SchemaVersionList:
"""
Access the versions
"""
return self._proxy.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.Events.V1.SchemaInstance {}>".format(context)
class SchemaContext(InstanceContext):
def __init__(self, version: Version, id: str):
"""
Initialize the SchemaContext
:param version: Version that contains the resource
:param id: The unique identifier of the schema. Each schema can have multiple versions, that share the same id.
"""
super().__init__(version)
# Path Solution
self._solution = {
"id": id,
}
self._uri = "/Schemas/{id}".format(**self._solution)
self._versions: Optional[SchemaVersionList] = None
def fetch(self) -> SchemaInstance:
"""
Fetch the SchemaInstance
:returns: The fetched SchemaInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return SchemaInstance(
self._version,
payload,
id=self._solution["id"],
)
async def fetch_async(self) -> SchemaInstance:
"""
Asynchronous coroutine to fetch the SchemaInstance
:returns: The fetched SchemaInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return SchemaInstance(
self._version,
payload,
id=self._solution["id"],
)
@property
def versions(self) -> SchemaVersionList:
"""
Access the versions
"""
if self._versions is None:
self._versions = SchemaVersionList(
self._version,
self._solution["id"],
)
return self._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.Events.V1.SchemaContext {}>".format(context)
class SchemaList(ListResource):
def __init__(self, version: Version):
"""
Initialize the SchemaList
:param version: Version that contains the resource
"""
super().__init__(version)
def get(self, id: str) -> SchemaContext:
"""
Constructs a SchemaContext
:param id: The unique identifier of the schema. Each schema can have multiple versions, that share the same id.
"""
return SchemaContext(self._version, id=id)
def __call__(self, id: str) -> SchemaContext:
"""
Constructs a SchemaContext
:param id: The unique identifier of the schema. Each schema can have multiple versions, that share the same id.
"""
return SchemaContext(self._version, id=id)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Events.V1.SchemaList>"
@@ -0,0 +1,417 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Events
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 SchemaVersionInstance(InstanceResource):
"""
:ivar id: The unique identifier of the schema. Each schema can have multiple versions, that share the same id.
:ivar schema_version: The version of this schema.
:ivar date_created: The date the schema version was created, given in ISO 8601 format.
:ivar url: The URL of this resource.
:ivar raw:
"""
def __init__(
self,
version: Version,
payload: Dict[str, Any],
id: str,
schema_version: Optional[int] = None,
):
super().__init__(version)
self.id: Optional[str] = payload.get("id")
self.schema_version: Optional[int] = deserialize.integer(
payload.get("schema_version")
)
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_created")
)
self.url: Optional[str] = payload.get("url")
self.raw: Optional[str] = payload.get("raw")
self._solution = {
"id": id,
"schema_version": schema_version or self.schema_version,
}
self._context: Optional[SchemaVersionContext] = None
@property
def _proxy(self) -> "SchemaVersionContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: SchemaVersionContext for this SchemaVersionInstance
"""
if self._context is None:
self._context = SchemaVersionContext(
self._version,
id=self._solution["id"],
schema_version=self._solution["schema_version"],
)
return self._context
def fetch(self) -> "SchemaVersionInstance":
"""
Fetch the SchemaVersionInstance
:returns: The fetched SchemaVersionInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "SchemaVersionInstance":
"""
Asynchronous coroutine to fetch the SchemaVersionInstance
:returns: The fetched SchemaVersionInstance
"""
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.Events.V1.SchemaVersionInstance {}>".format(context)
class SchemaVersionContext(InstanceContext):
def __init__(self, version: Version, id: str, schema_version: int):
"""
Initialize the SchemaVersionContext
:param version: Version that contains the resource
:param id: The unique identifier of the schema. Each schema can have multiple versions, that share the same id.
:param schema_version: The version of the schema
"""
super().__init__(version)
# Path Solution
self._solution = {
"id": id,
"schema_version": schema_version,
}
self._uri = "/Schemas/{id}/Versions/{schema_version}".format(**self._solution)
def fetch(self) -> SchemaVersionInstance:
"""
Fetch the SchemaVersionInstance
:returns: The fetched SchemaVersionInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return SchemaVersionInstance(
self._version,
payload,
id=self._solution["id"],
schema_version=self._solution["schema_version"],
)
async def fetch_async(self) -> SchemaVersionInstance:
"""
Asynchronous coroutine to fetch the SchemaVersionInstance
:returns: The fetched SchemaVersionInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return SchemaVersionInstance(
self._version,
payload,
id=self._solution["id"],
schema_version=self._solution["schema_version"],
)
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.Events.V1.SchemaVersionContext {}>".format(context)
class SchemaVersionPage(Page):
def get_instance(self, payload: Dict[str, Any]) -> SchemaVersionInstance:
"""
Build an instance of SchemaVersionInstance
:param payload: Payload response from the API
"""
return SchemaVersionInstance(self._version, payload, id=self._solution["id"])
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Events.V1.SchemaVersionPage>"
class SchemaVersionList(ListResource):
def __init__(self, version: Version, id: str):
"""
Initialize the SchemaVersionList
:param version: Version that contains the resource
:param id: The unique identifier of the schema. Each schema can have multiple versions, that share the same id.
"""
super().__init__(version)
# Path Solution
self._solution = {
"id": id,
}
self._uri = "/Schemas/{id}/Versions".format(**self._solution)
def stream(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[SchemaVersionInstance]:
"""
Streams SchemaVersionInstance 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[SchemaVersionInstance]:
"""
Asynchronously streams SchemaVersionInstance 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[SchemaVersionInstance]:
"""
Lists SchemaVersionInstance 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[SchemaVersionInstance]:
"""
Asynchronously lists SchemaVersionInstance 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,
) -> SchemaVersionPage:
"""
Retrieve a single page of SchemaVersionInstance 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 SchemaVersionInstance
"""
data = values.of(
{
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return SchemaVersionPage(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,
) -> SchemaVersionPage:
"""
Asynchronously retrieve a single page of SchemaVersionInstance 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 SchemaVersionInstance
"""
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 SchemaVersionPage(self._version, response, self._solution)
def get_page(self, target_url: str) -> SchemaVersionPage:
"""
Retrieve a specific page of SchemaVersionInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of SchemaVersionInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return SchemaVersionPage(self._version, response, self._solution)
async def get_page_async(self, target_url: str) -> SchemaVersionPage:
"""
Asynchronously retrieve a specific page of SchemaVersionInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of SchemaVersionInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return SchemaVersionPage(self._version, response, self._solution)
def get(self, schema_version: int) -> SchemaVersionContext:
"""
Constructs a SchemaVersionContext
:param schema_version: The version of the schema
"""
return SchemaVersionContext(
self._version, id=self._solution["id"], schema_version=schema_version
)
def __call__(self, schema_version: int) -> SchemaVersionContext:
"""
Constructs a SchemaVersionContext
:param schema_version: The version of the schema
"""
return SchemaVersionContext(
self._version, id=self._solution["id"], schema_version=schema_version
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Events.V1.SchemaVersionList>"
@@ -0,0 +1,667 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Events
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.events.v1.sink.sink_test import SinkTestList
from twilio.rest.events.v1.sink.sink_validate import SinkValidateList
class SinkInstance(InstanceResource):
class SinkType(object):
KINESIS = "kinesis"
WEBHOOK = "webhook"
SEGMENT = "segment"
class Status(object):
INITIALIZED = "initialized"
VALIDATING = "validating"
ACTIVE = "active"
FAILED = "failed"
"""
:ivar date_created: The date that this Sink was created, given in ISO 8601 format.
:ivar date_updated: The date that this Sink was updated, given in ISO 8601 format.
:ivar description: A human readable description for the Sink
:ivar sid: A 34 character string that uniquely identifies this Sink.
:ivar sink_configuration: The information required for Twilio to connect to the provided Sink encoded as JSON.
:ivar sink_type:
:ivar status:
:ivar url: The URL of this resource.
:ivar links: Contains a dictionary of URL links to nested resources of this Sink.
"""
def __init__(
self, version: Version, payload: Dict[str, Any], sid: Optional[str] = None
):
super().__init__(version)
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.description: Optional[str] = payload.get("description")
self.sid: Optional[str] = payload.get("sid")
self.sink_configuration: Optional[Dict[str, object]] = payload.get(
"sink_configuration"
)
self.sink_type: Optional["SinkInstance.SinkType"] = payload.get("sink_type")
self.status: Optional["SinkInstance.Status"] = payload.get("status")
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[SinkContext] = None
@property
def _proxy(self) -> "SinkContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: SinkContext for this SinkInstance
"""
if self._context is None:
self._context = SinkContext(
self._version,
sid=self._solution["sid"],
)
return self._context
def delete(self) -> bool:
"""
Deletes the SinkInstance
:returns: True if delete succeeds, False otherwise
"""
return self._proxy.delete()
async def delete_async(self) -> bool:
"""
Asynchronous coroutine that deletes the SinkInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._proxy.delete_async()
def fetch(self) -> "SinkInstance":
"""
Fetch the SinkInstance
:returns: The fetched SinkInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "SinkInstance":
"""
Asynchronous coroutine to fetch the SinkInstance
:returns: The fetched SinkInstance
"""
return await self._proxy.fetch_async()
def update(self, description: str) -> "SinkInstance":
"""
Update the SinkInstance
:param description: A human readable description for the Sink **This value should not contain PII.**
:returns: The updated SinkInstance
"""
return self._proxy.update(
description=description,
)
async def update_async(self, description: str) -> "SinkInstance":
"""
Asynchronous coroutine to update the SinkInstance
:param description: A human readable description for the Sink **This value should not contain PII.**
:returns: The updated SinkInstance
"""
return await self._proxy.update_async(
description=description,
)
@property
def sink_test(self) -> SinkTestList:
"""
Access the sink_test
"""
return self._proxy.sink_test
@property
def sink_validate(self) -> SinkValidateList:
"""
Access the sink_validate
"""
return self._proxy.sink_validate
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.Events.V1.SinkInstance {}>".format(context)
class SinkContext(InstanceContext):
def __init__(self, version: Version, sid: str):
"""
Initialize the SinkContext
:param version: Version that contains the resource
:param sid: A 34 character string that uniquely identifies this Sink.
"""
super().__init__(version)
# Path Solution
self._solution = {
"sid": sid,
}
self._uri = "/Sinks/{sid}".format(**self._solution)
self._sink_test: Optional[SinkTestList] = None
self._sink_validate: Optional[SinkValidateList] = None
def delete(self) -> bool:
"""
Deletes the SinkInstance
: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 SinkInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._version.delete_async(
method="DELETE",
uri=self._uri,
)
def fetch(self) -> SinkInstance:
"""
Fetch the SinkInstance
:returns: The fetched SinkInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return SinkInstance(
self._version,
payload,
sid=self._solution["sid"],
)
async def fetch_async(self) -> SinkInstance:
"""
Asynchronous coroutine to fetch the SinkInstance
:returns: The fetched SinkInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return SinkInstance(
self._version,
payload,
sid=self._solution["sid"],
)
def update(self, description: str) -> SinkInstance:
"""
Update the SinkInstance
:param description: A human readable description for the Sink **This value should not contain PII.**
:returns: The updated SinkInstance
"""
data = values.of(
{
"Description": description,
}
)
payload = self._version.update(
method="POST",
uri=self._uri,
data=data,
)
return SinkInstance(self._version, payload, sid=self._solution["sid"])
async def update_async(self, description: str) -> SinkInstance:
"""
Asynchronous coroutine to update the SinkInstance
:param description: A human readable description for the Sink **This value should not contain PII.**
:returns: The updated SinkInstance
"""
data = values.of(
{
"Description": description,
}
)
payload = await self._version.update_async(
method="POST",
uri=self._uri,
data=data,
)
return SinkInstance(self._version, payload, sid=self._solution["sid"])
@property
def sink_test(self) -> SinkTestList:
"""
Access the sink_test
"""
if self._sink_test is None:
self._sink_test = SinkTestList(
self._version,
self._solution["sid"],
)
return self._sink_test
@property
def sink_validate(self) -> SinkValidateList:
"""
Access the sink_validate
"""
if self._sink_validate is None:
self._sink_validate = SinkValidateList(
self._version,
self._solution["sid"],
)
return self._sink_validate
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.Events.V1.SinkContext {}>".format(context)
class SinkPage(Page):
def get_instance(self, payload: Dict[str, Any]) -> SinkInstance:
"""
Build an instance of SinkInstance
:param payload: Payload response from the API
"""
return SinkInstance(self._version, payload)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Events.V1.SinkPage>"
class SinkList(ListResource):
def __init__(self, version: Version):
"""
Initialize the SinkList
:param version: Version that contains the resource
"""
super().__init__(version)
self._uri = "/Sinks"
def create(
self,
description: str,
sink_configuration: object,
sink_type: "SinkInstance.SinkType",
) -> SinkInstance:
"""
Create the SinkInstance
:param description: A human readable description for the Sink **This value should not contain PII.**
:param sink_configuration: The information required for Twilio to connect to the provided Sink encoded as JSON.
:param sink_type:
:returns: The created SinkInstance
"""
data = values.of(
{
"Description": description,
"SinkConfiguration": serialize.object(sink_configuration),
"SinkType": sink_type,
}
)
payload = self._version.create(
method="POST",
uri=self._uri,
data=data,
)
return SinkInstance(self._version, payload)
async def create_async(
self,
description: str,
sink_configuration: object,
sink_type: "SinkInstance.SinkType",
) -> SinkInstance:
"""
Asynchronously create the SinkInstance
:param description: A human readable description for the Sink **This value should not contain PII.**
:param sink_configuration: The information required for Twilio to connect to the provided Sink encoded as JSON.
:param sink_type:
:returns: The created SinkInstance
"""
data = values.of(
{
"Description": description,
"SinkConfiguration": serialize.object(sink_configuration),
"SinkType": sink_type,
}
)
payload = await self._version.create_async(
method="POST",
uri=self._uri,
data=data,
)
return SinkInstance(self._version, payload)
def stream(
self,
in_use: Union[bool, object] = values.unset,
status: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[SinkInstance]:
"""
Streams SinkInstance 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 bool in_use: A boolean query parameter filtering the results to return sinks used/not used by a subscription.
:param str status: A String query parameter filtering the results by status `initialized`, `validating`, `active` or `failed`.
:param limit: Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the
limit with the most efficient page size, i.e. min(limit, 1000)
:returns: Generator that will yield up to limit results
"""
limits = self._version.read_limits(limit, page_size)
page = self.page(in_use=in_use, status=status, page_size=limits["page_size"])
return self._version.stream(page, limits["limit"])
async def stream_async(
self,
in_use: Union[bool, object] = values.unset,
status: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> AsyncIterator[SinkInstance]:
"""
Asynchronously streams SinkInstance 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 bool in_use: A boolean query parameter filtering the results to return sinks used/not used by a subscription.
:param str status: A String query parameter filtering the results by status `initialized`, `validating`, `active` or `failed`.
:param limit: Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the
limit with the most efficient page size, i.e. min(limit, 1000)
:returns: Generator that will yield up to limit results
"""
limits = self._version.read_limits(limit, page_size)
page = await self.page_async(
in_use=in_use, status=status, page_size=limits["page_size"]
)
return self._version.stream_async(page, limits["limit"])
def list(
self,
in_use: Union[bool, object] = values.unset,
status: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[SinkInstance]:
"""
Lists SinkInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param bool in_use: A boolean query parameter filtering the results to return sinks used/not used by a subscription.
:param str status: A String query parameter filtering the results by status `initialized`, `validating`, `active` or `failed`.
:param limit: Upper limit for the number of records to return. list() guarantees
never to return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, list() will attempt to read the limit
with the most efficient page size, i.e. min(limit, 1000)
:returns: list that will contain up to limit results
"""
return list(
self.stream(
in_use=in_use,
status=status,
limit=limit,
page_size=page_size,
)
)
async def list_async(
self,
in_use: Union[bool, object] = values.unset,
status: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[SinkInstance]:
"""
Asynchronously lists SinkInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param bool in_use: A boolean query parameter filtering the results to return sinks used/not used by a subscription.
:param str status: A String query parameter filtering the results by status `initialized`, `validating`, `active` or `failed`.
:param limit: Upper limit for the number of records to return. list() guarantees
never to return more than limit. Default is no limit
:param page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, list() will attempt to read the limit
with the most efficient page size, i.e. min(limit, 1000)
:returns: list that will contain up to limit results
"""
return [
record
async for record in await self.stream_async(
in_use=in_use,
status=status,
limit=limit,
page_size=page_size,
)
]
def page(
self,
in_use: Union[bool, object] = values.unset,
status: Union[str, object] = values.unset,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> SinkPage:
"""
Retrieve a single page of SinkInstance records from the API.
Request is executed immediately
:param in_use: A boolean query parameter filtering the results to return sinks used/not used by a subscription.
:param status: A String query parameter filtering the results by status `initialized`, `validating`, `active` or `failed`.
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of SinkInstance
"""
data = values.of(
{
"InUse": in_use,
"Status": status,
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return SinkPage(self._version, response)
async def page_async(
self,
in_use: Union[bool, object] = values.unset,
status: Union[str, object] = values.unset,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> SinkPage:
"""
Asynchronously retrieve a single page of SinkInstance records from the API.
Request is executed immediately
:param in_use: A boolean query parameter filtering the results to return sinks used/not used by a subscription.
:param status: A String query parameter filtering the results by status `initialized`, `validating`, `active` or `failed`.
:param page_token: PageToken provided by the API
:param page_number: Page Number, this value is simply for client state
:param page_size: Number of records to return, defaults to 50
:returns: Page of SinkInstance
"""
data = values.of(
{
"InUse": in_use,
"Status": status,
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = await self._version.page_async(
method="GET", uri=self._uri, params=data
)
return SinkPage(self._version, response)
def get_page(self, target_url: str) -> SinkPage:
"""
Retrieve a specific page of SinkInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of SinkInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return SinkPage(self._version, response)
async def get_page_async(self, target_url: str) -> SinkPage:
"""
Asynchronously retrieve a specific page of SinkInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of SinkInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return SinkPage(self._version, response)
def get(self, sid: str) -> SinkContext:
"""
Constructs a SinkContext
:param sid: A 34 character string that uniquely identifies this Sink.
"""
return SinkContext(self._version, sid=sid)
def __call__(self, sid: str) -> SinkContext:
"""
Constructs a SinkContext
:param sid: A 34 character string that uniquely identifies this Sink.
"""
return SinkContext(self._version, sid=sid)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Events.V1.SinkList>"
@@ -0,0 +1,101 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Events
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_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.version import Version
class SinkTestInstance(InstanceResource):
"""
:ivar result: Feedback indicating whether the test event was generated.
"""
def __init__(self, version: Version, payload: Dict[str, Any], sid: str):
super().__init__(version)
self.result: Optional[str] = payload.get("result")
self._solution = {
"sid": 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.Events.V1.SinkTestInstance {}>".format(context)
class SinkTestList(ListResource):
def __init__(self, version: Version, sid: str):
"""
Initialize the SinkTestList
:param version: Version that contains the resource
:param sid: A 34 character string that uniquely identifies the Sink to be Tested.
"""
super().__init__(version)
# Path Solution
self._solution = {
"sid": sid,
}
self._uri = "/Sinks/{sid}/Test".format(**self._solution)
def create(self) -> SinkTestInstance:
"""
Create the SinkTestInstance
:returns: The created SinkTestInstance
"""
payload = self._version.create(
method="POST",
uri=self._uri,
)
return SinkTestInstance(self._version, payload, sid=self._solution["sid"])
async def create_async(self) -> SinkTestInstance:
"""
Asynchronously create the SinkTestInstance
:returns: The created SinkTestInstance
"""
payload = await self._version.create_async(
method="POST",
uri=self._uri,
)
return SinkTestInstance(self._version, payload, sid=self._solution["sid"])
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Events.V1.SinkTestList>"
@@ -0,0 +1,116 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Events
This is the public Twilio REST API.
NOTE: This class is auto generated by OpenAPI Generator.
https://openapi-generator.tech
Do not edit the class manually.
"""
from typing import Any, Dict, Optional
from twilio.base import values
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.version import Version
class SinkValidateInstance(InstanceResource):
"""
:ivar result: Feedback indicating whether the given Sink was validated.
"""
def __init__(self, version: Version, payload: Dict[str, Any], sid: str):
super().__init__(version)
self.result: Optional[str] = payload.get("result")
self._solution = {
"sid": 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.Events.V1.SinkValidateInstance {}>".format(context)
class SinkValidateList(ListResource):
def __init__(self, version: Version, sid: str):
"""
Initialize the SinkValidateList
:param version: Version that contains the resource
:param sid: A 34 character string that uniquely identifies the Sink being validated.
"""
super().__init__(version)
# Path Solution
self._solution = {
"sid": sid,
}
self._uri = "/Sinks/{sid}/Validate".format(**self._solution)
def create(self, test_id: str) -> SinkValidateInstance:
"""
Create the SinkValidateInstance
:param test_id: A 34 character string that uniquely identifies the test event for a Sink being validated.
:returns: The created SinkValidateInstance
"""
data = values.of(
{
"TestId": test_id,
}
)
payload = self._version.create(
method="POST",
uri=self._uri,
data=data,
)
return SinkValidateInstance(self._version, payload, sid=self._solution["sid"])
async def create_async(self, test_id: str) -> SinkValidateInstance:
"""
Asynchronously create the SinkValidateInstance
:param test_id: A 34 character string that uniquely identifies the test event for a Sink being validated.
:returns: The created SinkValidateInstance
"""
data = values.of(
{
"TestId": test_id,
}
)
payload = await self._version.create_async(
method="POST",
uri=self._uri,
data=data,
)
return SinkValidateInstance(self._version, payload, sid=self._solution["sid"])
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Events.V1.SinkValidateList>"
@@ -0,0 +1,632 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Events
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.events.v1.subscription.subscribed_event import SubscribedEventList
class SubscriptionInstance(InstanceResource):
"""
:ivar account_sid: The unique SID identifier of the Account.
:ivar sid: A 34 character string that uniquely identifies this Subscription.
:ivar date_created: The date that this Subscription was created, given in ISO 8601 format.
:ivar date_updated: The date that this Subscription was updated, given in ISO 8601 format.
:ivar description: A human readable description for the Subscription
:ivar sink_sid: The SID of the sink that events selected by this subscription should be sent to. Sink must be active for the subscription to be created.
:ivar url: The URL of this resource.
:ivar links: Contains a dictionary of URL links to nested resources of this Subscription.
"""
def __init__(
self, version: Version, payload: Dict[str, Any], sid: Optional[str] = None
):
super().__init__(version)
self.account_sid: Optional[str] = payload.get("account_sid")
self.sid: Optional[str] = payload.get("sid")
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_created")
)
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_updated")
)
self.description: Optional[str] = payload.get("description")
self.sink_sid: Optional[str] = payload.get("sink_sid")
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[SubscriptionContext] = None
@property
def _proxy(self) -> "SubscriptionContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: SubscriptionContext for this SubscriptionInstance
"""
if self._context is None:
self._context = SubscriptionContext(
self._version,
sid=self._solution["sid"],
)
return self._context
def delete(self) -> bool:
"""
Deletes the SubscriptionInstance
:returns: True if delete succeeds, False otherwise
"""
return self._proxy.delete()
async def delete_async(self) -> bool:
"""
Asynchronous coroutine that deletes the SubscriptionInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._proxy.delete_async()
def fetch(self) -> "SubscriptionInstance":
"""
Fetch the SubscriptionInstance
:returns: The fetched SubscriptionInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "SubscriptionInstance":
"""
Asynchronous coroutine to fetch the SubscriptionInstance
:returns: The fetched SubscriptionInstance
"""
return await self._proxy.fetch_async()
def update(
self,
description: Union[str, object] = values.unset,
sink_sid: Union[str, object] = values.unset,
) -> "SubscriptionInstance":
"""
Update the SubscriptionInstance
:param description: A human readable description for the Subscription.
:param sink_sid: The SID of the sink that events selected by this subscription should be sent to. Sink must be active for the subscription to be created.
:returns: The updated SubscriptionInstance
"""
return self._proxy.update(
description=description,
sink_sid=sink_sid,
)
async def update_async(
self,
description: Union[str, object] = values.unset,
sink_sid: Union[str, object] = values.unset,
) -> "SubscriptionInstance":
"""
Asynchronous coroutine to update the SubscriptionInstance
:param description: A human readable description for the Subscription.
:param sink_sid: The SID of the sink that events selected by this subscription should be sent to. Sink must be active for the subscription to be created.
:returns: The updated SubscriptionInstance
"""
return await self._proxy.update_async(
description=description,
sink_sid=sink_sid,
)
@property
def subscribed_events(self) -> SubscribedEventList:
"""
Access the subscribed_events
"""
return self._proxy.subscribed_events
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.Events.V1.SubscriptionInstance {}>".format(context)
class SubscriptionContext(InstanceContext):
def __init__(self, version: Version, sid: str):
"""
Initialize the SubscriptionContext
:param version: Version that contains the resource
:param sid: A 34 character string that uniquely identifies this Subscription.
"""
super().__init__(version)
# Path Solution
self._solution = {
"sid": sid,
}
self._uri = "/Subscriptions/{sid}".format(**self._solution)
self._subscribed_events: Optional[SubscribedEventList] = None
def delete(self) -> bool:
"""
Deletes the SubscriptionInstance
: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 SubscriptionInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._version.delete_async(
method="DELETE",
uri=self._uri,
)
def fetch(self) -> SubscriptionInstance:
"""
Fetch the SubscriptionInstance
:returns: The fetched SubscriptionInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return SubscriptionInstance(
self._version,
payload,
sid=self._solution["sid"],
)
async def fetch_async(self) -> SubscriptionInstance:
"""
Asynchronous coroutine to fetch the SubscriptionInstance
:returns: The fetched SubscriptionInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return SubscriptionInstance(
self._version,
payload,
sid=self._solution["sid"],
)
def update(
self,
description: Union[str, object] = values.unset,
sink_sid: Union[str, object] = values.unset,
) -> SubscriptionInstance:
"""
Update the SubscriptionInstance
:param description: A human readable description for the Subscription.
:param sink_sid: The SID of the sink that events selected by this subscription should be sent to. Sink must be active for the subscription to be created.
:returns: The updated SubscriptionInstance
"""
data = values.of(
{
"Description": description,
"SinkSid": sink_sid,
}
)
payload = self._version.update(
method="POST",
uri=self._uri,
data=data,
)
return SubscriptionInstance(self._version, payload, sid=self._solution["sid"])
async def update_async(
self,
description: Union[str, object] = values.unset,
sink_sid: Union[str, object] = values.unset,
) -> SubscriptionInstance:
"""
Asynchronous coroutine to update the SubscriptionInstance
:param description: A human readable description for the Subscription.
:param sink_sid: The SID of the sink that events selected by this subscription should be sent to. Sink must be active for the subscription to be created.
:returns: The updated SubscriptionInstance
"""
data = values.of(
{
"Description": description,
"SinkSid": sink_sid,
}
)
payload = await self._version.update_async(
method="POST",
uri=self._uri,
data=data,
)
return SubscriptionInstance(self._version, payload, sid=self._solution["sid"])
@property
def subscribed_events(self) -> SubscribedEventList:
"""
Access the subscribed_events
"""
if self._subscribed_events is None:
self._subscribed_events = SubscribedEventList(
self._version,
self._solution["sid"],
)
return self._subscribed_events
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.Events.V1.SubscriptionContext {}>".format(context)
class SubscriptionPage(Page):
def get_instance(self, payload: Dict[str, Any]) -> SubscriptionInstance:
"""
Build an instance of SubscriptionInstance
:param payload: Payload response from the API
"""
return SubscriptionInstance(self._version, payload)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Events.V1.SubscriptionPage>"
class SubscriptionList(ListResource):
def __init__(self, version: Version):
"""
Initialize the SubscriptionList
:param version: Version that contains the resource
"""
super().__init__(version)
self._uri = "/Subscriptions"
def create(
self, description: str, sink_sid: str, types: List[object]
) -> SubscriptionInstance:
"""
Create the SubscriptionInstance
:param description: A human readable description for the Subscription **This value should not contain PII.**
:param sink_sid: The SID of the sink that events selected by this subscription should be sent to. Sink must be active for the subscription to be created.
:param types: An array of objects containing the subscribed Event Types
:returns: The created SubscriptionInstance
"""
data = values.of(
{
"Description": description,
"SinkSid": sink_sid,
"Types": serialize.map(types, lambda e: serialize.object(e)),
}
)
payload = self._version.create(
method="POST",
uri=self._uri,
data=data,
)
return SubscriptionInstance(self._version, payload)
async def create_async(
self, description: str, sink_sid: str, types: List[object]
) -> SubscriptionInstance:
"""
Asynchronously create the SubscriptionInstance
:param description: A human readable description for the Subscription **This value should not contain PII.**
:param sink_sid: The SID of the sink that events selected by this subscription should be sent to. Sink must be active for the subscription to be created.
:param types: An array of objects containing the subscribed Event Types
:returns: The created SubscriptionInstance
"""
data = values.of(
{
"Description": description,
"SinkSid": sink_sid,
"Types": serialize.map(types, lambda e: serialize.object(e)),
}
)
payload = await self._version.create_async(
method="POST",
uri=self._uri,
data=data,
)
return SubscriptionInstance(self._version, payload)
def stream(
self,
sink_sid: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[SubscriptionInstance]:
"""
Streams SubscriptionInstance 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 sink_sid: The SID of the sink that the list of Subscriptions should be filtered by.
: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(sink_sid=sink_sid, page_size=limits["page_size"])
return self._version.stream(page, limits["limit"])
async def stream_async(
self,
sink_sid: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> AsyncIterator[SubscriptionInstance]:
"""
Asynchronously streams SubscriptionInstance 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 sink_sid: The SID of the sink that the list of Subscriptions should be filtered by.
: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(sink_sid=sink_sid, page_size=limits["page_size"])
return self._version.stream_async(page, limits["limit"])
def list(
self,
sink_sid: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[SubscriptionInstance]:
"""
Lists SubscriptionInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param str sink_sid: The SID of the sink that the list of Subscriptions should be filtered by.
: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(
sink_sid=sink_sid,
limit=limit,
page_size=page_size,
)
)
async def list_async(
self,
sink_sid: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[SubscriptionInstance]:
"""
Asynchronously lists SubscriptionInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param str sink_sid: The SID of the sink that the list of Subscriptions should be filtered by.
: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(
sink_sid=sink_sid,
limit=limit,
page_size=page_size,
)
]
def page(
self,
sink_sid: Union[str, object] = values.unset,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> SubscriptionPage:
"""
Retrieve a single page of SubscriptionInstance records from the API.
Request is executed immediately
:param sink_sid: The SID of the sink that the list of Subscriptions should be filtered by.
: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 SubscriptionInstance
"""
data = values.of(
{
"SinkSid": sink_sid,
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return SubscriptionPage(self._version, response)
async def page_async(
self,
sink_sid: Union[str, object] = values.unset,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> SubscriptionPage:
"""
Asynchronously retrieve a single page of SubscriptionInstance records from the API.
Request is executed immediately
:param sink_sid: The SID of the sink that the list of Subscriptions should be filtered by.
: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 SubscriptionInstance
"""
data = values.of(
{
"SinkSid": sink_sid,
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = await self._version.page_async(
method="GET", uri=self._uri, params=data
)
return SubscriptionPage(self._version, response)
def get_page(self, target_url: str) -> SubscriptionPage:
"""
Retrieve a specific page of SubscriptionInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of SubscriptionInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return SubscriptionPage(self._version, response)
async def get_page_async(self, target_url: str) -> SubscriptionPage:
"""
Asynchronously retrieve a specific page of SubscriptionInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of SubscriptionInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return SubscriptionPage(self._version, response)
def get(self, sid: str) -> SubscriptionContext:
"""
Constructs a SubscriptionContext
:param sid: A 34 character string that uniquely identifies this Subscription.
"""
return SubscriptionContext(self._version, sid=sid)
def __call__(self, sid: str) -> SubscriptionContext:
"""
Constructs a SubscriptionContext
:param sid: A 34 character string that uniquely identifies this Subscription.
"""
return SubscriptionContext(self._version, sid=sid)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Events.V1.SubscriptionList>"
@@ -0,0 +1,608 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Events
This is the public Twilio REST API.
NOTE: This class is auto generated by OpenAPI Generator.
https://openapi-generator.tech
Do not edit the class manually.
"""
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
from twilio.base import 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 SubscribedEventInstance(InstanceResource):
"""
:ivar account_sid: The unique SID identifier of the Account.
:ivar type: Type of event being subscribed to.
:ivar schema_version: The schema version that the subscription should use.
:ivar subscription_sid: The unique SID identifier of the Subscription.
:ivar url: The URL of this resource.
"""
def __init__(
self,
version: Version,
payload: Dict[str, Any],
subscription_sid: str,
type: Optional[str] = None,
):
super().__init__(version)
self.account_sid: Optional[str] = payload.get("account_sid")
self.type: Optional[str] = payload.get("type")
self.schema_version: Optional[int] = deserialize.integer(
payload.get("schema_version")
)
self.subscription_sid: Optional[str] = payload.get("subscription_sid")
self.url: Optional[str] = payload.get("url")
self._solution = {
"subscription_sid": subscription_sid,
"type": type or self.type,
}
self._context: Optional[SubscribedEventContext] = None
@property
def _proxy(self) -> "SubscribedEventContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: SubscribedEventContext for this SubscribedEventInstance
"""
if self._context is None:
self._context = SubscribedEventContext(
self._version,
subscription_sid=self._solution["subscription_sid"],
type=self._solution["type"],
)
return self._context
def delete(self) -> bool:
"""
Deletes the SubscribedEventInstance
:returns: True if delete succeeds, False otherwise
"""
return self._proxy.delete()
async def delete_async(self) -> bool:
"""
Asynchronous coroutine that deletes the SubscribedEventInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._proxy.delete_async()
def fetch(self) -> "SubscribedEventInstance":
"""
Fetch the SubscribedEventInstance
:returns: The fetched SubscribedEventInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "SubscribedEventInstance":
"""
Asynchronous coroutine to fetch the SubscribedEventInstance
:returns: The fetched SubscribedEventInstance
"""
return await self._proxy.fetch_async()
def update(
self, schema_version: Union[int, object] = values.unset
) -> "SubscribedEventInstance":
"""
Update the SubscribedEventInstance
:param schema_version: The schema version that the subscription should use.
:returns: The updated SubscribedEventInstance
"""
return self._proxy.update(
schema_version=schema_version,
)
async def update_async(
self, schema_version: Union[int, object] = values.unset
) -> "SubscribedEventInstance":
"""
Asynchronous coroutine to update the SubscribedEventInstance
:param schema_version: The schema version that the subscription should use.
:returns: The updated SubscribedEventInstance
"""
return await self._proxy.update_async(
schema_version=schema_version,
)
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.Events.V1.SubscribedEventInstance {}>".format(context)
class SubscribedEventContext(InstanceContext):
def __init__(self, version: Version, subscription_sid: str, type: str):
"""
Initialize the SubscribedEventContext
:param version: Version that contains the resource
:param subscription_sid: The unique SID identifier of the Subscription.
:param type: Type of event being subscribed to.
"""
super().__init__(version)
# Path Solution
self._solution = {
"subscription_sid": subscription_sid,
"type": type,
}
self._uri = "/Subscriptions/{subscription_sid}/SubscribedEvents/{type}".format(
**self._solution
)
def delete(self) -> bool:
"""
Deletes the SubscribedEventInstance
: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 SubscribedEventInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._version.delete_async(
method="DELETE",
uri=self._uri,
)
def fetch(self) -> SubscribedEventInstance:
"""
Fetch the SubscribedEventInstance
:returns: The fetched SubscribedEventInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return SubscribedEventInstance(
self._version,
payload,
subscription_sid=self._solution["subscription_sid"],
type=self._solution["type"],
)
async def fetch_async(self) -> SubscribedEventInstance:
"""
Asynchronous coroutine to fetch the SubscribedEventInstance
:returns: The fetched SubscribedEventInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return SubscribedEventInstance(
self._version,
payload,
subscription_sid=self._solution["subscription_sid"],
type=self._solution["type"],
)
def update(
self, schema_version: Union[int, object] = values.unset
) -> SubscribedEventInstance:
"""
Update the SubscribedEventInstance
:param schema_version: The schema version that the subscription should use.
:returns: The updated SubscribedEventInstance
"""
data = values.of(
{
"SchemaVersion": schema_version,
}
)
payload = self._version.update(
method="POST",
uri=self._uri,
data=data,
)
return SubscribedEventInstance(
self._version,
payload,
subscription_sid=self._solution["subscription_sid"],
type=self._solution["type"],
)
async def update_async(
self, schema_version: Union[int, object] = values.unset
) -> SubscribedEventInstance:
"""
Asynchronous coroutine to update the SubscribedEventInstance
:param schema_version: The schema version that the subscription should use.
:returns: The updated SubscribedEventInstance
"""
data = values.of(
{
"SchemaVersion": schema_version,
}
)
payload = await self._version.update_async(
method="POST",
uri=self._uri,
data=data,
)
return SubscribedEventInstance(
self._version,
payload,
subscription_sid=self._solution["subscription_sid"],
type=self._solution["type"],
)
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.Events.V1.SubscribedEventContext {}>".format(context)
class SubscribedEventPage(Page):
def get_instance(self, payload: Dict[str, Any]) -> SubscribedEventInstance:
"""
Build an instance of SubscribedEventInstance
:param payload: Payload response from the API
"""
return SubscribedEventInstance(
self._version, payload, subscription_sid=self._solution["subscription_sid"]
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Events.V1.SubscribedEventPage>"
class SubscribedEventList(ListResource):
def __init__(self, version: Version, subscription_sid: str):
"""
Initialize the SubscribedEventList
:param version: Version that contains the resource
:param subscription_sid: The unique SID identifier of the Subscription.
"""
super().__init__(version)
# Path Solution
self._solution = {
"subscription_sid": subscription_sid,
}
self._uri = "/Subscriptions/{subscription_sid}/SubscribedEvents".format(
**self._solution
)
def create(
self, type: str, schema_version: Union[int, object] = values.unset
) -> SubscribedEventInstance:
"""
Create the SubscribedEventInstance
:param type: Type of event being subscribed to.
:param schema_version: The schema version that the subscription should use.
:returns: The created SubscribedEventInstance
"""
data = values.of(
{
"Type": type,
"SchemaVersion": schema_version,
}
)
payload = self._version.create(
method="POST",
uri=self._uri,
data=data,
)
return SubscribedEventInstance(
self._version, payload, subscription_sid=self._solution["subscription_sid"]
)
async def create_async(
self, type: str, schema_version: Union[int, object] = values.unset
) -> SubscribedEventInstance:
"""
Asynchronously create the SubscribedEventInstance
:param type: Type of event being subscribed to.
:param schema_version: The schema version that the subscription should use.
:returns: The created SubscribedEventInstance
"""
data = values.of(
{
"Type": type,
"SchemaVersion": schema_version,
}
)
payload = await self._version.create_async(
method="POST",
uri=self._uri,
data=data,
)
return SubscribedEventInstance(
self._version, payload, subscription_sid=self._solution["subscription_sid"]
)
def stream(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[SubscribedEventInstance]:
"""
Streams SubscribedEventInstance 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[SubscribedEventInstance]:
"""
Asynchronously streams SubscribedEventInstance 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[SubscribedEventInstance]:
"""
Lists SubscribedEventInstance 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[SubscribedEventInstance]:
"""
Asynchronously lists SubscribedEventInstance 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,
) -> SubscribedEventPage:
"""
Retrieve a single page of SubscribedEventInstance 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 SubscribedEventInstance
"""
data = values.of(
{
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return SubscribedEventPage(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,
) -> SubscribedEventPage:
"""
Asynchronously retrieve a single page of SubscribedEventInstance 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 SubscribedEventInstance
"""
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 SubscribedEventPage(self._version, response, self._solution)
def get_page(self, target_url: str) -> SubscribedEventPage:
"""
Retrieve a specific page of SubscribedEventInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of SubscribedEventInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return SubscribedEventPage(self._version, response, self._solution)
async def get_page_async(self, target_url: str) -> SubscribedEventPage:
"""
Asynchronously retrieve a specific page of SubscribedEventInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of SubscribedEventInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return SubscribedEventPage(self._version, response, self._solution)
def get(self, type: str) -> SubscribedEventContext:
"""
Constructs a SubscribedEventContext
:param type: Type of event being subscribed to.
"""
return SubscribedEventContext(
self._version,
subscription_sid=self._solution["subscription_sid"],
type=type,
)
def __call__(self, type: str) -> SubscribedEventContext:
"""
Constructs a SubscribedEventContext
:param type: Type of event being subscribed to.
"""
return SubscribedEventContext(
self._version,
subscription_sid=self._solution["subscription_sid"],
type=type,
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Events.V1.SubscribedEventList>"