|
| 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 | + |
0 commit comments