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.bulkexports.v1 import V1
class BulkexportsBase(Domain):
def __init__(self, twilio: Client):
"""
Initialize the Bulkexports Domain
:returns: Domain for Bulkexports
"""
super().__init__(twilio, "https://bulkexports.twilio.com")
self._v1: Optional[V1] = None
@property
def v1(self) -> V1:
"""
:returns: Versions v1 of Bulkexports
"""
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.Bulkexports>"
@@ -0,0 +1,25 @@
from warnings import warn
from twilio.rest.bulkexports.BulkexportsBase import BulkexportsBase
from twilio.rest.bulkexports.v1.export import ExportList
from twilio.rest.bulkexports.v1.export_configuration import ExportConfigurationList
class Bulkexports(BulkexportsBase):
@property
def exports(self) -> ExportList:
warn(
"exports is deprecated. Use v1.exports instead.",
DeprecationWarning,
stacklevel=2,
)
return self.v1.exports
@property
def export_configuration(self) -> ExportConfigurationList:
warn(
"export_configuration is deprecated. Use v1.export_configuration instead.",
DeprecationWarning,
stacklevel=2,
)
return self.v1.export_configuration
@@ -0,0 +1,50 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Bulkexports
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.bulkexports.v1.export import ExportList
from twilio.rest.bulkexports.v1.export_configuration import ExportConfigurationList
class V1(Version):
def __init__(self, domain: Domain):
"""
Initialize the V1 version of Bulkexports
:param domain: The Twilio.bulkexports domain
"""
super().__init__(domain, "v1")
self._exports: Optional[ExportList] = None
self._export_configuration: Optional[ExportConfigurationList] = None
@property
def exports(self) -> ExportList:
if self._exports is None:
self._exports = ExportList(self)
return self._exports
@property
def export_configuration(self) -> ExportConfigurationList:
if self._export_configuration is None:
self._export_configuration = ExportConfigurationList(self)
return self._export_configuration
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Bulkexports.V1>"
@@ -0,0 +1,245 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Bulkexports
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
from twilio.rest.bulkexports.v1.export.day import DayList
from twilio.rest.bulkexports.v1.export.export_custom_job import ExportCustomJobList
from twilio.rest.bulkexports.v1.export.job import JobList
class ExportInstance(InstanceResource):
"""
:ivar resource_type: The type of communication Messages, Calls, Conferences, and Participants
:ivar url: The URL of this resource.
:ivar links: Contains a dictionary of URL links to nested resources of this Export.
"""
def __init__(
self,
version: Version,
payload: Dict[str, Any],
resource_type: Optional[str] = None,
):
super().__init__(version)
self.resource_type: Optional[str] = payload.get("resource_type")
self.url: Optional[str] = payload.get("url")
self.links: Optional[Dict[str, object]] = payload.get("links")
self._solution = {
"resource_type": resource_type or self.resource_type,
}
self._context: Optional[ExportContext] = None
@property
def _proxy(self) -> "ExportContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: ExportContext for this ExportInstance
"""
if self._context is None:
self._context = ExportContext(
self._version,
resource_type=self._solution["resource_type"],
)
return self._context
def fetch(self) -> "ExportInstance":
"""
Fetch the ExportInstance
:returns: The fetched ExportInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "ExportInstance":
"""
Asynchronous coroutine to fetch the ExportInstance
:returns: The fetched ExportInstance
"""
return await self._proxy.fetch_async()
@property
def days(self) -> DayList:
"""
Access the days
"""
return self._proxy.days
@property
def export_custom_jobs(self) -> ExportCustomJobList:
"""
Access the export_custom_jobs
"""
return self._proxy.export_custom_jobs
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.Bulkexports.V1.ExportInstance {}>".format(context)
class ExportContext(InstanceContext):
def __init__(self, version: Version, resource_type: str):
"""
Initialize the ExportContext
:param version: Version that contains the resource
:param resource_type: The type of communication Messages, Calls, Conferences, and Participants
"""
super().__init__(version)
# Path Solution
self._solution = {
"resource_type": resource_type,
}
self._uri = "/Exports/{resource_type}".format(**self._solution)
self._days: Optional[DayList] = None
self._export_custom_jobs: Optional[ExportCustomJobList] = None
def fetch(self) -> ExportInstance:
"""
Fetch the ExportInstance
:returns: The fetched ExportInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return ExportInstance(
self._version,
payload,
resource_type=self._solution["resource_type"],
)
async def fetch_async(self) -> ExportInstance:
"""
Asynchronous coroutine to fetch the ExportInstance
:returns: The fetched ExportInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return ExportInstance(
self._version,
payload,
resource_type=self._solution["resource_type"],
)
@property
def days(self) -> DayList:
"""
Access the days
"""
if self._days is None:
self._days = DayList(
self._version,
self._solution["resource_type"],
)
return self._days
@property
def export_custom_jobs(self) -> ExportCustomJobList:
"""
Access the export_custom_jobs
"""
if self._export_custom_jobs is None:
self._export_custom_jobs = ExportCustomJobList(
self._version,
self._solution["resource_type"],
)
return self._export_custom_jobs
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.Bulkexports.V1.ExportContext {}>".format(context)
class ExportList(ListResource):
def __init__(self, version: Version):
"""
Initialize the ExportList
:param version: Version that contains the resource
"""
super().__init__(version)
self._uri = "/Exports"
self._jobs: Optional[JobList] = None
@property
def jobs(self) -> JobList:
"""
Access the jobs
"""
if self._jobs is None:
self._jobs = JobList(self._version)
return self._jobs
def get(self, resource_type: str) -> ExportContext:
"""
Constructs a ExportContext
:param resource_type: The type of communication Messages, Calls, Conferences, and Participants
"""
return ExportContext(self._version, resource_type=resource_type)
def __call__(self, resource_type: str) -> ExportContext:
"""
Constructs a ExportContext
:param resource_type: The type of communication Messages, Calls, Conferences, and Participants
"""
return ExportContext(self._version, resource_type=resource_type)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Bulkexports.V1.ExportList>"
@@ -0,0 +1,416 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Bulkexports
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 DayInstance(InstanceResource):
"""
:ivar redirect_to:
:ivar day: The ISO 8601 format date of the resources in the file, for a UTC day
:ivar size: The size of the day's data file in bytes
:ivar create_date: The ISO 8601 format date when resources is created
:ivar friendly_name: The friendly name specified when creating the job
:ivar resource_type: The type of communication Messages, Calls, Conferences, and Participants
"""
def __init__(
self,
version: Version,
payload: Dict[str, Any],
resource_type: str,
day: Optional[str] = None,
):
super().__init__(version)
self.redirect_to: Optional[str] = payload.get("redirect_to")
self.day: Optional[str] = payload.get("day")
self.size: Optional[int] = deserialize.integer(payload.get("size"))
self.create_date: Optional[str] = payload.get("create_date")
self.friendly_name: Optional[str] = payload.get("friendly_name")
self.resource_type: Optional[str] = payload.get("resource_type")
self._solution = {
"resource_type": resource_type,
"day": day or self.day,
}
self._context: Optional[DayContext] = None
@property
def _proxy(self) -> "DayContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: DayContext for this DayInstance
"""
if self._context is None:
self._context = DayContext(
self._version,
resource_type=self._solution["resource_type"],
day=self._solution["day"],
)
return self._context
def fetch(self) -> "DayInstance":
"""
Fetch the DayInstance
:returns: The fetched DayInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "DayInstance":
"""
Asynchronous coroutine to fetch the DayInstance
:returns: The fetched DayInstance
"""
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.Bulkexports.V1.DayInstance {}>".format(context)
class DayContext(InstanceContext):
def __init__(self, version: Version, resource_type: str, day: str):
"""
Initialize the DayContext
:param version: Version that contains the resource
:param resource_type: The type of communication Messages, Calls, Conferences, and Participants
:param day: The ISO 8601 format date of the resources in the file, for a UTC day
"""
super().__init__(version)
# Path Solution
self._solution = {
"resource_type": resource_type,
"day": day,
}
self._uri = "/Exports/{resource_type}/Days/{day}".format(**self._solution)
def fetch(self) -> DayInstance:
"""
Fetch the DayInstance
:returns: The fetched DayInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return DayInstance(
self._version,
payload,
resource_type=self._solution["resource_type"],
day=self._solution["day"],
)
async def fetch_async(self) -> DayInstance:
"""
Asynchronous coroutine to fetch the DayInstance
:returns: The fetched DayInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return DayInstance(
self._version,
payload,
resource_type=self._solution["resource_type"],
day=self._solution["day"],
)
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.Bulkexports.V1.DayContext {}>".format(context)
class DayPage(Page):
def get_instance(self, payload: Dict[str, Any]) -> DayInstance:
"""
Build an instance of DayInstance
:param payload: Payload response from the API
"""
return DayInstance(
self._version, payload, resource_type=self._solution["resource_type"]
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Bulkexports.V1.DayPage>"
class DayList(ListResource):
def __init__(self, version: Version, resource_type: str):
"""
Initialize the DayList
:param version: Version that contains the resource
:param resource_type: The type of communication Messages, Calls, Conferences, and Participants
"""
super().__init__(version)
# Path Solution
self._solution = {
"resource_type": resource_type,
}
self._uri = "/Exports/{resource_type}/Days".format(**self._solution)
def stream(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[DayInstance]:
"""
Streams DayInstance 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[DayInstance]:
"""
Asynchronously streams DayInstance 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[DayInstance]:
"""
Lists DayInstance 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[DayInstance]:
"""
Asynchronously lists DayInstance 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,
) -> DayPage:
"""
Retrieve a single page of DayInstance 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 DayInstance
"""
data = values.of(
{
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return DayPage(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,
) -> DayPage:
"""
Asynchronously retrieve a single page of DayInstance 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 DayInstance
"""
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 DayPage(self._version, response, self._solution)
def get_page(self, target_url: str) -> DayPage:
"""
Retrieve a specific page of DayInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of DayInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return DayPage(self._version, response, self._solution)
async def get_page_async(self, target_url: str) -> DayPage:
"""
Asynchronously retrieve a specific page of DayInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of DayInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return DayPage(self._version, response, self._solution)
def get(self, day: str) -> DayContext:
"""
Constructs a DayContext
:param day: The ISO 8601 format date of the resources in the file, for a UTC day
"""
return DayContext(
self._version, resource_type=self._solution["resource_type"], day=day
)
def __call__(self, day: str) -> DayContext:
"""
Constructs a DayContext
:param day: The ISO 8601 format date of the resources in the file, for a UTC day
"""
return DayContext(
self._version, resource_type=self._solution["resource_type"], day=day
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Bulkexports.V1.DayList>"
@@ -0,0 +1,382 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Bulkexports
This is the public Twilio REST API.
NOTE: This class is auto generated by OpenAPI Generator.
https://openapi-generator.tech
Do not edit the class manually.
"""
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
from twilio.base import values
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.version import Version
from twilio.base.page import Page
class ExportCustomJobInstance(InstanceResource):
"""
:ivar friendly_name: The friendly name specified when creating the job
:ivar resource_type: The type of communication Messages, Calls, Conferences, and Participants
:ivar start_day: The start day for the custom export specified when creating the job
:ivar end_day: The end day for the export specified when creating the job
:ivar webhook_url: The optional webhook url called on completion of the job. If this is supplied, `WebhookMethod` must also be supplied.
:ivar webhook_method: This is the method used to call the webhook on completion of the job. If this is supplied, `WebhookUrl` must also be supplied.
:ivar email: The optional email to send the completion notification to
:ivar job_sid: The unique job_sid returned when the custom export was created
:ivar details: The details of a job which is an object that contains an array of status grouped by `status` state. Each `status` object has a `status` string, a count which is the number of days in that `status`, and list of days in that `status`. The day strings are in the format yyyy-MM-dd. As an example, a currently running job may have a status object for COMPLETED and a `status` object for SUBMITTED each with its own count and list of days.
:ivar job_queue_position: This is the job position from the 1st in line. Your queue position will never increase. As jobs ahead of yours in the queue are processed, the queue position number will decrease
:ivar estimated_completion_time: this is the time estimated until your job is complete. This is calculated each time you request the job list. The time is calculated based on the current rate of job completion (which may vary) and your job queue position
"""
def __init__(self, version: Version, payload: Dict[str, Any], resource_type: str):
super().__init__(version)
self.friendly_name: Optional[str] = payload.get("friendly_name")
self.resource_type: Optional[str] = payload.get("resource_type")
self.start_day: Optional[str] = payload.get("start_day")
self.end_day: Optional[str] = payload.get("end_day")
self.webhook_url: Optional[str] = payload.get("webhook_url")
self.webhook_method: Optional[str] = payload.get("webhook_method")
self.email: Optional[str] = payload.get("email")
self.job_sid: Optional[str] = payload.get("job_sid")
self.details: Optional[Dict[str, object]] = payload.get("details")
self.job_queue_position: Optional[str] = payload.get("job_queue_position")
self.estimated_completion_time: Optional[str] = payload.get(
"estimated_completion_time"
)
self._solution = {
"resource_type": resource_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.Bulkexports.V1.ExportCustomJobInstance {}>".format(context)
class ExportCustomJobPage(Page):
def get_instance(self, payload: Dict[str, Any]) -> ExportCustomJobInstance:
"""
Build an instance of ExportCustomJobInstance
:param payload: Payload response from the API
"""
return ExportCustomJobInstance(
self._version, payload, resource_type=self._solution["resource_type"]
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Bulkexports.V1.ExportCustomJobPage>"
class ExportCustomJobList(ListResource):
def __init__(self, version: Version, resource_type: str):
"""
Initialize the ExportCustomJobList
:param version: Version that contains the resource
:param resource_type: The type of communication Messages, Calls, Conferences, and Participants
"""
super().__init__(version)
# Path Solution
self._solution = {
"resource_type": resource_type,
}
self._uri = "/Exports/{resource_type}/Jobs".format(**self._solution)
def create(
self,
start_day: str,
end_day: str,
friendly_name: str,
webhook_url: Union[str, object] = values.unset,
webhook_method: Union[str, object] = values.unset,
email: Union[str, object] = values.unset,
) -> ExportCustomJobInstance:
"""
Create the ExportCustomJobInstance
:param start_day: The start day for the custom export specified as a string in the format of yyyy-mm-dd
:param end_day: The end day for the custom export specified as a string in the format of yyyy-mm-dd. End day is inclusive and must be 2 days earlier than the current UTC day.
:param friendly_name: The friendly name specified when creating the job
:param webhook_url: The optional webhook url called on completion of the job. If this is supplied, `WebhookMethod` must also be supplied. If you set neither webhook nor email, you will have to check your job's status manually.
:param webhook_method: This is the method used to call the webhook on completion of the job. If this is supplied, `WebhookUrl` must also be supplied.
:param email: The optional email to send the completion notification to. You can set both webhook, and email, or one or the other. If you set neither, the job will run but you will have to query to determine your job's status.
:returns: The created ExportCustomJobInstance
"""
data = values.of(
{
"StartDay": start_day,
"EndDay": end_day,
"FriendlyName": friendly_name,
"WebhookUrl": webhook_url,
"WebhookMethod": webhook_method,
"Email": email,
}
)
payload = self._version.create(
method="POST",
uri=self._uri,
data=data,
)
return ExportCustomJobInstance(
self._version, payload, resource_type=self._solution["resource_type"]
)
async def create_async(
self,
start_day: str,
end_day: str,
friendly_name: str,
webhook_url: Union[str, object] = values.unset,
webhook_method: Union[str, object] = values.unset,
email: Union[str, object] = values.unset,
) -> ExportCustomJobInstance:
"""
Asynchronously create the ExportCustomJobInstance
:param start_day: The start day for the custom export specified as a string in the format of yyyy-mm-dd
:param end_day: The end day for the custom export specified as a string in the format of yyyy-mm-dd. End day is inclusive and must be 2 days earlier than the current UTC day.
:param friendly_name: The friendly name specified when creating the job
:param webhook_url: The optional webhook url called on completion of the job. If this is supplied, `WebhookMethod` must also be supplied. If you set neither webhook nor email, you will have to check your job's status manually.
:param webhook_method: This is the method used to call the webhook on completion of the job. If this is supplied, `WebhookUrl` must also be supplied.
:param email: The optional email to send the completion notification to. You can set both webhook, and email, or one or the other. If you set neither, the job will run but you will have to query to determine your job's status.
:returns: The created ExportCustomJobInstance
"""
data = values.of(
{
"StartDay": start_day,
"EndDay": end_day,
"FriendlyName": friendly_name,
"WebhookUrl": webhook_url,
"WebhookMethod": webhook_method,
"Email": email,
}
)
payload = await self._version.create_async(
method="POST",
uri=self._uri,
data=data,
)
return ExportCustomJobInstance(
self._version, payload, resource_type=self._solution["resource_type"]
)
def stream(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[ExportCustomJobInstance]:
"""
Streams ExportCustomJobInstance 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[ExportCustomJobInstance]:
"""
Asynchronously streams ExportCustomJobInstance 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[ExportCustomJobInstance]:
"""
Lists ExportCustomJobInstance 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[ExportCustomJobInstance]:
"""
Asynchronously lists ExportCustomJobInstance 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,
) -> ExportCustomJobPage:
"""
Retrieve a single page of ExportCustomJobInstance 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 ExportCustomJobInstance
"""
data = values.of(
{
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return ExportCustomJobPage(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,
) -> ExportCustomJobPage:
"""
Asynchronously retrieve a single page of ExportCustomJobInstance 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 ExportCustomJobInstance
"""
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 ExportCustomJobPage(self._version, response, self._solution)
def get_page(self, target_url: str) -> ExportCustomJobPage:
"""
Retrieve a specific page of ExportCustomJobInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of ExportCustomJobInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return ExportCustomJobPage(self._version, response, self._solution)
async def get_page_async(self, target_url: str) -> ExportCustomJobPage:
"""
Asynchronously retrieve a specific page of ExportCustomJobInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of ExportCustomJobInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return ExportCustomJobPage(self._version, response, self._solution)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Bulkexports.V1.ExportCustomJobList>"
@@ -0,0 +1,246 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Bulkexports
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 JobInstance(InstanceResource):
"""
:ivar resource_type: The type of communication Messages, Calls, Conferences, and Participants
:ivar friendly_name: The friendly name specified when creating the job
:ivar details: The details of a job which is an object that contains an array of status grouped by `status` state. Each `status` object has a `status` string, a count which is the number of days in that `status`, and list of days in that `status`. The day strings are in the format yyyy-MM-dd. As an example, a currently running job may have a status object for COMPLETED and a `status` object for SUBMITTED each with its own count and list of days.
:ivar start_day: The start time for the export specified when creating the job
:ivar end_day: The end time for the export specified when creating the job
:ivar job_sid: The job_sid returned when the export was created
:ivar webhook_url: The optional webhook url called on completion
:ivar webhook_method: This is the method used to call the webhook
:ivar email: The optional email to send the completion notification to
:ivar url:
:ivar job_queue_position: This is the job position from the 1st in line. Your queue position will never increase. As jobs ahead of yours in the queue are processed, the queue position number will decrease
:ivar estimated_completion_time: this is the time estimated until your job is complete. This is calculated each time you request the job list. The time is calculated based on the current rate of job completion (which may vary) and your job queue position
"""
def __init__(
self, version: Version, payload: Dict[str, Any], job_sid: Optional[str] = None
):
super().__init__(version)
self.resource_type: Optional[str] = payload.get("resource_type")
self.friendly_name: Optional[str] = payload.get("friendly_name")
self.details: Optional[Dict[str, object]] = payload.get("details")
self.start_day: Optional[str] = payload.get("start_day")
self.end_day: Optional[str] = payload.get("end_day")
self.job_sid: Optional[str] = payload.get("job_sid")
self.webhook_url: Optional[str] = payload.get("webhook_url")
self.webhook_method: Optional[str] = payload.get("webhook_method")
self.email: Optional[str] = payload.get("email")
self.url: Optional[str] = payload.get("url")
self.job_queue_position: Optional[str] = payload.get("job_queue_position")
self.estimated_completion_time: Optional[str] = payload.get(
"estimated_completion_time"
)
self._solution = {
"job_sid": job_sid or self.job_sid,
}
self._context: Optional[JobContext] = None
@property
def _proxy(self) -> "JobContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: JobContext for this JobInstance
"""
if self._context is None:
self._context = JobContext(
self._version,
job_sid=self._solution["job_sid"],
)
return self._context
def delete(self) -> bool:
"""
Deletes the JobInstance
:returns: True if delete succeeds, False otherwise
"""
return self._proxy.delete()
async def delete_async(self) -> bool:
"""
Asynchronous coroutine that deletes the JobInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._proxy.delete_async()
def fetch(self) -> "JobInstance":
"""
Fetch the JobInstance
:returns: The fetched JobInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "JobInstance":
"""
Asynchronous coroutine to fetch the JobInstance
:returns: The fetched JobInstance
"""
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.Bulkexports.V1.JobInstance {}>".format(context)
class JobContext(InstanceContext):
def __init__(self, version: Version, job_sid: str):
"""
Initialize the JobContext
:param version: Version that contains the resource
:param job_sid: The unique string that that we created to identify the Bulk Export job
"""
super().__init__(version)
# Path Solution
self._solution = {
"job_sid": job_sid,
}
self._uri = "/Exports/Jobs/{job_sid}".format(**self._solution)
def delete(self) -> bool:
"""
Deletes the JobInstance
: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 JobInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._version.delete_async(
method="DELETE",
uri=self._uri,
)
def fetch(self) -> JobInstance:
"""
Fetch the JobInstance
:returns: The fetched JobInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return JobInstance(
self._version,
payload,
job_sid=self._solution["job_sid"],
)
async def fetch_async(self) -> JobInstance:
"""
Asynchronous coroutine to fetch the JobInstance
:returns: The fetched JobInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return JobInstance(
self._version,
payload,
job_sid=self._solution["job_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.Bulkexports.V1.JobContext {}>".format(context)
class JobList(ListResource):
def __init__(self, version: Version):
"""
Initialize the JobList
:param version: Version that contains the resource
"""
super().__init__(version)
def get(self, job_sid: str) -> JobContext:
"""
Constructs a JobContext
:param job_sid: The unique string that that we created to identify the Bulk Export job
"""
return JobContext(self._version, job_sid=job_sid)
def __call__(self, job_sid: str) -> JobContext:
"""
Constructs a JobContext
:param job_sid: The unique string that that we created to identify the Bulk Export job
"""
return JobContext(self._version, job_sid=job_sid)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Bulkexports.V1.JobList>"
@@ -0,0 +1,300 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Bulkexports
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, Union
from twilio.base import values
from twilio.base.instance_context import InstanceContext
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.version import Version
class ExportConfigurationInstance(InstanceResource):
"""
:ivar enabled: If true, Twilio will automatically generate every day's file when the day is over.
:ivar webhook_url: Stores the URL destination for the method specified in webhook_method.
:ivar webhook_method: Sets whether Twilio should call a webhook URL when the automatic generation is complete, using GET or POST. The actual destination is set in the webhook_url
:ivar resource_type: The type of communication Messages, Calls, Conferences, and Participants
:ivar url: The URL of this resource.
"""
def __init__(
self,
version: Version,
payload: Dict[str, Any],
resource_type: Optional[str] = None,
):
super().__init__(version)
self.enabled: Optional[bool] = payload.get("enabled")
self.webhook_url: Optional[str] = payload.get("webhook_url")
self.webhook_method: Optional[str] = payload.get("webhook_method")
self.resource_type: Optional[str] = payload.get("resource_type")
self.url: Optional[str] = payload.get("url")
self._solution = {
"resource_type": resource_type or self.resource_type,
}
self._context: Optional[ExportConfigurationContext] = None
@property
def _proxy(self) -> "ExportConfigurationContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: ExportConfigurationContext for this ExportConfigurationInstance
"""
if self._context is None:
self._context = ExportConfigurationContext(
self._version,
resource_type=self._solution["resource_type"],
)
return self._context
def fetch(self) -> "ExportConfigurationInstance":
"""
Fetch the ExportConfigurationInstance
:returns: The fetched ExportConfigurationInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "ExportConfigurationInstance":
"""
Asynchronous coroutine to fetch the ExportConfigurationInstance
:returns: The fetched ExportConfigurationInstance
"""
return await self._proxy.fetch_async()
def update(
self,
enabled: Union[bool, object] = values.unset,
webhook_url: Union[str, object] = values.unset,
webhook_method: Union[str, object] = values.unset,
) -> "ExportConfigurationInstance":
"""
Update the ExportConfigurationInstance
:param enabled: If true, Twilio will automatically generate every day's file when the day is over.
:param webhook_url: Stores the URL destination for the method specified in webhook_method.
:param webhook_method: Sets whether Twilio should call a webhook URL when the automatic generation is complete, using GET or POST. The actual destination is set in the webhook_url
:returns: The updated ExportConfigurationInstance
"""
return self._proxy.update(
enabled=enabled,
webhook_url=webhook_url,
webhook_method=webhook_method,
)
async def update_async(
self,
enabled: Union[bool, object] = values.unset,
webhook_url: Union[str, object] = values.unset,
webhook_method: Union[str, object] = values.unset,
) -> "ExportConfigurationInstance":
"""
Asynchronous coroutine to update the ExportConfigurationInstance
:param enabled: If true, Twilio will automatically generate every day's file when the day is over.
:param webhook_url: Stores the URL destination for the method specified in webhook_method.
:param webhook_method: Sets whether Twilio should call a webhook URL when the automatic generation is complete, using GET or POST. The actual destination is set in the webhook_url
:returns: The updated ExportConfigurationInstance
"""
return await self._proxy.update_async(
enabled=enabled,
webhook_url=webhook_url,
webhook_method=webhook_method,
)
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.Bulkexports.V1.ExportConfigurationInstance {}>".format(context)
class ExportConfigurationContext(InstanceContext):
def __init__(self, version: Version, resource_type: str):
"""
Initialize the ExportConfigurationContext
:param version: Version that contains the resource
:param resource_type: The type of communication Messages, Calls, Conferences, and Participants
"""
super().__init__(version)
# Path Solution
self._solution = {
"resource_type": resource_type,
}
self._uri = "/Exports/{resource_type}/Configuration".format(**self._solution)
def fetch(self) -> ExportConfigurationInstance:
"""
Fetch the ExportConfigurationInstance
:returns: The fetched ExportConfigurationInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return ExportConfigurationInstance(
self._version,
payload,
resource_type=self._solution["resource_type"],
)
async def fetch_async(self) -> ExportConfigurationInstance:
"""
Asynchronous coroutine to fetch the ExportConfigurationInstance
:returns: The fetched ExportConfigurationInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return ExportConfigurationInstance(
self._version,
payload,
resource_type=self._solution["resource_type"],
)
def update(
self,
enabled: Union[bool, object] = values.unset,
webhook_url: Union[str, object] = values.unset,
webhook_method: Union[str, object] = values.unset,
) -> ExportConfigurationInstance:
"""
Update the ExportConfigurationInstance
:param enabled: If true, Twilio will automatically generate every day's file when the day is over.
:param webhook_url: Stores the URL destination for the method specified in webhook_method.
:param webhook_method: Sets whether Twilio should call a webhook URL when the automatic generation is complete, using GET or POST. The actual destination is set in the webhook_url
:returns: The updated ExportConfigurationInstance
"""
data = values.of(
{
"Enabled": enabled,
"WebhookUrl": webhook_url,
"WebhookMethod": webhook_method,
}
)
payload = self._version.update(
method="POST",
uri=self._uri,
data=data,
)
return ExportConfigurationInstance(
self._version, payload, resource_type=self._solution["resource_type"]
)
async def update_async(
self,
enabled: Union[bool, object] = values.unset,
webhook_url: Union[str, object] = values.unset,
webhook_method: Union[str, object] = values.unset,
) -> ExportConfigurationInstance:
"""
Asynchronous coroutine to update the ExportConfigurationInstance
:param enabled: If true, Twilio will automatically generate every day's file when the day is over.
:param webhook_url: Stores the URL destination for the method specified in webhook_method.
:param webhook_method: Sets whether Twilio should call a webhook URL when the automatic generation is complete, using GET or POST. The actual destination is set in the webhook_url
:returns: The updated ExportConfigurationInstance
"""
data = values.of(
{
"Enabled": enabled,
"WebhookUrl": webhook_url,
"WebhookMethod": webhook_method,
}
)
payload = await self._version.update_async(
method="POST",
uri=self._uri,
data=data,
)
return ExportConfigurationInstance(
self._version, payload, resource_type=self._solution["resource_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.Bulkexports.V1.ExportConfigurationContext {}>".format(context)
class ExportConfigurationList(ListResource):
def __init__(self, version: Version):
"""
Initialize the ExportConfigurationList
:param version: Version that contains the resource
"""
super().__init__(version)
def get(self, resource_type: str) -> ExportConfigurationContext:
"""
Constructs a ExportConfigurationContext
:param resource_type: The type of communication Messages, Calls, Conferences, and Participants
"""
return ExportConfigurationContext(self._version, resource_type=resource_type)
def __call__(self, resource_type: str) -> ExportConfigurationContext:
"""
Constructs a ExportConfigurationContext
:param resource_type: The type of communication Messages, Calls, Conferences, and Participants
"""
return ExportConfigurationContext(self._version, resource_type=resource_type)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Bulkexports.V1.ExportConfigurationList>"