Skip to content

Commit d2e4cc8

Browse files
committed
add recording report endpoint
1 parent a3fe181 commit d2e4cc8

File tree

7 files changed

+430
-127
lines changed

7 files changed

+430
-127
lines changed

webexteamssdk/__init__.py

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,26 +33,55 @@
3333
import logging
3434

3535
import webexteamssdk.models.cards as cards
36+
3637
from ._metadata import (
37-
__author__, __author_email__, __copyright__, __description__,
38-
__download_url__, __license__, __title__, __url__, __version__,
38+
__author__,
39+
__author_email__,
40+
__copyright__,
41+
__description__,
42+
__download_url__,
43+
__license__,
44+
__title__,
45+
__url__,
46+
__version__,
3947
)
4048
from .api import WebexTeamsAPI
4149
from .exceptions import (
42-
AccessTokenError, ApiError, ApiWarning, MalformedResponse, RateLimitError,
43-
RateLimitWarning, webexteamssdkException, webexteamssdkWarning,
50+
AccessTokenError,
51+
ApiError,
52+
ApiWarning,
53+
MalformedResponse,
54+
RateLimitError,
55+
RateLimitWarning,
56+
webexteamssdkException,
57+
webexteamssdkWarning,
4458
)
4559
from .models.dictionary import dict_data_factory
4660
from .models.immutable import (
47-
AccessToken, AdminAuditEvent, AttachmentAction, Event, GuestIssuerToken,
48-
immutable_data_factory, License, Membership, Message, Organization, Person,
49-
Role, Room, RoomMeetingInfo, Team, TeamMembership, Webhook, WebhookEvent,
50-
Recording
61+
AccessToken,
62+
AdminAuditEvent,
63+
AttachmentAction,
64+
Event,
65+
GuestIssuerToken,
66+
License,
67+
Membership,
68+
Message,
69+
Organization,
70+
Person,
71+
Recording,
72+
RecordingReport,
73+
Role,
74+
Room,
75+
RoomMeetingInfo,
76+
Team,
77+
TeamMembership,
78+
Webhook,
79+
WebhookEvent,
80+
immutable_data_factory,
5181
)
52-
from .models.simple import simple_data_factory, SimpleDataModel
82+
from .models.simple import SimpleDataModel, simple_data_factory
5383
from .utils import WebexTeamsDateTime
5484

55-
5685
# Initialize Package Logging
5786
logger = logging.getLogger(__name__)
5887
logger.addHandler(logging.NullHandler())

webexteamssdk/api/__init__.py

Lines changed: 42 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -22,38 +22,41 @@
2222
SOFTWARE.
2323
"""
2424

25+
import os
26+
2527
from past.types import basestring
2628

2729
from webexteamssdk.config import (
28-
DEFAULT_BASE_URL, DEFAULT_SINGLE_REQUEST_TIMEOUT,
30+
DEFAULT_BASE_URL,
31+
DEFAULT_SINGLE_REQUEST_TIMEOUT,
2932
DEFAULT_WAIT_ON_RATE_LIMIT,
3033
)
3134
from webexteamssdk.environment import WEBEX_TEAMS_ACCESS_TOKEN
3235
from webexteamssdk.exceptions import AccessTokenError
3336
from webexteamssdk.models.immutable import immutable_data_factory
3437
from webexteamssdk.restsession import RestSession
3538
from webexteamssdk.utils import check_type
39+
3640
from .access_tokens import AccessTokensAPI
3741
from .admin_audit_events import AdminAuditEventsAPI
3842
from .attachment_actions import AttachmentActionsAPI
3943
from .events import EventsAPI
4044
from .guest_issuer import GuestIssuerAPI
4145
from .licenses import LicensesAPI
46+
from .meeting_invitees import MeetingInviteesAPI
47+
from .meeting_templates import MeetingTemplatesAPI
48+
from .meetings import MeetingsAPI
4249
from .memberships import MembershipsAPI
4350
from .messages import MessagesAPI
4451
from .organizations import OrganizationsAPI
4552
from .people import PeopleAPI
53+
from .recording_report import RecordingReportAPI
54+
from .recordings import RecordingsAPI
4655
from .roles import RolesAPI
4756
from .rooms import RoomsAPI
48-
from .recordings import RecordingsAPI
4957
from .team_memberships import TeamMembershipsAPI
5058
from .teams import TeamsAPI
5159
from .webhooks import WebhooksAPI
52-
from .meetings import MeetingsAPI
53-
from .meeting_templates import MeetingTemplatesAPI
54-
from .meeting_invitees import MeetingInviteesAPI
55-
56-
import os
5760

5861

5962
class WebexTeamsAPI(object):
@@ -67,18 +70,22 @@ class WebexTeamsAPI(object):
6770
them in a simple hierarchical structure.
6871
"""
6972

70-
def __init__(self, access_token=None, base_url=DEFAULT_BASE_URL,
71-
single_request_timeout=DEFAULT_SINGLE_REQUEST_TIMEOUT,
72-
wait_on_rate_limit=DEFAULT_WAIT_ON_RATE_LIMIT,
73-
object_factory=immutable_data_factory,
74-
client_id=None,
75-
client_secret=None,
76-
oauth_code=None,
77-
redirect_uri=None,
78-
proxies=None,
79-
be_geo_id=None,
80-
caller=None,
81-
disable_ssl_verify=False):
73+
def __init__(
74+
self,
75+
access_token=None,
76+
base_url=DEFAULT_BASE_URL,
77+
single_request_timeout=DEFAULT_SINGLE_REQUEST_TIMEOUT,
78+
wait_on_rate_limit=DEFAULT_WAIT_ON_RATE_LIMIT,
79+
object_factory=immutable_data_factory,
80+
client_id=None,
81+
client_secret=None,
82+
oauth_code=None,
83+
redirect_uri=None,
84+
proxies=None,
85+
be_geo_id=None,
86+
caller=None,
87+
disable_ssl_verify=False,
88+
):
8289
"""Create a new WebexTeamsAPI object.
8390
8491
An access token must be used when interacting with the Webex Teams API.
@@ -158,7 +165,8 @@ def __init__(self, access_token=None, base_url=DEFAULT_BASE_URL,
158165

159166
# Init AccessTokensAPI wrapper early to use for oauth requests
160167
self.access_tokens = AccessTokensAPI(
161-
base_url, object_factory,
168+
base_url,
169+
object_factory,
162170
single_request_timeout=single_request_timeout,
163171
)
164172

@@ -169,12 +177,12 @@ def __init__(self, access_token=None, base_url=DEFAULT_BASE_URL,
169177
client_id=client_id,
170178
client_secret=client_secret,
171179
code=oauth_code,
172-
redirect_uri=redirect_uri
180+
redirect_uri=redirect_uri,
173181
).access_token
174182

175183
# Set optional API metrics tracking variables from env vars if there
176-
be_geo_id = be_geo_id or os.environ.get('BE_GEO_ID')
177-
caller = caller or os.environ.get('WEBEX_PYTHON_SDK_CALLER')
184+
be_geo_id = be_geo_id or os.environ.get("BE_GEO_ID")
185+
caller = caller or os.environ.get("WEBEX_PYTHON_SDK_CALLER")
178186

179187
# If an access token hasn't been provided as a parameter, environment
180188
# variable, or obtained via an OAuth exchange raise an error.
@@ -197,15 +205,17 @@ def __init__(self, access_token=None, base_url=DEFAULT_BASE_URL,
197205
proxies=proxies,
198206
be_geo_id=be_geo_id,
199207
caller=caller,
200-
disable_ssl_verify=disable_ssl_verify
208+
disable_ssl_verify=disable_ssl_verify,
201209
)
202210

203211
# API wrappers
204212
self.admin_audit_events = AdminAuditEventsAPI(
205-
self._session, object_factory,
213+
self._session,
214+
object_factory,
206215
)
207216
self.attachment_actions = AttachmentActionsAPI(
208-
self._session, object_factory,
217+
self._session,
218+
object_factory,
209219
)
210220
self.events = EventsAPI(self._session, object_factory)
211221
self.guest_issuer = GuestIssuerAPI(self._session, object_factory)
@@ -218,13 +228,16 @@ def __init__(self, access_token=None, base_url=DEFAULT_BASE_URL,
218228
self.rooms = RoomsAPI(self._session, object_factory)
219229
self.teams = TeamsAPI(self._session, object_factory)
220230
self.team_memberships = TeamMembershipsAPI(
221-
self._session, object_factory,
231+
self._session,
232+
object_factory,
222233
)
223234
self.webhooks = WebhooksAPI(self._session, object_factory)
224235
self.recordings = RecordingsAPI(self._session, object_factory)
236+
self.recording_report = RecordingReportAPI(self._session, object_factory)
225237
self.meetings = MeetingsAPI(self._session, object_factory)
226238
self.meeting_templates = MeetingTemplatesAPI(self._session, object_factory)
227239
self.meeting_invitees = MeetingInviteesAPI(self._session, object_factory)
240+
228241
@property
229242
def access_token(self):
230243
"""The access token used for API calls to the Webex Teams service."""
@@ -277,8 +290,7 @@ def from_oauth_code(cls, client_id, client_secret, code, redirect_uri):
277290
TypeError: If the parameter types are incorrect.
278291
ApiError: If the Webex Teams cloud returns an error.
279292
"""
280-
token_obj = cls.access_tokens.get(client_id, client_secret, code,
281-
redirect_uri)
293+
token_obj = cls.access_tokens.get(client_id, client_secret, code, redirect_uri)
282294

283295
return cls(access_token=token_obj.access_token)
284296

@@ -304,6 +316,5 @@ def from_oauth_refresh(cls, client_id, client_secret, refresh_token):
304316
TypeError: If the parameter types are incorrect.
305317
ApiError: If the Webex Teams cloud returns an error.
306318
"""
307-
token_obj = cls.access_tokens.refresh(client_id, client_secret,
308-
refresh_token)
319+
token_obj = cls.access_tokens.refresh(client_id, client_secret, refresh_token)
309320
return cls(access_token=token_obj.access_token)

webexteamssdk/api/recording_report.py

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
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+
33+
from past.builtins import basestring
34+
35+
from webexteamssdk.generator_containers import generator_container
36+
from webexteamssdk.restsession import RestSession
37+
from webexteamssdk.utils import check_type, dict_from_items_with_values
38+
39+
API_ENDPOINT = "recordingReport"
40+
OBJECT_TYPE = "recording_report"
41+
42+
43+
class RecordingReportAPI(object):
44+
"""Webex Teams Recording report API.
45+
46+
Wraps the Webex Teams Recording report API and exposes the API as native Python
47+
methods that return native Python objects.
48+
49+
"""
50+
51+
def __init__(self, session, object_factory):
52+
"""Init a new RecordingReportAPI object with the provided RestSession.
53+
54+
Args:
55+
session(RestSession): The RESTful session object to be used for
56+
API calls to the Webex Teams service.
57+
58+
Raises:
59+
TypeError: If the parameter types are incorrect.
60+
61+
"""
62+
check_type(session, RestSession)
63+
super(RecordingReportAPI, self).__init__()
64+
self._session = session
65+
self._object_factory = object_factory
66+
67+
@generator_container
68+
def access_summary(
69+
self,
70+
max=None,
71+
_from=None,
72+
to=None,
73+
hostEmail="all",
74+
siteUrl=None,
75+
**request_parameters,
76+
):
77+
"""Lists recording audit report summary.
78+
You can specify a date range, a parent meeting ID and the maximum number of recordings to return.
79+
80+
Only recordings of meetings hosted by or shared with the authenticated user will be listed.
81+
The list returned is sorted in descending order by the date and time that the recordings were created.
82+
83+
This method supports Webex Teams's implementation of RFC5988 Web
84+
Linking to provide pagination support. It returns a generator
85+
container that incrementally yields all recordings returned by the
86+
query. The generator will automatically request additional 'pages' of
87+
responses from Webex as needed until all responses have been returned.
88+
The container makes the generator safe for reuse. A new API call will
89+
be made, using the same parameters that were specified when the
90+
generator was created, every time a new iterator is requested from the
91+
container.
92+
93+
Args:
94+
max(int): Limit the maximum number of items returned from the Webex
95+
Teams service per request.
96+
_from(basestring): List recording audit report which occurred after a specific
97+
date and time.
98+
to(basestring): List recording audit report which occurred before a specific date
99+
and time.
100+
hostEmail(basestring): Email address of meeting host. Default is "all".
101+
siteUrl(basestring): URL of the Webex site which the API lists recordings from.
102+
**request_parameters: Additional request parameters (provides
103+
support for parameters that may be added in the future).
104+
105+
Returns:
106+
GeneratorContainer: A GeneratorContainer which, when iterated,
107+
yields the recordings returned by the Webex Teams query.
108+
109+
Raises:
110+
TypeError: If the parameter types are incorrect.
111+
ApiError: If the Webex Teams cloud returns an error.
112+
"""
113+
check_type(max, int, optional=True)
114+
check_type(_from, basestring, optional=True)
115+
check_type(to, basestring, optional=True)
116+
check_type(hostEmail, basestring, optional=True)
117+
check_type(siteUrl, basestring, optional=True)
118+
119+
params = dict_from_items_with_values(
120+
request_parameters,
121+
max_recordings=max,
122+
_from=_from,
123+
to=to,
124+
hostEmail=hostEmail,
125+
siteUrl=siteUrl,
126+
)
127+
128+
items = self._session.get_items(API_ENDPOINT + "/accessSummary", params=params)
129+
130+
for item in items:
131+
yield self._object_factory(OBJECT_TYPE, item)
132+
133+
def access_detail(
134+
self, recordingId, max=None, hostEmail=None, **request_parameters
135+
):
136+
"""Retrieves details for a recording audit report with a specified recording ID.
137+
138+
Args:
139+
recordingId(basestring): The ID of the recording to be retrieved.
140+
max(int): Limit the maximum number of items returned from the Webex
141+
Teams service per request.
142+
hostEmail(basestring): Email address of meeting host.
143+
144+
Returns:
145+
Recording: A RecordingReport object with the details of the requested
146+
recording.
147+
148+
Raises:
149+
TypeError: If the parameter types are incorrect.
150+
ApiError: If the Webex Teams cloud returns an error.
151+
152+
"""
153+
check_type(max, int, optional=True)
154+
check_type(recordingId, basestring)
155+
check_type(hostEmail, basestring, optional=True)
156+
157+
params = dict_from_items_with_values(
158+
request_parameters,
159+
max=max,
160+
recordingId=recordingId,
161+
hostEmail=hostEmail,
162+
)
163+
164+
json_data = self._session.get(API_ENDPOINT + "/accessDetail", params=params)
165+
166+
return self._object_factory(OBJECT_TYPE, json_data)

0 commit comments

Comments
 (0)