This commit is contained in:
parent
3f682dd031
commit
84d307a8e6
109
src/resources.py
109
src/resources.py
@ -165,7 +165,11 @@ class UserParameterApi(Resource):
|
||||
:return:
|
||||
"""
|
||||
body = request.get_json()
|
||||
user = VideonUser.query.filter_by(name=username).first_or_404()
|
||||
try:
|
||||
user = VideonUser.query.filter_by(name=username).first_or_404()
|
||||
except Exception as e:
|
||||
current_app.logger.warning(e)
|
||||
abort(404, "could not find user")
|
||||
try:
|
||||
userobj = self.userschema.load(body)
|
||||
except Exception as e:
|
||||
@ -206,7 +210,11 @@ class CreateIngestResource(Resource):
|
||||
|
||||
username = get_jwt_identity()
|
||||
# username = "jozska"
|
||||
user = VideonUser.query.filter_by(name=username).first_or_404()
|
||||
try:
|
||||
user = VideonUser.query.filter_by(name=username).first_or_404()
|
||||
except Exception as e:
|
||||
current_app.logger.warning(e)
|
||||
abort(404, "could not find user")
|
||||
ingest.owner_id = user.id
|
||||
ingest.stream_key = str(uuid4())
|
||||
try:
|
||||
@ -254,7 +262,11 @@ class CreateRestreamResource(Resource):
|
||||
|
||||
username = get_jwt_identity()
|
||||
# username = "jozska"
|
||||
user = VideonUser.query.filter_by(name=username).first_or_404()
|
||||
try:
|
||||
user = VideonUser.query.filter_by(name=username).first_or_404()
|
||||
except Exception as e:
|
||||
current_app.logger.warning(e)
|
||||
abort(404, "could not find user")
|
||||
restream.owner_id = user.id
|
||||
restream.stream_key = str(uuid4())
|
||||
if 'inputNeighbour' in restreamobj:
|
||||
@ -301,7 +313,11 @@ class CreateEncodeResource(Resource):
|
||||
|
||||
username = get_jwt_identity()
|
||||
# username = "jozska"
|
||||
user = VideonUser.query.filter_by(name=username).first_or_404()
|
||||
try:
|
||||
user = VideonUser.query.filter_by(name=username).first_or_404()
|
||||
except Exception as e:
|
||||
current_app.logger.warning(e)
|
||||
abort(404, "could not find user")
|
||||
encoder.owner_id = user.id
|
||||
encoder.stream_key = str(uuid4())
|
||||
if 'inputNeighbour' in encoderobj:
|
||||
@ -349,8 +365,16 @@ class GetAllStreamResources(Resource):
|
||||
def get(self):
|
||||
username = get_jwt_identity()
|
||||
# username = "jozska"
|
||||
user = VideonUser.query.filter_by(name=username).first_or_404()
|
||||
streamreousrces = StreamResource.query.filter_by(owner_id=user.id).all()
|
||||
try:
|
||||
user = VideonUser.query.filter_by(name=username).first_or_404()
|
||||
except Exception as e:
|
||||
current_app.logger.warning(e)
|
||||
abort(404, "could not find user")
|
||||
try:
|
||||
streamreousrces = StreamResource.query.filter_by(owner_id=user.id).all()
|
||||
except Exception as e:
|
||||
current_app.logger.warning(e)
|
||||
abort(422, "invalid arguments")
|
||||
return self.streamresourceschema.dump(streamreousrces), 200
|
||||
|
||||
|
||||
@ -366,8 +390,16 @@ class ManipulateStreamResource(Resource):
|
||||
"""
|
||||
username = get_jwt_identity()
|
||||
# username = "jozska"
|
||||
user = VideonUser.query.filter_by(name=username).first_or_404()
|
||||
streamreousrce = StreamResource.query.filter_by(id=UUID(resourceid), owner_id=user.id).first_or_404()
|
||||
try:
|
||||
user = VideonUser.query.filter_by(name=username).first_or_404()
|
||||
except Exception as e:
|
||||
current_app.logger.warning(e)
|
||||
abort(404, "could not find user")
|
||||
try:
|
||||
streamreousrce = StreamResource.query.filter_by(id=UUID(resourceid), owner_id=user.id).first_or_404()
|
||||
except Exception as e:
|
||||
current_app.logger.warning(e)
|
||||
abort(422, "invalid arguments")
|
||||
return self.streamresourceschema.dump(streamreousrce), 200
|
||||
|
||||
@jwt_required
|
||||
@ -379,9 +411,16 @@ class ManipulateStreamResource(Resource):
|
||||
"""
|
||||
username = get_jwt_identity()
|
||||
# username = "jozska"
|
||||
user = VideonUser.query.filter_by(name=username).first_or_404()
|
||||
streamreousrce = StreamResource.query.filter_by(id=UUID(resourceid), owner_id=user.id).first_or_404()
|
||||
|
||||
try:
|
||||
user = VideonUser.query.filter_by(name=username).first_or_404()
|
||||
except Exception as e:
|
||||
current_app.logger.warning(e)
|
||||
abort(404, "could not find user")
|
||||
try:
|
||||
streamreousrce = StreamResource.query.filter_by(id=UUID(resourceid), owner_id=user.id).first_or_404()
|
||||
except Exception as e:
|
||||
current_app.logger.warning(e)
|
||||
abort(422, "invalid arguments")
|
||||
try:
|
||||
db.session.delete(streamreousrce)
|
||||
Kubectl(name=streamreousrce.id, resourcetype=streamreousrce.resource_type).delete_resource()
|
||||
@ -412,8 +451,16 @@ class ModifyIngressResource(Resource):
|
||||
|
||||
username = get_jwt_identity()
|
||||
# username = "jozska"
|
||||
user = VideonUser.query.filter_by(name=username).first_or_404()
|
||||
ingest = StreamResource.query.filter_by(id=resourceid, owner_id=user.id).first_or_404()
|
||||
try:
|
||||
user = VideonUser.query.filter_by(name=username).first_or_404()
|
||||
except Exception as e:
|
||||
current_app.logger.warning(e)
|
||||
abort(404, "could not find user")
|
||||
try:
|
||||
ingest = StreamResource.query.filter_by(id=resourceid, owner_id=user.id).first_or_404()
|
||||
except Exception as e:
|
||||
current_app.logger.warning(e)
|
||||
abort(422, "invalid arguments")
|
||||
ingest.x = ingestobj['x']
|
||||
ingest.y = ingestobj['y']
|
||||
|
||||
@ -473,8 +520,16 @@ class ModifyRestreamResource(Resource):
|
||||
|
||||
username = get_jwt_identity()
|
||||
# username = "jozska"
|
||||
user = VideonUser.query.filter_by(name=username).first_or_404()
|
||||
restream = StreamResource.query.filter_by(id=resourceid, owner_id=user.id).first_or_404()
|
||||
try:
|
||||
user = VideonUser.query.filter_by(name=username).first_or_404()
|
||||
except Exception as e:
|
||||
current_app.logger.warning(e)
|
||||
abort(404, "could not find user")
|
||||
try:
|
||||
restream = StreamResource.query.filter_by(id=resourceid, owner_id=user.id).first_or_404()
|
||||
except Exception as e:
|
||||
current_app.logger.warning(e)
|
||||
abort(422, "invalid arguments")
|
||||
restream.x = restreamobj['x']
|
||||
restream.y = restreamobj['y']
|
||||
|
||||
@ -533,8 +588,16 @@ class ModifyEncodeResource(Resource):
|
||||
|
||||
username = get_jwt_identity()
|
||||
# username = "jozska"
|
||||
user = VideonUser.query.filter_by(name=username).first_or_404()
|
||||
encode = StreamResource.query.filter_by(id=resourceid, owner_id=user.id).first_or_404()
|
||||
try:
|
||||
user = VideonUser.query.filter_by(name=username).first_or_404()
|
||||
except Exception as e:
|
||||
current_app.logger.warning(e)
|
||||
abort(404, "could not find user")
|
||||
try:
|
||||
encode = StreamResource.query.filter_by(id=resourceid, owner_id=user.id).first_or_404()
|
||||
except Exception as e:
|
||||
current_app.logger.warning(e)
|
||||
abort(422, "invalid arguments")
|
||||
encode.x = encodeobj['x']
|
||||
encode.y = encodeobj['y']
|
||||
|
||||
@ -606,8 +669,16 @@ class CoordModifyResource(Resource):
|
||||
|
||||
username = get_jwt_identity()
|
||||
# username = "jozska"
|
||||
user = VideonUser.query.filter_by(name=username).first_or_404()
|
||||
resource = StreamResource.query.filter_by(id=resourceid, owner_id=user.id).first_or_404()
|
||||
try:
|
||||
user = VideonUser.query.filter_by(name=username).first_or_404()
|
||||
except Exception as e:
|
||||
current_app.logger.warning(e)
|
||||
abort(404, "could not find user")
|
||||
try:
|
||||
resource = StreamResource.query.filter_by(id=resourceid, owner_id=user.id).first_or_404()
|
||||
except Exception as e:
|
||||
current_app.logger.warning(e)
|
||||
abort(422, "invalid arguments")
|
||||
resource.x = coordobj['x']
|
||||
resource.y = coordobj['y']
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user