Initial commit: Email alerts application
This commit is contained in:
@@ -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.media.v1 import V1
|
||||
|
||||
|
||||
class MediaBase(Domain):
|
||||
def __init__(self, twilio: Client):
|
||||
"""
|
||||
Initialize the Media Domain
|
||||
|
||||
:returns: Domain for Media
|
||||
"""
|
||||
super().__init__(twilio, "https://media.twilio.com")
|
||||
self._v1: Optional[V1] = None
|
||||
|
||||
@property
|
||||
def v1(self) -> V1:
|
||||
"""
|
||||
:returns: Versions v1 of Media
|
||||
"""
|
||||
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.Media>"
|
||||
@@ -0,0 +1,35 @@
|
||||
from warnings import warn
|
||||
|
||||
from twilio.rest.media.MediaBase import MediaBase
|
||||
from twilio.rest.media.v1.media_processor import MediaProcessorList
|
||||
from twilio.rest.media.v1.media_recording import MediaRecordingList
|
||||
from twilio.rest.media.v1.player_streamer import PlayerStreamerList
|
||||
|
||||
|
||||
class Media(MediaBase):
|
||||
@property
|
||||
def media_processor(self) -> MediaProcessorList:
|
||||
warn(
|
||||
"media_processor is deprecated. Use v1.media_processor instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.v1.media_processor
|
||||
|
||||
@property
|
||||
def media_recording(self) -> MediaRecordingList:
|
||||
warn(
|
||||
"media_recording is deprecated. Use v1.media_recording instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.v1.media_recording
|
||||
|
||||
@property
|
||||
def player_streamer(self) -> PlayerStreamerList:
|
||||
warn(
|
||||
"player_streamer is deprecated. Use v1.player_streamer instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.v1.player_streamer
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -0,0 +1,58 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Media
|
||||
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.media.v1.media_processor import MediaProcessorList
|
||||
from twilio.rest.media.v1.media_recording import MediaRecordingList
|
||||
from twilio.rest.media.v1.player_streamer import PlayerStreamerList
|
||||
|
||||
|
||||
class V1(Version):
|
||||
def __init__(self, domain: Domain):
|
||||
"""
|
||||
Initialize the V1 version of Media
|
||||
|
||||
:param domain: The Twilio.media domain
|
||||
"""
|
||||
super().__init__(domain, "v1")
|
||||
self._media_processor: Optional[MediaProcessorList] = None
|
||||
self._media_recording: Optional[MediaRecordingList] = None
|
||||
self._player_streamer: Optional[PlayerStreamerList] = None
|
||||
|
||||
@property
|
||||
def media_processor(self) -> MediaProcessorList:
|
||||
if self._media_processor is None:
|
||||
self._media_processor = MediaProcessorList(self)
|
||||
return self._media_processor
|
||||
|
||||
@property
|
||||
def media_recording(self) -> MediaRecordingList:
|
||||
if self._media_recording is None:
|
||||
self._media_recording = MediaRecordingList(self)
|
||||
return self._media_recording
|
||||
|
||||
@property
|
||||
def player_streamer(self) -> PlayerStreamerList:
|
||||
if self._player_streamer is None:
|
||||
self._player_streamer = PlayerStreamerList(self)
|
||||
return self._player_streamer
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Media.V1>"
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -0,0 +1,617 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Media
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, serialize, values
|
||||
from twilio.base.instance_context import InstanceContext
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.page import Page
|
||||
|
||||
|
||||
class MediaProcessorInstance(InstanceResource):
|
||||
class Order(object):
|
||||
ASC = "asc"
|
||||
DESC = "desc"
|
||||
|
||||
class Status(object):
|
||||
FAILED = "failed"
|
||||
STARTED = "started"
|
||||
ENDED = "ended"
|
||||
|
||||
class UpdateStatus(object):
|
||||
ENDED = "ended"
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the MediaProcessor resource.
|
||||
:ivar sid: The unique string generated to identify the MediaProcessor resource.
|
||||
:ivar date_created: The date and time in GMT when the resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:ivar date_updated: The date and time in GMT when the resource was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:ivar extension: The [Media Extension](/docs/live/media-extensions-overview) name or URL. Ex: `video-composer-v2`
|
||||
:ivar extension_context: The context of the Media Extension, represented as a JSON dictionary. See the documentation for the specific [Media Extension](/docs/live/media-extensions-overview) you are using for more information about the context to send.
|
||||
:ivar status:
|
||||
:ivar url: The absolute URL of the resource.
|
||||
:ivar ended_reason: The reason why a MediaProcessor ended. When a MediaProcessor is in progress, will be `null`. When a MediaProcessor is completed, can be `ended-via-api`, `max-duration-exceeded`, `error-loading-extension`, `error-streaming-media` or `internal-service-error`. See [ended reasons](/docs/live/api/mediaprocessors#mediaprocessor-ended-reason-values) for more details.
|
||||
:ivar status_callback: The URL to which Twilio will send asynchronous webhook requests for every MediaProcessor event. See [Status Callbacks](/docs/live/api/status-callbacks) for details.
|
||||
:ivar status_callback_method: The HTTP method Twilio should use to call the `status_callback` URL. Can be `POST` or `GET` and the default is `POST`.
|
||||
:ivar max_duration: The maximum time, in seconds, that the MediaProcessor can run before automatically ends. The default value is 300 seconds, and the maximum value is 90000 seconds. Once this maximum duration is reached, Twilio will end the MediaProcessor, regardless of whether media is still streaming.
|
||||
"""
|
||||
|
||||
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.extension: Optional[str] = payload.get("extension")
|
||||
self.extension_context: Optional[str] = payload.get("extension_context")
|
||||
self.status: Optional["MediaProcessorInstance.Status"] = payload.get("status")
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
self.ended_reason: Optional[str] = payload.get("ended_reason")
|
||||
self.status_callback: Optional[str] = payload.get("status_callback")
|
||||
self.status_callback_method: Optional[str] = payload.get(
|
||||
"status_callback_method"
|
||||
)
|
||||
self.max_duration: Optional[int] = deserialize.integer(
|
||||
payload.get("max_duration")
|
||||
)
|
||||
|
||||
self._solution = {
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[MediaProcessorContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "MediaProcessorContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: MediaProcessorContext for this MediaProcessorInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = MediaProcessorContext(
|
||||
self._version,
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def fetch(self) -> "MediaProcessorInstance":
|
||||
"""
|
||||
Fetch the MediaProcessorInstance
|
||||
|
||||
|
||||
:returns: The fetched MediaProcessorInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "MediaProcessorInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the MediaProcessorInstance
|
||||
|
||||
|
||||
:returns: The fetched MediaProcessorInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self, status: "MediaProcessorInstance.UpdateStatus"
|
||||
) -> "MediaProcessorInstance":
|
||||
"""
|
||||
Update the MediaProcessorInstance
|
||||
|
||||
:param status:
|
||||
|
||||
:returns: The updated MediaProcessorInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
status=status,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self, status: "MediaProcessorInstance.UpdateStatus"
|
||||
) -> "MediaProcessorInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the MediaProcessorInstance
|
||||
|
||||
:param status:
|
||||
|
||||
:returns: The updated MediaProcessorInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
status=status,
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Media.V1.MediaProcessorInstance {}>".format(context)
|
||||
|
||||
|
||||
class MediaProcessorContext(InstanceContext):
|
||||
def __init__(self, version: Version, sid: str):
|
||||
"""
|
||||
Initialize the MediaProcessorContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param sid: The SID of the MediaProcessor resource to update.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/MediaProcessors/{sid}".format(**self._solution)
|
||||
|
||||
def fetch(self) -> MediaProcessorInstance:
|
||||
"""
|
||||
Fetch the MediaProcessorInstance
|
||||
|
||||
|
||||
:returns: The fetched MediaProcessorInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return MediaProcessorInstance(
|
||||
self._version,
|
||||
payload,
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> MediaProcessorInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the MediaProcessorInstance
|
||||
|
||||
|
||||
:returns: The fetched MediaProcessorInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return MediaProcessorInstance(
|
||||
self._version,
|
||||
payload,
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self, status: "MediaProcessorInstance.UpdateStatus"
|
||||
) -> MediaProcessorInstance:
|
||||
"""
|
||||
Update the MediaProcessorInstance
|
||||
|
||||
:param status:
|
||||
|
||||
:returns: The updated MediaProcessorInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Status": status,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return MediaProcessorInstance(self._version, payload, sid=self._solution["sid"])
|
||||
|
||||
async def update_async(
|
||||
self, status: "MediaProcessorInstance.UpdateStatus"
|
||||
) -> MediaProcessorInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the MediaProcessorInstance
|
||||
|
||||
:param status:
|
||||
|
||||
:returns: The updated MediaProcessorInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Status": status,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return MediaProcessorInstance(self._version, payload, sid=self._solution["sid"])
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Media.V1.MediaProcessorContext {}>".format(context)
|
||||
|
||||
|
||||
class MediaProcessorPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> MediaProcessorInstance:
|
||||
"""
|
||||
Build an instance of MediaProcessorInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return MediaProcessorInstance(self._version, payload)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Media.V1.MediaProcessorPage>"
|
||||
|
||||
|
||||
class MediaProcessorList(ListResource):
|
||||
def __init__(self, version: Version):
|
||||
"""
|
||||
Initialize the MediaProcessorList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
self._uri = "/MediaProcessors"
|
||||
|
||||
def create(
|
||||
self,
|
||||
extension: str,
|
||||
extension_context: str,
|
||||
extension_environment: Union[object, object] = values.unset,
|
||||
status_callback: Union[str, object] = values.unset,
|
||||
status_callback_method: Union[str, object] = values.unset,
|
||||
max_duration: Union[int, object] = values.unset,
|
||||
) -> MediaProcessorInstance:
|
||||
"""
|
||||
Create the MediaProcessorInstance
|
||||
|
||||
:param extension: The [Media Extension](/docs/live/media-extensions-overview) name or URL. Ex: `video-composer-v2`
|
||||
:param extension_context: The context of the Media Extension, represented as a JSON dictionary. See the documentation for the specific [Media Extension](/docs/live/media-extensions-overview) you are using for more information about the context to send.
|
||||
:param extension_environment: User-defined environment variables for the Media Extension, represented as a JSON dictionary of key/value strings. See the documentation for the specific [Media Extension](/docs/live/media-extensions-overview) you are using for more information about whether you need to provide this.
|
||||
:param status_callback: The URL to which Twilio will send asynchronous webhook requests for every MediaProcessor event. See [Status Callbacks](/docs/live/api/status-callbacks) for details.
|
||||
:param status_callback_method: The HTTP method Twilio should use to call the `status_callback` URL. Can be `POST` or `GET` and the default is `POST`.
|
||||
:param max_duration: The maximum time, in seconds, that the MediaProcessor can run before automatically ends. The default value is 300 seconds, and the maximum value is 90000 seconds. Once this maximum duration is reached, Twilio will end the MediaProcessor, regardless of whether media is still streaming.
|
||||
|
||||
:returns: The created MediaProcessorInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Extension": extension,
|
||||
"ExtensionContext": extension_context,
|
||||
"ExtensionEnvironment": serialize.object(extension_environment),
|
||||
"StatusCallback": status_callback,
|
||||
"StatusCallbackMethod": status_callback_method,
|
||||
"MaxDuration": max_duration,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return MediaProcessorInstance(self._version, payload)
|
||||
|
||||
async def create_async(
|
||||
self,
|
||||
extension: str,
|
||||
extension_context: str,
|
||||
extension_environment: Union[object, object] = values.unset,
|
||||
status_callback: Union[str, object] = values.unset,
|
||||
status_callback_method: Union[str, object] = values.unset,
|
||||
max_duration: Union[int, object] = values.unset,
|
||||
) -> MediaProcessorInstance:
|
||||
"""
|
||||
Asynchronously create the MediaProcessorInstance
|
||||
|
||||
:param extension: The [Media Extension](/docs/live/media-extensions-overview) name or URL. Ex: `video-composer-v2`
|
||||
:param extension_context: The context of the Media Extension, represented as a JSON dictionary. See the documentation for the specific [Media Extension](/docs/live/media-extensions-overview) you are using for more information about the context to send.
|
||||
:param extension_environment: User-defined environment variables for the Media Extension, represented as a JSON dictionary of key/value strings. See the documentation for the specific [Media Extension](/docs/live/media-extensions-overview) you are using for more information about whether you need to provide this.
|
||||
:param status_callback: The URL to which Twilio will send asynchronous webhook requests for every MediaProcessor event. See [Status Callbacks](/docs/live/api/status-callbacks) for details.
|
||||
:param status_callback_method: The HTTP method Twilio should use to call the `status_callback` URL. Can be `POST` or `GET` and the default is `POST`.
|
||||
:param max_duration: The maximum time, in seconds, that the MediaProcessor can run before automatically ends. The default value is 300 seconds, and the maximum value is 90000 seconds. Once this maximum duration is reached, Twilio will end the MediaProcessor, regardless of whether media is still streaming.
|
||||
|
||||
:returns: The created MediaProcessorInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Extension": extension,
|
||||
"ExtensionContext": extension_context,
|
||||
"ExtensionEnvironment": serialize.object(extension_environment),
|
||||
"StatusCallback": status_callback,
|
||||
"StatusCallbackMethod": status_callback_method,
|
||||
"MaxDuration": max_duration,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return MediaProcessorInstance(self._version, payload)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
order: Union["MediaProcessorInstance.Order", object] = values.unset,
|
||||
status: Union["MediaProcessorInstance.Status", object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[MediaProcessorInstance]:
|
||||
"""
|
||||
Streams MediaProcessorInstance 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 "MediaProcessorInstance.Order" order: The sort order of the list by `date_created`. Can be: `asc` (ascending) or `desc` (descending) with `desc` as the default.
|
||||
:param "MediaProcessorInstance.Status" status: Status to filter by, with possible values `started`, `ended` 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(order=order, status=status, page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
order: Union["MediaProcessorInstance.Order", object] = values.unset,
|
||||
status: Union["MediaProcessorInstance.Status", object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[MediaProcessorInstance]:
|
||||
"""
|
||||
Asynchronously streams MediaProcessorInstance 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 "MediaProcessorInstance.Order" order: The sort order of the list by `date_created`. Can be: `asc` (ascending) or `desc` (descending) with `desc` as the default.
|
||||
:param "MediaProcessorInstance.Status" status: Status to filter by, with possible values `started`, `ended` 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(
|
||||
order=order, status=status, page_size=limits["page_size"]
|
||||
)
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
order: Union["MediaProcessorInstance.Order", object] = values.unset,
|
||||
status: Union["MediaProcessorInstance.Status", object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[MediaProcessorInstance]:
|
||||
"""
|
||||
Lists MediaProcessorInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param "MediaProcessorInstance.Order" order: The sort order of the list by `date_created`. Can be: `asc` (ascending) or `desc` (descending) with `desc` as the default.
|
||||
:param "MediaProcessorInstance.Status" status: Status to filter by, with possible values `started`, `ended` 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(
|
||||
order=order,
|
||||
status=status,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
order: Union["MediaProcessorInstance.Order", object] = values.unset,
|
||||
status: Union["MediaProcessorInstance.Status", object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[MediaProcessorInstance]:
|
||||
"""
|
||||
Asynchronously lists MediaProcessorInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param "MediaProcessorInstance.Order" order: The sort order of the list by `date_created`. Can be: `asc` (ascending) or `desc` (descending) with `desc` as the default.
|
||||
:param "MediaProcessorInstance.Status" status: Status to filter by, with possible values `started`, `ended` 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(
|
||||
order=order,
|
||||
status=status,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
order: Union["MediaProcessorInstance.Order", object] = values.unset,
|
||||
status: Union["MediaProcessorInstance.Status", object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> MediaProcessorPage:
|
||||
"""
|
||||
Retrieve a single page of MediaProcessorInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param order: The sort order of the list by `date_created`. Can be: `asc` (ascending) or `desc` (descending) with `desc` as the default.
|
||||
:param status: Status to filter by, with possible values `started`, `ended` 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 MediaProcessorInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Order": order,
|
||||
"Status": status,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return MediaProcessorPage(self._version, response)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
order: Union["MediaProcessorInstance.Order", object] = values.unset,
|
||||
status: Union["MediaProcessorInstance.Status", object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> MediaProcessorPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of MediaProcessorInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param order: The sort order of the list by `date_created`. Can be: `asc` (ascending) or `desc` (descending) with `desc` as the default.
|
||||
:param status: Status to filter by, with possible values `started`, `ended` 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 MediaProcessorInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Order": order,
|
||||
"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 MediaProcessorPage(self._version, response)
|
||||
|
||||
def get_page(self, target_url: str) -> MediaProcessorPage:
|
||||
"""
|
||||
Retrieve a specific page of MediaProcessorInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of MediaProcessorInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return MediaProcessorPage(self._version, response)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> MediaProcessorPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of MediaProcessorInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of MediaProcessorInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return MediaProcessorPage(self._version, response)
|
||||
|
||||
def get(self, sid: str) -> MediaProcessorContext:
|
||||
"""
|
||||
Constructs a MediaProcessorContext
|
||||
|
||||
:param sid: The SID of the MediaProcessor resource to update.
|
||||
"""
|
||||
return MediaProcessorContext(self._version, sid=sid)
|
||||
|
||||
def __call__(self, sid: str) -> MediaProcessorContext:
|
||||
"""
|
||||
Constructs a MediaProcessorContext
|
||||
|
||||
:param sid: The SID of the MediaProcessor resource to update.
|
||||
"""
|
||||
return MediaProcessorContext(self._version, sid=sid)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Media.V1.MediaProcessorList>"
|
||||
@@ -0,0 +1,551 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Media
|
||||
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 MediaRecordingInstance(InstanceResource):
|
||||
class Format(object):
|
||||
MP4 = "mp4"
|
||||
WEBM = "webm"
|
||||
|
||||
class Order(object):
|
||||
ASC = "asc"
|
||||
DESC = "desc"
|
||||
|
||||
class Status(object):
|
||||
PROCESSING = "processing"
|
||||
COMPLETED = "completed"
|
||||
DELETED = "deleted"
|
||||
FAILED = "failed"
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the MediaRecording resource.
|
||||
:ivar date_created: The date and time in GMT when the resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:ivar date_updated: The date and time in GMT when the resource was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:ivar duration: The duration of the MediaRecording in seconds.
|
||||
:ivar format:
|
||||
:ivar links: The URLs of related resources.
|
||||
:ivar processor_sid: The SID of the MediaProcessor resource which produced the MediaRecording.
|
||||
:ivar resolution: The dimensions of the video image in pixels expressed as columns (width) and rows (height).
|
||||
:ivar source_sid: The SID of the resource that generated the original media track(s) of the MediaRecording.
|
||||
:ivar sid: The unique string generated to identify the MediaRecording resource.
|
||||
:ivar media_size: The size of the recording media in bytes.
|
||||
:ivar status:
|
||||
:ivar status_callback: The URL to which Twilio will send asynchronous webhook requests for every MediaRecording event. See [Status Callbacks](/docs/live/api/status-callbacks) for more details.
|
||||
:ivar status_callback_method: The HTTP method Twilio should use to call the `status_callback` URL. Can be `POST` or `GET` and the default is `POST`.
|
||||
:ivar url: The absolute URL of the resource.
|
||||
"""
|
||||
|
||||
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.date_created: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.duration: Optional[int] = deserialize.integer(payload.get("duration"))
|
||||
self.format: Optional["MediaRecordingInstance.Format"] = payload.get("format")
|
||||
self.links: Optional[Dict[str, object]] = payload.get("links")
|
||||
self.processor_sid: Optional[str] = payload.get("processor_sid")
|
||||
self.resolution: Optional[str] = payload.get("resolution")
|
||||
self.source_sid: Optional[str] = payload.get("source_sid")
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.media_size: Optional[int] = payload.get("media_size")
|
||||
self.status: Optional["MediaRecordingInstance.Status"] = payload.get("status")
|
||||
self.status_callback: Optional[str] = payload.get("status_callback")
|
||||
self.status_callback_method: Optional[str] = payload.get(
|
||||
"status_callback_method"
|
||||
)
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
|
||||
self._solution = {
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[MediaRecordingContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "MediaRecordingContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: MediaRecordingContext for this MediaRecordingInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = MediaRecordingContext(
|
||||
self._version,
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the MediaRecordingInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the MediaRecordingInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
def fetch(self) -> "MediaRecordingInstance":
|
||||
"""
|
||||
Fetch the MediaRecordingInstance
|
||||
|
||||
|
||||
:returns: The fetched MediaRecordingInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "MediaRecordingInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the MediaRecordingInstance
|
||||
|
||||
|
||||
:returns: The fetched MediaRecordingInstance
|
||||
"""
|
||||
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.Media.V1.MediaRecordingInstance {}>".format(context)
|
||||
|
||||
|
||||
class MediaRecordingContext(InstanceContext):
|
||||
def __init__(self, version: Version, sid: str):
|
||||
"""
|
||||
Initialize the MediaRecordingContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param sid: The SID of the MediaRecording resource to fetch.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/MediaRecordings/{sid}".format(**self._solution)
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the MediaRecordingInstance
|
||||
|
||||
|
||||
: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 MediaRecordingInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
def fetch(self) -> MediaRecordingInstance:
|
||||
"""
|
||||
Fetch the MediaRecordingInstance
|
||||
|
||||
|
||||
:returns: The fetched MediaRecordingInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return MediaRecordingInstance(
|
||||
self._version,
|
||||
payload,
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> MediaRecordingInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the MediaRecordingInstance
|
||||
|
||||
|
||||
:returns: The fetched MediaRecordingInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return MediaRecordingInstance(
|
||||
self._version,
|
||||
payload,
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Media.V1.MediaRecordingContext {}>".format(context)
|
||||
|
||||
|
||||
class MediaRecordingPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> MediaRecordingInstance:
|
||||
"""
|
||||
Build an instance of MediaRecordingInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return MediaRecordingInstance(self._version, payload)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Media.V1.MediaRecordingPage>"
|
||||
|
||||
|
||||
class MediaRecordingList(ListResource):
|
||||
def __init__(self, version: Version):
|
||||
"""
|
||||
Initialize the MediaRecordingList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
self._uri = "/MediaRecordings"
|
||||
|
||||
def stream(
|
||||
self,
|
||||
order: Union["MediaRecordingInstance.Order", object] = values.unset,
|
||||
status: Union["MediaRecordingInstance.Status", object] = values.unset,
|
||||
processor_sid: Union[str, object] = values.unset,
|
||||
source_sid: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[MediaRecordingInstance]:
|
||||
"""
|
||||
Streams MediaRecordingInstance 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 "MediaRecordingInstance.Order" order: The sort order of the list by `date_created`. Can be: `asc` (ascending) or `desc` (descending) with `desc` as the default.
|
||||
:param "MediaRecordingInstance.Status" status: Status to filter by, with possible values `processing`, `completed`, `deleted`, or `failed`.
|
||||
:param str processor_sid: SID of a MediaProcessor to filter by.
|
||||
:param str source_sid: SID of a MediaRecording source to filter 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(
|
||||
order=order,
|
||||
status=status,
|
||||
processor_sid=processor_sid,
|
||||
source_sid=source_sid,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
order: Union["MediaRecordingInstance.Order", object] = values.unset,
|
||||
status: Union["MediaRecordingInstance.Status", object] = values.unset,
|
||||
processor_sid: Union[str, object] = values.unset,
|
||||
source_sid: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[MediaRecordingInstance]:
|
||||
"""
|
||||
Asynchronously streams MediaRecordingInstance 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 "MediaRecordingInstance.Order" order: The sort order of the list by `date_created`. Can be: `asc` (ascending) or `desc` (descending) with `desc` as the default.
|
||||
:param "MediaRecordingInstance.Status" status: Status to filter by, with possible values `processing`, `completed`, `deleted`, or `failed`.
|
||||
:param str processor_sid: SID of a MediaProcessor to filter by.
|
||||
:param str source_sid: SID of a MediaRecording source to filter 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(
|
||||
order=order,
|
||||
status=status,
|
||||
processor_sid=processor_sid,
|
||||
source_sid=source_sid,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
order: Union["MediaRecordingInstance.Order", object] = values.unset,
|
||||
status: Union["MediaRecordingInstance.Status", object] = values.unset,
|
||||
processor_sid: Union[str, object] = values.unset,
|
||||
source_sid: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[MediaRecordingInstance]:
|
||||
"""
|
||||
Lists MediaRecordingInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param "MediaRecordingInstance.Order" order: The sort order of the list by `date_created`. Can be: `asc` (ascending) or `desc` (descending) with `desc` as the default.
|
||||
:param "MediaRecordingInstance.Status" status: Status to filter by, with possible values `processing`, `completed`, `deleted`, or `failed`.
|
||||
:param str processor_sid: SID of a MediaProcessor to filter by.
|
||||
:param str source_sid: SID of a MediaRecording source to filter 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(
|
||||
order=order,
|
||||
status=status,
|
||||
processor_sid=processor_sid,
|
||||
source_sid=source_sid,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
order: Union["MediaRecordingInstance.Order", object] = values.unset,
|
||||
status: Union["MediaRecordingInstance.Status", object] = values.unset,
|
||||
processor_sid: Union[str, object] = values.unset,
|
||||
source_sid: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[MediaRecordingInstance]:
|
||||
"""
|
||||
Asynchronously lists MediaRecordingInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param "MediaRecordingInstance.Order" order: The sort order of the list by `date_created`. Can be: `asc` (ascending) or `desc` (descending) with `desc` as the default.
|
||||
:param "MediaRecordingInstance.Status" status: Status to filter by, with possible values `processing`, `completed`, `deleted`, or `failed`.
|
||||
:param str processor_sid: SID of a MediaProcessor to filter by.
|
||||
:param str source_sid: SID of a MediaRecording source to filter 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(
|
||||
order=order,
|
||||
status=status,
|
||||
processor_sid=processor_sid,
|
||||
source_sid=source_sid,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
order: Union["MediaRecordingInstance.Order", object] = values.unset,
|
||||
status: Union["MediaRecordingInstance.Status", object] = values.unset,
|
||||
processor_sid: Union[str, object] = values.unset,
|
||||
source_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,
|
||||
) -> MediaRecordingPage:
|
||||
"""
|
||||
Retrieve a single page of MediaRecordingInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param order: The sort order of the list by `date_created`. Can be: `asc` (ascending) or `desc` (descending) with `desc` as the default.
|
||||
:param status: Status to filter by, with possible values `processing`, `completed`, `deleted`, or `failed`.
|
||||
:param processor_sid: SID of a MediaProcessor to filter by.
|
||||
:param source_sid: SID of a MediaRecording source to filter 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 MediaRecordingInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Order": order,
|
||||
"Status": status,
|
||||
"ProcessorSid": processor_sid,
|
||||
"SourceSid": source_sid,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return MediaRecordingPage(self._version, response)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
order: Union["MediaRecordingInstance.Order", object] = values.unset,
|
||||
status: Union["MediaRecordingInstance.Status", object] = values.unset,
|
||||
processor_sid: Union[str, object] = values.unset,
|
||||
source_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,
|
||||
) -> MediaRecordingPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of MediaRecordingInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param order: The sort order of the list by `date_created`. Can be: `asc` (ascending) or `desc` (descending) with `desc` as the default.
|
||||
:param status: Status to filter by, with possible values `processing`, `completed`, `deleted`, or `failed`.
|
||||
:param processor_sid: SID of a MediaProcessor to filter by.
|
||||
:param source_sid: SID of a MediaRecording source to filter 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 MediaRecordingInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Order": order,
|
||||
"Status": status,
|
||||
"ProcessorSid": processor_sid,
|
||||
"SourceSid": source_sid,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return MediaRecordingPage(self._version, response)
|
||||
|
||||
def get_page(self, target_url: str) -> MediaRecordingPage:
|
||||
"""
|
||||
Retrieve a specific page of MediaRecordingInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of MediaRecordingInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return MediaRecordingPage(self._version, response)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> MediaRecordingPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of MediaRecordingInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of MediaRecordingInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return MediaRecordingPage(self._version, response)
|
||||
|
||||
def get(self, sid: str) -> MediaRecordingContext:
|
||||
"""
|
||||
Constructs a MediaRecordingContext
|
||||
|
||||
:param sid: The SID of the MediaRecording resource to fetch.
|
||||
"""
|
||||
return MediaRecordingContext(self._version, sid=sid)
|
||||
|
||||
def __call__(self, sid: str) -> MediaRecordingContext:
|
||||
"""
|
||||
Constructs a MediaRecordingContext
|
||||
|
||||
:param sid: The SID of the MediaRecording resource to fetch.
|
||||
"""
|
||||
return MediaRecordingContext(self._version, sid=sid)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Media.V1.MediaRecordingList>"
|
||||
@@ -0,0 +1,636 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Media
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, values
|
||||
from twilio.base.instance_context import InstanceContext
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.page import Page
|
||||
from twilio.rest.media.v1.player_streamer.playback_grant import PlaybackGrantList
|
||||
|
||||
|
||||
class PlayerStreamerInstance(InstanceResource):
|
||||
class EndedReason(object):
|
||||
ENDED_VIA_API = "ended-via-api"
|
||||
MAX_DURATION_EXCEEDED = "max-duration-exceeded"
|
||||
STREAM_DISCONNECTED_BY_SOURCE = "stream-disconnected-by-source"
|
||||
UNEXPECTED_FAILURE = "unexpected-failure"
|
||||
|
||||
class Order(object):
|
||||
ASC = "asc"
|
||||
DESC = "desc"
|
||||
|
||||
class Status(object):
|
||||
CREATED = "created"
|
||||
STARTED = "started"
|
||||
ENDED = "ended"
|
||||
FAILED = "failed"
|
||||
|
||||
class UpdateStatus(object):
|
||||
ENDED = "ended"
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the PlayerStreamer resource.
|
||||
:ivar date_created: The date and time in GMT when the resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:ivar date_updated: The date and time in GMT when the resource was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:ivar video: Specifies whether the PlayerStreamer is configured to stream video. Defaults to `true`.
|
||||
:ivar links: The URLs of related resources.
|
||||
:ivar sid: The unique string generated to identify the PlayerStreamer resource.
|
||||
:ivar status:
|
||||
:ivar url: The absolute URL of the resource.
|
||||
:ivar status_callback: The URL to which Twilio will send asynchronous webhook requests for every PlayerStreamer event. See [Status Callbacks](/docs/live/api/status-callbacks) for more details.
|
||||
:ivar status_callback_method: The HTTP method Twilio should use to call the `status_callback` URL. Can be `POST` or `GET` and the default is `POST`.
|
||||
:ivar ended_reason:
|
||||
:ivar max_duration: The maximum time, in seconds, that the PlayerStreamer is active (`created` or `started`) before automatically ends. The default value is 300 seconds, and the maximum value is 90000 seconds. Once this maximum duration is reached, Twilio will end the PlayerStreamer, regardless of whether media is still streaming.
|
||||
"""
|
||||
|
||||
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.date_created: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.video: Optional[bool] = payload.get("video")
|
||||
self.links: Optional[Dict[str, object]] = payload.get("links")
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.status: Optional["PlayerStreamerInstance.Status"] = payload.get("status")
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
self.status_callback: Optional[str] = payload.get("status_callback")
|
||||
self.status_callback_method: Optional[str] = payload.get(
|
||||
"status_callback_method"
|
||||
)
|
||||
self.ended_reason: Optional["PlayerStreamerInstance.EndedReason"] = payload.get(
|
||||
"ended_reason"
|
||||
)
|
||||
self.max_duration: Optional[int] = deserialize.integer(
|
||||
payload.get("max_duration")
|
||||
)
|
||||
|
||||
self._solution = {
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[PlayerStreamerContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "PlayerStreamerContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: PlayerStreamerContext for this PlayerStreamerInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = PlayerStreamerContext(
|
||||
self._version,
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def fetch(self) -> "PlayerStreamerInstance":
|
||||
"""
|
||||
Fetch the PlayerStreamerInstance
|
||||
|
||||
|
||||
:returns: The fetched PlayerStreamerInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "PlayerStreamerInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the PlayerStreamerInstance
|
||||
|
||||
|
||||
:returns: The fetched PlayerStreamerInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self, status: "PlayerStreamerInstance.UpdateStatus"
|
||||
) -> "PlayerStreamerInstance":
|
||||
"""
|
||||
Update the PlayerStreamerInstance
|
||||
|
||||
:param status:
|
||||
|
||||
:returns: The updated PlayerStreamerInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
status=status,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self, status: "PlayerStreamerInstance.UpdateStatus"
|
||||
) -> "PlayerStreamerInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the PlayerStreamerInstance
|
||||
|
||||
:param status:
|
||||
|
||||
:returns: The updated PlayerStreamerInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
status=status,
|
||||
)
|
||||
|
||||
@property
|
||||
def playback_grant(self) -> PlaybackGrantList:
|
||||
"""
|
||||
Access the playback_grant
|
||||
"""
|
||||
return self._proxy.playback_grant
|
||||
|
||||
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.Media.V1.PlayerStreamerInstance {}>".format(context)
|
||||
|
||||
|
||||
class PlayerStreamerContext(InstanceContext):
|
||||
def __init__(self, version: Version, sid: str):
|
||||
"""
|
||||
Initialize the PlayerStreamerContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param sid: The SID of the PlayerStreamer resource to update.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/PlayerStreamers/{sid}".format(**self._solution)
|
||||
|
||||
self._playback_grant: Optional[PlaybackGrantList] = None
|
||||
|
||||
def fetch(self) -> PlayerStreamerInstance:
|
||||
"""
|
||||
Fetch the PlayerStreamerInstance
|
||||
|
||||
|
||||
:returns: The fetched PlayerStreamerInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return PlayerStreamerInstance(
|
||||
self._version,
|
||||
payload,
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> PlayerStreamerInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the PlayerStreamerInstance
|
||||
|
||||
|
||||
:returns: The fetched PlayerStreamerInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return PlayerStreamerInstance(
|
||||
self._version,
|
||||
payload,
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self, status: "PlayerStreamerInstance.UpdateStatus"
|
||||
) -> PlayerStreamerInstance:
|
||||
"""
|
||||
Update the PlayerStreamerInstance
|
||||
|
||||
:param status:
|
||||
|
||||
:returns: The updated PlayerStreamerInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Status": status,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return PlayerStreamerInstance(self._version, payload, sid=self._solution["sid"])
|
||||
|
||||
async def update_async(
|
||||
self, status: "PlayerStreamerInstance.UpdateStatus"
|
||||
) -> PlayerStreamerInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the PlayerStreamerInstance
|
||||
|
||||
:param status:
|
||||
|
||||
:returns: The updated PlayerStreamerInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Status": status,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return PlayerStreamerInstance(self._version, payload, sid=self._solution["sid"])
|
||||
|
||||
@property
|
||||
def playback_grant(self) -> PlaybackGrantList:
|
||||
"""
|
||||
Access the playback_grant
|
||||
"""
|
||||
if self._playback_grant is None:
|
||||
self._playback_grant = PlaybackGrantList(
|
||||
self._version,
|
||||
self._solution["sid"],
|
||||
)
|
||||
return self._playback_grant
|
||||
|
||||
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.Media.V1.PlayerStreamerContext {}>".format(context)
|
||||
|
||||
|
||||
class PlayerStreamerPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> PlayerStreamerInstance:
|
||||
"""
|
||||
Build an instance of PlayerStreamerInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return PlayerStreamerInstance(self._version, payload)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Media.V1.PlayerStreamerPage>"
|
||||
|
||||
|
||||
class PlayerStreamerList(ListResource):
|
||||
def __init__(self, version: Version):
|
||||
"""
|
||||
Initialize the PlayerStreamerList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
self._uri = "/PlayerStreamers"
|
||||
|
||||
def create(
|
||||
self,
|
||||
video: Union[bool, object] = values.unset,
|
||||
status_callback: Union[str, object] = values.unset,
|
||||
status_callback_method: Union[str, object] = values.unset,
|
||||
max_duration: Union[int, object] = values.unset,
|
||||
) -> PlayerStreamerInstance:
|
||||
"""
|
||||
Create the PlayerStreamerInstance
|
||||
|
||||
:param video: Specifies whether the PlayerStreamer is configured to stream video. Defaults to `true`.
|
||||
:param status_callback: The URL to which Twilio will send asynchronous webhook requests for every PlayerStreamer event. See [Status Callbacks](/docs/live/api/status-callbacks) for more details.
|
||||
:param status_callback_method: The HTTP method Twilio should use to call the `status_callback` URL. Can be `POST` or `GET` and the default is `POST`.
|
||||
:param max_duration: The maximum time, in seconds, that the PlayerStreamer is active (`created` or `started`) before automatically ends. The default value is 300 seconds, and the maximum value is 90000 seconds. Once this maximum duration is reached, Twilio will end the PlayerStreamer, regardless of whether media is still streaming.
|
||||
|
||||
:returns: The created PlayerStreamerInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Video": video,
|
||||
"StatusCallback": status_callback,
|
||||
"StatusCallbackMethod": status_callback_method,
|
||||
"MaxDuration": max_duration,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return PlayerStreamerInstance(self._version, payload)
|
||||
|
||||
async def create_async(
|
||||
self,
|
||||
video: Union[bool, object] = values.unset,
|
||||
status_callback: Union[str, object] = values.unset,
|
||||
status_callback_method: Union[str, object] = values.unset,
|
||||
max_duration: Union[int, object] = values.unset,
|
||||
) -> PlayerStreamerInstance:
|
||||
"""
|
||||
Asynchronously create the PlayerStreamerInstance
|
||||
|
||||
:param video: Specifies whether the PlayerStreamer is configured to stream video. Defaults to `true`.
|
||||
:param status_callback: The URL to which Twilio will send asynchronous webhook requests for every PlayerStreamer event. See [Status Callbacks](/docs/live/api/status-callbacks) for more details.
|
||||
:param status_callback_method: The HTTP method Twilio should use to call the `status_callback` URL. Can be `POST` or `GET` and the default is `POST`.
|
||||
:param max_duration: The maximum time, in seconds, that the PlayerStreamer is active (`created` or `started`) before automatically ends. The default value is 300 seconds, and the maximum value is 90000 seconds. Once this maximum duration is reached, Twilio will end the PlayerStreamer, regardless of whether media is still streaming.
|
||||
|
||||
:returns: The created PlayerStreamerInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Video": video,
|
||||
"StatusCallback": status_callback,
|
||||
"StatusCallbackMethod": status_callback_method,
|
||||
"MaxDuration": max_duration,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return PlayerStreamerInstance(self._version, payload)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
order: Union["PlayerStreamerInstance.Order", object] = values.unset,
|
||||
status: Union["PlayerStreamerInstance.Status", object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[PlayerStreamerInstance]:
|
||||
"""
|
||||
Streams PlayerStreamerInstance 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 "PlayerStreamerInstance.Order" order: The sort order of the list by `date_created`. Can be: `asc` (ascending) or `desc` (descending) with `desc` as the default.
|
||||
:param "PlayerStreamerInstance.Status" status: Status to filter by, with possible values `created`, `started`, `ended`, 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(order=order, status=status, page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
order: Union["PlayerStreamerInstance.Order", object] = values.unset,
|
||||
status: Union["PlayerStreamerInstance.Status", object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[PlayerStreamerInstance]:
|
||||
"""
|
||||
Asynchronously streams PlayerStreamerInstance 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 "PlayerStreamerInstance.Order" order: The sort order of the list by `date_created`. Can be: `asc` (ascending) or `desc` (descending) with `desc` as the default.
|
||||
:param "PlayerStreamerInstance.Status" status: Status to filter by, with possible values `created`, `started`, `ended`, 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(
|
||||
order=order, status=status, page_size=limits["page_size"]
|
||||
)
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
order: Union["PlayerStreamerInstance.Order", object] = values.unset,
|
||||
status: Union["PlayerStreamerInstance.Status", object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[PlayerStreamerInstance]:
|
||||
"""
|
||||
Lists PlayerStreamerInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param "PlayerStreamerInstance.Order" order: The sort order of the list by `date_created`. Can be: `asc` (ascending) or `desc` (descending) with `desc` as the default.
|
||||
:param "PlayerStreamerInstance.Status" status: Status to filter by, with possible values `created`, `started`, `ended`, 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(
|
||||
order=order,
|
||||
status=status,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
order: Union["PlayerStreamerInstance.Order", object] = values.unset,
|
||||
status: Union["PlayerStreamerInstance.Status", object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[PlayerStreamerInstance]:
|
||||
"""
|
||||
Asynchronously lists PlayerStreamerInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param "PlayerStreamerInstance.Order" order: The sort order of the list by `date_created`. Can be: `asc` (ascending) or `desc` (descending) with `desc` as the default.
|
||||
:param "PlayerStreamerInstance.Status" status: Status to filter by, with possible values `created`, `started`, `ended`, 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(
|
||||
order=order,
|
||||
status=status,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
order: Union["PlayerStreamerInstance.Order", object] = values.unset,
|
||||
status: Union["PlayerStreamerInstance.Status", object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> PlayerStreamerPage:
|
||||
"""
|
||||
Retrieve a single page of PlayerStreamerInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param order: The sort order of the list by `date_created`. Can be: `asc` (ascending) or `desc` (descending) with `desc` as the default.
|
||||
:param status: Status to filter by, with possible values `created`, `started`, `ended`, 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 PlayerStreamerInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Order": order,
|
||||
"Status": status,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return PlayerStreamerPage(self._version, response)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
order: Union["PlayerStreamerInstance.Order", object] = values.unset,
|
||||
status: Union["PlayerStreamerInstance.Status", object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> PlayerStreamerPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of PlayerStreamerInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param order: The sort order of the list by `date_created`. Can be: `asc` (ascending) or `desc` (descending) with `desc` as the default.
|
||||
:param status: Status to filter by, with possible values `created`, `started`, `ended`, 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 PlayerStreamerInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Order": order,
|
||||
"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 PlayerStreamerPage(self._version, response)
|
||||
|
||||
def get_page(self, target_url: str) -> PlayerStreamerPage:
|
||||
"""
|
||||
Retrieve a specific page of PlayerStreamerInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of PlayerStreamerInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return PlayerStreamerPage(self._version, response)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> PlayerStreamerPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of PlayerStreamerInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of PlayerStreamerInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return PlayerStreamerPage(self._version, response)
|
||||
|
||||
def get(self, sid: str) -> PlayerStreamerContext:
|
||||
"""
|
||||
Constructs a PlayerStreamerContext
|
||||
|
||||
:param sid: The SID of the PlayerStreamer resource to update.
|
||||
"""
|
||||
return PlayerStreamerContext(self._version, sid=sid)
|
||||
|
||||
def __call__(self, sid: str) -> PlayerStreamerContext:
|
||||
"""
|
||||
Constructs a PlayerStreamerContext
|
||||
|
||||
:param sid: The SID of the PlayerStreamer resource to update.
|
||||
"""
|
||||
return PlayerStreamerContext(self._version, sid=sid)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Media.V1.PlayerStreamerList>"
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
+280
@@ -0,0 +1,280 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Media
|
||||
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, Union
|
||||
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
|
||||
|
||||
|
||||
class PlaybackGrantInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar sid: The unique string generated to identify the PlayerStreamer resource that this PlaybackGrant authorizes views for.
|
||||
:ivar url: The absolute URL of the resource.
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created this resource.
|
||||
:ivar date_created: The date and time in GMT when the resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:ivar grant: The grant that authorizes the player sdk to connect to the livestream
|
||||
"""
|
||||
|
||||
def __init__(self, version: Version, payload: Dict[str, Any], sid: str):
|
||||
super().__init__(version)
|
||||
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.grant: Optional[Dict[str, object]] = payload.get("grant")
|
||||
|
||||
self._solution = {
|
||||
"sid": sid,
|
||||
}
|
||||
self._context: Optional[PlaybackGrantContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "PlaybackGrantContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: PlaybackGrantContext for this PlaybackGrantInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = PlaybackGrantContext(
|
||||
self._version,
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def create(
|
||||
self,
|
||||
ttl: Union[int, object] = values.unset,
|
||||
access_control_allow_origin: Union[str, object] = values.unset,
|
||||
) -> "PlaybackGrantInstance":
|
||||
"""
|
||||
Create the PlaybackGrantInstance
|
||||
|
||||
:param ttl: The time to live of the PlaybackGrant. Default value is 15 seconds. Maximum value is 60 seconds.
|
||||
:param access_control_allow_origin: The full origin URL where the livestream can be streamed. If this is not provided, it can be streamed from any domain.
|
||||
|
||||
:returns: The created PlaybackGrantInstance
|
||||
"""
|
||||
return self._proxy.create(
|
||||
ttl=ttl,
|
||||
access_control_allow_origin=access_control_allow_origin,
|
||||
)
|
||||
|
||||
async def create_async(
|
||||
self,
|
||||
ttl: Union[int, object] = values.unset,
|
||||
access_control_allow_origin: Union[str, object] = values.unset,
|
||||
) -> "PlaybackGrantInstance":
|
||||
"""
|
||||
Asynchronous coroutine to create the PlaybackGrantInstance
|
||||
|
||||
:param ttl: The time to live of the PlaybackGrant. Default value is 15 seconds. Maximum value is 60 seconds.
|
||||
:param access_control_allow_origin: The full origin URL where the livestream can be streamed. If this is not provided, it can be streamed from any domain.
|
||||
|
||||
:returns: The created PlaybackGrantInstance
|
||||
"""
|
||||
return await self._proxy.create_async(
|
||||
ttl=ttl,
|
||||
access_control_allow_origin=access_control_allow_origin,
|
||||
)
|
||||
|
||||
def fetch(self) -> "PlaybackGrantInstance":
|
||||
"""
|
||||
Fetch the PlaybackGrantInstance
|
||||
|
||||
|
||||
:returns: The fetched PlaybackGrantInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "PlaybackGrantInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the PlaybackGrantInstance
|
||||
|
||||
|
||||
:returns: The fetched PlaybackGrantInstance
|
||||
"""
|
||||
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.Media.V1.PlaybackGrantInstance {}>".format(context)
|
||||
|
||||
|
||||
class PlaybackGrantContext(InstanceContext):
|
||||
def __init__(self, version: Version, sid: str):
|
||||
"""
|
||||
Initialize the PlaybackGrantContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param sid: The SID of the PlayerStreamer resource to fetch.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/PlayerStreamers/{sid}/PlaybackGrant".format(**self._solution)
|
||||
|
||||
def create(
|
||||
self,
|
||||
ttl: Union[int, object] = values.unset,
|
||||
access_control_allow_origin: Union[str, object] = values.unset,
|
||||
) -> PlaybackGrantInstance:
|
||||
"""
|
||||
Create the PlaybackGrantInstance
|
||||
|
||||
:param ttl: The time to live of the PlaybackGrant. Default value is 15 seconds. Maximum value is 60 seconds.
|
||||
:param access_control_allow_origin: The full origin URL where the livestream can be streamed. If this is not provided, it can be streamed from any domain.
|
||||
|
||||
:returns: The created PlaybackGrantInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Ttl": ttl,
|
||||
"AccessControlAllowOrigin": access_control_allow_origin,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(method="POST", uri=self._uri, data=data)
|
||||
|
||||
return PlaybackGrantInstance(self._version, payload, sid=self._solution["sid"])
|
||||
|
||||
async def create_async(
|
||||
self,
|
||||
ttl: Union[int, object] = values.unset,
|
||||
access_control_allow_origin: Union[str, object] = values.unset,
|
||||
) -> PlaybackGrantInstance:
|
||||
"""
|
||||
Asynchronous coroutine to create the PlaybackGrantInstance
|
||||
|
||||
:param ttl: The time to live of the PlaybackGrant. Default value is 15 seconds. Maximum value is 60 seconds.
|
||||
:param access_control_allow_origin: The full origin URL where the livestream can be streamed. If this is not provided, it can be streamed from any domain.
|
||||
|
||||
:returns: The created PlaybackGrantInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Ttl": ttl,
|
||||
"AccessControlAllowOrigin": access_control_allow_origin,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST", uri=self._uri, data=data
|
||||
)
|
||||
|
||||
return PlaybackGrantInstance(self._version, payload, sid=self._solution["sid"])
|
||||
|
||||
def fetch(self) -> PlaybackGrantInstance:
|
||||
"""
|
||||
Fetch the PlaybackGrantInstance
|
||||
|
||||
|
||||
:returns: The fetched PlaybackGrantInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return PlaybackGrantInstance(
|
||||
self._version,
|
||||
payload,
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> PlaybackGrantInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the PlaybackGrantInstance
|
||||
|
||||
|
||||
:returns: The fetched PlaybackGrantInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return PlaybackGrantInstance(
|
||||
self._version,
|
||||
payload,
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
|
||||
return "<Twilio.Media.V1.PlaybackGrantContext {}>".format(context)
|
||||
|
||||
|
||||
class PlaybackGrantList(ListResource):
|
||||
def __init__(self, version: Version, sid: str):
|
||||
"""
|
||||
Initialize the PlaybackGrantList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param sid: The unique string generated to identify the PlayerStreamer resource associated with this PlaybackGrant
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"sid": sid,
|
||||
}
|
||||
|
||||
def get(self) -> PlaybackGrantContext:
|
||||
"""
|
||||
Constructs a PlaybackGrantContext
|
||||
|
||||
"""
|
||||
return PlaybackGrantContext(self._version, sid=self._solution["sid"])
|
||||
|
||||
def __call__(self) -> PlaybackGrantContext:
|
||||
"""
|
||||
Constructs a PlaybackGrantContext
|
||||
|
||||
"""
|
||||
return PlaybackGrantContext(self._version, sid=self._solution["sid"])
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Media.V1.PlaybackGrantList>"
|
||||
Reference in New Issue
Block a user