Skip to content

Commit 21ac6f8

Browse files
committed
add API and model for Webex Teams Recording endpoints
1 parent 40acce8 commit 21ac6f8

File tree

9 files changed

+345
-0
lines changed

9 files changed

+345
-0
lines changed

tests/api/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
ACCESS_TOKEN_ENVIRONMENT_VARIABLE, DEFAULT_BASE_URL,
4646
DEFAULT_SINGLE_REQUEST_TIMEOUT, DEFAULT_WAIT_ON_RATE_LIMIT,
4747
)
48+
from webexteamssdk.api.recordings import RecordingsAPI
4849

4950

5051
# Constants
@@ -198,3 +199,6 @@ def test_teams_api_object_creation(api):
198199

199200
def test_webhooks_api_object_creation(api):
200201
assert isinstance(api.webhooks, WebhooksAPI)
202+
203+
def test_recordings_api_object_creation(api):
204+
assert isinstance(api.recordings, RecordingsAPI)

tests/api/test_recordings.py

Whitespace-only changes.

tests/conftest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
'tests.api.test_teammemberships',
5151
'tests.api.test_teams',
5252
"tests.api.test_events",
53+
"test.api.test_recordings"
5354
]
5455

5556
email_template = string.Template("test${number}@" + WEBEX_TEAMS_TEST_DOMAIN)

tests/test_webexteamssdk.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ def test_package_contents(self):
5656
assert hasattr(webexteamssdk, "TeamMembership")
5757
assert hasattr(webexteamssdk, "Webhook")
5858
assert hasattr(webexteamssdk, "WebhookEvent")
59+
assert hasattr(webexteamssdk, "Recording")
5960
assert hasattr(webexteamssdk, "immutable_data_factory")
6061
assert hasattr(webexteamssdk, "SimpleDataModel")
6162
assert hasattr(webexteamssdk, "simple_data_factory")

webexteamssdk/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
AccessToken, AdminAuditEvent, AttachmentAction, Event, GuestIssuerToken,
4848
immutable_data_factory, License, Membership, Message, Organization, Person,
4949
Role, Room, RoomMeetingInfo, Team, TeamMembership, Webhook, WebhookEvent,
50+
Recording
5051
)
5152
from .models.simple import simple_data_factory, SimpleDataModel
5253
from .utils import WebexTeamsDateTime

webexteamssdk/api/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
from .people import PeopleAPI
4646
from .roles import RolesAPI
4747
from .rooms import RoomsAPI
48+
from .recordings import RecordingsAPI
4849
from .team_memberships import TeamMembershipsAPI
4950
from .teams import TeamsAPI
5051
from .webhooks import WebhooksAPI
@@ -216,6 +217,7 @@ def __init__(self, access_token=None, base_url=DEFAULT_BASE_URL,
216217
self._session, object_factory,
217218
)
218219
self.webhooks = WebhooksAPI(self._session, object_factory)
220+
self.recordings = RecordingsAPI(self._session, object_factory)
219221

220222
@property
221223
def access_token(self):

webexteamssdk/api/recordings.py

Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
# -*- coding: utf-8 -*-
2+
"""Webex Teams Recordings API wrapper.
3+
4+
Copyright (c) 2016-2020 Cisco and/or its affiliates.
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
SOFTWARE.
23+
"""
24+
from __future__ import (
25+
absolute_import,
26+
division,
27+
print_function,
28+
unicode_literals,
29+
)
30+
31+
from builtins import *
32+
from past.builtins import basestring
33+
34+
from webexteamssdk.generator_containers import generator_container
35+
36+
from webexteamssdk.utils import check_type, dict_from_items_with_values
37+
38+
from webexteamssdk.restsession import RestSession
39+
40+
API_ENDPOINT = 'recordings'
41+
OBJECT_TYPE = 'recording'
42+
43+
class RecordingsAPI(object):
44+
"""Webex Teams Recordings API.
45+
46+
Wraps the Webex Teams Recordings API and exposes the API as native Python
47+
methods that return native Python objects.
48+
49+
"""
50+
def __init__(self, session, object_factory):
51+
"""Init a new RecordingsAPI object with the provided RestSession.
52+
53+
Args:
54+
session(RestSession): The RESTful session object to be used for
55+
API calls to the Webex Teams service.
56+
57+
Raises:
58+
TypeError: If the parameter types are incorrect.
59+
60+
"""
61+
check_type(session, RestSession)
62+
super(RecordingsAPI, self).__init__()
63+
self._session = session
64+
self._object_factory = object_factory
65+
66+
@generator_container
67+
def list(self, max=None, _from=None, to=None, meetingId=None,
68+
hostEmail=None, siteUrl=None, integrationTag=None, topic=None, format=None,
69+
serviceType=None, **request_parameters):
70+
"""Lists recordings.
71+
You can specify a date range, a parent meeting ID and the maximum number of recordings to return.
72+
73+
Only recordings of meetings hosted by or shared with the authenticated user will be listed.
74+
The list returned is sorted in descending order by the date and time that the recordings were created.
75+
76+
This method supports Webex Teams's implementation of RFC5988 Web
77+
Linking to provide pagination support. It returns a generator
78+
container that incrementally yields all recordings returned by the
79+
query. The generator will automatically request additional 'pages' of
80+
responses from Webex as needed until all responses have been returned.
81+
The container makes the generator safe for reuse. A new API call will
82+
be made, using the same parameters that were specified when the
83+
generator was created, every time a new iterator is requested from the
84+
container.
85+
86+
Args:
87+
max(int): Limit the maximum number of items returned from the Webex
88+
Teams service per request.
89+
_from(basestring): List recordings which occurred after a specific
90+
date and time.
91+
to(basestring): List recordings which occurred before a specific date
92+
and time.
93+
meetingId(basestring): List recordings filtered by ID.
94+
hostEmail(basestring): Email address of meeting host.
95+
siteUrl(basestring): URL of the Webex site which the API lists recordings from.
96+
integrationTag(basestring): External key of the parent meeting created
97+
by an integration application.
98+
topic(basestring): Recording's topic (case-insensitive).
99+
format(basestring): Recording's format; if specified, it should be either
100+
"MP4" or "ARF".
101+
serviceType(basestring): Recording's service type; if specified, it should be either of:
102+
MeetingCenter,
103+
EventCenter,
104+
SupportCenter,
105+
TrainingCenter
106+
**request_parameters: Additional request parameters (provides
107+
support for parameters that may be added in the future).
108+
109+
Returns:
110+
GeneratorContainer: A GeneratorContainer which, when iterated,
111+
yields the recordings returned by the Webex Teams query.
112+
113+
Raises:
114+
TypeError: If the parameter types are incorrect.
115+
ApiError: If the Webex Teams cloud returns an error.
116+
"""
117+
check_type(max, int, optional=True)
118+
check_type(_from, basestring, optional=True)
119+
check_type(to, basestring, optional=True)
120+
check_type(meetingId, basestring, optional=True)
121+
check_type(hostEmail, basestring, optional=True)
122+
check_type(siteUrl, basestring, optional=True)
123+
check_type(integrationTag, basestring)
124+
check_type(topic, basestring, optional=True)
125+
check_type(format, basestring, optional=True)
126+
check_type(serviceType, basestring, optional=True)
127+
128+
params = dict_from_items_with_values(
129+
request_parameters,
130+
max_recordings=max,
131+
_from=_from,
132+
to=to,
133+
meetingId=meetingId,
134+
hostEmail=hostEmail,
135+
siteUrl=siteUrl,
136+
integrationTag=integrationTag,
137+
topic=topic,
138+
format=format,
139+
serviceType=serviceType
140+
)
141+
142+
items = self._session.get_items(API_ENDPOINT, params=params)
143+
144+
for item in items:
145+
yield self._object_factory(OBJECT_TYPE, item)
146+
147+
def get(self, recordingId, siteUrl=None, hostEmail=None):
148+
"""Get the details of a recording, by ID.
149+
150+
Args:
151+
recordingId(basestring): The ID of the recording to be retrieved.
152+
siteUrl(basestring): URL of the Webex site which the API gets recordings from.
153+
hostEmail(basestring): Email address of meeting host.
154+
155+
Returns:
156+
Recording: A Recording object with the details of the requested
157+
recording.
158+
159+
Raises:
160+
TypeError: If the parameter types are incorrect.
161+
ApiError: If the Webex Teams cloud returns an error.
162+
163+
"""
164+
check_type(recordingId, basestring)
165+
check_type(siteUrl, basestring, optional=True)
166+
check_type(hostEmail, basestring, optional=True)
167+
168+
params = dict_from_items_with_values(
169+
siteUrl=siteUrl,
170+
hostEmail=hostEmail
171+
)
172+
173+
json_data = self._session.get(API_ENDPOINT+'/'+recordingId, params=params)
174+
175+
return self._object_factory(OBJECT_TYPE, json_data)
176+
177+
def delete(self, recordingId, siteUrl=None, hostEmail=None):
178+
"""Delete a recording.
179+
180+
Args:
181+
recordingId(basestring): The ID of the recording to be deleted.
182+
siteUrl(basestring): URL of the Webex site which the API deletes recording from.
183+
hostEmail(basestring): Email address of meeting host.
184+
185+
Raises:
186+
TypeError: If the parameter types are incorrect.
187+
ApiError: If the Webex Teams cloud returns an error.
188+
189+
"""
190+
check_type(recordingId, basestring)
191+
check_type(siteUrl, basestring, optional=True)
192+
check_type(hostEmail, basestring, optional=True)
193+
194+
params = dict_from_items_with_values(
195+
siteUrl=siteUrl,
196+
hostEmail=hostEmail
197+
)
198+
199+
self._session.get(API_ENDPOINT+'/'+recordingId, params=params)
200+
201+
202+

webexteamssdk/models/immutable.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
from .mixins.team_membership import TeamMembershipBasicPropertiesMixin
6161
from .mixins.webhook import WebhookBasicPropertiesMixin
6262
from .mixins.webhook_event import WebhookEventBasicPropertiesMixin
63+
from .mixins.recording import RecordingBasicPropertiesMixin
6364

6465

6566
class ImmutableData(object):
@@ -270,6 +271,10 @@ class GuestIssuerToken(ImmutableData, GuestIssuerTokenBasicPropertiesMixin):
270271
"""Webex Teams Guest Issuer Token data model"""
271272

272273

274+
class Recording(ImmutableData, RecordingBasicPropertiesMixin):
275+
"""Webex Teams Recording data model"""
276+
277+
273278
immutable_data_models = defaultdict(
274279
lambda: ImmutableData,
275280
access_token=AccessToken,
@@ -289,6 +294,7 @@ class GuestIssuerToken(ImmutableData, GuestIssuerTokenBasicPropertiesMixin):
289294
webhook=Webhook,
290295
webhook_event=WebhookEvent,
291296
guest_issuer_token=GuestIssuerToken,
297+
recording=Recording
292298
)
293299

294300

0 commit comments

Comments
 (0)