def _validate_session(self, request_body): session = {} data = json.loads(request_body) session['recording_id'] = data.get("recording_id", "") session['uwnetid'] = data.get("uwnetid", "") session['name'] = self._valid_recording_name(data.get("name", "").strip()) session['external_id'] = self._valid_external_id( data.get("external_id", "").strip()) session['recorder_id'] = self._valid_recorder_id( data.get("recorder_id", "").strip()) session['folder_external_id'] = data.get( "folder_external_id", "").strip() session['session_id'] = data.get("session_id", "").strip() if len(session['session_id']): self._valid_external_id(session['session_id']) # do not permit param tamperings key = course_event_key(session['uwnetid'], session['name'], session['external_id'], session['recorder_id']) if key != data.get("key", ''): raise InvalidParamException('Invalid Client Key') session['is_broadcast'] = self._valid_boolean(data.get("is_broadcast", False)) session['is_public'] = self._valid_boolean(data.get("is_public", False)) session['start_time'] = self._valid_time(data.get("start_time", "").strip()) session['end_time'] = self._valid_time(data.get("end_time", "").strip()) session['folder_name'] = data.get("folder_name", "").strip() session['folder_id'] = self._valid_folder(session['folder_name'], session['folder_external_id']) session['folder_creators'] = data.get("creators", None) return session
def DELETE(self, request, **kwargs): try: session_id = self._valid_recorder_id(kwargs.get('session_id')) # do not permit param tampering key = course_event_key(request.GET.get('uwnetid', ''), request.GET.get('name', ''), request.GET.get('eid', ''), request.GET.get('rid', '')) if key != request.GET.get("key", None): raise InvalidParamException('Invalid Client Key') self._session_api.deleteSessions([session_id]) self._audit_log.info('%s deleted session %s' % (request.user, session_id)) return self.json_response({ 'deleted_recording_id': session_id }) except InvalidParamException as err: return self.error_response(400, "Invalid Parameter: %s" % err)