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.video.v1 import V1
class VideoBase(Domain):
def __init__(self, twilio: Client):
"""
Initialize the Video Domain
:returns: Domain for Video
"""
super().__init__(twilio, "https://video.twilio.com")
self._v1: Optional[V1] = None
@property
def v1(self) -> V1:
"""
:returns: Versions v1 of Video
"""
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.Video>"
@@ -0,0 +1,65 @@
from warnings import warn
from twilio.rest.video.VideoBase import VideoBase
from twilio.rest.video.v1.composition import CompositionList
from twilio.rest.video.v1.composition_hook import CompositionHookList
from twilio.rest.video.v1.composition_settings import CompositionSettingsList
from twilio.rest.video.v1.recording import RecordingList
from twilio.rest.video.v1.recording_settings import RecordingSettingsList
from twilio.rest.video.v1.room import RoomList
class Video(VideoBase):
@property
def compositions(self) -> CompositionList:
warn(
"compositions is deprecated. Use v1.compositions instead.",
DeprecationWarning,
stacklevel=2,
)
return self.v1.compositions
@property
def composition_hooks(self) -> CompositionHookList:
warn(
"composition_hooks is deprecated. Use v1.composition_hooks instead.",
DeprecationWarning,
stacklevel=2,
)
return self.v1.composition_hooks
@property
def composition_settings(self) -> CompositionSettingsList:
warn(
"composition_settings is deprecated. Use v1.composition_settings instead.",
DeprecationWarning,
stacklevel=2,
)
return self.v1.composition_settings
@property
def recordings(self) -> RecordingList:
warn(
"recordings is deprecated. Use v1.recordings instead.",
DeprecationWarning,
stacklevel=2,
)
return self.v1.recordings
@property
def recording_settings(self) -> RecordingSettingsList:
warn(
"recording_settings is deprecated. Use v1.recording_settings instead.",
DeprecationWarning,
stacklevel=2,
)
return self.v1.recording_settings
@property
def rooms(self) -> RoomList:
warn(
"rooms is deprecated. Use v1.rooms instead.",
DeprecationWarning,
stacklevel=2,
)
return self.v1.rooms
@@ -0,0 +1,82 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Video
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.video.v1.composition import CompositionList
from twilio.rest.video.v1.composition_hook import CompositionHookList
from twilio.rest.video.v1.composition_settings import CompositionSettingsList
from twilio.rest.video.v1.recording import RecordingList
from twilio.rest.video.v1.recording_settings import RecordingSettingsList
from twilio.rest.video.v1.room import RoomList
class V1(Version):
def __init__(self, domain: Domain):
"""
Initialize the V1 version of Video
:param domain: The Twilio.video domain
"""
super().__init__(domain, "v1")
self._compositions: Optional[CompositionList] = None
self._composition_hooks: Optional[CompositionHookList] = None
self._composition_settings: Optional[CompositionSettingsList] = None
self._recordings: Optional[RecordingList] = None
self._recording_settings: Optional[RecordingSettingsList] = None
self._rooms: Optional[RoomList] = None
@property
def compositions(self) -> CompositionList:
if self._compositions is None:
self._compositions = CompositionList(self)
return self._compositions
@property
def composition_hooks(self) -> CompositionHookList:
if self._composition_hooks is None:
self._composition_hooks = CompositionHookList(self)
return self._composition_hooks
@property
def composition_settings(self) -> CompositionSettingsList:
if self._composition_settings is None:
self._composition_settings = CompositionSettingsList(self)
return self._composition_settings
@property
def recordings(self) -> RecordingList:
if self._recordings is None:
self._recordings = RecordingList(self)
return self._recordings
@property
def recording_settings(self) -> RecordingSettingsList:
if self._recording_settings is None:
self._recording_settings = RecordingSettingsList(self)
return self._recording_settings
@property
def rooms(self) -> RoomList:
if self._rooms is None:
self._rooms = RoomList(self)
return self._rooms
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Video.V1>"
@@ -0,0 +1,668 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Video
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 CompositionInstance(InstanceResource):
class Format(object):
MP4 = "mp4"
WEBM = "webm"
class Status(object):
ENQUEUED = "enqueued"
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 Composition resource.
:ivar status:
: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_completed: The date and time in GMT when the composition's media processing task finished, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
:ivar date_deleted: The date and time in GMT when the composition generated media was deleted, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
:ivar sid: The unique string that we created to identify the Composition resource.
:ivar room_sid: The SID of the Group Room that generated the audio and video tracks used in the composition. All media sources included in a composition must belong to the same Group Room.
:ivar audio_sources: The array of track names to include in the composition. The composition includes all audio sources specified in `audio_sources` except those specified in `audio_sources_excluded`. The track names in this property can include an asterisk as a wild card character, which matches zero or more characters in a track name. For example, `student*` includes tracks named `student` as well as `studentTeam`.
:ivar audio_sources_excluded: The array of track names to exclude from the composition. The composition includes all audio sources specified in `audio_sources` except for those specified in `audio_sources_excluded`. The track names in this property can include an asterisk as a wild card character, which matches zero or more characters in a track name. For example, `student*` excludes `student` as well as `studentTeam`. This parameter can also be empty.
:ivar video_layout: An object that describes the video layout of the composition in terms of regions. See [Specifying Video Layouts](https://www.twilio.com/docs/video/api/compositions-resource#specifying-video-layouts) for more info.
:ivar resolution: The dimensions of the video image in pixels expressed as columns (width) and rows (height). The string's format is `{width}x{height}`, such as `640x480`.
:ivar trim: Whether to remove intervals with no media, as specified in the POST request that created the composition. Compositions with `trim` enabled are shorter when the Room is created and no Participant joins for a while as well as if all the Participants leave the room and join later, because those gaps will be removed. See [Specifying Video Layouts](https://www.twilio.com/docs/video/api/compositions-resource#specifying-video-layouts) for more info.
:ivar format:
:ivar bitrate: The average bit rate of the composition's media.
:ivar size: The size of the composed media file in bytes.
:ivar duration: The duration of the composition's media file in seconds.
:ivar media_external_location: The URL of the media file associated with the composition when stored externally. See [External S3 Compositions](/docs/video/api/external-s3-compositions) for more details.
:ivar status_callback: The URL called using the `status_callback_method` to send status information on every composition event.
:ivar status_callback_method: The HTTP method used to call `status_callback`. Can be: `POST` or `GET`, defaults to `POST`.
:ivar url: The absolute URL of the resource.
:ivar links: The URL of the media file associated with the composition.
"""
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.status: Optional["CompositionInstance.Status"] = payload.get("status")
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_created")
)
self.date_completed: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_completed")
)
self.date_deleted: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_deleted")
)
self.sid: Optional[str] = payload.get("sid")
self.room_sid: Optional[str] = payload.get("room_sid")
self.audio_sources: Optional[List[str]] = payload.get("audio_sources")
self.audio_sources_excluded: Optional[List[str]] = payload.get(
"audio_sources_excluded"
)
self.video_layout: Optional[Dict[str, object]] = payload.get("video_layout")
self.resolution: Optional[str] = payload.get("resolution")
self.trim: Optional[bool] = payload.get("trim")
self.format: Optional["CompositionInstance.Format"] = payload.get("format")
self.bitrate: Optional[int] = deserialize.integer(payload.get("bitrate"))
self.size: Optional[int] = payload.get("size")
self.duration: Optional[int] = deserialize.integer(payload.get("duration"))
self.media_external_location: Optional[str] = payload.get(
"media_external_location"
)
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.links: Optional[Dict[str, object]] = payload.get("links")
self._solution = {
"sid": sid or self.sid,
}
self._context: Optional[CompositionContext] = None
@property
def _proxy(self) -> "CompositionContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: CompositionContext for this CompositionInstance
"""
if self._context is None:
self._context = CompositionContext(
self._version,
sid=self._solution["sid"],
)
return self._context
def delete(self) -> bool:
"""
Deletes the CompositionInstance
:returns: True if delete succeeds, False otherwise
"""
return self._proxy.delete()
async def delete_async(self) -> bool:
"""
Asynchronous coroutine that deletes the CompositionInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._proxy.delete_async()
def fetch(self) -> "CompositionInstance":
"""
Fetch the CompositionInstance
:returns: The fetched CompositionInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "CompositionInstance":
"""
Asynchronous coroutine to fetch the CompositionInstance
:returns: The fetched CompositionInstance
"""
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.Video.V1.CompositionInstance {}>".format(context)
class CompositionContext(InstanceContext):
def __init__(self, version: Version, sid: str):
"""
Initialize the CompositionContext
:param version: Version that contains the resource
:param sid: The SID of the Composition resource to fetch.
"""
super().__init__(version)
# Path Solution
self._solution = {
"sid": sid,
}
self._uri = "/Compositions/{sid}".format(**self._solution)
def delete(self) -> bool:
"""
Deletes the CompositionInstance
: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 CompositionInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._version.delete_async(
method="DELETE",
uri=self._uri,
)
def fetch(self) -> CompositionInstance:
"""
Fetch the CompositionInstance
:returns: The fetched CompositionInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return CompositionInstance(
self._version,
payload,
sid=self._solution["sid"],
)
async def fetch_async(self) -> CompositionInstance:
"""
Asynchronous coroutine to fetch the CompositionInstance
:returns: The fetched CompositionInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return CompositionInstance(
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.Video.V1.CompositionContext {}>".format(context)
class CompositionPage(Page):
def get_instance(self, payload: Dict[str, Any]) -> CompositionInstance:
"""
Build an instance of CompositionInstance
:param payload: Payload response from the API
"""
return CompositionInstance(self._version, payload)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Video.V1.CompositionPage>"
class CompositionList(ListResource):
def __init__(self, version: Version):
"""
Initialize the CompositionList
:param version: Version that contains the resource
"""
super().__init__(version)
self._uri = "/Compositions"
def create(
self,
room_sid: str,
video_layout: Union[object, object] = values.unset,
audio_sources: Union[List[str], object] = values.unset,
audio_sources_excluded: Union[List[str], object] = values.unset,
resolution: Union[str, object] = values.unset,
format: Union["CompositionInstance.Format", object] = values.unset,
status_callback: Union[str, object] = values.unset,
status_callback_method: Union[str, object] = values.unset,
trim: Union[bool, object] = values.unset,
) -> CompositionInstance:
"""
Create the CompositionInstance
:param room_sid: The SID of the Group Room with the media tracks to be used as composition sources.
:param video_layout: An object that describes the video layout of the composition in terms of regions. See [Specifying Video Layouts](https://www.twilio.com/docs/video/api/compositions-resource#specifying-video-layouts) for more info. Please, be aware that either video_layout or audio_sources have to be provided to get a valid creation request
:param audio_sources: An array of track names from the same group room to merge into the new composition. Can include zero or more track names. The new composition includes all audio sources specified in `audio_sources` except for those specified in `audio_sources_excluded`. The track names in this parameter can include an asterisk as a wild card character, which will match zero or more characters in a track name. For example, `student*` includes `student` as well as `studentTeam`. Please, be aware that either video_layout or audio_sources have to be provided to get a valid creation request
:param audio_sources_excluded: An array of track names to exclude. The new composition includes all audio sources specified in `audio_sources` except for those specified in `audio_sources_excluded`. The track names in this parameter can include an asterisk as a wild card character, which will match zero or more characters in a track name. For example, `student*` excludes `student` as well as `studentTeam`. This parameter can also be empty.
:param resolution: A string that describes the columns (width) and rows (height) of the generated composed video in pixels. Defaults to `640x480`. The string's format is `{width}x{height}` where: * 16 <= `{width}` <= 1280 * 16 <= `{height}` <= 1280 * `{width}` * `{height}` <= 921,600 Typical values are: * HD = `1280x720` * PAL = `1024x576` * VGA = `640x480` * CIF = `320x240` Note that the `resolution` imposes an aspect ratio to the resulting composition. When the original video tracks are constrained by the aspect ratio, they are scaled to fit. See [Specifying Video Layouts](https://www.twilio.com/docs/video/api/compositions-resource#specifying-video-layouts) for more info.
:param format:
:param status_callback: The URL we should call using the `status_callback_method` to send status information to your application on every composition event. If not provided, status callback events will not be dispatched.
:param status_callback_method: The HTTP method we should use to call `status_callback`. Can be: `POST` or `GET` and the default is `POST`.
:param trim: Whether to clip the intervals where there is no active media in the composition. The default is `true`. Compositions with `trim` enabled are shorter when the Room is created and no Participant joins for a while as well as if all the Participants leave the room and join later, because those gaps will be removed. See [Specifying Video Layouts](https://www.twilio.com/docs/video/api/compositions-resource#specifying-video-layouts) for more info.
:returns: The created CompositionInstance
"""
data = values.of(
{
"RoomSid": room_sid,
"VideoLayout": serialize.object(video_layout),
"AudioSources": serialize.map(audio_sources, lambda e: e),
"AudioSourcesExcluded": serialize.map(
audio_sources_excluded, lambda e: e
),
"Resolution": resolution,
"Format": format,
"StatusCallback": status_callback,
"StatusCallbackMethod": status_callback_method,
"Trim": trim,
}
)
payload = self._version.create(
method="POST",
uri=self._uri,
data=data,
)
return CompositionInstance(self._version, payload)
async def create_async(
self,
room_sid: str,
video_layout: Union[object, object] = values.unset,
audio_sources: Union[List[str], object] = values.unset,
audio_sources_excluded: Union[List[str], object] = values.unset,
resolution: Union[str, object] = values.unset,
format: Union["CompositionInstance.Format", object] = values.unset,
status_callback: Union[str, object] = values.unset,
status_callback_method: Union[str, object] = values.unset,
trim: Union[bool, object] = values.unset,
) -> CompositionInstance:
"""
Asynchronously create the CompositionInstance
:param room_sid: The SID of the Group Room with the media tracks to be used as composition sources.
:param video_layout: An object that describes the video layout of the composition in terms of regions. See [Specifying Video Layouts](https://www.twilio.com/docs/video/api/compositions-resource#specifying-video-layouts) for more info. Please, be aware that either video_layout or audio_sources have to be provided to get a valid creation request
:param audio_sources: An array of track names from the same group room to merge into the new composition. Can include zero or more track names. The new composition includes all audio sources specified in `audio_sources` except for those specified in `audio_sources_excluded`. The track names in this parameter can include an asterisk as a wild card character, which will match zero or more characters in a track name. For example, `student*` includes `student` as well as `studentTeam`. Please, be aware that either video_layout or audio_sources have to be provided to get a valid creation request
:param audio_sources_excluded: An array of track names to exclude. The new composition includes all audio sources specified in `audio_sources` except for those specified in `audio_sources_excluded`. The track names in this parameter can include an asterisk as a wild card character, which will match zero or more characters in a track name. For example, `student*` excludes `student` as well as `studentTeam`. This parameter can also be empty.
:param resolution: A string that describes the columns (width) and rows (height) of the generated composed video in pixels. Defaults to `640x480`. The string's format is `{width}x{height}` where: * 16 <= `{width}` <= 1280 * 16 <= `{height}` <= 1280 * `{width}` * `{height}` <= 921,600 Typical values are: * HD = `1280x720` * PAL = `1024x576` * VGA = `640x480` * CIF = `320x240` Note that the `resolution` imposes an aspect ratio to the resulting composition. When the original video tracks are constrained by the aspect ratio, they are scaled to fit. See [Specifying Video Layouts](https://www.twilio.com/docs/video/api/compositions-resource#specifying-video-layouts) for more info.
:param format:
:param status_callback: The URL we should call using the `status_callback_method` to send status information to your application on every composition event. If not provided, status callback events will not be dispatched.
:param status_callback_method: The HTTP method we should use to call `status_callback`. Can be: `POST` or `GET` and the default is `POST`.
:param trim: Whether to clip the intervals where there is no active media in the composition. The default is `true`. Compositions with `trim` enabled are shorter when the Room is created and no Participant joins for a while as well as if all the Participants leave the room and join later, because those gaps will be removed. See [Specifying Video Layouts](https://www.twilio.com/docs/video/api/compositions-resource#specifying-video-layouts) for more info.
:returns: The created CompositionInstance
"""
data = values.of(
{
"RoomSid": room_sid,
"VideoLayout": serialize.object(video_layout),
"AudioSources": serialize.map(audio_sources, lambda e: e),
"AudioSourcesExcluded": serialize.map(
audio_sources_excluded, lambda e: e
),
"Resolution": resolution,
"Format": format,
"StatusCallback": status_callback,
"StatusCallbackMethod": status_callback_method,
"Trim": trim,
}
)
payload = await self._version.create_async(
method="POST",
uri=self._uri,
data=data,
)
return CompositionInstance(self._version, payload)
def stream(
self,
status: Union["CompositionInstance.Status", object] = values.unset,
date_created_after: Union[datetime, object] = values.unset,
date_created_before: Union[datetime, object] = values.unset,
room_sid: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[CompositionInstance]:
"""
Streams CompositionInstance 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 &quot;CompositionInstance.Status&quot; status: Read only Composition resources with this status. Can be: `enqueued`, `processing`, `completed`, `deleted`, or `failed`.
:param datetime date_created_after: Read only Composition resources created on or after this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time with time zone.
:param datetime date_created_before: Read only Composition resources created before this ISO 8601 date-time with time zone.
:param str room_sid: Read only Composition resources with this Room SID.
: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(
status=status,
date_created_after=date_created_after,
date_created_before=date_created_before,
room_sid=room_sid,
page_size=limits["page_size"],
)
return self._version.stream(page, limits["limit"])
async def stream_async(
self,
status: Union["CompositionInstance.Status", object] = values.unset,
date_created_after: Union[datetime, object] = values.unset,
date_created_before: Union[datetime, object] = values.unset,
room_sid: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> AsyncIterator[CompositionInstance]:
"""
Asynchronously streams CompositionInstance 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 &quot;CompositionInstance.Status&quot; status: Read only Composition resources with this status. Can be: `enqueued`, `processing`, `completed`, `deleted`, or `failed`.
:param datetime date_created_after: Read only Composition resources created on or after this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time with time zone.
:param datetime date_created_before: Read only Composition resources created before this ISO 8601 date-time with time zone.
:param str room_sid: Read only Composition resources with this Room SID.
: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(
status=status,
date_created_after=date_created_after,
date_created_before=date_created_before,
room_sid=room_sid,
page_size=limits["page_size"],
)
return self._version.stream_async(page, limits["limit"])
def list(
self,
status: Union["CompositionInstance.Status", object] = values.unset,
date_created_after: Union[datetime, object] = values.unset,
date_created_before: Union[datetime, object] = values.unset,
room_sid: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[CompositionInstance]:
"""
Lists CompositionInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param &quot;CompositionInstance.Status&quot; status: Read only Composition resources with this status. Can be: `enqueued`, `processing`, `completed`, `deleted`, or `failed`.
:param datetime date_created_after: Read only Composition resources created on or after this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time with time zone.
:param datetime date_created_before: Read only Composition resources created before this ISO 8601 date-time with time zone.
:param str room_sid: Read only Composition resources with this Room SID.
: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(
status=status,
date_created_after=date_created_after,
date_created_before=date_created_before,
room_sid=room_sid,
limit=limit,
page_size=page_size,
)
)
async def list_async(
self,
status: Union["CompositionInstance.Status", object] = values.unset,
date_created_after: Union[datetime, object] = values.unset,
date_created_before: Union[datetime, object] = values.unset,
room_sid: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[CompositionInstance]:
"""
Asynchronously lists CompositionInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param &quot;CompositionInstance.Status&quot; status: Read only Composition resources with this status. Can be: `enqueued`, `processing`, `completed`, `deleted`, or `failed`.
:param datetime date_created_after: Read only Composition resources created on or after this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time with time zone.
:param datetime date_created_before: Read only Composition resources created before this ISO 8601 date-time with time zone.
:param str room_sid: Read only Composition resources with this Room SID.
: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(
status=status,
date_created_after=date_created_after,
date_created_before=date_created_before,
room_sid=room_sid,
limit=limit,
page_size=page_size,
)
]
def page(
self,
status: Union["CompositionInstance.Status", object] = values.unset,
date_created_after: Union[datetime, object] = values.unset,
date_created_before: Union[datetime, object] = values.unset,
room_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,
) -> CompositionPage:
"""
Retrieve a single page of CompositionInstance records from the API.
Request is executed immediately
:param status: Read only Composition resources with this status. Can be: `enqueued`, `processing`, `completed`, `deleted`, or `failed`.
:param date_created_after: Read only Composition resources created on or after this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time with time zone.
:param date_created_before: Read only Composition resources created before this ISO 8601 date-time with time zone.
:param room_sid: Read only Composition resources with this Room SID.
: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 CompositionInstance
"""
data = values.of(
{
"Status": status,
"DateCreatedAfter": serialize.iso8601_datetime(date_created_after),
"DateCreatedBefore": serialize.iso8601_datetime(date_created_before),
"RoomSid": room_sid,
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return CompositionPage(self._version, response)
async def page_async(
self,
status: Union["CompositionInstance.Status", object] = values.unset,
date_created_after: Union[datetime, object] = values.unset,
date_created_before: Union[datetime, object] = values.unset,
room_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,
) -> CompositionPage:
"""
Asynchronously retrieve a single page of CompositionInstance records from the API.
Request is executed immediately
:param status: Read only Composition resources with this status. Can be: `enqueued`, `processing`, `completed`, `deleted`, or `failed`.
:param date_created_after: Read only Composition resources created on or after this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time with time zone.
:param date_created_before: Read only Composition resources created before this ISO 8601 date-time with time zone.
:param room_sid: Read only Composition resources with this Room SID.
: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 CompositionInstance
"""
data = values.of(
{
"Status": status,
"DateCreatedAfter": serialize.iso8601_datetime(date_created_after),
"DateCreatedBefore": serialize.iso8601_datetime(date_created_before),
"RoomSid": room_sid,
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = await self._version.page_async(
method="GET", uri=self._uri, params=data
)
return CompositionPage(self._version, response)
def get_page(self, target_url: str) -> CompositionPage:
"""
Retrieve a specific page of CompositionInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of CompositionInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return CompositionPage(self._version, response)
async def get_page_async(self, target_url: str) -> CompositionPage:
"""
Asynchronously retrieve a specific page of CompositionInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of CompositionInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return CompositionPage(self._version, response)
def get(self, sid: str) -> CompositionContext:
"""
Constructs a CompositionContext
:param sid: The SID of the Composition resource to fetch.
"""
return CompositionContext(self._version, sid=sid)
def __call__(self, sid: str) -> CompositionContext:
"""
Constructs a CompositionContext
:param sid: The SID of the Composition resource to fetch.
"""
return CompositionContext(self._version, sid=sid)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Video.V1.CompositionList>"
@@ -0,0 +1,847 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Video
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 CompositionHookInstance(InstanceResource):
class Format(object):
MP4 = "mp4"
WEBM = "webm"
"""
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the CompositionHook resource.
:ivar friendly_name: The string that you assigned to describe the resource. Can be up to 100 characters long and must be unique within the account.
:ivar enabled: Whether the CompositionHook is active. When `true`, the CompositionHook is triggered for every completed Group Room on the account. When `false`, the CompositionHook is never triggered.
: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 sid: The unique string that we created to identify the CompositionHook resource.
:ivar audio_sources: The array of track names to include in the compositions created by the composition hook. A composition triggered by the composition hook includes all audio sources specified in `audio_sources` except those specified in `audio_sources_excluded`. The track names in this property can include an asterisk as a wild card character, which matches zero or more characters in a track name. For example, `student*` includes tracks named `student` as well as `studentTeam`. Please, be aware that either video_layout or audio_sources have to be provided to get a valid creation request
:ivar audio_sources_excluded: The array of track names to exclude from the compositions created by the composition hook. A composition triggered by the composition hook includes all audio sources specified in `audio_sources` except for those specified in `audio_sources_excluded`. The track names in this property can include an asterisk as a wild card character, which matches zero or more characters in a track name. For example, `student*` excludes `student` as well as `studentTeam`. This parameter can also be empty.
:ivar video_layout: A JSON object that describes the video layout of the composition in terms of regions as specified in the HTTP POST request that created the CompositionHook resource. See [POST Parameters](https://www.twilio.com/docs/video/api/compositions-resource#http-post-parameters) for more information. Please, be aware that either video_layout or audio_sources have to be provided to get a valid creation request
:ivar resolution: The dimensions of the video image in pixels expressed as columns (width) and rows (height). The string's format is `{width}x{height}`, such as `640x480`.
:ivar trim: Whether intervals with no media are clipped, as specified in the POST request that created the CompositionHook resource. Compositions with `trim` enabled are shorter when the Room is created and no Participant joins for a while as well as if all the Participants leave the room and join later, because those gaps will be removed. See [Specifying Video Layouts](https://www.twilio.com/docs/video/api/compositions-resource#specifying-video-layouts) for more info.
:ivar format:
:ivar status_callback: The URL we call using the `status_callback_method` to send status information to your application.
:ivar status_callback_method: The HTTP method we should use to call `status_callback`. Can be `POST` or `GET` and defaults to `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.friendly_name: Optional[str] = payload.get("friendly_name")
self.enabled: Optional[bool] = payload.get("enabled")
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.sid: Optional[str] = payload.get("sid")
self.audio_sources: Optional[List[str]] = payload.get("audio_sources")
self.audio_sources_excluded: Optional[List[str]] = payload.get(
"audio_sources_excluded"
)
self.video_layout: Optional[Dict[str, object]] = payload.get("video_layout")
self.resolution: Optional[str] = payload.get("resolution")
self.trim: Optional[bool] = payload.get("trim")
self.format: Optional["CompositionHookInstance.Format"] = payload.get("format")
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[CompositionHookContext] = None
@property
def _proxy(self) -> "CompositionHookContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: CompositionHookContext for this CompositionHookInstance
"""
if self._context is None:
self._context = CompositionHookContext(
self._version,
sid=self._solution["sid"],
)
return self._context
def delete(self) -> bool:
"""
Deletes the CompositionHookInstance
:returns: True if delete succeeds, False otherwise
"""
return self._proxy.delete()
async def delete_async(self) -> bool:
"""
Asynchronous coroutine that deletes the CompositionHookInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._proxy.delete_async()
def fetch(self) -> "CompositionHookInstance":
"""
Fetch the CompositionHookInstance
:returns: The fetched CompositionHookInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "CompositionHookInstance":
"""
Asynchronous coroutine to fetch the CompositionHookInstance
:returns: The fetched CompositionHookInstance
"""
return await self._proxy.fetch_async()
def update(
self,
friendly_name: str,
enabled: Union[bool, object] = values.unset,
video_layout: Union[object, object] = values.unset,
audio_sources: Union[List[str], object] = values.unset,
audio_sources_excluded: Union[List[str], object] = values.unset,
trim: Union[bool, object] = values.unset,
format: Union["CompositionHookInstance.Format", object] = values.unset,
resolution: Union[str, object] = values.unset,
status_callback: Union[str, object] = values.unset,
status_callback_method: Union[str, object] = values.unset,
) -> "CompositionHookInstance":
"""
Update the CompositionHookInstance
:param friendly_name: A descriptive string that you create to describe the resource. It can be up to 100 characters long and it must be unique within the account.
:param enabled: Whether the composition hook is active. When `true`, the composition hook will be triggered for every completed Group Room in the account. When `false`, the composition hook never triggers.
:param video_layout: A JSON object that describes the video layout of the composition hook in terms of regions. See [Specifying Video Layouts](https://www.twilio.com/docs/video/api/compositions-resource#specifying-video-layouts) for more info.
:param audio_sources: An array of track names from the same group room to merge into the compositions created by the composition hook. Can include zero or more track names. A composition triggered by the composition hook includes all audio sources specified in `audio_sources` except those specified in `audio_sources_excluded`. The track names in this parameter can include an asterisk as a wild card character, which matches zero or more characters in a track name. For example, `student*` includes tracks named `student` as well as `studentTeam`.
:param audio_sources_excluded: An array of track names to exclude. A composition triggered by the composition hook includes all audio sources specified in `audio_sources` except for those specified in `audio_sources_excluded`. The track names in this parameter can include an asterisk as a wild card character, which matches zero or more characters in a track name. For example, `student*` excludes `student` as well as `studentTeam`. This parameter can also be empty.
:param trim: Whether to clip the intervals where there is no active media in the compositions triggered by the composition hook. The default is `true`. Compositions with `trim` enabled are shorter when the Room is created and no Participant joins for a while as well as if all the Participants leave the room and join later, because those gaps will be removed. See [Specifying Video Layouts](https://www.twilio.com/docs/video/api/compositions-resource#specifying-video-layouts) for more info.
:param format:
:param resolution: A string that describes the columns (width) and rows (height) of the generated composed video in pixels. Defaults to `640x480`. The string's format is `{width}x{height}` where: * 16 <= `{width}` <= 1280 * 16 <= `{height}` <= 1280 * `{width}` * `{height}` <= 921,600 Typical values are: * HD = `1280x720` * PAL = `1024x576` * VGA = `640x480` * CIF = `320x240` Note that the `resolution` imposes an aspect ratio to the resulting composition. When the original video tracks are constrained by the aspect ratio, they are scaled to fit. See [Specifying Video Layouts](https://www.twilio.com/docs/video/api/compositions-resource#specifying-video-layouts) for more info.
:param status_callback: The URL we should call using the `status_callback_method` to send status information to your application on every composition event. If not provided, status callback events will not be dispatched.
:param status_callback_method: The HTTP method we should use to call `status_callback`. Can be: `POST` or `GET` and the default is `POST`.
:returns: The updated CompositionHookInstance
"""
return self._proxy.update(
friendly_name=friendly_name,
enabled=enabled,
video_layout=video_layout,
audio_sources=audio_sources,
audio_sources_excluded=audio_sources_excluded,
trim=trim,
format=format,
resolution=resolution,
status_callback=status_callback,
status_callback_method=status_callback_method,
)
async def update_async(
self,
friendly_name: str,
enabled: Union[bool, object] = values.unset,
video_layout: Union[object, object] = values.unset,
audio_sources: Union[List[str], object] = values.unset,
audio_sources_excluded: Union[List[str], object] = values.unset,
trim: Union[bool, object] = values.unset,
format: Union["CompositionHookInstance.Format", object] = values.unset,
resolution: Union[str, object] = values.unset,
status_callback: Union[str, object] = values.unset,
status_callback_method: Union[str, object] = values.unset,
) -> "CompositionHookInstance":
"""
Asynchronous coroutine to update the CompositionHookInstance
:param friendly_name: A descriptive string that you create to describe the resource. It can be up to 100 characters long and it must be unique within the account.
:param enabled: Whether the composition hook is active. When `true`, the composition hook will be triggered for every completed Group Room in the account. When `false`, the composition hook never triggers.
:param video_layout: A JSON object that describes the video layout of the composition hook in terms of regions. See [Specifying Video Layouts](https://www.twilio.com/docs/video/api/compositions-resource#specifying-video-layouts) for more info.
:param audio_sources: An array of track names from the same group room to merge into the compositions created by the composition hook. Can include zero or more track names. A composition triggered by the composition hook includes all audio sources specified in `audio_sources` except those specified in `audio_sources_excluded`. The track names in this parameter can include an asterisk as a wild card character, which matches zero or more characters in a track name. For example, `student*` includes tracks named `student` as well as `studentTeam`.
:param audio_sources_excluded: An array of track names to exclude. A composition triggered by the composition hook includes all audio sources specified in `audio_sources` except for those specified in `audio_sources_excluded`. The track names in this parameter can include an asterisk as a wild card character, which matches zero or more characters in a track name. For example, `student*` excludes `student` as well as `studentTeam`. This parameter can also be empty.
:param trim: Whether to clip the intervals where there is no active media in the compositions triggered by the composition hook. The default is `true`. Compositions with `trim` enabled are shorter when the Room is created and no Participant joins for a while as well as if all the Participants leave the room and join later, because those gaps will be removed. See [Specifying Video Layouts](https://www.twilio.com/docs/video/api/compositions-resource#specifying-video-layouts) for more info.
:param format:
:param resolution: A string that describes the columns (width) and rows (height) of the generated composed video in pixels. Defaults to `640x480`. The string's format is `{width}x{height}` where: * 16 <= `{width}` <= 1280 * 16 <= `{height}` <= 1280 * `{width}` * `{height}` <= 921,600 Typical values are: * HD = `1280x720` * PAL = `1024x576` * VGA = `640x480` * CIF = `320x240` Note that the `resolution` imposes an aspect ratio to the resulting composition. When the original video tracks are constrained by the aspect ratio, they are scaled to fit. See [Specifying Video Layouts](https://www.twilio.com/docs/video/api/compositions-resource#specifying-video-layouts) for more info.
:param status_callback: The URL we should call using the `status_callback_method` to send status information to your application on every composition event. If not provided, status callback events will not be dispatched.
:param status_callback_method: The HTTP method we should use to call `status_callback`. Can be: `POST` or `GET` and the default is `POST`.
:returns: The updated CompositionHookInstance
"""
return await self._proxy.update_async(
friendly_name=friendly_name,
enabled=enabled,
video_layout=video_layout,
audio_sources=audio_sources,
audio_sources_excluded=audio_sources_excluded,
trim=trim,
format=format,
resolution=resolution,
status_callback=status_callback,
status_callback_method=status_callback_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.Video.V1.CompositionHookInstance {}>".format(context)
class CompositionHookContext(InstanceContext):
def __init__(self, version: Version, sid: str):
"""
Initialize the CompositionHookContext
:param version: Version that contains the resource
:param sid: The SID of the CompositionHook resource to update.
"""
super().__init__(version)
# Path Solution
self._solution = {
"sid": sid,
}
self._uri = "/CompositionHooks/{sid}".format(**self._solution)
def delete(self) -> bool:
"""
Deletes the CompositionHookInstance
: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 CompositionHookInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._version.delete_async(
method="DELETE",
uri=self._uri,
)
def fetch(self) -> CompositionHookInstance:
"""
Fetch the CompositionHookInstance
:returns: The fetched CompositionHookInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return CompositionHookInstance(
self._version,
payload,
sid=self._solution["sid"],
)
async def fetch_async(self) -> CompositionHookInstance:
"""
Asynchronous coroutine to fetch the CompositionHookInstance
:returns: The fetched CompositionHookInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return CompositionHookInstance(
self._version,
payload,
sid=self._solution["sid"],
)
def update(
self,
friendly_name: str,
enabled: Union[bool, object] = values.unset,
video_layout: Union[object, object] = values.unset,
audio_sources: Union[List[str], object] = values.unset,
audio_sources_excluded: Union[List[str], object] = values.unset,
trim: Union[bool, object] = values.unset,
format: Union["CompositionHookInstance.Format", object] = values.unset,
resolution: Union[str, object] = values.unset,
status_callback: Union[str, object] = values.unset,
status_callback_method: Union[str, object] = values.unset,
) -> CompositionHookInstance:
"""
Update the CompositionHookInstance
:param friendly_name: A descriptive string that you create to describe the resource. It can be up to 100 characters long and it must be unique within the account.
:param enabled: Whether the composition hook is active. When `true`, the composition hook will be triggered for every completed Group Room in the account. When `false`, the composition hook never triggers.
:param video_layout: A JSON object that describes the video layout of the composition hook in terms of regions. See [Specifying Video Layouts](https://www.twilio.com/docs/video/api/compositions-resource#specifying-video-layouts) for more info.
:param audio_sources: An array of track names from the same group room to merge into the compositions created by the composition hook. Can include zero or more track names. A composition triggered by the composition hook includes all audio sources specified in `audio_sources` except those specified in `audio_sources_excluded`. The track names in this parameter can include an asterisk as a wild card character, which matches zero or more characters in a track name. For example, `student*` includes tracks named `student` as well as `studentTeam`.
:param audio_sources_excluded: An array of track names to exclude. A composition triggered by the composition hook includes all audio sources specified in `audio_sources` except for those specified in `audio_sources_excluded`. The track names in this parameter can include an asterisk as a wild card character, which matches zero or more characters in a track name. For example, `student*` excludes `student` as well as `studentTeam`. This parameter can also be empty.
:param trim: Whether to clip the intervals where there is no active media in the compositions triggered by the composition hook. The default is `true`. Compositions with `trim` enabled are shorter when the Room is created and no Participant joins for a while as well as if all the Participants leave the room and join later, because those gaps will be removed. See [Specifying Video Layouts](https://www.twilio.com/docs/video/api/compositions-resource#specifying-video-layouts) for more info.
:param format:
:param resolution: A string that describes the columns (width) and rows (height) of the generated composed video in pixels. Defaults to `640x480`. The string's format is `{width}x{height}` where: * 16 <= `{width}` <= 1280 * 16 <= `{height}` <= 1280 * `{width}` * `{height}` <= 921,600 Typical values are: * HD = `1280x720` * PAL = `1024x576` * VGA = `640x480` * CIF = `320x240` Note that the `resolution` imposes an aspect ratio to the resulting composition. When the original video tracks are constrained by the aspect ratio, they are scaled to fit. See [Specifying Video Layouts](https://www.twilio.com/docs/video/api/compositions-resource#specifying-video-layouts) for more info.
:param status_callback: The URL we should call using the `status_callback_method` to send status information to your application on every composition event. If not provided, status callback events will not be dispatched.
:param status_callback_method: The HTTP method we should use to call `status_callback`. Can be: `POST` or `GET` and the default is `POST`.
:returns: The updated CompositionHookInstance
"""
data = values.of(
{
"FriendlyName": friendly_name,
"Enabled": enabled,
"VideoLayout": serialize.object(video_layout),
"AudioSources": serialize.map(audio_sources, lambda e: e),
"AudioSourcesExcluded": serialize.map(
audio_sources_excluded, lambda e: e
),
"Trim": trim,
"Format": format,
"Resolution": resolution,
"StatusCallback": status_callback,
"StatusCallbackMethod": status_callback_method,
}
)
payload = self._version.update(
method="POST",
uri=self._uri,
data=data,
)
return CompositionHookInstance(
self._version, payload, sid=self._solution["sid"]
)
async def update_async(
self,
friendly_name: str,
enabled: Union[bool, object] = values.unset,
video_layout: Union[object, object] = values.unset,
audio_sources: Union[List[str], object] = values.unset,
audio_sources_excluded: Union[List[str], object] = values.unset,
trim: Union[bool, object] = values.unset,
format: Union["CompositionHookInstance.Format", object] = values.unset,
resolution: Union[str, object] = values.unset,
status_callback: Union[str, object] = values.unset,
status_callback_method: Union[str, object] = values.unset,
) -> CompositionHookInstance:
"""
Asynchronous coroutine to update the CompositionHookInstance
:param friendly_name: A descriptive string that you create to describe the resource. It can be up to 100 characters long and it must be unique within the account.
:param enabled: Whether the composition hook is active. When `true`, the composition hook will be triggered for every completed Group Room in the account. When `false`, the composition hook never triggers.
:param video_layout: A JSON object that describes the video layout of the composition hook in terms of regions. See [Specifying Video Layouts](https://www.twilio.com/docs/video/api/compositions-resource#specifying-video-layouts) for more info.
:param audio_sources: An array of track names from the same group room to merge into the compositions created by the composition hook. Can include zero or more track names. A composition triggered by the composition hook includes all audio sources specified in `audio_sources` except those specified in `audio_sources_excluded`. The track names in this parameter can include an asterisk as a wild card character, which matches zero or more characters in a track name. For example, `student*` includes tracks named `student` as well as `studentTeam`.
:param audio_sources_excluded: An array of track names to exclude. A composition triggered by the composition hook includes all audio sources specified in `audio_sources` except for those specified in `audio_sources_excluded`. The track names in this parameter can include an asterisk as a wild card character, which matches zero or more characters in a track name. For example, `student*` excludes `student` as well as `studentTeam`. This parameter can also be empty.
:param trim: Whether to clip the intervals where there is no active media in the compositions triggered by the composition hook. The default is `true`. Compositions with `trim` enabled are shorter when the Room is created and no Participant joins for a while as well as if all the Participants leave the room and join later, because those gaps will be removed. See [Specifying Video Layouts](https://www.twilio.com/docs/video/api/compositions-resource#specifying-video-layouts) for more info.
:param format:
:param resolution: A string that describes the columns (width) and rows (height) of the generated composed video in pixels. Defaults to `640x480`. The string's format is `{width}x{height}` where: * 16 <= `{width}` <= 1280 * 16 <= `{height}` <= 1280 * `{width}` * `{height}` <= 921,600 Typical values are: * HD = `1280x720` * PAL = `1024x576` * VGA = `640x480` * CIF = `320x240` Note that the `resolution` imposes an aspect ratio to the resulting composition. When the original video tracks are constrained by the aspect ratio, they are scaled to fit. See [Specifying Video Layouts](https://www.twilio.com/docs/video/api/compositions-resource#specifying-video-layouts) for more info.
:param status_callback: The URL we should call using the `status_callback_method` to send status information to your application on every composition event. If not provided, status callback events will not be dispatched.
:param status_callback_method: The HTTP method we should use to call `status_callback`. Can be: `POST` or `GET` and the default is `POST`.
:returns: The updated CompositionHookInstance
"""
data = values.of(
{
"FriendlyName": friendly_name,
"Enabled": enabled,
"VideoLayout": serialize.object(video_layout),
"AudioSources": serialize.map(audio_sources, lambda e: e),
"AudioSourcesExcluded": serialize.map(
audio_sources_excluded, lambda e: e
),
"Trim": trim,
"Format": format,
"Resolution": resolution,
"StatusCallback": status_callback,
"StatusCallbackMethod": status_callback_method,
}
)
payload = await self._version.update_async(
method="POST",
uri=self._uri,
data=data,
)
return CompositionHookInstance(
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.Video.V1.CompositionHookContext {}>".format(context)
class CompositionHookPage(Page):
def get_instance(self, payload: Dict[str, Any]) -> CompositionHookInstance:
"""
Build an instance of CompositionHookInstance
:param payload: Payload response from the API
"""
return CompositionHookInstance(self._version, payload)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Video.V1.CompositionHookPage>"
class CompositionHookList(ListResource):
def __init__(self, version: Version):
"""
Initialize the CompositionHookList
:param version: Version that contains the resource
"""
super().__init__(version)
self._uri = "/CompositionHooks"
def create(
self,
friendly_name: str,
enabled: Union[bool, object] = values.unset,
video_layout: Union[object, object] = values.unset,
audio_sources: Union[List[str], object] = values.unset,
audio_sources_excluded: Union[List[str], object] = values.unset,
resolution: Union[str, object] = values.unset,
format: Union["CompositionHookInstance.Format", object] = values.unset,
status_callback: Union[str, object] = values.unset,
status_callback_method: Union[str, object] = values.unset,
trim: Union[bool, object] = values.unset,
) -> CompositionHookInstance:
"""
Create the CompositionHookInstance
:param friendly_name: A descriptive string that you create to describe the resource. It can be up to 100 characters long and it must be unique within the account.
:param enabled: Whether the composition hook is active. When `true`, the composition hook will be triggered for every completed Group Room in the account. When `false`, the composition hook will never be triggered.
:param video_layout: An object that describes the video layout of the composition hook in terms of regions. See [Specifying Video Layouts](https://www.twilio.com/docs/video/api/compositions-resource#specifying-video-layouts) for more info.
:param audio_sources: An array of track names from the same group room to merge into the compositions created by the composition hook. Can include zero or more track names. A composition triggered by the composition hook includes all audio sources specified in `audio_sources` except those specified in `audio_sources_excluded`. The track names in this parameter can include an asterisk as a wild card character, which matches zero or more characters in a track name. For example, `student*` includes tracks named `student` as well as `studentTeam`.
:param audio_sources_excluded: An array of track names to exclude. A composition triggered by the composition hook includes all audio sources specified in `audio_sources` except for those specified in `audio_sources_excluded`. The track names in this parameter can include an asterisk as a wild card character, which matches zero or more characters in a track name. For example, `student*` excludes `student` as well as `studentTeam`. This parameter can also be empty.
:param resolution: A string that describes the columns (width) and rows (height) of the generated composed video in pixels. Defaults to `640x480`. The string's format is `{width}x{height}` where: * 16 <= `{width}` <= 1280 * 16 <= `{height}` <= 1280 * `{width}` * `{height}` <= 921,600 Typical values are: * HD = `1280x720` * PAL = `1024x576` * VGA = `640x480` * CIF = `320x240` Note that the `resolution` imposes an aspect ratio to the resulting composition. When the original video tracks are constrained by the aspect ratio, they are scaled to fit. See [Specifying Video Layouts](https://www.twilio.com/docs/video/api/compositions-resource#specifying-video-layouts) for more info.
:param format:
:param status_callback: The URL we should call using the `status_callback_method` to send status information to your application on every composition event. If not provided, status callback events will not be dispatched.
:param status_callback_method: The HTTP method we should use to call `status_callback`. Can be: `POST` or `GET` and the default is `POST`.
:param trim: Whether to clip the intervals where there is no active media in the Compositions triggered by the composition hook. The default is `true`. Compositions with `trim` enabled are shorter when the Room is created and no Participant joins for a while as well as if all the Participants leave the room and join later, because those gaps will be removed. See [Specifying Video Layouts](https://www.twilio.com/docs/video/api/compositions-resource#specifying-video-layouts) for more info.
:returns: The created CompositionHookInstance
"""
data = values.of(
{
"FriendlyName": friendly_name,
"Enabled": enabled,
"VideoLayout": serialize.object(video_layout),
"AudioSources": serialize.map(audio_sources, lambda e: e),
"AudioSourcesExcluded": serialize.map(
audio_sources_excluded, lambda e: e
),
"Resolution": resolution,
"Format": format,
"StatusCallback": status_callback,
"StatusCallbackMethod": status_callback_method,
"Trim": trim,
}
)
payload = self._version.create(
method="POST",
uri=self._uri,
data=data,
)
return CompositionHookInstance(self._version, payload)
async def create_async(
self,
friendly_name: str,
enabled: Union[bool, object] = values.unset,
video_layout: Union[object, object] = values.unset,
audio_sources: Union[List[str], object] = values.unset,
audio_sources_excluded: Union[List[str], object] = values.unset,
resolution: Union[str, object] = values.unset,
format: Union["CompositionHookInstance.Format", object] = values.unset,
status_callback: Union[str, object] = values.unset,
status_callback_method: Union[str, object] = values.unset,
trim: Union[bool, object] = values.unset,
) -> CompositionHookInstance:
"""
Asynchronously create the CompositionHookInstance
:param friendly_name: A descriptive string that you create to describe the resource. It can be up to 100 characters long and it must be unique within the account.
:param enabled: Whether the composition hook is active. When `true`, the composition hook will be triggered for every completed Group Room in the account. When `false`, the composition hook will never be triggered.
:param video_layout: An object that describes the video layout of the composition hook in terms of regions. See [Specifying Video Layouts](https://www.twilio.com/docs/video/api/compositions-resource#specifying-video-layouts) for more info.
:param audio_sources: An array of track names from the same group room to merge into the compositions created by the composition hook. Can include zero or more track names. A composition triggered by the composition hook includes all audio sources specified in `audio_sources` except those specified in `audio_sources_excluded`. The track names in this parameter can include an asterisk as a wild card character, which matches zero or more characters in a track name. For example, `student*` includes tracks named `student` as well as `studentTeam`.
:param audio_sources_excluded: An array of track names to exclude. A composition triggered by the composition hook includes all audio sources specified in `audio_sources` except for those specified in `audio_sources_excluded`. The track names in this parameter can include an asterisk as a wild card character, which matches zero or more characters in a track name. For example, `student*` excludes `student` as well as `studentTeam`. This parameter can also be empty.
:param resolution: A string that describes the columns (width) and rows (height) of the generated composed video in pixels. Defaults to `640x480`. The string's format is `{width}x{height}` where: * 16 <= `{width}` <= 1280 * 16 <= `{height}` <= 1280 * `{width}` * `{height}` <= 921,600 Typical values are: * HD = `1280x720` * PAL = `1024x576` * VGA = `640x480` * CIF = `320x240` Note that the `resolution` imposes an aspect ratio to the resulting composition. When the original video tracks are constrained by the aspect ratio, they are scaled to fit. See [Specifying Video Layouts](https://www.twilio.com/docs/video/api/compositions-resource#specifying-video-layouts) for more info.
:param format:
:param status_callback: The URL we should call using the `status_callback_method` to send status information to your application on every composition event. If not provided, status callback events will not be dispatched.
:param status_callback_method: The HTTP method we should use to call `status_callback`. Can be: `POST` or `GET` and the default is `POST`.
:param trim: Whether to clip the intervals where there is no active media in the Compositions triggered by the composition hook. The default is `true`. Compositions with `trim` enabled are shorter when the Room is created and no Participant joins for a while as well as if all the Participants leave the room and join later, because those gaps will be removed. See [Specifying Video Layouts](https://www.twilio.com/docs/video/api/compositions-resource#specifying-video-layouts) for more info.
:returns: The created CompositionHookInstance
"""
data = values.of(
{
"FriendlyName": friendly_name,
"Enabled": enabled,
"VideoLayout": serialize.object(video_layout),
"AudioSources": serialize.map(audio_sources, lambda e: e),
"AudioSourcesExcluded": serialize.map(
audio_sources_excluded, lambda e: e
),
"Resolution": resolution,
"Format": format,
"StatusCallback": status_callback,
"StatusCallbackMethod": status_callback_method,
"Trim": trim,
}
)
payload = await self._version.create_async(
method="POST",
uri=self._uri,
data=data,
)
return CompositionHookInstance(self._version, payload)
def stream(
self,
enabled: Union[bool, object] = values.unset,
date_created_after: Union[datetime, object] = values.unset,
date_created_before: Union[datetime, object] = values.unset,
friendly_name: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[CompositionHookInstance]:
"""
Streams CompositionHookInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param bool enabled: Read only CompositionHook resources with an `enabled` value that matches this parameter.
:param datetime date_created_after: Read only CompositionHook resources created on or after this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime with time zone.
:param datetime date_created_before: Read only CompositionHook resources created before this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime with time zone.
:param str friendly_name: Read only CompositionHook resources with friendly names that match this string. The match is not case sensitive and can include asterisk `*` characters as wildcard match.
: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(
enabled=enabled,
date_created_after=date_created_after,
date_created_before=date_created_before,
friendly_name=friendly_name,
page_size=limits["page_size"],
)
return self._version.stream(page, limits["limit"])
async def stream_async(
self,
enabled: Union[bool, object] = values.unset,
date_created_after: Union[datetime, object] = values.unset,
date_created_before: Union[datetime, object] = values.unset,
friendly_name: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> AsyncIterator[CompositionHookInstance]:
"""
Asynchronously streams CompositionHookInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param bool enabled: Read only CompositionHook resources with an `enabled` value that matches this parameter.
:param datetime date_created_after: Read only CompositionHook resources created on or after this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime with time zone.
:param datetime date_created_before: Read only CompositionHook resources created before this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime with time zone.
:param str friendly_name: Read only CompositionHook resources with friendly names that match this string. The match is not case sensitive and can include asterisk `*` characters as wildcard match.
: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(
enabled=enabled,
date_created_after=date_created_after,
date_created_before=date_created_before,
friendly_name=friendly_name,
page_size=limits["page_size"],
)
return self._version.stream_async(page, limits["limit"])
def list(
self,
enabled: Union[bool, object] = values.unset,
date_created_after: Union[datetime, object] = values.unset,
date_created_before: Union[datetime, object] = values.unset,
friendly_name: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[CompositionHookInstance]:
"""
Lists CompositionHookInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param bool enabled: Read only CompositionHook resources with an `enabled` value that matches this parameter.
:param datetime date_created_after: Read only CompositionHook resources created on or after this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime with time zone.
:param datetime date_created_before: Read only CompositionHook resources created before this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime with time zone.
:param str friendly_name: Read only CompositionHook resources with friendly names that match this string. The match is not case sensitive and can include asterisk `*` characters as wildcard match.
: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(
enabled=enabled,
date_created_after=date_created_after,
date_created_before=date_created_before,
friendly_name=friendly_name,
limit=limit,
page_size=page_size,
)
)
async def list_async(
self,
enabled: Union[bool, object] = values.unset,
date_created_after: Union[datetime, object] = values.unset,
date_created_before: Union[datetime, object] = values.unset,
friendly_name: Union[str, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[CompositionHookInstance]:
"""
Asynchronously lists CompositionHookInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param bool enabled: Read only CompositionHook resources with an `enabled` value that matches this parameter.
:param datetime date_created_after: Read only CompositionHook resources created on or after this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime with time zone.
:param datetime date_created_before: Read only CompositionHook resources created before this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime with time zone.
:param str friendly_name: Read only CompositionHook resources with friendly names that match this string. The match is not case sensitive and can include asterisk `*` characters as wildcard match.
: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(
enabled=enabled,
date_created_after=date_created_after,
date_created_before=date_created_before,
friendly_name=friendly_name,
limit=limit,
page_size=page_size,
)
]
def page(
self,
enabled: Union[bool, object] = values.unset,
date_created_after: Union[datetime, object] = values.unset,
date_created_before: Union[datetime, object] = values.unset,
friendly_name: 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,
) -> CompositionHookPage:
"""
Retrieve a single page of CompositionHookInstance records from the API.
Request is executed immediately
:param enabled: Read only CompositionHook resources with an `enabled` value that matches this parameter.
:param date_created_after: Read only CompositionHook resources created on or after this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime with time zone.
:param date_created_before: Read only CompositionHook resources created before this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime with time zone.
:param friendly_name: Read only CompositionHook resources with friendly names that match this string. The match is not case sensitive and can include asterisk `*` characters as wildcard match.
: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 CompositionHookInstance
"""
data = values.of(
{
"Enabled": enabled,
"DateCreatedAfter": serialize.iso8601_datetime(date_created_after),
"DateCreatedBefore": serialize.iso8601_datetime(date_created_before),
"FriendlyName": friendly_name,
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return CompositionHookPage(self._version, response)
async def page_async(
self,
enabled: Union[bool, object] = values.unset,
date_created_after: Union[datetime, object] = values.unset,
date_created_before: Union[datetime, object] = values.unset,
friendly_name: 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,
) -> CompositionHookPage:
"""
Asynchronously retrieve a single page of CompositionHookInstance records from the API.
Request is executed immediately
:param enabled: Read only CompositionHook resources with an `enabled` value that matches this parameter.
:param date_created_after: Read only CompositionHook resources created on or after this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime with time zone.
:param date_created_before: Read only CompositionHook resources created before this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime with time zone.
:param friendly_name: Read only CompositionHook resources with friendly names that match this string. The match is not case sensitive and can include asterisk `*` characters as wildcard match.
: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 CompositionHookInstance
"""
data = values.of(
{
"Enabled": enabled,
"DateCreatedAfter": serialize.iso8601_datetime(date_created_after),
"DateCreatedBefore": serialize.iso8601_datetime(date_created_before),
"FriendlyName": friendly_name,
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = await self._version.page_async(
method="GET", uri=self._uri, params=data
)
return CompositionHookPage(self._version, response)
def get_page(self, target_url: str) -> CompositionHookPage:
"""
Retrieve a specific page of CompositionHookInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of CompositionHookInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return CompositionHookPage(self._version, response)
async def get_page_async(self, target_url: str) -> CompositionHookPage:
"""
Asynchronously retrieve a specific page of CompositionHookInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of CompositionHookInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return CompositionHookPage(self._version, response)
def get(self, sid: str) -> CompositionHookContext:
"""
Constructs a CompositionHookContext
:param sid: The SID of the CompositionHook resource to update.
"""
return CompositionHookContext(self._version, sid=sid)
def __call__(self, sid: str) -> CompositionHookContext:
"""
Constructs a CompositionHookContext
:param sid: The SID of the CompositionHook resource to update.
"""
return CompositionHookContext(self._version, sid=sid)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Video.V1.CompositionHookList>"
@@ -0,0 +1,314 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Video
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 CompositionSettingsInstance(InstanceResource):
"""
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the CompositionSettings resource.
:ivar friendly_name: The string that you assigned to describe the resource and that will be shown in the console
:ivar aws_credentials_sid: The SID of the stored Credential resource.
:ivar aws_s3_url: The URL of the AWS S3 bucket where the compositions are stored. We only support DNS-compliant URLs like `https://documentation-example-twilio-bucket/compositions`, where `compositions` is the path in which you want the compositions to be stored. This URL accepts only URI-valid characters, as described in the <a href='https://tools.ietf.org/html/rfc3986#section-2'>RFC 3986</a>.
:ivar aws_storage_enabled: Whether all compositions are written to the `aws_s3_url`. When `false`, all compositions are stored in our cloud.
:ivar encryption_key_sid: The SID of the Public Key resource used for encryption.
:ivar encryption_enabled: Whether all compositions are stored in an encrypted form. The default is `false`.
:ivar url: The absolute URL of the resource.
"""
def __init__(self, version: Version, payload: Dict[str, Any]):
super().__init__(version)
self.account_sid: Optional[str] = payload.get("account_sid")
self.friendly_name: Optional[str] = payload.get("friendly_name")
self.aws_credentials_sid: Optional[str] = payload.get("aws_credentials_sid")
self.aws_s3_url: Optional[str] = payload.get("aws_s3_url")
self.aws_storage_enabled: Optional[bool] = payload.get("aws_storage_enabled")
self.encryption_key_sid: Optional[str] = payload.get("encryption_key_sid")
self.encryption_enabled: Optional[bool] = payload.get("encryption_enabled")
self.url: Optional[str] = payload.get("url")
self._context: Optional[CompositionSettingsContext] = None
@property
def _proxy(self) -> "CompositionSettingsContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: CompositionSettingsContext for this CompositionSettingsInstance
"""
if self._context is None:
self._context = CompositionSettingsContext(
self._version,
)
return self._context
def create(
self,
friendly_name: str,
aws_credentials_sid: Union[str, object] = values.unset,
encryption_key_sid: Union[str, object] = values.unset,
aws_s3_url: Union[str, object] = values.unset,
aws_storage_enabled: Union[bool, object] = values.unset,
encryption_enabled: Union[bool, object] = values.unset,
) -> "CompositionSettingsInstance":
"""
Create the CompositionSettingsInstance
:param friendly_name: A descriptive string that you create to describe the resource and show to the user in the console
:param aws_credentials_sid: The SID of the stored Credential resource.
:param encryption_key_sid: The SID of the Public Key resource to use for encryption.
:param aws_s3_url: The URL of the AWS S3 bucket where the compositions should be stored. We only support DNS-compliant URLs like `https://documentation-example-twilio-bucket/compositions`, where `compositions` is the path in which you want the compositions to be stored. This URL accepts only URI-valid characters, as described in the <a href='https://tools.ietf.org/html/rfc3986#section-2'>RFC 3986</a>.
:param aws_storage_enabled: Whether all compositions should be written to the `aws_s3_url`. When `false`, all compositions are stored in our cloud.
:param encryption_enabled: Whether all compositions should be stored in an encrypted form. The default is `false`.
:returns: The created CompositionSettingsInstance
"""
return self._proxy.create(
friendly_name,
aws_credentials_sid=aws_credentials_sid,
encryption_key_sid=encryption_key_sid,
aws_s3_url=aws_s3_url,
aws_storage_enabled=aws_storage_enabled,
encryption_enabled=encryption_enabled,
)
async def create_async(
self,
friendly_name: str,
aws_credentials_sid: Union[str, object] = values.unset,
encryption_key_sid: Union[str, object] = values.unset,
aws_s3_url: Union[str, object] = values.unset,
aws_storage_enabled: Union[bool, object] = values.unset,
encryption_enabled: Union[bool, object] = values.unset,
) -> "CompositionSettingsInstance":
"""
Asynchronous coroutine to create the CompositionSettingsInstance
:param friendly_name: A descriptive string that you create to describe the resource and show to the user in the console
:param aws_credentials_sid: The SID of the stored Credential resource.
:param encryption_key_sid: The SID of the Public Key resource to use for encryption.
:param aws_s3_url: The URL of the AWS S3 bucket where the compositions should be stored. We only support DNS-compliant URLs like `https://documentation-example-twilio-bucket/compositions`, where `compositions` is the path in which you want the compositions to be stored. This URL accepts only URI-valid characters, as described in the <a href='https://tools.ietf.org/html/rfc3986#section-2'>RFC 3986</a>.
:param aws_storage_enabled: Whether all compositions should be written to the `aws_s3_url`. When `false`, all compositions are stored in our cloud.
:param encryption_enabled: Whether all compositions should be stored in an encrypted form. The default is `false`.
:returns: The created CompositionSettingsInstance
"""
return await self._proxy.create_async(
friendly_name,
aws_credentials_sid=aws_credentials_sid,
encryption_key_sid=encryption_key_sid,
aws_s3_url=aws_s3_url,
aws_storage_enabled=aws_storage_enabled,
encryption_enabled=encryption_enabled,
)
def fetch(self) -> "CompositionSettingsInstance":
"""
Fetch the CompositionSettingsInstance
:returns: The fetched CompositionSettingsInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "CompositionSettingsInstance":
"""
Asynchronous coroutine to fetch the CompositionSettingsInstance
:returns: The fetched CompositionSettingsInstance
"""
return await self._proxy.fetch_async()
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Video.V1.CompositionSettingsInstance>"
class CompositionSettingsContext(InstanceContext):
def __init__(self, version: Version):
"""
Initialize the CompositionSettingsContext
:param version: Version that contains the resource
"""
super().__init__(version)
self._uri = "/CompositionSettings/Default"
def create(
self,
friendly_name: str,
aws_credentials_sid: Union[str, object] = values.unset,
encryption_key_sid: Union[str, object] = values.unset,
aws_s3_url: Union[str, object] = values.unset,
aws_storage_enabled: Union[bool, object] = values.unset,
encryption_enabled: Union[bool, object] = values.unset,
) -> CompositionSettingsInstance:
"""
Create the CompositionSettingsInstance
:param friendly_name: A descriptive string that you create to describe the resource and show to the user in the console
:param aws_credentials_sid: The SID of the stored Credential resource.
:param encryption_key_sid: The SID of the Public Key resource to use for encryption.
:param aws_s3_url: The URL of the AWS S3 bucket where the compositions should be stored. We only support DNS-compliant URLs like `https://documentation-example-twilio-bucket/compositions`, where `compositions` is the path in which you want the compositions to be stored. This URL accepts only URI-valid characters, as described in the <a href='https://tools.ietf.org/html/rfc3986#section-2'>RFC 3986</a>.
:param aws_storage_enabled: Whether all compositions should be written to the `aws_s3_url`. When `false`, all compositions are stored in our cloud.
:param encryption_enabled: Whether all compositions should be stored in an encrypted form. The default is `false`.
:returns: The created CompositionSettingsInstance
"""
data = values.of(
{
"FriendlyName": friendly_name,
"AwsCredentialsSid": aws_credentials_sid,
"EncryptionKeySid": encryption_key_sid,
"AwsS3Url": aws_s3_url,
"AwsStorageEnabled": aws_storage_enabled,
"EncryptionEnabled": encryption_enabled,
}
)
payload = self._version.create(method="POST", uri=self._uri, data=data)
return CompositionSettingsInstance(self._version, payload)
async def create_async(
self,
friendly_name: str,
aws_credentials_sid: Union[str, object] = values.unset,
encryption_key_sid: Union[str, object] = values.unset,
aws_s3_url: Union[str, object] = values.unset,
aws_storage_enabled: Union[bool, object] = values.unset,
encryption_enabled: Union[bool, object] = values.unset,
) -> CompositionSettingsInstance:
"""
Asynchronous coroutine to create the CompositionSettingsInstance
:param friendly_name: A descriptive string that you create to describe the resource and show to the user in the console
:param aws_credentials_sid: The SID of the stored Credential resource.
:param encryption_key_sid: The SID of the Public Key resource to use for encryption.
:param aws_s3_url: The URL of the AWS S3 bucket where the compositions should be stored. We only support DNS-compliant URLs like `https://documentation-example-twilio-bucket/compositions`, where `compositions` is the path in which you want the compositions to be stored. This URL accepts only URI-valid characters, as described in the <a href='https://tools.ietf.org/html/rfc3986#section-2'>RFC 3986</a>.
:param aws_storage_enabled: Whether all compositions should be written to the `aws_s3_url`. When `false`, all compositions are stored in our cloud.
:param encryption_enabled: Whether all compositions should be stored in an encrypted form. The default is `false`.
:returns: The created CompositionSettingsInstance
"""
data = values.of(
{
"FriendlyName": friendly_name,
"AwsCredentialsSid": aws_credentials_sid,
"EncryptionKeySid": encryption_key_sid,
"AwsS3Url": aws_s3_url,
"AwsStorageEnabled": aws_storage_enabled,
"EncryptionEnabled": encryption_enabled,
}
)
payload = await self._version.create_async(
method="POST", uri=self._uri, data=data
)
return CompositionSettingsInstance(self._version, payload)
def fetch(self) -> CompositionSettingsInstance:
"""
Fetch the CompositionSettingsInstance
:returns: The fetched CompositionSettingsInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return CompositionSettingsInstance(
self._version,
payload,
)
async def fetch_async(self) -> CompositionSettingsInstance:
"""
Asynchronous coroutine to fetch the CompositionSettingsInstance
:returns: The fetched CompositionSettingsInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return CompositionSettingsInstance(
self._version,
payload,
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Video.V1.CompositionSettingsContext>"
class CompositionSettingsList(ListResource):
def __init__(self, version: Version):
"""
Initialize the CompositionSettingsList
:param version: Version that contains the resource
"""
super().__init__(version)
def get(self) -> CompositionSettingsContext:
"""
Constructs a CompositionSettingsContext
"""
return CompositionSettingsContext(self._version)
def __call__(self) -> CompositionSettingsContext:
"""
Constructs a CompositionSettingsContext
"""
return CompositionSettingsContext(self._version)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Video.V1.CompositionSettingsList>"
@@ -0,0 +1,602 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Video
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 RecordingInstance(InstanceResource):
class Codec(object):
VP8 = "VP8"
H264 = "H264"
OPUS = "OPUS"
PCMU = "PCMU"
class Format(object):
MKA = "mka"
MKV = "mkv"
class Status(object):
PROCESSING = "processing"
COMPLETED = "completed"
DELETED = "deleted"
FAILED = "failed"
class Type(object):
AUDIO = "audio"
VIDEO = "video"
DATA = "data"
"""
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Recording resource.
:ivar status:
: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 sid: The unique string that we created to identify the Recording resource.
:ivar source_sid: The SID of the recording source. For a Room Recording, this value is a `track_sid`.
:ivar size: The size of the recorded track, in bytes.
:ivar url: The absolute URL of the resource.
:ivar type:
:ivar duration: The duration of the recording in seconds rounded to the nearest second. Sub-second tracks have a `Duration` property of 1 second
:ivar container_format:
:ivar codec:
:ivar grouping_sids: A list of SIDs related to the recording. Includes the `room_sid` and `participant_sid`.
:ivar track_name: The name that was given to the source track of the recording. If no name is given, the `source_sid` is used.
:ivar offset: The time in milliseconds elapsed between an arbitrary point in time, common to all group rooms, and the moment when the source room of this track started. This information provides a synchronization mechanism for recordings belonging to the same room.
:ivar media_external_location: The URL of the media file associated with the recording when stored externally. See [External S3 Recordings](/docs/video/api/external-s3-recordings) for more details.
:ivar status_callback: The URL called using the `status_callback_method` to send status information on every recording event.
:ivar status_callback_method: The HTTP method used to call `status_callback`. Can be: `POST` or `GET`, defaults to `POST`.
:ivar links: The URLs of related resources.
"""
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.status: Optional["RecordingInstance.Status"] = payload.get("status")
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_created")
)
self.sid: Optional[str] = payload.get("sid")
self.source_sid: Optional[str] = payload.get("source_sid")
self.size: Optional[int] = payload.get("size")
self.url: Optional[str] = payload.get("url")
self.type: Optional["RecordingInstance.Type"] = payload.get("type")
self.duration: Optional[int] = deserialize.integer(payload.get("duration"))
self.container_format: Optional["RecordingInstance.Format"] = payload.get(
"container_format"
)
self.codec: Optional["RecordingInstance.Codec"] = payload.get("codec")
self.grouping_sids: Optional[Dict[str, object]] = payload.get("grouping_sids")
self.track_name: Optional[str] = payload.get("track_name")
self.offset: Optional[int] = payload.get("offset")
self.media_external_location: Optional[str] = payload.get(
"media_external_location"
)
self.status_callback: Optional[str] = payload.get("status_callback")
self.status_callback_method: Optional[str] = payload.get(
"status_callback_method"
)
self.links: Optional[Dict[str, object]] = payload.get("links")
self._solution = {
"sid": sid or self.sid,
}
self._context: Optional[RecordingContext] = None
@property
def _proxy(self) -> "RecordingContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: RecordingContext for this RecordingInstance
"""
if self._context is None:
self._context = RecordingContext(
self._version,
sid=self._solution["sid"],
)
return self._context
def delete(self) -> bool:
"""
Deletes the RecordingInstance
:returns: True if delete succeeds, False otherwise
"""
return self._proxy.delete()
async def delete_async(self) -> bool:
"""
Asynchronous coroutine that deletes the RecordingInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._proxy.delete_async()
def fetch(self) -> "RecordingInstance":
"""
Fetch the RecordingInstance
:returns: The fetched RecordingInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "RecordingInstance":
"""
Asynchronous coroutine to fetch the RecordingInstance
:returns: The fetched RecordingInstance
"""
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.Video.V1.RecordingInstance {}>".format(context)
class RecordingContext(InstanceContext):
def __init__(self, version: Version, sid: str):
"""
Initialize the RecordingContext
:param version: Version that contains the resource
:param sid: The SID of the Recording resource to fetch.
"""
super().__init__(version)
# Path Solution
self._solution = {
"sid": sid,
}
self._uri = "/Recordings/{sid}".format(**self._solution)
def delete(self) -> bool:
"""
Deletes the RecordingInstance
: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 RecordingInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._version.delete_async(
method="DELETE",
uri=self._uri,
)
def fetch(self) -> RecordingInstance:
"""
Fetch the RecordingInstance
:returns: The fetched RecordingInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return RecordingInstance(
self._version,
payload,
sid=self._solution["sid"],
)
async def fetch_async(self) -> RecordingInstance:
"""
Asynchronous coroutine to fetch the RecordingInstance
:returns: The fetched RecordingInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return RecordingInstance(
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.Video.V1.RecordingContext {}>".format(context)
class RecordingPage(Page):
def get_instance(self, payload: Dict[str, Any]) -> RecordingInstance:
"""
Build an instance of RecordingInstance
:param payload: Payload response from the API
"""
return RecordingInstance(self._version, payload)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Video.V1.RecordingPage>"
class RecordingList(ListResource):
def __init__(self, version: Version):
"""
Initialize the RecordingList
:param version: Version that contains the resource
"""
super().__init__(version)
self._uri = "/Recordings"
def stream(
self,
status: Union["RecordingInstance.Status", object] = values.unset,
source_sid: Union[str, object] = values.unset,
grouping_sid: Union[List[str], object] = values.unset,
date_created_after: Union[datetime, object] = values.unset,
date_created_before: Union[datetime, object] = values.unset,
media_type: Union["RecordingInstance.Type", object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[RecordingInstance]:
"""
Streams RecordingInstance 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 &quot;RecordingInstance.Status&quot; status: Read only the recordings that have this status. Can be: `processing`, `completed`, or `deleted`.
:param str source_sid: Read only the recordings that have this `source_sid`.
:param List[str] grouping_sid: Read only recordings with this `grouping_sid`, which may include a `participant_sid` and/or a `room_sid`.
:param datetime date_created_after: Read only recordings that started on or after this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time with time zone.
:param datetime date_created_before: Read only recordings that started before this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time with time zone, given as `YYYY-MM-DDThh:mm:ss+|-hh:mm` or `YYYY-MM-DDThh:mm:ssZ`.
:param &quot;RecordingInstance.Type&quot; media_type: Read only recordings that have this media type. Can be either `audio` or `video`.
: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(
status=status,
source_sid=source_sid,
grouping_sid=grouping_sid,
date_created_after=date_created_after,
date_created_before=date_created_before,
media_type=media_type,
page_size=limits["page_size"],
)
return self._version.stream(page, limits["limit"])
async def stream_async(
self,
status: Union["RecordingInstance.Status", object] = values.unset,
source_sid: Union[str, object] = values.unset,
grouping_sid: Union[List[str], object] = values.unset,
date_created_after: Union[datetime, object] = values.unset,
date_created_before: Union[datetime, object] = values.unset,
media_type: Union["RecordingInstance.Type", object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> AsyncIterator[RecordingInstance]:
"""
Asynchronously streams RecordingInstance 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 &quot;RecordingInstance.Status&quot; status: Read only the recordings that have this status. Can be: `processing`, `completed`, or `deleted`.
:param str source_sid: Read only the recordings that have this `source_sid`.
:param List[str] grouping_sid: Read only recordings with this `grouping_sid`, which may include a `participant_sid` and/or a `room_sid`.
:param datetime date_created_after: Read only recordings that started on or after this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time with time zone.
:param datetime date_created_before: Read only recordings that started before this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time with time zone, given as `YYYY-MM-DDThh:mm:ss+|-hh:mm` or `YYYY-MM-DDThh:mm:ssZ`.
:param &quot;RecordingInstance.Type&quot; media_type: Read only recordings that have this media type. Can be either `audio` or `video`.
: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(
status=status,
source_sid=source_sid,
grouping_sid=grouping_sid,
date_created_after=date_created_after,
date_created_before=date_created_before,
media_type=media_type,
page_size=limits["page_size"],
)
return self._version.stream_async(page, limits["limit"])
def list(
self,
status: Union["RecordingInstance.Status", object] = values.unset,
source_sid: Union[str, object] = values.unset,
grouping_sid: Union[List[str], object] = values.unset,
date_created_after: Union[datetime, object] = values.unset,
date_created_before: Union[datetime, object] = values.unset,
media_type: Union["RecordingInstance.Type", object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[RecordingInstance]:
"""
Lists RecordingInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param &quot;RecordingInstance.Status&quot; status: Read only the recordings that have this status. Can be: `processing`, `completed`, or `deleted`.
:param str source_sid: Read only the recordings that have this `source_sid`.
:param List[str] grouping_sid: Read only recordings with this `grouping_sid`, which may include a `participant_sid` and/or a `room_sid`.
:param datetime date_created_after: Read only recordings that started on or after this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time with time zone.
:param datetime date_created_before: Read only recordings that started before this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time with time zone, given as `YYYY-MM-DDThh:mm:ss+|-hh:mm` or `YYYY-MM-DDThh:mm:ssZ`.
:param &quot;RecordingInstance.Type&quot; media_type: Read only recordings that have this media type. Can be either `audio` or `video`.
: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(
status=status,
source_sid=source_sid,
grouping_sid=grouping_sid,
date_created_after=date_created_after,
date_created_before=date_created_before,
media_type=media_type,
limit=limit,
page_size=page_size,
)
)
async def list_async(
self,
status: Union["RecordingInstance.Status", object] = values.unset,
source_sid: Union[str, object] = values.unset,
grouping_sid: Union[List[str], object] = values.unset,
date_created_after: Union[datetime, object] = values.unset,
date_created_before: Union[datetime, object] = values.unset,
media_type: Union["RecordingInstance.Type", object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[RecordingInstance]:
"""
Asynchronously lists RecordingInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param &quot;RecordingInstance.Status&quot; status: Read only the recordings that have this status. Can be: `processing`, `completed`, or `deleted`.
:param str source_sid: Read only the recordings that have this `source_sid`.
:param List[str] grouping_sid: Read only recordings with this `grouping_sid`, which may include a `participant_sid` and/or a `room_sid`.
:param datetime date_created_after: Read only recordings that started on or after this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time with time zone.
:param datetime date_created_before: Read only recordings that started before this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time with time zone, given as `YYYY-MM-DDThh:mm:ss+|-hh:mm` or `YYYY-MM-DDThh:mm:ssZ`.
:param &quot;RecordingInstance.Type&quot; media_type: Read only recordings that have this media type. Can be either `audio` or `video`.
: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(
status=status,
source_sid=source_sid,
grouping_sid=grouping_sid,
date_created_after=date_created_after,
date_created_before=date_created_before,
media_type=media_type,
limit=limit,
page_size=page_size,
)
]
def page(
self,
status: Union["RecordingInstance.Status", object] = values.unset,
source_sid: Union[str, object] = values.unset,
grouping_sid: Union[List[str], object] = values.unset,
date_created_after: Union[datetime, object] = values.unset,
date_created_before: Union[datetime, object] = values.unset,
media_type: Union["RecordingInstance.Type", object] = values.unset,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> RecordingPage:
"""
Retrieve a single page of RecordingInstance records from the API.
Request is executed immediately
:param status: Read only the recordings that have this status. Can be: `processing`, `completed`, or `deleted`.
:param source_sid: Read only the recordings that have this `source_sid`.
:param grouping_sid: Read only recordings with this `grouping_sid`, which may include a `participant_sid` and/or a `room_sid`.
:param date_created_after: Read only recordings that started on or after this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time with time zone.
:param date_created_before: Read only recordings that started before this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time with time zone, given as `YYYY-MM-DDThh:mm:ss+|-hh:mm` or `YYYY-MM-DDThh:mm:ssZ`.
:param media_type: Read only recordings that have this media type. Can be either `audio` or `video`.
: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 RecordingInstance
"""
data = values.of(
{
"Status": status,
"SourceSid": source_sid,
"GroupingSid": serialize.map(grouping_sid, lambda e: e),
"DateCreatedAfter": serialize.iso8601_datetime(date_created_after),
"DateCreatedBefore": serialize.iso8601_datetime(date_created_before),
"MediaType": media_type,
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return RecordingPage(self._version, response)
async def page_async(
self,
status: Union["RecordingInstance.Status", object] = values.unset,
source_sid: Union[str, object] = values.unset,
grouping_sid: Union[List[str], object] = values.unset,
date_created_after: Union[datetime, object] = values.unset,
date_created_before: Union[datetime, object] = values.unset,
media_type: Union["RecordingInstance.Type", object] = values.unset,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> RecordingPage:
"""
Asynchronously retrieve a single page of RecordingInstance records from the API.
Request is executed immediately
:param status: Read only the recordings that have this status. Can be: `processing`, `completed`, or `deleted`.
:param source_sid: Read only the recordings that have this `source_sid`.
:param grouping_sid: Read only recordings with this `grouping_sid`, which may include a `participant_sid` and/or a `room_sid`.
:param date_created_after: Read only recordings that started on or after this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time with time zone.
:param date_created_before: Read only recordings that started before this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time with time zone, given as `YYYY-MM-DDThh:mm:ss+|-hh:mm` or `YYYY-MM-DDThh:mm:ssZ`.
:param media_type: Read only recordings that have this media type. Can be either `audio` or `video`.
: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 RecordingInstance
"""
data = values.of(
{
"Status": status,
"SourceSid": source_sid,
"GroupingSid": serialize.map(grouping_sid, lambda e: e),
"DateCreatedAfter": serialize.iso8601_datetime(date_created_after),
"DateCreatedBefore": serialize.iso8601_datetime(date_created_before),
"MediaType": media_type,
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = await self._version.page_async(
method="GET", uri=self._uri, params=data
)
return RecordingPage(self._version, response)
def get_page(self, target_url: str) -> RecordingPage:
"""
Retrieve a specific page of RecordingInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of RecordingInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return RecordingPage(self._version, response)
async def get_page_async(self, target_url: str) -> RecordingPage:
"""
Asynchronously retrieve a specific page of RecordingInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of RecordingInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return RecordingPage(self._version, response)
def get(self, sid: str) -> RecordingContext:
"""
Constructs a RecordingContext
:param sid: The SID of the Recording resource to fetch.
"""
return RecordingContext(self._version, sid=sid)
def __call__(self, sid: str) -> RecordingContext:
"""
Constructs a RecordingContext
:param sid: The SID of the Recording resource to fetch.
"""
return RecordingContext(self._version, sid=sid)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Video.V1.RecordingList>"
@@ -0,0 +1,314 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Video
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 RecordingSettingsInstance(InstanceResource):
"""
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the RecordingSettings resource.
:ivar friendly_name: The string that you assigned to describe the resource and show the user in the console
:ivar aws_credentials_sid: The SID of the stored Credential resource.
:ivar aws_s3_url: The URL of the AWS S3 bucket where the recordings are stored. We only support DNS-compliant URLs like `https://documentation-example-twilio-bucket/recordings`, where `recordings` is the path in which you want the recordings to be stored. This URL accepts only URI-valid characters, as described in the <a href='https://tools.ietf.org/html/rfc3986#section-2'>RFC 3986</a>.
:ivar aws_storage_enabled: Whether all recordings are written to the `aws_s3_url`. When `false`, all recordings are stored in our cloud.
:ivar encryption_key_sid: The SID of the Public Key resource used for encryption.
:ivar encryption_enabled: Whether all recordings are stored in an encrypted form. The default is `false`.
:ivar url: The absolute URL of the resource.
"""
def __init__(self, version: Version, payload: Dict[str, Any]):
super().__init__(version)
self.account_sid: Optional[str] = payload.get("account_sid")
self.friendly_name: Optional[str] = payload.get("friendly_name")
self.aws_credentials_sid: Optional[str] = payload.get("aws_credentials_sid")
self.aws_s3_url: Optional[str] = payload.get("aws_s3_url")
self.aws_storage_enabled: Optional[bool] = payload.get("aws_storage_enabled")
self.encryption_key_sid: Optional[str] = payload.get("encryption_key_sid")
self.encryption_enabled: Optional[bool] = payload.get("encryption_enabled")
self.url: Optional[str] = payload.get("url")
self._context: Optional[RecordingSettingsContext] = None
@property
def _proxy(self) -> "RecordingSettingsContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: RecordingSettingsContext for this RecordingSettingsInstance
"""
if self._context is None:
self._context = RecordingSettingsContext(
self._version,
)
return self._context
def create(
self,
friendly_name: str,
aws_credentials_sid: Union[str, object] = values.unset,
encryption_key_sid: Union[str, object] = values.unset,
aws_s3_url: Union[str, object] = values.unset,
aws_storage_enabled: Union[bool, object] = values.unset,
encryption_enabled: Union[bool, object] = values.unset,
) -> "RecordingSettingsInstance":
"""
Create the RecordingSettingsInstance
:param friendly_name: A descriptive string that you create to describe the resource and be shown to users in the console
:param aws_credentials_sid: The SID of the stored Credential resource.
:param encryption_key_sid: The SID of the Public Key resource to use for encryption.
:param aws_s3_url: The URL of the AWS S3 bucket where the recordings should be stored. We only support DNS-compliant URLs like `https://documentation-example-twilio-bucket/recordings`, where `recordings` is the path in which you want the recordings to be stored. This URL accepts only URI-valid characters, as described in the <a href='https://tools.ietf.org/html/rfc3986#section-2'>RFC 3986</a>.
:param aws_storage_enabled: Whether all recordings should be written to the `aws_s3_url`. When `false`, all recordings are stored in our cloud.
:param encryption_enabled: Whether all recordings should be stored in an encrypted form. The default is `false`.
:returns: The created RecordingSettingsInstance
"""
return self._proxy.create(
friendly_name,
aws_credentials_sid=aws_credentials_sid,
encryption_key_sid=encryption_key_sid,
aws_s3_url=aws_s3_url,
aws_storage_enabled=aws_storage_enabled,
encryption_enabled=encryption_enabled,
)
async def create_async(
self,
friendly_name: str,
aws_credentials_sid: Union[str, object] = values.unset,
encryption_key_sid: Union[str, object] = values.unset,
aws_s3_url: Union[str, object] = values.unset,
aws_storage_enabled: Union[bool, object] = values.unset,
encryption_enabled: Union[bool, object] = values.unset,
) -> "RecordingSettingsInstance":
"""
Asynchronous coroutine to create the RecordingSettingsInstance
:param friendly_name: A descriptive string that you create to describe the resource and be shown to users in the console
:param aws_credentials_sid: The SID of the stored Credential resource.
:param encryption_key_sid: The SID of the Public Key resource to use for encryption.
:param aws_s3_url: The URL of the AWS S3 bucket where the recordings should be stored. We only support DNS-compliant URLs like `https://documentation-example-twilio-bucket/recordings`, where `recordings` is the path in which you want the recordings to be stored. This URL accepts only URI-valid characters, as described in the <a href='https://tools.ietf.org/html/rfc3986#section-2'>RFC 3986</a>.
:param aws_storage_enabled: Whether all recordings should be written to the `aws_s3_url`. When `false`, all recordings are stored in our cloud.
:param encryption_enabled: Whether all recordings should be stored in an encrypted form. The default is `false`.
:returns: The created RecordingSettingsInstance
"""
return await self._proxy.create_async(
friendly_name,
aws_credentials_sid=aws_credentials_sid,
encryption_key_sid=encryption_key_sid,
aws_s3_url=aws_s3_url,
aws_storage_enabled=aws_storage_enabled,
encryption_enabled=encryption_enabled,
)
def fetch(self) -> "RecordingSettingsInstance":
"""
Fetch the RecordingSettingsInstance
:returns: The fetched RecordingSettingsInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "RecordingSettingsInstance":
"""
Asynchronous coroutine to fetch the RecordingSettingsInstance
:returns: The fetched RecordingSettingsInstance
"""
return await self._proxy.fetch_async()
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Video.V1.RecordingSettingsInstance>"
class RecordingSettingsContext(InstanceContext):
def __init__(self, version: Version):
"""
Initialize the RecordingSettingsContext
:param version: Version that contains the resource
"""
super().__init__(version)
self._uri = "/RecordingSettings/Default"
def create(
self,
friendly_name: str,
aws_credentials_sid: Union[str, object] = values.unset,
encryption_key_sid: Union[str, object] = values.unset,
aws_s3_url: Union[str, object] = values.unset,
aws_storage_enabled: Union[bool, object] = values.unset,
encryption_enabled: Union[bool, object] = values.unset,
) -> RecordingSettingsInstance:
"""
Create the RecordingSettingsInstance
:param friendly_name: A descriptive string that you create to describe the resource and be shown to users in the console
:param aws_credentials_sid: The SID of the stored Credential resource.
:param encryption_key_sid: The SID of the Public Key resource to use for encryption.
:param aws_s3_url: The URL of the AWS S3 bucket where the recordings should be stored. We only support DNS-compliant URLs like `https://documentation-example-twilio-bucket/recordings`, where `recordings` is the path in which you want the recordings to be stored. This URL accepts only URI-valid characters, as described in the <a href='https://tools.ietf.org/html/rfc3986#section-2'>RFC 3986</a>.
:param aws_storage_enabled: Whether all recordings should be written to the `aws_s3_url`. When `false`, all recordings are stored in our cloud.
:param encryption_enabled: Whether all recordings should be stored in an encrypted form. The default is `false`.
:returns: The created RecordingSettingsInstance
"""
data = values.of(
{
"FriendlyName": friendly_name,
"AwsCredentialsSid": aws_credentials_sid,
"EncryptionKeySid": encryption_key_sid,
"AwsS3Url": aws_s3_url,
"AwsStorageEnabled": aws_storage_enabled,
"EncryptionEnabled": encryption_enabled,
}
)
payload = self._version.create(method="POST", uri=self._uri, data=data)
return RecordingSettingsInstance(self._version, payload)
async def create_async(
self,
friendly_name: str,
aws_credentials_sid: Union[str, object] = values.unset,
encryption_key_sid: Union[str, object] = values.unset,
aws_s3_url: Union[str, object] = values.unset,
aws_storage_enabled: Union[bool, object] = values.unset,
encryption_enabled: Union[bool, object] = values.unset,
) -> RecordingSettingsInstance:
"""
Asynchronous coroutine to create the RecordingSettingsInstance
:param friendly_name: A descriptive string that you create to describe the resource and be shown to users in the console
:param aws_credentials_sid: The SID of the stored Credential resource.
:param encryption_key_sid: The SID of the Public Key resource to use for encryption.
:param aws_s3_url: The URL of the AWS S3 bucket where the recordings should be stored. We only support DNS-compliant URLs like `https://documentation-example-twilio-bucket/recordings`, where `recordings` is the path in which you want the recordings to be stored. This URL accepts only URI-valid characters, as described in the <a href='https://tools.ietf.org/html/rfc3986#section-2'>RFC 3986</a>.
:param aws_storage_enabled: Whether all recordings should be written to the `aws_s3_url`. When `false`, all recordings are stored in our cloud.
:param encryption_enabled: Whether all recordings should be stored in an encrypted form. The default is `false`.
:returns: The created RecordingSettingsInstance
"""
data = values.of(
{
"FriendlyName": friendly_name,
"AwsCredentialsSid": aws_credentials_sid,
"EncryptionKeySid": encryption_key_sid,
"AwsS3Url": aws_s3_url,
"AwsStorageEnabled": aws_storage_enabled,
"EncryptionEnabled": encryption_enabled,
}
)
payload = await self._version.create_async(
method="POST", uri=self._uri, data=data
)
return RecordingSettingsInstance(self._version, payload)
def fetch(self) -> RecordingSettingsInstance:
"""
Fetch the RecordingSettingsInstance
:returns: The fetched RecordingSettingsInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return RecordingSettingsInstance(
self._version,
payload,
)
async def fetch_async(self) -> RecordingSettingsInstance:
"""
Asynchronous coroutine to fetch the RecordingSettingsInstance
:returns: The fetched RecordingSettingsInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return RecordingSettingsInstance(
self._version,
payload,
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Video.V1.RecordingSettingsContext>"
class RecordingSettingsList(ListResource):
def __init__(self, version: Version):
"""
Initialize the RecordingSettingsList
:param version: Version that contains the resource
"""
super().__init__(version)
def get(self) -> RecordingSettingsContext:
"""
Constructs a RecordingSettingsContext
"""
return RecordingSettingsContext(self._version)
def __call__(self) -> RecordingSettingsContext:
"""
Constructs a RecordingSettingsContext
"""
return RecordingSettingsContext(self._version)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Video.V1.RecordingSettingsList>"
@@ -0,0 +1,810 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Video
This is the public Twilio REST API.
NOTE: This class is auto generated by OpenAPI Generator.
https://openapi-generator.tech
Do not edit the class manually.
"""
from datetime import datetime
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
from twilio.base import deserialize, serialize, values
from twilio.base.instance_context import InstanceContext
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.version import Version
from twilio.base.page import Page
from twilio.rest.video.v1.room.participant import ParticipantList
from twilio.rest.video.v1.room.recording_rules import RecordingRulesList
from twilio.rest.video.v1.room.room_recording import RoomRecordingList
class RoomInstance(InstanceResource):
class RoomStatus(object):
IN_PROGRESS = "in-progress"
COMPLETED = "completed"
FAILED = "failed"
class RoomType(object):
GO = "go"
PEER_TO_PEER = "peer-to-peer"
GROUP = "group"
GROUP_SMALL = "group-small"
class VideoCodec(object):
VP8 = "VP8"
H264 = "H264"
"""
:ivar sid: The unique string that we created to identify the Room resource.
:ivar status:
: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 account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Room resource.
:ivar enable_turn: Deprecated, now always considered to be true.
:ivar unique_name: An application-defined string that uniquely identifies the resource. It can be used as a `room_sid` in place of the resource's `sid` in the URL to address the resource, assuming it does not contain any [reserved characters](https://tools.ietf.org/html/rfc3986#section-2.2) that would need to be URL encoded. This value is unique for `in-progress` rooms. SDK clients can use this name to connect to the room. REST API clients can use this name in place of the Room SID to interact with the room as long as the room is `in-progress`.
:ivar status_callback: The URL we call using the `status_callback_method` to send status information to your application on every room event. See [Status Callbacks](https://www.twilio.com/docs/video/api/status-callbacks) for more info.
:ivar status_callback_method: The HTTP method we use to call `status_callback`. Can be `POST` or `GET` and defaults to `POST`.
:ivar end_time: The UTC end time of the room in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601#UTC) format.
:ivar duration: The duration of the room in seconds.
:ivar type:
:ivar max_participants: The maximum number of concurrent Participants allowed in the room.
:ivar max_participant_duration: The maximum number of seconds a Participant can be connected to the room. The maximum possible value is 86400 seconds (24 hours). The default is 14400 seconds (4 hours).
:ivar max_concurrent_published_tracks: The maximum number of published audio, video, and data tracks all participants combined are allowed to publish in the room at the same time. Check [Programmable Video Limits](https://www.twilio.com/docs/video/programmable-video-limits) for more details. If it is set to 0 it means unconstrained.
:ivar record_participants_on_connect: Whether to start recording when Participants connect. ***This feature is not available in `peer-to-peer` rooms.***
:ivar video_codecs: An array of the video codecs that are supported when publishing a track in the room. Can be: `VP8` and `H264`. ***This feature is not available in `peer-to-peer` rooms***
:ivar media_region: The region for the media server in Group Rooms. Can be: one of the [available Media Regions](https://www.twilio.com/docs/video/ip-addresses#media-servers). ***This feature is not available in `peer-to-peer` rooms.***
:ivar audio_only: When set to true, indicates that the participants in the room will only publish audio. No video tracks will be allowed. Group rooms only.
:ivar empty_room_timeout: Specifies how long (in minutes) a room will remain active after last participant leaves. Can be configured when creating a room via REST API. For Ad-Hoc rooms this value cannot be changed.
:ivar unused_room_timeout: Specifies how long (in minutes) a room will remain active if no one joins. Can be configured when creating a room via REST API. For Ad-Hoc rooms this value cannot be changed.
:ivar large_room: Indicates if this is a large room.
:ivar url: The absolute URL of the resource.
:ivar links: The URLs of related resources.
"""
def __init__(
self, version: Version, payload: Dict[str, Any], sid: Optional[str] = None
):
super().__init__(version)
self.sid: Optional[str] = payload.get("sid")
self.status: Optional["RoomInstance.RoomStatus"] = payload.get("status")
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.account_sid: Optional[str] = payload.get("account_sid")
self.enable_turn: Optional[bool] = payload.get("enable_turn")
self.unique_name: Optional[str] = payload.get("unique_name")
self.status_callback: Optional[str] = payload.get("status_callback")
self.status_callback_method: Optional[str] = payload.get(
"status_callback_method"
)
self.end_time: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("end_time")
)
self.duration: Optional[int] = deserialize.integer(payload.get("duration"))
self.type: Optional["RoomInstance.RoomType"] = payload.get("type")
self.max_participants: Optional[int] = deserialize.integer(
payload.get("max_participants")
)
self.max_participant_duration: Optional[int] = deserialize.integer(
payload.get("max_participant_duration")
)
self.max_concurrent_published_tracks: Optional[int] = deserialize.integer(
payload.get("max_concurrent_published_tracks")
)
self.record_participants_on_connect: Optional[bool] = payload.get(
"record_participants_on_connect"
)
self.video_codecs: Optional[List["RoomInstance.VideoCodec"]] = payload.get(
"video_codecs"
)
self.media_region: Optional[str] = payload.get("media_region")
self.audio_only: Optional[bool] = payload.get("audio_only")
self.empty_room_timeout: Optional[int] = deserialize.integer(
payload.get("empty_room_timeout")
)
self.unused_room_timeout: Optional[int] = deserialize.integer(
payload.get("unused_room_timeout")
)
self.large_room: Optional[bool] = payload.get("large_room")
self.url: Optional[str] = payload.get("url")
self.links: Optional[Dict[str, object]] = payload.get("links")
self._solution = {
"sid": sid or self.sid,
}
self._context: Optional[RoomContext] = None
@property
def _proxy(self) -> "RoomContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: RoomContext for this RoomInstance
"""
if self._context is None:
self._context = RoomContext(
self._version,
sid=self._solution["sid"],
)
return self._context
def fetch(self) -> "RoomInstance":
"""
Fetch the RoomInstance
:returns: The fetched RoomInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "RoomInstance":
"""
Asynchronous coroutine to fetch the RoomInstance
:returns: The fetched RoomInstance
"""
return await self._proxy.fetch_async()
def update(self, status: "RoomInstance.RoomStatus") -> "RoomInstance":
"""
Update the RoomInstance
:param status:
:returns: The updated RoomInstance
"""
return self._proxy.update(
status=status,
)
async def update_async(self, status: "RoomInstance.RoomStatus") -> "RoomInstance":
"""
Asynchronous coroutine to update the RoomInstance
:param status:
:returns: The updated RoomInstance
"""
return await self._proxy.update_async(
status=status,
)
@property
def participants(self) -> ParticipantList:
"""
Access the participants
"""
return self._proxy.participants
@property
def recording_rules(self) -> RecordingRulesList:
"""
Access the recording_rules
"""
return self._proxy.recording_rules
@property
def recordings(self) -> RoomRecordingList:
"""
Access the recordings
"""
return self._proxy.recordings
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.Video.V1.RoomInstance {}>".format(context)
class RoomContext(InstanceContext):
def __init__(self, version: Version, sid: str):
"""
Initialize the RoomContext
:param version: Version that contains the resource
:param sid: The SID of the Room resource to update.
"""
super().__init__(version)
# Path Solution
self._solution = {
"sid": sid,
}
self._uri = "/Rooms/{sid}".format(**self._solution)
self._participants: Optional[ParticipantList] = None
self._recording_rules: Optional[RecordingRulesList] = None
self._recordings: Optional[RoomRecordingList] = None
def fetch(self) -> RoomInstance:
"""
Fetch the RoomInstance
:returns: The fetched RoomInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return RoomInstance(
self._version,
payload,
sid=self._solution["sid"],
)
async def fetch_async(self) -> RoomInstance:
"""
Asynchronous coroutine to fetch the RoomInstance
:returns: The fetched RoomInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return RoomInstance(
self._version,
payload,
sid=self._solution["sid"],
)
def update(self, status: "RoomInstance.RoomStatus") -> RoomInstance:
"""
Update the RoomInstance
:param status:
:returns: The updated RoomInstance
"""
data = values.of(
{
"Status": status,
}
)
payload = self._version.update(
method="POST",
uri=self._uri,
data=data,
)
return RoomInstance(self._version, payload, sid=self._solution["sid"])
async def update_async(self, status: "RoomInstance.RoomStatus") -> RoomInstance:
"""
Asynchronous coroutine to update the RoomInstance
:param status:
:returns: The updated RoomInstance
"""
data = values.of(
{
"Status": status,
}
)
payload = await self._version.update_async(
method="POST",
uri=self._uri,
data=data,
)
return RoomInstance(self._version, payload, sid=self._solution["sid"])
@property
def participants(self) -> ParticipantList:
"""
Access the participants
"""
if self._participants is None:
self._participants = ParticipantList(
self._version,
self._solution["sid"],
)
return self._participants
@property
def recording_rules(self) -> RecordingRulesList:
"""
Access the recording_rules
"""
if self._recording_rules is None:
self._recording_rules = RecordingRulesList(
self._version,
self._solution["sid"],
)
return self._recording_rules
@property
def recordings(self) -> RoomRecordingList:
"""
Access the recordings
"""
if self._recordings is None:
self._recordings = RoomRecordingList(
self._version,
self._solution["sid"],
)
return self._recordings
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.Video.V1.RoomContext {}>".format(context)
class RoomPage(Page):
def get_instance(self, payload: Dict[str, Any]) -> RoomInstance:
"""
Build an instance of RoomInstance
:param payload: Payload response from the API
"""
return RoomInstance(self._version, payload)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Video.V1.RoomPage>"
class RoomList(ListResource):
def __init__(self, version: Version):
"""
Initialize the RoomList
:param version: Version that contains the resource
"""
super().__init__(version)
self._uri = "/Rooms"
def create(
self,
enable_turn: Union[bool, object] = values.unset,
type: Union["RoomInstance.RoomType", object] = values.unset,
unique_name: Union[str, object] = values.unset,
status_callback: Union[str, object] = values.unset,
status_callback_method: Union[str, object] = values.unset,
max_participants: Union[int, object] = values.unset,
record_participants_on_connect: Union[bool, object] = values.unset,
video_codecs: Union[List["RoomInstance.VideoCodec"], object] = values.unset,
media_region: Union[str, object] = values.unset,
recording_rules: Union[object, object] = values.unset,
audio_only: Union[bool, object] = values.unset,
max_participant_duration: Union[int, object] = values.unset,
empty_room_timeout: Union[int, object] = values.unset,
unused_room_timeout: Union[int, object] = values.unset,
large_room: Union[bool, object] = values.unset,
) -> RoomInstance:
"""
Create the RoomInstance
:param enable_turn: Deprecated, now always considered to be true.
:param type:
:param unique_name: An application-defined string that uniquely identifies the resource. It can be used as a `room_sid` in place of the resource's `sid` in the URL to address the resource, assuming it does not contain any [reserved characters](https://tools.ietf.org/html/rfc3986#section-2.2) that would need to be URL encoded. This value is unique for `in-progress` rooms. SDK clients can use this name to connect to the room. REST API clients can use this name in place of the Room SID to interact with the room as long as the room is `in-progress`.
:param status_callback: The URL we should call using the `status_callback_method` to send status information to your application on every room event. See [Status Callbacks](https://www.twilio.com/docs/video/api/status-callbacks) for more info.
:param status_callback_method: The HTTP method we should use to call `status_callback`. Can be `POST` or `GET`.
:param max_participants: The maximum number of concurrent Participants allowed in the room. Peer-to-peer rooms can have up to 10 Participants. Small Group rooms can have up to 4 Participants. Group rooms can have up to 50 Participants.
:param record_participants_on_connect: Whether to start recording when Participants connect. ***This feature is not available in `peer-to-peer` rooms.***
:param video_codecs: An array of the video codecs that are supported when publishing a track in the room. Can be: `VP8` and `H264`. ***This feature is not available in `peer-to-peer` rooms***
:param media_region: The region for the media server in Group Rooms. Can be: one of the [available Media Regions](https://www.twilio.com/docs/video/ip-addresses#group-rooms-media-servers). ***This feature is not available in `peer-to-peer` rooms.***
:param recording_rules: A collection of Recording Rules that describe how to include or exclude matching tracks for recording
:param audio_only: When set to true, indicates that the participants in the room will only publish audio. No video tracks will be allowed. Group rooms only.
:param max_participant_duration: The maximum number of seconds a Participant can be connected to the room. The maximum possible value is 86400 seconds (24 hours). The default is 14400 seconds (4 hours).
:param empty_room_timeout: Configures how long (in minutes) a room will remain active after last participant leaves. Valid values range from 1 to 60 minutes (no fractions).
:param unused_room_timeout: Configures how long (in minutes) a room will remain active if no one joins. Valid values range from 1 to 60 minutes (no fractions).
:param large_room: When set to true, indicated that this is the large room.
:returns: The created RoomInstance
"""
data = values.of(
{
"EnableTurn": enable_turn,
"Type": type,
"UniqueName": unique_name,
"StatusCallback": status_callback,
"StatusCallbackMethod": status_callback_method,
"MaxParticipants": max_participants,
"RecordParticipantsOnConnect": record_participants_on_connect,
"VideoCodecs": serialize.map(video_codecs, lambda e: e),
"MediaRegion": media_region,
"RecordingRules": serialize.object(recording_rules),
"AudioOnly": audio_only,
"MaxParticipantDuration": max_participant_duration,
"EmptyRoomTimeout": empty_room_timeout,
"UnusedRoomTimeout": unused_room_timeout,
"LargeRoom": large_room,
}
)
payload = self._version.create(
method="POST",
uri=self._uri,
data=data,
)
return RoomInstance(self._version, payload)
async def create_async(
self,
enable_turn: Union[bool, object] = values.unset,
type: Union["RoomInstance.RoomType", object] = values.unset,
unique_name: Union[str, object] = values.unset,
status_callback: Union[str, object] = values.unset,
status_callback_method: Union[str, object] = values.unset,
max_participants: Union[int, object] = values.unset,
record_participants_on_connect: Union[bool, object] = values.unset,
video_codecs: Union[List["RoomInstance.VideoCodec"], object] = values.unset,
media_region: Union[str, object] = values.unset,
recording_rules: Union[object, object] = values.unset,
audio_only: Union[bool, object] = values.unset,
max_participant_duration: Union[int, object] = values.unset,
empty_room_timeout: Union[int, object] = values.unset,
unused_room_timeout: Union[int, object] = values.unset,
large_room: Union[bool, object] = values.unset,
) -> RoomInstance:
"""
Asynchronously create the RoomInstance
:param enable_turn: Deprecated, now always considered to be true.
:param type:
:param unique_name: An application-defined string that uniquely identifies the resource. It can be used as a `room_sid` in place of the resource's `sid` in the URL to address the resource, assuming it does not contain any [reserved characters](https://tools.ietf.org/html/rfc3986#section-2.2) that would need to be URL encoded. This value is unique for `in-progress` rooms. SDK clients can use this name to connect to the room. REST API clients can use this name in place of the Room SID to interact with the room as long as the room is `in-progress`.
:param status_callback: The URL we should call using the `status_callback_method` to send status information to your application on every room event. See [Status Callbacks](https://www.twilio.com/docs/video/api/status-callbacks) for more info.
:param status_callback_method: The HTTP method we should use to call `status_callback`. Can be `POST` or `GET`.
:param max_participants: The maximum number of concurrent Participants allowed in the room. Peer-to-peer rooms can have up to 10 Participants. Small Group rooms can have up to 4 Participants. Group rooms can have up to 50 Participants.
:param record_participants_on_connect: Whether to start recording when Participants connect. ***This feature is not available in `peer-to-peer` rooms.***
:param video_codecs: An array of the video codecs that are supported when publishing a track in the room. Can be: `VP8` and `H264`. ***This feature is not available in `peer-to-peer` rooms***
:param media_region: The region for the media server in Group Rooms. Can be: one of the [available Media Regions](https://www.twilio.com/docs/video/ip-addresses#group-rooms-media-servers). ***This feature is not available in `peer-to-peer` rooms.***
:param recording_rules: A collection of Recording Rules that describe how to include or exclude matching tracks for recording
:param audio_only: When set to true, indicates that the participants in the room will only publish audio. No video tracks will be allowed. Group rooms only.
:param max_participant_duration: The maximum number of seconds a Participant can be connected to the room. The maximum possible value is 86400 seconds (24 hours). The default is 14400 seconds (4 hours).
:param empty_room_timeout: Configures how long (in minutes) a room will remain active after last participant leaves. Valid values range from 1 to 60 minutes (no fractions).
:param unused_room_timeout: Configures how long (in minutes) a room will remain active if no one joins. Valid values range from 1 to 60 minutes (no fractions).
:param large_room: When set to true, indicated that this is the large room.
:returns: The created RoomInstance
"""
data = values.of(
{
"EnableTurn": enable_turn,
"Type": type,
"UniqueName": unique_name,
"StatusCallback": status_callback,
"StatusCallbackMethod": status_callback_method,
"MaxParticipants": max_participants,
"RecordParticipantsOnConnect": record_participants_on_connect,
"VideoCodecs": serialize.map(video_codecs, lambda e: e),
"MediaRegion": media_region,
"RecordingRules": serialize.object(recording_rules),
"AudioOnly": audio_only,
"MaxParticipantDuration": max_participant_duration,
"EmptyRoomTimeout": empty_room_timeout,
"UnusedRoomTimeout": unused_room_timeout,
"LargeRoom": large_room,
}
)
payload = await self._version.create_async(
method="POST",
uri=self._uri,
data=data,
)
return RoomInstance(self._version, payload)
def stream(
self,
status: Union["RoomInstance.RoomStatus", object] = values.unset,
unique_name: Union[str, object] = values.unset,
date_created_after: Union[datetime, object] = values.unset,
date_created_before: Union[datetime, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[RoomInstance]:
"""
Streams RoomInstance 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 &quot;RoomInstance.RoomStatus&quot; status: Read only the rooms with this status. Can be: `in-progress` (default) or `completed`
:param str unique_name: Read only rooms with the this `unique_name`.
:param datetime date_created_after: Read only rooms that started on or after this date, given as `YYYY-MM-DD`.
:param datetime date_created_before: Read only rooms that started before this date, given as `YYYY-MM-DD`.
: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(
status=status,
unique_name=unique_name,
date_created_after=date_created_after,
date_created_before=date_created_before,
page_size=limits["page_size"],
)
return self._version.stream(page, limits["limit"])
async def stream_async(
self,
status: Union["RoomInstance.RoomStatus", object] = values.unset,
unique_name: Union[str, object] = values.unset,
date_created_after: Union[datetime, object] = values.unset,
date_created_before: Union[datetime, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> AsyncIterator[RoomInstance]:
"""
Asynchronously streams RoomInstance 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 &quot;RoomInstance.RoomStatus&quot; status: Read only the rooms with this status. Can be: `in-progress` (default) or `completed`
:param str unique_name: Read only rooms with the this `unique_name`.
:param datetime date_created_after: Read only rooms that started on or after this date, given as `YYYY-MM-DD`.
:param datetime date_created_before: Read only rooms that started before this date, given as `YYYY-MM-DD`.
: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(
status=status,
unique_name=unique_name,
date_created_after=date_created_after,
date_created_before=date_created_before,
page_size=limits["page_size"],
)
return self._version.stream_async(page, limits["limit"])
def list(
self,
status: Union["RoomInstance.RoomStatus", object] = values.unset,
unique_name: Union[str, object] = values.unset,
date_created_after: Union[datetime, object] = values.unset,
date_created_before: Union[datetime, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[RoomInstance]:
"""
Lists RoomInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param &quot;RoomInstance.RoomStatus&quot; status: Read only the rooms with this status. Can be: `in-progress` (default) or `completed`
:param str unique_name: Read only rooms with the this `unique_name`.
:param datetime date_created_after: Read only rooms that started on or after this date, given as `YYYY-MM-DD`.
:param datetime date_created_before: Read only rooms that started before this date, given as `YYYY-MM-DD`.
: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(
status=status,
unique_name=unique_name,
date_created_after=date_created_after,
date_created_before=date_created_before,
limit=limit,
page_size=page_size,
)
)
async def list_async(
self,
status: Union["RoomInstance.RoomStatus", object] = values.unset,
unique_name: Union[str, object] = values.unset,
date_created_after: Union[datetime, object] = values.unset,
date_created_before: Union[datetime, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[RoomInstance]:
"""
Asynchronously lists RoomInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param &quot;RoomInstance.RoomStatus&quot; status: Read only the rooms with this status. Can be: `in-progress` (default) or `completed`
:param str unique_name: Read only rooms with the this `unique_name`.
:param datetime date_created_after: Read only rooms that started on or after this date, given as `YYYY-MM-DD`.
:param datetime date_created_before: Read only rooms that started before this date, given as `YYYY-MM-DD`.
: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(
status=status,
unique_name=unique_name,
date_created_after=date_created_after,
date_created_before=date_created_before,
limit=limit,
page_size=page_size,
)
]
def page(
self,
status: Union["RoomInstance.RoomStatus", object] = values.unset,
unique_name: Union[str, object] = values.unset,
date_created_after: Union[datetime, object] = values.unset,
date_created_before: Union[datetime, object] = values.unset,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> RoomPage:
"""
Retrieve a single page of RoomInstance records from the API.
Request is executed immediately
:param status: Read only the rooms with this status. Can be: `in-progress` (default) or `completed`
:param unique_name: Read only rooms with the this `unique_name`.
:param date_created_after: Read only rooms that started on or after this date, given as `YYYY-MM-DD`.
:param date_created_before: Read only rooms that started before this date, given as `YYYY-MM-DD`.
: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 RoomInstance
"""
data = values.of(
{
"Status": status,
"UniqueName": unique_name,
"DateCreatedAfter": serialize.iso8601_datetime(date_created_after),
"DateCreatedBefore": serialize.iso8601_datetime(date_created_before),
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return RoomPage(self._version, response)
async def page_async(
self,
status: Union["RoomInstance.RoomStatus", object] = values.unset,
unique_name: Union[str, object] = values.unset,
date_created_after: Union[datetime, object] = values.unset,
date_created_before: Union[datetime, object] = values.unset,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> RoomPage:
"""
Asynchronously retrieve a single page of RoomInstance records from the API.
Request is executed immediately
:param status: Read only the rooms with this status. Can be: `in-progress` (default) or `completed`
:param unique_name: Read only rooms with the this `unique_name`.
:param date_created_after: Read only rooms that started on or after this date, given as `YYYY-MM-DD`.
:param date_created_before: Read only rooms that started before this date, given as `YYYY-MM-DD`.
: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 RoomInstance
"""
data = values.of(
{
"Status": status,
"UniqueName": unique_name,
"DateCreatedAfter": serialize.iso8601_datetime(date_created_after),
"DateCreatedBefore": serialize.iso8601_datetime(date_created_before),
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = await self._version.page_async(
method="GET", uri=self._uri, params=data
)
return RoomPage(self._version, response)
def get_page(self, target_url: str) -> RoomPage:
"""
Retrieve a specific page of RoomInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of RoomInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return RoomPage(self._version, response)
async def get_page_async(self, target_url: str) -> RoomPage:
"""
Asynchronously retrieve a specific page of RoomInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of RoomInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return RoomPage(self._version, response)
def get(self, sid: str) -> RoomContext:
"""
Constructs a RoomContext
:param sid: The SID of the Room resource to update.
"""
return RoomContext(self._version, sid=sid)
def __call__(self, sid: str) -> RoomContext:
"""
Constructs a RoomContext
:param sid: The SID of the Room resource to update.
"""
return RoomContext(self._version, sid=sid)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Video.V1.RoomList>"
@@ -0,0 +1,691 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Video
This is the public Twilio REST API.
NOTE: This class is auto generated by OpenAPI Generator.
https://openapi-generator.tech
Do not edit the class manually.
"""
from datetime import datetime
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
from twilio.base import deserialize, serialize, values
from twilio.base.instance_context import InstanceContext
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.version import Version
from twilio.base.page import Page
from twilio.rest.video.v1.room.participant.anonymize import AnonymizeList
from twilio.rest.video.v1.room.participant.published_track import PublishedTrackList
from twilio.rest.video.v1.room.participant.subscribe_rules import SubscribeRulesList
from twilio.rest.video.v1.room.participant.subscribed_track import SubscribedTrackList
class ParticipantInstance(InstanceResource):
class Status(object):
CONNECTED = "connected"
DISCONNECTED = "disconnected"
"""
:ivar sid: The unique string that we created to identify the RoomParticipant resource.
:ivar room_sid: The SID of the participant's room.
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the RoomParticipant resource.
:ivar status:
:ivar identity: The application-defined string that uniquely identifies the resource's User within a Room. If a client joins with an existing Identity, the existing client is disconnected. See [access tokens](https://www.twilio.com/docs/video/tutorials/user-identity-access-tokens) and [limits](https://www.twilio.com/docs/video/programmable-video-limits) for more info.
: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 start_time: The time of participant connected to the room in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601#UTC) format.
:ivar end_time: The time when the participant disconnected from the room in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601#UTC) format.
:ivar duration: The duration in seconds that the participant was `connected`. Populated only after the participant is `disconnected`.
:ivar url: The absolute URL of the resource.
:ivar links: The URLs of related resources.
"""
def __init__(
self,
version: Version,
payload: Dict[str, Any],
room_sid: str,
sid: Optional[str] = None,
):
super().__init__(version)
self.sid: Optional[str] = payload.get("sid")
self.room_sid: Optional[str] = payload.get("room_sid")
self.account_sid: Optional[str] = payload.get("account_sid")
self.status: Optional["ParticipantInstance.Status"] = payload.get("status")
self.identity: Optional[str] = payload.get("identity")
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.start_time: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("start_time")
)
self.end_time: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("end_time")
)
self.duration: Optional[int] = deserialize.integer(payload.get("duration"))
self.url: Optional[str] = payload.get("url")
self.links: Optional[Dict[str, object]] = payload.get("links")
self._solution = {
"room_sid": room_sid,
"sid": sid or self.sid,
}
self._context: Optional[ParticipantContext] = None
@property
def _proxy(self) -> "ParticipantContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: ParticipantContext for this ParticipantInstance
"""
if self._context is None:
self._context = ParticipantContext(
self._version,
room_sid=self._solution["room_sid"],
sid=self._solution["sid"],
)
return self._context
def fetch(self) -> "ParticipantInstance":
"""
Fetch the ParticipantInstance
:returns: The fetched ParticipantInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "ParticipantInstance":
"""
Asynchronous coroutine to fetch the ParticipantInstance
:returns: The fetched ParticipantInstance
"""
return await self._proxy.fetch_async()
def update(
self, status: Union["ParticipantInstance.Status", object] = values.unset
) -> "ParticipantInstance":
"""
Update the ParticipantInstance
:param status:
:returns: The updated ParticipantInstance
"""
return self._proxy.update(
status=status,
)
async def update_async(
self, status: Union["ParticipantInstance.Status", object] = values.unset
) -> "ParticipantInstance":
"""
Asynchronous coroutine to update the ParticipantInstance
:param status:
:returns: The updated ParticipantInstance
"""
return await self._proxy.update_async(
status=status,
)
@property
def anonymize(self) -> AnonymizeList:
"""
Access the anonymize
"""
return self._proxy.anonymize
@property
def published_tracks(self) -> PublishedTrackList:
"""
Access the published_tracks
"""
return self._proxy.published_tracks
@property
def subscribe_rules(self) -> SubscribeRulesList:
"""
Access the subscribe_rules
"""
return self._proxy.subscribe_rules
@property
def subscribed_tracks(self) -> SubscribedTrackList:
"""
Access the subscribed_tracks
"""
return self._proxy.subscribed_tracks
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.Video.V1.ParticipantInstance {}>".format(context)
class ParticipantContext(InstanceContext):
def __init__(self, version: Version, room_sid: str, sid: str):
"""
Initialize the ParticipantContext
:param version: Version that contains the resource
:param room_sid: The SID of the room with the participant to update.
:param sid: The SID of the RoomParticipant resource to update.
"""
super().__init__(version)
# Path Solution
self._solution = {
"room_sid": room_sid,
"sid": sid,
}
self._uri = "/Rooms/{room_sid}/Participants/{sid}".format(**self._solution)
self._anonymize: Optional[AnonymizeList] = None
self._published_tracks: Optional[PublishedTrackList] = None
self._subscribe_rules: Optional[SubscribeRulesList] = None
self._subscribed_tracks: Optional[SubscribedTrackList] = None
def fetch(self) -> ParticipantInstance:
"""
Fetch the ParticipantInstance
:returns: The fetched ParticipantInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return ParticipantInstance(
self._version,
payload,
room_sid=self._solution["room_sid"],
sid=self._solution["sid"],
)
async def fetch_async(self) -> ParticipantInstance:
"""
Asynchronous coroutine to fetch the ParticipantInstance
:returns: The fetched ParticipantInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return ParticipantInstance(
self._version,
payload,
room_sid=self._solution["room_sid"],
sid=self._solution["sid"],
)
def update(
self, status: Union["ParticipantInstance.Status", object] = values.unset
) -> ParticipantInstance:
"""
Update the ParticipantInstance
:param status:
:returns: The updated ParticipantInstance
"""
data = values.of(
{
"Status": status,
}
)
payload = self._version.update(
method="POST",
uri=self._uri,
data=data,
)
return ParticipantInstance(
self._version,
payload,
room_sid=self._solution["room_sid"],
sid=self._solution["sid"],
)
async def update_async(
self, status: Union["ParticipantInstance.Status", object] = values.unset
) -> ParticipantInstance:
"""
Asynchronous coroutine to update the ParticipantInstance
:param status:
:returns: The updated ParticipantInstance
"""
data = values.of(
{
"Status": status,
}
)
payload = await self._version.update_async(
method="POST",
uri=self._uri,
data=data,
)
return ParticipantInstance(
self._version,
payload,
room_sid=self._solution["room_sid"],
sid=self._solution["sid"],
)
@property
def anonymize(self) -> AnonymizeList:
"""
Access the anonymize
"""
if self._anonymize is None:
self._anonymize = AnonymizeList(
self._version,
self._solution["room_sid"],
self._solution["sid"],
)
return self._anonymize
@property
def published_tracks(self) -> PublishedTrackList:
"""
Access the published_tracks
"""
if self._published_tracks is None:
self._published_tracks = PublishedTrackList(
self._version,
self._solution["room_sid"],
self._solution["sid"],
)
return self._published_tracks
@property
def subscribe_rules(self) -> SubscribeRulesList:
"""
Access the subscribe_rules
"""
if self._subscribe_rules is None:
self._subscribe_rules = SubscribeRulesList(
self._version,
self._solution["room_sid"],
self._solution["sid"],
)
return self._subscribe_rules
@property
def subscribed_tracks(self) -> SubscribedTrackList:
"""
Access the subscribed_tracks
"""
if self._subscribed_tracks is None:
self._subscribed_tracks = SubscribedTrackList(
self._version,
self._solution["room_sid"],
self._solution["sid"],
)
return self._subscribed_tracks
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.Video.V1.ParticipantContext {}>".format(context)
class ParticipantPage(Page):
def get_instance(self, payload: Dict[str, Any]) -> ParticipantInstance:
"""
Build an instance of ParticipantInstance
:param payload: Payload response from the API
"""
return ParticipantInstance(
self._version, payload, room_sid=self._solution["room_sid"]
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Video.V1.ParticipantPage>"
class ParticipantList(ListResource):
def __init__(self, version: Version, room_sid: str):
"""
Initialize the ParticipantList
:param version: Version that contains the resource
:param room_sid: The SID of the room with the Participant resources to read.
"""
super().__init__(version)
# Path Solution
self._solution = {
"room_sid": room_sid,
}
self._uri = "/Rooms/{room_sid}/Participants".format(**self._solution)
def stream(
self,
status: Union["ParticipantInstance.Status", object] = values.unset,
identity: Union[str, object] = values.unset,
date_created_after: Union[datetime, object] = values.unset,
date_created_before: Union[datetime, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[ParticipantInstance]:
"""
Streams ParticipantInstance 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 &quot;ParticipantInstance.Status&quot; status: Read only the participants with this status. Can be: `connected` or `disconnected`. For `in-progress` Rooms the default Status is `connected`, for `completed` Rooms only `disconnected` Participants are returned.
:param str identity: Read only the Participants with this [User](https://www.twilio.com/docs/chat/rest/user-resource) `identity` value.
:param datetime date_created_after: Read only Participants that started after this date in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601#UTC) format.
:param datetime date_created_before: Read only Participants that started before this date in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601#UTC) format.
: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(
status=status,
identity=identity,
date_created_after=date_created_after,
date_created_before=date_created_before,
page_size=limits["page_size"],
)
return self._version.stream(page, limits["limit"])
async def stream_async(
self,
status: Union["ParticipantInstance.Status", object] = values.unset,
identity: Union[str, object] = values.unset,
date_created_after: Union[datetime, object] = values.unset,
date_created_before: Union[datetime, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> AsyncIterator[ParticipantInstance]:
"""
Asynchronously streams ParticipantInstance 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 &quot;ParticipantInstance.Status&quot; status: Read only the participants with this status. Can be: `connected` or `disconnected`. For `in-progress` Rooms the default Status is `connected`, for `completed` Rooms only `disconnected` Participants are returned.
:param str identity: Read only the Participants with this [User](https://www.twilio.com/docs/chat/rest/user-resource) `identity` value.
:param datetime date_created_after: Read only Participants that started after this date in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601#UTC) format.
:param datetime date_created_before: Read only Participants that started before this date in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601#UTC) format.
: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(
status=status,
identity=identity,
date_created_after=date_created_after,
date_created_before=date_created_before,
page_size=limits["page_size"],
)
return self._version.stream_async(page, limits["limit"])
def list(
self,
status: Union["ParticipantInstance.Status", object] = values.unset,
identity: Union[str, object] = values.unset,
date_created_after: Union[datetime, object] = values.unset,
date_created_before: Union[datetime, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[ParticipantInstance]:
"""
Lists ParticipantInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param &quot;ParticipantInstance.Status&quot; status: Read only the participants with this status. Can be: `connected` or `disconnected`. For `in-progress` Rooms the default Status is `connected`, for `completed` Rooms only `disconnected` Participants are returned.
:param str identity: Read only the Participants with this [User](https://www.twilio.com/docs/chat/rest/user-resource) `identity` value.
:param datetime date_created_after: Read only Participants that started after this date in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601#UTC) format.
:param datetime date_created_before: Read only Participants that started before this date in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601#UTC) format.
: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(
status=status,
identity=identity,
date_created_after=date_created_after,
date_created_before=date_created_before,
limit=limit,
page_size=page_size,
)
)
async def list_async(
self,
status: Union["ParticipantInstance.Status", object] = values.unset,
identity: Union[str, object] = values.unset,
date_created_after: Union[datetime, object] = values.unset,
date_created_before: Union[datetime, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[ParticipantInstance]:
"""
Asynchronously lists ParticipantInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param &quot;ParticipantInstance.Status&quot; status: Read only the participants with this status. Can be: `connected` or `disconnected`. For `in-progress` Rooms the default Status is `connected`, for `completed` Rooms only `disconnected` Participants are returned.
:param str identity: Read only the Participants with this [User](https://www.twilio.com/docs/chat/rest/user-resource) `identity` value.
:param datetime date_created_after: Read only Participants that started after this date in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601#UTC) format.
:param datetime date_created_before: Read only Participants that started before this date in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601#UTC) format.
: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(
status=status,
identity=identity,
date_created_after=date_created_after,
date_created_before=date_created_before,
limit=limit,
page_size=page_size,
)
]
def page(
self,
status: Union["ParticipantInstance.Status", object] = values.unset,
identity: Union[str, object] = values.unset,
date_created_after: Union[datetime, object] = values.unset,
date_created_before: Union[datetime, object] = values.unset,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> ParticipantPage:
"""
Retrieve a single page of ParticipantInstance records from the API.
Request is executed immediately
:param status: Read only the participants with this status. Can be: `connected` or `disconnected`. For `in-progress` Rooms the default Status is `connected`, for `completed` Rooms only `disconnected` Participants are returned.
:param identity: Read only the Participants with this [User](https://www.twilio.com/docs/chat/rest/user-resource) `identity` value.
:param date_created_after: Read only Participants that started after this date in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601#UTC) format.
:param date_created_before: Read only Participants that started before this date in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601#UTC) format.
: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 ParticipantInstance
"""
data = values.of(
{
"Status": status,
"Identity": identity,
"DateCreatedAfter": serialize.iso8601_datetime(date_created_after),
"DateCreatedBefore": serialize.iso8601_datetime(date_created_before),
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return ParticipantPage(self._version, response, self._solution)
async def page_async(
self,
status: Union["ParticipantInstance.Status", object] = values.unset,
identity: Union[str, object] = values.unset,
date_created_after: Union[datetime, object] = values.unset,
date_created_before: Union[datetime, object] = values.unset,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> ParticipantPage:
"""
Asynchronously retrieve a single page of ParticipantInstance records from the API.
Request is executed immediately
:param status: Read only the participants with this status. Can be: `connected` or `disconnected`. For `in-progress` Rooms the default Status is `connected`, for `completed` Rooms only `disconnected` Participants are returned.
:param identity: Read only the Participants with this [User](https://www.twilio.com/docs/chat/rest/user-resource) `identity` value.
:param date_created_after: Read only Participants that started after this date in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601#UTC) format.
:param date_created_before: Read only Participants that started before this date in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601#UTC) format.
: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 ParticipantInstance
"""
data = values.of(
{
"Status": status,
"Identity": identity,
"DateCreatedAfter": serialize.iso8601_datetime(date_created_after),
"DateCreatedBefore": serialize.iso8601_datetime(date_created_before),
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = await self._version.page_async(
method="GET", uri=self._uri, params=data
)
return ParticipantPage(self._version, response, self._solution)
def get_page(self, target_url: str) -> ParticipantPage:
"""
Retrieve a specific page of ParticipantInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of ParticipantInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return ParticipantPage(self._version, response, self._solution)
async def get_page_async(self, target_url: str) -> ParticipantPage:
"""
Asynchronously retrieve a specific page of ParticipantInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of ParticipantInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return ParticipantPage(self._version, response, self._solution)
def get(self, sid: str) -> ParticipantContext:
"""
Constructs a ParticipantContext
:param sid: The SID of the RoomParticipant resource to update.
"""
return ParticipantContext(
self._version, room_sid=self._solution["room_sid"], sid=sid
)
def __call__(self, sid: str) -> ParticipantContext:
"""
Constructs a ParticipantContext
:param sid: The SID of the RoomParticipant resource to update.
"""
return ParticipantContext(
self._version, room_sid=self._solution["room_sid"], sid=sid
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Video.V1.ParticipantList>"
@@ -0,0 +1,239 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Video
This is the public Twilio REST API.
NOTE: This class is auto generated by OpenAPI Generator.
https://openapi-generator.tech
Do not edit the class manually.
"""
from datetime import datetime
from typing import Any, Dict, Optional
from twilio.base import deserialize, 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 AnonymizeInstance(InstanceResource):
class Status(object):
CONNECTED = "connected"
DISCONNECTED = "disconnected"
"""
:ivar sid: The unique string that we created to identify the RoomParticipant resource.
:ivar room_sid: The SID of the participant's room.
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the RoomParticipant resource.
:ivar status:
:ivar identity: The SID of the participant.
: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 start_time: The time of participant connected to the room in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601#UTC) format.
:ivar end_time: The time when the participant disconnected from the room in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601#UTC) format.
:ivar duration: The duration in seconds that the participant was `connected`. Populated only after the participant is `disconnected`.
:ivar url: The absolute URL of the resource.
"""
def __init__(
self, version: Version, payload: Dict[str, Any], room_sid: str, sid: str
):
super().__init__(version)
self.sid: Optional[str] = payload.get("sid")
self.room_sid: Optional[str] = payload.get("room_sid")
self.account_sid: Optional[str] = payload.get("account_sid")
self.status: Optional["AnonymizeInstance.Status"] = payload.get("status")
self.identity: Optional[str] = payload.get("identity")
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.start_time: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("start_time")
)
self.end_time: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("end_time")
)
self.duration: Optional[int] = deserialize.integer(payload.get("duration"))
self.url: Optional[str] = payload.get("url")
self._solution = {
"room_sid": room_sid,
"sid": sid,
}
self._context: Optional[AnonymizeContext] = None
@property
def _proxy(self) -> "AnonymizeContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: AnonymizeContext for this AnonymizeInstance
"""
if self._context is None:
self._context = AnonymizeContext(
self._version,
room_sid=self._solution["room_sid"],
sid=self._solution["sid"],
)
return self._context
def update(self) -> "AnonymizeInstance":
"""
Update the AnonymizeInstance
:returns: The updated AnonymizeInstance
"""
return self._proxy.update()
async def update_async(self) -> "AnonymizeInstance":
"""
Asynchronous coroutine to update the AnonymizeInstance
:returns: The updated AnonymizeInstance
"""
return await self._proxy.update_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.Video.V1.AnonymizeInstance {}>".format(context)
class AnonymizeContext(InstanceContext):
def __init__(self, version: Version, room_sid: str, sid: str):
"""
Initialize the AnonymizeContext
:param version: Version that contains the resource
:param room_sid: The SID of the room with the participant to update.
:param sid: The SID of the RoomParticipant resource to update.
"""
super().__init__(version)
# Path Solution
self._solution = {
"room_sid": room_sid,
"sid": sid,
}
self._uri = "/Rooms/{room_sid}/Participants/{sid}/Anonymize".format(
**self._solution
)
def update(self) -> AnonymizeInstance:
"""
Update the AnonymizeInstance
:returns: The updated AnonymizeInstance
"""
data = values.of({})
payload = self._version.update(
method="POST",
uri=self._uri,
data=data,
)
return AnonymizeInstance(
self._version,
payload,
room_sid=self._solution["room_sid"],
sid=self._solution["sid"],
)
async def update_async(self) -> AnonymizeInstance:
"""
Asynchronous coroutine to update the AnonymizeInstance
:returns: The updated AnonymizeInstance
"""
data = values.of({})
payload = await self._version.update_async(
method="POST",
uri=self._uri,
data=data,
)
return AnonymizeInstance(
self._version,
payload,
room_sid=self._solution["room_sid"],
sid=self._solution["sid"],
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Video.V1.AnonymizeContext {}>".format(context)
class AnonymizeList(ListResource):
def __init__(self, version: Version, room_sid: str, sid: str):
"""
Initialize the AnonymizeList
:param version: Version that contains the resource
:param room_sid: The SID of the room with the participant to update.
:param sid: The SID of the RoomParticipant resource to update.
"""
super().__init__(version)
# Path Solution
self._solution = {
"room_sid": room_sid,
"sid": sid,
}
def get(self) -> AnonymizeContext:
"""
Constructs a AnonymizeContext
"""
return AnonymizeContext(
self._version,
room_sid=self._solution["room_sid"],
sid=self._solution["sid"],
)
def __call__(self) -> AnonymizeContext:
"""
Constructs a AnonymizeContext
"""
return AnonymizeContext(
self._version,
room_sid=self._solution["room_sid"],
sid=self._solution["sid"],
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Video.V1.AnonymizeList>"
@@ -0,0 +1,455 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Video
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 PublishedTrackInstance(InstanceResource):
class Kind(object):
AUDIO = "audio"
VIDEO = "video"
DATA = "data"
"""
:ivar sid: The unique string that we created to identify the RoomParticipantPublishedTrack resource.
:ivar participant_sid: The SID of the Participant resource with the published track.
:ivar room_sid: The SID of the Room resource where the track is published.
:ivar name: The track name. Must be no more than 128 characters, and be unique among the participant's published tracks.
: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 enabled: Whether the track is enabled.
:ivar kind:
:ivar url: The absolute URL of the resource.
"""
def __init__(
self,
version: Version,
payload: Dict[str, Any],
room_sid: str,
participant_sid: str,
sid: Optional[str] = None,
):
super().__init__(version)
self.sid: Optional[str] = payload.get("sid")
self.participant_sid: Optional[str] = payload.get("participant_sid")
self.room_sid: Optional[str] = payload.get("room_sid")
self.name: Optional[str] = payload.get("name")
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_created")
)
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_updated")
)
self.enabled: Optional[bool] = payload.get("enabled")
self.kind: Optional["PublishedTrackInstance.Kind"] = payload.get("kind")
self.url: Optional[str] = payload.get("url")
self._solution = {
"room_sid": room_sid,
"participant_sid": participant_sid,
"sid": sid or self.sid,
}
self._context: Optional[PublishedTrackContext] = None
@property
def _proxy(self) -> "PublishedTrackContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: PublishedTrackContext for this PublishedTrackInstance
"""
if self._context is None:
self._context = PublishedTrackContext(
self._version,
room_sid=self._solution["room_sid"],
participant_sid=self._solution["participant_sid"],
sid=self._solution["sid"],
)
return self._context
def fetch(self) -> "PublishedTrackInstance":
"""
Fetch the PublishedTrackInstance
:returns: The fetched PublishedTrackInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "PublishedTrackInstance":
"""
Asynchronous coroutine to fetch the PublishedTrackInstance
:returns: The fetched PublishedTrackInstance
"""
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.Video.V1.PublishedTrackInstance {}>".format(context)
class PublishedTrackContext(InstanceContext):
def __init__(self, version: Version, room_sid: str, participant_sid: str, sid: str):
"""
Initialize the PublishedTrackContext
:param version: Version that contains the resource
:param room_sid: The SID of the Room resource where the Track resource to fetch is published.
:param participant_sid: The SID of the Participant resource with the published track to fetch.
:param sid: The SID of the RoomParticipantPublishedTrack resource to fetch.
"""
super().__init__(version)
# Path Solution
self._solution = {
"room_sid": room_sid,
"participant_sid": participant_sid,
"sid": sid,
}
self._uri = "/Rooms/{room_sid}/Participants/{participant_sid}/PublishedTracks/{sid}".format(
**self._solution
)
def fetch(self) -> PublishedTrackInstance:
"""
Fetch the PublishedTrackInstance
:returns: The fetched PublishedTrackInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return PublishedTrackInstance(
self._version,
payload,
room_sid=self._solution["room_sid"],
participant_sid=self._solution["participant_sid"],
sid=self._solution["sid"],
)
async def fetch_async(self) -> PublishedTrackInstance:
"""
Asynchronous coroutine to fetch the PublishedTrackInstance
:returns: The fetched PublishedTrackInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return PublishedTrackInstance(
self._version,
payload,
room_sid=self._solution["room_sid"],
participant_sid=self._solution["participant_sid"],
sid=self._solution["sid"],
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Video.V1.PublishedTrackContext {}>".format(context)
class PublishedTrackPage(Page):
def get_instance(self, payload: Dict[str, Any]) -> PublishedTrackInstance:
"""
Build an instance of PublishedTrackInstance
:param payload: Payload response from the API
"""
return PublishedTrackInstance(
self._version,
payload,
room_sid=self._solution["room_sid"],
participant_sid=self._solution["participant_sid"],
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Video.V1.PublishedTrackPage>"
class PublishedTrackList(ListResource):
def __init__(self, version: Version, room_sid: str, participant_sid: str):
"""
Initialize the PublishedTrackList
:param version: Version that contains the resource
:param room_sid: The SID of the Room resource where the Track resources to read are published.
:param participant_sid: The SID of the Participant resource with the published tracks to read.
"""
super().__init__(version)
# Path Solution
self._solution = {
"room_sid": room_sid,
"participant_sid": participant_sid,
}
self._uri = (
"/Rooms/{room_sid}/Participants/{participant_sid}/PublishedTracks".format(
**self._solution
)
)
def stream(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[PublishedTrackInstance]:
"""
Streams PublishedTrackInstance 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[PublishedTrackInstance]:
"""
Asynchronously streams PublishedTrackInstance 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[PublishedTrackInstance]:
"""
Lists PublishedTrackInstance 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[PublishedTrackInstance]:
"""
Asynchronously lists PublishedTrackInstance 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,
) -> PublishedTrackPage:
"""
Retrieve a single page of PublishedTrackInstance 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 PublishedTrackInstance
"""
data = values.of(
{
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return PublishedTrackPage(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,
) -> PublishedTrackPage:
"""
Asynchronously retrieve a single page of PublishedTrackInstance 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 PublishedTrackInstance
"""
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 PublishedTrackPage(self._version, response, self._solution)
def get_page(self, target_url: str) -> PublishedTrackPage:
"""
Retrieve a specific page of PublishedTrackInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of PublishedTrackInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return PublishedTrackPage(self._version, response, self._solution)
async def get_page_async(self, target_url: str) -> PublishedTrackPage:
"""
Asynchronously retrieve a specific page of PublishedTrackInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of PublishedTrackInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return PublishedTrackPage(self._version, response, self._solution)
def get(self, sid: str) -> PublishedTrackContext:
"""
Constructs a PublishedTrackContext
:param sid: The SID of the RoomParticipantPublishedTrack resource to fetch.
"""
return PublishedTrackContext(
self._version,
room_sid=self._solution["room_sid"],
participant_sid=self._solution["participant_sid"],
sid=sid,
)
def __call__(self, sid: str) -> PublishedTrackContext:
"""
Constructs a PublishedTrackContext
:param sid: The SID of the RoomParticipantPublishedTrack resource to fetch.
"""
return PublishedTrackContext(
self._version,
room_sid=self._solution["room_sid"],
participant_sid=self._solution["participant_sid"],
sid=sid,
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Video.V1.PublishedTrackList>"
@@ -0,0 +1,186 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Video
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
from twilio.base import deserialize, serialize, values
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.version import Version
class SubscribeRulesInstance(InstanceResource):
"""
:ivar participant_sid: The SID of the Participant resource for the Subscribe Rules.
:ivar room_sid: The SID of the Room resource for the Subscribe Rules
:ivar rules: A collection of Subscribe Rules that describe how to include or exclude matching tracks. See the [Specifying Subscribe Rules](https://www.twilio.com/docs/video/api/track-subscriptions#specifying-sr) section for further information.
: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.
"""
def __init__(
self,
version: Version,
payload: Dict[str, Any],
room_sid: str,
participant_sid: str,
):
super().__init__(version)
self.participant_sid: Optional[str] = payload.get("participant_sid")
self.room_sid: Optional[str] = payload.get("room_sid")
self.rules: Optional[List[str]] = payload.get("rules")
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._solution = {
"room_sid": room_sid,
"participant_sid": participant_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.Video.V1.SubscribeRulesInstance {}>".format(context)
class SubscribeRulesList(ListResource):
def __init__(self, version: Version, room_sid: str, participant_sid: str):
"""
Initialize the SubscribeRulesList
:param version: Version that contains the resource
:param room_sid: The SID of the Room resource where the subscribe rules to update apply.
:param participant_sid: The SID of the Participant resource to update the Subscribe Rules.
"""
super().__init__(version)
# Path Solution
self._solution = {
"room_sid": room_sid,
"participant_sid": participant_sid,
}
self._uri = (
"/Rooms/{room_sid}/Participants/{participant_sid}/SubscribeRules".format(
**self._solution
)
)
def fetch(self) -> SubscribeRulesInstance:
"""
Asynchronously fetch the SubscribeRulesInstance
:returns: The fetched SubscribeRulesInstance
"""
payload = self._version.fetch(method="GET", uri=self._uri)
return SubscribeRulesInstance(
self._version,
payload,
room_sid=self._solution["room_sid"],
participant_sid=self._solution["participant_sid"],
)
async def fetch_async(self) -> SubscribeRulesInstance:
"""
Asynchronously fetch the SubscribeRulesInstance
:returns: The fetched SubscribeRulesInstance
"""
payload = await self._version.fetch_async(method="GET", uri=self._uri)
return SubscribeRulesInstance(
self._version,
payload,
room_sid=self._solution["room_sid"],
participant_sid=self._solution["participant_sid"],
)
def update(
self, rules: Union[object, object] = values.unset
) -> SubscribeRulesInstance:
"""
Update the SubscribeRulesInstance
:param rules: A JSON-encoded array of subscribe rules. See the [Specifying Subscribe Rules](https://www.twilio.com/docs/video/api/track-subscriptions#specifying-sr) section for further information.
:returns: The created SubscribeRulesInstance
"""
data = values.of(
{
"Rules": serialize.object(rules),
}
)
payload = self._version.update(
method="POST",
uri=self._uri,
data=data,
)
return SubscribeRulesInstance(
self._version,
payload,
room_sid=self._solution["room_sid"],
participant_sid=self._solution["participant_sid"],
)
async def update_async(
self, rules: Union[object, object] = values.unset
) -> SubscribeRulesInstance:
"""
Asynchronously update the SubscribeRulesInstance
:param rules: A JSON-encoded array of subscribe rules. See the [Specifying Subscribe Rules](https://www.twilio.com/docs/video/api/track-subscriptions#specifying-sr) section for further information.
:returns: The created SubscribeRulesInstance
"""
data = values.of(
{
"Rules": serialize.object(rules),
}
)
payload = await self._version.update_async(
method="POST",
uri=self._uri,
data=data,
)
return SubscribeRulesInstance(
self._version,
payload,
room_sid=self._solution["room_sid"],
participant_sid=self._solution["participant_sid"],
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Video.V1.SubscribeRulesList>"
@@ -0,0 +1,457 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Video
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 SubscribedTrackInstance(InstanceResource):
class Kind(object):
AUDIO = "audio"
VIDEO = "video"
DATA = "data"
"""
:ivar sid: The unique string that we created to identify the RoomParticipantSubscribedTrack resource.
:ivar participant_sid: The SID of the participant that subscribes to the track.
:ivar publisher_sid: The SID of the participant that publishes the track.
:ivar room_sid: The SID of the room where the track is published.
:ivar name: The track name. Must have no more than 128 characters and be unique among the participant's published tracks.
: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 enabled: Whether the track is enabled.
:ivar kind:
:ivar url: The absolute URL of the resource.
"""
def __init__(
self,
version: Version,
payload: Dict[str, Any],
room_sid: str,
participant_sid: str,
sid: Optional[str] = None,
):
super().__init__(version)
self.sid: Optional[str] = payload.get("sid")
self.participant_sid: Optional[str] = payload.get("participant_sid")
self.publisher_sid: Optional[str] = payload.get("publisher_sid")
self.room_sid: Optional[str] = payload.get("room_sid")
self.name: Optional[str] = payload.get("name")
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_created")
)
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_updated")
)
self.enabled: Optional[bool] = payload.get("enabled")
self.kind: Optional["SubscribedTrackInstance.Kind"] = payload.get("kind")
self.url: Optional[str] = payload.get("url")
self._solution = {
"room_sid": room_sid,
"participant_sid": participant_sid,
"sid": sid or self.sid,
}
self._context: Optional[SubscribedTrackContext] = None
@property
def _proxy(self) -> "SubscribedTrackContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: SubscribedTrackContext for this SubscribedTrackInstance
"""
if self._context is None:
self._context = SubscribedTrackContext(
self._version,
room_sid=self._solution["room_sid"],
participant_sid=self._solution["participant_sid"],
sid=self._solution["sid"],
)
return self._context
def fetch(self) -> "SubscribedTrackInstance":
"""
Fetch the SubscribedTrackInstance
:returns: The fetched SubscribedTrackInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "SubscribedTrackInstance":
"""
Asynchronous coroutine to fetch the SubscribedTrackInstance
:returns: The fetched SubscribedTrackInstance
"""
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.Video.V1.SubscribedTrackInstance {}>".format(context)
class SubscribedTrackContext(InstanceContext):
def __init__(self, version: Version, room_sid: str, participant_sid: str, sid: str):
"""
Initialize the SubscribedTrackContext
:param version: Version that contains the resource
:param room_sid: The SID of the Room where the Track resource to fetch is subscribed.
:param participant_sid: The SID of the participant that subscribes to the Track resource to fetch.
:param sid: The SID of the RoomParticipantSubscribedTrack resource to fetch.
"""
super().__init__(version)
# Path Solution
self._solution = {
"room_sid": room_sid,
"participant_sid": participant_sid,
"sid": sid,
}
self._uri = "/Rooms/{room_sid}/Participants/{participant_sid}/SubscribedTracks/{sid}".format(
**self._solution
)
def fetch(self) -> SubscribedTrackInstance:
"""
Fetch the SubscribedTrackInstance
:returns: The fetched SubscribedTrackInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return SubscribedTrackInstance(
self._version,
payload,
room_sid=self._solution["room_sid"],
participant_sid=self._solution["participant_sid"],
sid=self._solution["sid"],
)
async def fetch_async(self) -> SubscribedTrackInstance:
"""
Asynchronous coroutine to fetch the SubscribedTrackInstance
:returns: The fetched SubscribedTrackInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return SubscribedTrackInstance(
self._version,
payload,
room_sid=self._solution["room_sid"],
participant_sid=self._solution["participant_sid"],
sid=self._solution["sid"],
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Video.V1.SubscribedTrackContext {}>".format(context)
class SubscribedTrackPage(Page):
def get_instance(self, payload: Dict[str, Any]) -> SubscribedTrackInstance:
"""
Build an instance of SubscribedTrackInstance
:param payload: Payload response from the API
"""
return SubscribedTrackInstance(
self._version,
payload,
room_sid=self._solution["room_sid"],
participant_sid=self._solution["participant_sid"],
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Video.V1.SubscribedTrackPage>"
class SubscribedTrackList(ListResource):
def __init__(self, version: Version, room_sid: str, participant_sid: str):
"""
Initialize the SubscribedTrackList
:param version: Version that contains the resource
:param room_sid: The SID of the Room resource with the Track resources to read.
:param participant_sid: The SID of the participant that subscribes to the Track resources to read.
"""
super().__init__(version)
# Path Solution
self._solution = {
"room_sid": room_sid,
"participant_sid": participant_sid,
}
self._uri = (
"/Rooms/{room_sid}/Participants/{participant_sid}/SubscribedTracks".format(
**self._solution
)
)
def stream(
self,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[SubscribedTrackInstance]:
"""
Streams SubscribedTrackInstance 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[SubscribedTrackInstance]:
"""
Asynchronously streams SubscribedTrackInstance 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[SubscribedTrackInstance]:
"""
Lists SubscribedTrackInstance 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[SubscribedTrackInstance]:
"""
Asynchronously lists SubscribedTrackInstance 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,
) -> SubscribedTrackPage:
"""
Retrieve a single page of SubscribedTrackInstance 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 SubscribedTrackInstance
"""
data = values.of(
{
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return SubscribedTrackPage(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,
) -> SubscribedTrackPage:
"""
Asynchronously retrieve a single page of SubscribedTrackInstance 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 SubscribedTrackInstance
"""
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 SubscribedTrackPage(self._version, response, self._solution)
def get_page(self, target_url: str) -> SubscribedTrackPage:
"""
Retrieve a specific page of SubscribedTrackInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of SubscribedTrackInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return SubscribedTrackPage(self._version, response, self._solution)
async def get_page_async(self, target_url: str) -> SubscribedTrackPage:
"""
Asynchronously retrieve a specific page of SubscribedTrackInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of SubscribedTrackInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return SubscribedTrackPage(self._version, response, self._solution)
def get(self, sid: str) -> SubscribedTrackContext:
"""
Constructs a SubscribedTrackContext
:param sid: The SID of the RoomParticipantSubscribedTrack resource to fetch.
"""
return SubscribedTrackContext(
self._version,
room_sid=self._solution["room_sid"],
participant_sid=self._solution["participant_sid"],
sid=sid,
)
def __call__(self, sid: str) -> SubscribedTrackContext:
"""
Constructs a SubscribedTrackContext
:param sid: The SID of the RoomParticipantSubscribedTrack resource to fetch.
"""
return SubscribedTrackContext(
self._version,
room_sid=self._solution["room_sid"],
participant_sid=self._solution["participant_sid"],
sid=sid,
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Video.V1.SubscribedTrackList>"
@@ -0,0 +1,159 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Video
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
from twilio.base import deserialize, serialize, values
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.version import Version
class RecordingRulesInstance(InstanceResource):
"""
:ivar room_sid: The SID of the Room resource for the Recording Rules
:ivar rules: A collection of Recording Rules that describe how to include or exclude matching tracks for recording
: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.
"""
def __init__(self, version: Version, payload: Dict[str, Any], room_sid: str):
super().__init__(version)
self.room_sid: Optional[str] = payload.get("room_sid")
self.rules: Optional[List[str]] = payload.get("rules")
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._solution = {
"room_sid": room_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.Video.V1.RecordingRulesInstance {}>".format(context)
class RecordingRulesList(ListResource):
def __init__(self, version: Version, room_sid: str):
"""
Initialize the RecordingRulesList
:param version: Version that contains the resource
:param room_sid: The SID of the Room resource where the recording rules to update apply.
"""
super().__init__(version)
# Path Solution
self._solution = {
"room_sid": room_sid,
}
self._uri = "/Rooms/{room_sid}/RecordingRules".format(**self._solution)
def fetch(self) -> RecordingRulesInstance:
"""
Asynchronously fetch the RecordingRulesInstance
:returns: The fetched RecordingRulesInstance
"""
payload = self._version.fetch(method="GET", uri=self._uri)
return RecordingRulesInstance(
self._version, payload, room_sid=self._solution["room_sid"]
)
async def fetch_async(self) -> RecordingRulesInstance:
"""
Asynchronously fetch the RecordingRulesInstance
:returns: The fetched RecordingRulesInstance
"""
payload = await self._version.fetch_async(method="GET", uri=self._uri)
return RecordingRulesInstance(
self._version, payload, room_sid=self._solution["room_sid"]
)
def update(
self, rules: Union[object, object] = values.unset
) -> RecordingRulesInstance:
"""
Update the RecordingRulesInstance
:param rules: A JSON-encoded array of recording rules.
:returns: The created RecordingRulesInstance
"""
data = values.of(
{
"Rules": serialize.object(rules),
}
)
payload = self._version.update(
method="POST",
uri=self._uri,
data=data,
)
return RecordingRulesInstance(
self._version, payload, room_sid=self._solution["room_sid"]
)
async def update_async(
self, rules: Union[object, object] = values.unset
) -> RecordingRulesInstance:
"""
Asynchronously update the RecordingRulesInstance
:param rules: A JSON-encoded array of recording rules.
:returns: The created RecordingRulesInstance
"""
data = values.of(
{
"Rules": serialize.object(rules),
}
)
payload = await self._version.update_async(
method="POST",
uri=self._uri,
data=data,
)
return RecordingRulesInstance(
self._version, payload, room_sid=self._solution["room_sid"]
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Video.V1.RecordingRulesList>"
@@ -0,0 +1,583 @@
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Video
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 RoomRecordingInstance(InstanceResource):
class Codec(object):
VP8 = "VP8"
H264 = "H264"
OPUS = "OPUS"
PCMU = "PCMU"
class Format(object):
MKA = "mka"
MKV = "mkv"
class Status(object):
PROCESSING = "processing"
COMPLETED = "completed"
DELETED = "deleted"
FAILED = "failed"
class Type(object):
AUDIO = "audio"
VIDEO = "video"
DATA = "data"
"""
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the RoomRecording resource.
:ivar status:
: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 sid: The unique string that we created to identify the RoomRecording resource.
:ivar source_sid: The SID of the recording source. For a Room Recording, this value is a `track_sid`.
:ivar size: The size of the recorded track in bytes.
:ivar url: The absolute URL of the resource.
:ivar type:
:ivar duration: The duration of the recording rounded to the nearest second. Sub-second duration tracks have a `duration` of 1 second
:ivar container_format:
:ivar codec:
:ivar grouping_sids: A list of SIDs related to the Recording. Includes the `room_sid` and `participant_sid`.
:ivar track_name: The name that was given to the source track of the recording. If no name is given, the `source_sid` is used.
:ivar offset: The time in milliseconds elapsed between an arbitrary point in time, common to all group rooms, and the moment when the source room of this track started. This information provides a synchronization mechanism for recordings belonging to the same room.
:ivar media_external_location: The URL of the media file associated with the recording when stored externally. See [External S3 Recordings](/docs/video/api/external-s3-recordings) for more details.
:ivar room_sid: The SID of the Room resource the recording is associated with.
:ivar links: The URLs of related resources.
"""
def __init__(
self,
version: Version,
payload: Dict[str, Any],
room_sid: str,
sid: Optional[str] = None,
):
super().__init__(version)
self.account_sid: Optional[str] = payload.get("account_sid")
self.status: Optional["RoomRecordingInstance.Status"] = payload.get("status")
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_created")
)
self.sid: Optional[str] = payload.get("sid")
self.source_sid: Optional[str] = payload.get("source_sid")
self.size: Optional[int] = payload.get("size")
self.url: Optional[str] = payload.get("url")
self.type: Optional["RoomRecordingInstance.Type"] = payload.get("type")
self.duration: Optional[int] = deserialize.integer(payload.get("duration"))
self.container_format: Optional["RoomRecordingInstance.Format"] = payload.get(
"container_format"
)
self.codec: Optional["RoomRecordingInstance.Codec"] = payload.get("codec")
self.grouping_sids: Optional[Dict[str, object]] = payload.get("grouping_sids")
self.track_name: Optional[str] = payload.get("track_name")
self.offset: Optional[int] = payload.get("offset")
self.media_external_location: Optional[str] = payload.get(
"media_external_location"
)
self.room_sid: Optional[str] = payload.get("room_sid")
self.links: Optional[Dict[str, object]] = payload.get("links")
self._solution = {
"room_sid": room_sid,
"sid": sid or self.sid,
}
self._context: Optional[RoomRecordingContext] = None
@property
def _proxy(self) -> "RoomRecordingContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: RoomRecordingContext for this RoomRecordingInstance
"""
if self._context is None:
self._context = RoomRecordingContext(
self._version,
room_sid=self._solution["room_sid"],
sid=self._solution["sid"],
)
return self._context
def delete(self) -> bool:
"""
Deletes the RoomRecordingInstance
:returns: True if delete succeeds, False otherwise
"""
return self._proxy.delete()
async def delete_async(self) -> bool:
"""
Asynchronous coroutine that deletes the RoomRecordingInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._proxy.delete_async()
def fetch(self) -> "RoomRecordingInstance":
"""
Fetch the RoomRecordingInstance
:returns: The fetched RoomRecordingInstance
"""
return self._proxy.fetch()
async def fetch_async(self) -> "RoomRecordingInstance":
"""
Asynchronous coroutine to fetch the RoomRecordingInstance
:returns: The fetched RoomRecordingInstance
"""
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.Video.V1.RoomRecordingInstance {}>".format(context)
class RoomRecordingContext(InstanceContext):
def __init__(self, version: Version, room_sid: str, sid: str):
"""
Initialize the RoomRecordingContext
:param version: Version that contains the resource
:param room_sid: The SID of the Room resource with the recording to fetch.
:param sid: The SID of the RoomRecording resource to fetch.
"""
super().__init__(version)
# Path Solution
self._solution = {
"room_sid": room_sid,
"sid": sid,
}
self._uri = "/Rooms/{room_sid}/Recordings/{sid}".format(**self._solution)
def delete(self) -> bool:
"""
Deletes the RoomRecordingInstance
: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 RoomRecordingInstance
:returns: True if delete succeeds, False otherwise
"""
return await self._version.delete_async(
method="DELETE",
uri=self._uri,
)
def fetch(self) -> RoomRecordingInstance:
"""
Fetch the RoomRecordingInstance
:returns: The fetched RoomRecordingInstance
"""
payload = self._version.fetch(
method="GET",
uri=self._uri,
)
return RoomRecordingInstance(
self._version,
payload,
room_sid=self._solution["room_sid"],
sid=self._solution["sid"],
)
async def fetch_async(self) -> RoomRecordingInstance:
"""
Asynchronous coroutine to fetch the RoomRecordingInstance
:returns: The fetched RoomRecordingInstance
"""
payload = await self._version.fetch_async(
method="GET",
uri=self._uri,
)
return RoomRecordingInstance(
self._version,
payload,
room_sid=self._solution["room_sid"],
sid=self._solution["sid"],
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Video.V1.RoomRecordingContext {}>".format(context)
class RoomRecordingPage(Page):
def get_instance(self, payload: Dict[str, Any]) -> RoomRecordingInstance:
"""
Build an instance of RoomRecordingInstance
:param payload: Payload response from the API
"""
return RoomRecordingInstance(
self._version, payload, room_sid=self._solution["room_sid"]
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Video.V1.RoomRecordingPage>"
class RoomRecordingList(ListResource):
def __init__(self, version: Version, room_sid: str):
"""
Initialize the RoomRecordingList
:param version: Version that contains the resource
:param room_sid: The SID of the room with the RoomRecording resources to read.
"""
super().__init__(version)
# Path Solution
self._solution = {
"room_sid": room_sid,
}
self._uri = "/Rooms/{room_sid}/Recordings".format(**self._solution)
def stream(
self,
status: Union["RoomRecordingInstance.Status", object] = values.unset,
source_sid: Union[str, object] = values.unset,
date_created_after: Union[datetime, object] = values.unset,
date_created_before: Union[datetime, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> Iterator[RoomRecordingInstance]:
"""
Streams RoomRecordingInstance 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 &quot;RoomRecordingInstance.Status&quot; status: Read only the recordings with this status. Can be: `processing`, `completed`, or `deleted`.
:param str source_sid: Read only the recordings that have this `source_sid`.
:param datetime date_created_after: Read only recordings that started on or after this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime with time zone.
:param datetime date_created_before: Read only Recordings that started before this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime with time zone.
: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(
status=status,
source_sid=source_sid,
date_created_after=date_created_after,
date_created_before=date_created_before,
page_size=limits["page_size"],
)
return self._version.stream(page, limits["limit"])
async def stream_async(
self,
status: Union["RoomRecordingInstance.Status", object] = values.unset,
source_sid: Union[str, object] = values.unset,
date_created_after: Union[datetime, object] = values.unset,
date_created_before: Union[datetime, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> AsyncIterator[RoomRecordingInstance]:
"""
Asynchronously streams RoomRecordingInstance 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 &quot;RoomRecordingInstance.Status&quot; status: Read only the recordings with this status. Can be: `processing`, `completed`, or `deleted`.
:param str source_sid: Read only the recordings that have this `source_sid`.
:param datetime date_created_after: Read only recordings that started on or after this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime with time zone.
:param datetime date_created_before: Read only Recordings that started before this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime with time zone.
: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(
status=status,
source_sid=source_sid,
date_created_after=date_created_after,
date_created_before=date_created_before,
page_size=limits["page_size"],
)
return self._version.stream_async(page, limits["limit"])
def list(
self,
status: Union["RoomRecordingInstance.Status", object] = values.unset,
source_sid: Union[str, object] = values.unset,
date_created_after: Union[datetime, object] = values.unset,
date_created_before: Union[datetime, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[RoomRecordingInstance]:
"""
Lists RoomRecordingInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param &quot;RoomRecordingInstance.Status&quot; status: Read only the recordings with this status. Can be: `processing`, `completed`, or `deleted`.
:param str source_sid: Read only the recordings that have this `source_sid`.
:param datetime date_created_after: Read only recordings that started on or after this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime with time zone.
:param datetime date_created_before: Read only Recordings that started before this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime with time zone.
: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(
status=status,
source_sid=source_sid,
date_created_after=date_created_after,
date_created_before=date_created_before,
limit=limit,
page_size=page_size,
)
)
async def list_async(
self,
status: Union["RoomRecordingInstance.Status", object] = values.unset,
source_sid: Union[str, object] = values.unset,
date_created_after: Union[datetime, object] = values.unset,
date_created_before: Union[datetime, object] = values.unset,
limit: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[RoomRecordingInstance]:
"""
Asynchronously lists RoomRecordingInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param &quot;RoomRecordingInstance.Status&quot; status: Read only the recordings with this status. Can be: `processing`, `completed`, or `deleted`.
:param str source_sid: Read only the recordings that have this `source_sid`.
:param datetime date_created_after: Read only recordings that started on or after this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime with time zone.
:param datetime date_created_before: Read only Recordings that started before this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime with time zone.
: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(
status=status,
source_sid=source_sid,
date_created_after=date_created_after,
date_created_before=date_created_before,
limit=limit,
page_size=page_size,
)
]
def page(
self,
status: Union["RoomRecordingInstance.Status", object] = values.unset,
source_sid: Union[str, object] = values.unset,
date_created_after: Union[datetime, object] = values.unset,
date_created_before: Union[datetime, object] = values.unset,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> RoomRecordingPage:
"""
Retrieve a single page of RoomRecordingInstance records from the API.
Request is executed immediately
:param status: Read only the recordings with this status. Can be: `processing`, `completed`, or `deleted`.
:param source_sid: Read only the recordings that have this `source_sid`.
:param date_created_after: Read only recordings that started on or after this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime with time zone.
:param date_created_before: Read only Recordings that started before this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime with time zone.
: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 RoomRecordingInstance
"""
data = values.of(
{
"Status": status,
"SourceSid": source_sid,
"DateCreatedAfter": serialize.iso8601_datetime(date_created_after),
"DateCreatedBefore": serialize.iso8601_datetime(date_created_before),
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = self._version.page(method="GET", uri=self._uri, params=data)
return RoomRecordingPage(self._version, response, self._solution)
async def page_async(
self,
status: Union["RoomRecordingInstance.Status", object] = values.unset,
source_sid: Union[str, object] = values.unset,
date_created_after: Union[datetime, object] = values.unset,
date_created_before: Union[datetime, object] = values.unset,
page_token: Union[str, object] = values.unset,
page_number: Union[int, object] = values.unset,
page_size: Union[int, object] = values.unset,
) -> RoomRecordingPage:
"""
Asynchronously retrieve a single page of RoomRecordingInstance records from the API.
Request is executed immediately
:param status: Read only the recordings with this status. Can be: `processing`, `completed`, or `deleted`.
:param source_sid: Read only the recordings that have this `source_sid`.
:param date_created_after: Read only recordings that started on or after this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime with time zone.
:param date_created_before: Read only Recordings that started before this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime with time zone.
: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 RoomRecordingInstance
"""
data = values.of(
{
"Status": status,
"SourceSid": source_sid,
"DateCreatedAfter": serialize.iso8601_datetime(date_created_after),
"DateCreatedBefore": serialize.iso8601_datetime(date_created_before),
"PageToken": page_token,
"Page": page_number,
"PageSize": page_size,
}
)
response = await self._version.page_async(
method="GET", uri=self._uri, params=data
)
return RoomRecordingPage(self._version, response, self._solution)
def get_page(self, target_url: str) -> RoomRecordingPage:
"""
Retrieve a specific page of RoomRecordingInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of RoomRecordingInstance
"""
response = self._version.domain.twilio.request("GET", target_url)
return RoomRecordingPage(self._version, response, self._solution)
async def get_page_async(self, target_url: str) -> RoomRecordingPage:
"""
Asynchronously retrieve a specific page of RoomRecordingInstance records from the API.
Request is executed immediately
:param target_url: API-generated URL for the requested results page
:returns: Page of RoomRecordingInstance
"""
response = await self._version.domain.twilio.request_async("GET", target_url)
return RoomRecordingPage(self._version, response, self._solution)
def get(self, sid: str) -> RoomRecordingContext:
"""
Constructs a RoomRecordingContext
:param sid: The SID of the RoomRecording resource to fetch.
"""
return RoomRecordingContext(
self._version, room_sid=self._solution["room_sid"], sid=sid
)
def __call__(self, sid: str) -> RoomRecordingContext:
"""
Constructs a RoomRecordingContext
:param sid: The SID of the RoomRecording resource to fetch.
"""
return RoomRecordingContext(
self._version, room_sid=self._solution["room_sid"], sid=sid
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Video.V1.RoomRecordingList>"