Skip to content

Version 4.0.0 #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion client/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ aiohttp>=3.7.4
aiofiles>=0.7.0
aiohttp-retry>=2.4.6
certifi>=2022.12.7
Deprecated>=1.2.14
50 changes: 3 additions & 47 deletions client/src/dolbyio_rest_apis/communications/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,57 +5,12 @@
This module contains the functions to work with the authentication API.
"""

from deprecated import deprecated
from dolbyio_rest_apis.communications.internal.http_context import CommunicationsHttpContext
from dolbyio_rest_apis.core.helpers import add_if_not_none
from dolbyio_rest_apis.core.urls import get_comms_session_url, get_comms_url_v2
from dolbyio_rest_apis.core.urls import get_comms_url_v2
from dolbyio_rest_apis.models import AccessToken
from typing import List

@deprecated(reason='''
This function is now deprecated and will be removed in the next release of this SDK.
Please start using :meth:`get_client_access_token_v2` instead.
''')
async def get_client_access_token(
app_key: str,
app_secret: str,
expires_in: int=None,
) -> AccessToken:
r"""
This API returns an access token that your backend can request on behalf of a client to initialize
the Dolby.io SDK in a secure way.

See: https://docs.dolby.io/communications-apis/reference/get-client-access-token-v1

Args:
app_key: Your Dolby.io App Key.
app_secret: Your Dolby.io App Secret.
expires_in: (Optional) Access token expiration time in seconds.
The maximum value is 86,400, indicating 24 hours.
If no value is specified, the default is 3,600, indicating one hour.

Returns:
An :class:`AccessToken` object.

Raises:
HttpRequestError: If a client error one occurred.
HTTPError: If one occurred.
"""
data = {
'grant_type': 'client_credentials',
}
add_if_not_none(data, 'expires_in', expires_in)

async with CommunicationsHttpContext() as http_context:
json_response = await http_context.requests_post_basic_auth(
app_key=app_key,
app_secret=app_secret,
url=f'{get_comms_session_url()}/oauth2/token',
data=data
)

return AccessToken(json_response)

async def get_client_access_token_v2(
access_token: str,
session_scope: List[str],
Expand All @@ -71,7 +26,8 @@ async def get_client_access_token_v2(
Args:
access_token: Access token to use for authentication.
session_scope: A list of case-sensitive strings allowing you to control
what scope of access the client access token should have.
what scope of access the client access token should have. If not specified,
the token will possess unrestricted access to all resources and actions.
The API supports the following scopes:
- conf:create: Allows creating a new conference.
- notifications:set: Allows the client to subscribe to events.
Expand Down
11 changes: 11 additions & 0 deletions client/src/dolbyio_rest_apis/communications/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,17 @@ def __init__(self, dictionary: dict):
self.region = get_value_or_default(self, 'region', None)
self.alias = get_value_or_default(self, 'alias', None)

class RtsStream(dict):
"""Representation of an RTS Stream start response."""

def __init__(self, dictionary: dict):
dict.__init__(self, dictionary)

self.stream_name = get_value_or_default(self, 'streamName', None)
self.subscribe_token = get_value_or_default(self, 'subscribeToken', None)
self.stream_account_id = get_value_or_default(self, 'streamAccountID', None)
self.viewer_url = get_value_or_default(self, 'viewerURL', None)

@dataclass
class Coordinates:
"""Representation of a Coordinate object."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from dolbyio_rest_apis.communications.internal.http_context import CommunicationsHttpContext
from dolbyio_rest_apis.communications.monitor.models import GetConferencesResponse, ConferenceSummary, ConferenceStatistics, ConferenceParticipants, ConferenceParticipant
from dolbyio_rest_apis.core.urls import get_comms_monitor_url
from dolbyio_rest_apis.core.urls import get_comms_monitor_url_v1
from typing import Any, Dict, List

async def get_conferences(
Expand Down Expand Up @@ -59,7 +59,7 @@ async def get_conferences(
HttpRequestError: If a client error one occurred.
HTTPError: If one occurred.
"""
url = f'{get_comms_monitor_url()}/conferences'
url = f'{get_comms_monitor_url_v1()}/conferences'

params = {
'from': tr_from,
Expand Down Expand Up @@ -129,7 +129,7 @@ async def get_all_conferences(
HttpRequestError: If a client error one occurred.
HTTPError: If one occurred.
"""
url = f'{get_comms_monitor_url()}/conferences'
url = f'{get_comms_monitor_url_v1()}/conferences'

params = {
'from': tr_from,
Expand Down Expand Up @@ -187,7 +187,7 @@ async def get_conference(
HTTPError: If one occurred.
"""

url = f'{get_comms_monitor_url()}/conferences/{conference_id}'
url = f'{get_comms_monitor_url_v1()}/conferences/{conference_id}'

params = {
'livestats': str(live_stats),
Expand Down Expand Up @@ -230,7 +230,7 @@ async def get_conference_statistics(
HTTPError: If one occurred.
"""

url = f'{get_comms_monitor_url()}/conferences/{conference_id}/statistics'
url = f'{get_comms_monitor_url_v1()}/conferences/{conference_id}/statistics'

async with CommunicationsHttpContext() as http_context:
json_response = await http_context.requests_get(
Expand Down Expand Up @@ -280,7 +280,7 @@ async def get_conference_participants(
HttpRequestError: If a client error one occurred.
HTTPError: If one occurred.
"""
url = f'{get_comms_monitor_url()}/conferences/{conference_id}/participants'
url = f'{get_comms_monitor_url_v1()}/conferences/{conference_id}/participants'

params = {
'from': tr_from,
Expand Down Expand Up @@ -336,7 +336,7 @@ async def get_all_conference_participants(
HttpRequestError: If a client error one occurred.
HTTPError: If one occurred.
"""
url = f'{get_comms_monitor_url()}/conferences/{conference_id}/participants'
url = f'{get_comms_monitor_url_v1()}/conferences/{conference_id}/participants'

params = {
'from': tr_from,
Expand Down Expand Up @@ -415,7 +415,7 @@ async def get_conference_participant(
HttpRequestError: If a client error one occurred.
HTTPError: If one occurred.
"""
url = f'{get_comms_monitor_url()}/conferences/{conference_id}/participants/{participant_id}'
url = f'{get_comms_monitor_url_v1()}/conferences/{conference_id}/participants/{participant_id}'

params = {
'from': tr_from,
Expand Down
97 changes: 36 additions & 61 deletions client/src/dolbyio_rest_apis/communications/monitor/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ConferenceOwner(dict):
def __init__(self, dictionary: dict):
dict.__init__(self, dictionary)

self.user_id = get_value_or_default(self, 'userID', None)
self.user_id = get_value_or_default(self, 'userId', None)

if in_and_not_none(self, 'metadata'):
self.metadata = UserMetadata(self['metadata'])
Expand Down Expand Up @@ -194,71 +194,48 @@ def __init__(self, dictionary: dict):
self.external_photo_url = get_value_or_default(self, 'externalPhotoUrl', None)
self.ip_address = get_value_or_default(self, 'ipAddress', None)

class RecordingSplit(dict):
"""Representation of a Recording Split."""
class ConferenceRecordingMix(dict):
"""Representation of a Conference Recording Mix."""

def __init__(self, dictionary: dict):
dict.__init__(self, dictionary)

self.start_time = get_value_or_default(self, 'startTime', 0)
self.duration = get_value_or_default(self, 'duration', 0)
self.size = get_value_or_default(self, 'size', 0)
self.file_name = get_value_or_default(self, 'fileName', None)
self.url = get_value_or_default(self, 'url', None)
self.mix_id = get_value_or_default(self, 'mixId', None)
self.width = get_value_or_default(self, 'width', -1)
self.height = get_value_or_default(self, 'height', -1)
self.layout_url = get_value_or_default(self, 'layoutUrl', None)

if in_and_not_none(self, 'metadata'):
self.metadata = UserMetadata(self['metadata'])

class RecordingRecord(dict):
"""Representation of a Recording Record."""
class Conference(dict):
"""Representation of a Conference."""

def __init__(self, dictionary: dict):
dict.__init__(self, dictionary)

self.start_time = get_value_or_default(self, 'startTime', 0)
self.duration = get_value_or_default(self, 'duration', 0)
self.size = get_value_or_default(self, 'size', 0)
self.file_name = get_value_or_default(self, 'fileName', None)
self.url = get_value_or_default(self, 'url', None)

self.splits = []
if in_and_not_none(self, 'splits'):
for split in self['splits']:
self.splits.append(RecordingSplit(split))
self.conf_id = get_value_or_default(self, 'confId', None)
self.conf_alias = get_value_or_default(self, 'confAlias', None)

class RecordingAudio(dict):
"""Representation of a Recording Audio."""
class ConferenceRecording(dict):
"""Representation of a Conference Recording."""

def __init__(self, dictionary: dict):
dict.__init__(self, dictionary)

self.region = get_value_or_default(self, 'region', None)

if in_and_not_none(self, 'mix'):
self.mix = RecordingMix(self['mix'])

self.records = []
if in_and_not_none(self, 'records'):
for record in self['records']:
self.records.append(RecordingRecord(record))

class Recording(dict):
"""Representation of a Recording."""

def __init__(self, dictionary: dict):
dict.__init__(self, dictionary)
if in_and_not_none(self, 'conference'):
self.conference = Conference(self['conference'])

self.conf_id = get_value_or_default(self, 'confId', None)
self.alias = get_value_or_default(self, 'alias', None)
self.duration = get_value_or_default(self, 'duration', 0)
self.ts = get_value_or_default(self, 'ts', 0)
self.region = get_value_or_default(self, 'region', None)
self.url = get_value_or_default(self, 'url', None)
self.created_at = get_value_or_default(self, 'createdAt', None)
self.recording_type = get_value_or_default(self, 'recordingType', None)
self.duration = get_value_or_default(self, 'duration', -1)
self.filename = get_value_or_default(self, 'filename', None)
self.size = get_value_or_default(self, 'size', -1)
self.start_time = get_value_or_default(self, 'startTime', 0)
self.media_type = get_value_or_default(self, 'mediaType', None)
self.region = get_value_or_default(self, 'region', None)

if in_and_not_none(self, 'mix'):
self.mix = RecordingMix(self['mix'])

if in_and_not_none(self, 'audio'):
self.audio = RecordingAudio(self['audio'])
self.mix = ConferenceRecordingMix(self['mix'])

class GetRecordingsResponse(PagedResponse):
"""Representation of a Recordings response."""
Expand All @@ -269,25 +246,23 @@ def __init__(self, dictionary: dict):
self.recordings = []
if in_and_not_none(self, 'recordings'):
for recording in self['recordings']:
self.recordings.append(Recording(recording))
self.recordings.append(ConferenceRecording(recording))

class DolbyVoiceRecording(dict):
"""Representation of a Dolby Voice Recording."""
class GetConferenceRecordingsResponse(GetRecordingsResponse):
"""Representation of a Conference Recordings response."""

def __init__(self, dictionary: dict):
dict.__init__(self, dictionary)
GetRecordingsResponse.__init__(self, dictionary)

self.region = get_value_or_default(self, 'region', None)
self.conf_id = None
self.conf_alias = None
if in_and_not_none(self, 'conference'):
self.conf_id = get_value_or_default(self, 'confId', None)
self.conf_alias = get_value_or_default(self, 'confAlias', None)
self.conference = Conference(self['conference'])

self.records = []
if in_and_not_none(self, 'records'):
for record in self['records']:
self.records.append(RecordingRecord(record))
self.live_conference = get_value_or_default(self, 'liveConference', False)

self.recordings = []
if in_and_not_none(self, 'recordings'):
for recording in self['recordings']:
self.recordings.append(ConferenceRecording(recording))

class WebHookResponse(dict):
"""Representation of a WebHook event response."""
Expand Down
Loading