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:
|
:return:
|
||||||
"""
|
"""
|
||||||
body = request.get_json()
|
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:
|
try:
|
||||||
userobj = self.userschema.load(body)
|
userobj = self.userschema.load(body)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@ -206,7 +210,11 @@ class CreateIngestResource(Resource):
|
|||||||
|
|
||||||
username = get_jwt_identity()
|
username = get_jwt_identity()
|
||||||
# username = "jozska"
|
# 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.owner_id = user.id
|
||||||
ingest.stream_key = str(uuid4())
|
ingest.stream_key = str(uuid4())
|
||||||
try:
|
try:
|
||||||
@ -254,7 +262,11 @@ class CreateRestreamResource(Resource):
|
|||||||
|
|
||||||
username = get_jwt_identity()
|
username = get_jwt_identity()
|
||||||
# username = "jozska"
|
# 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.owner_id = user.id
|
||||||
restream.stream_key = str(uuid4())
|
restream.stream_key = str(uuid4())
|
||||||
if 'inputNeighbour' in restreamobj:
|
if 'inputNeighbour' in restreamobj:
|
||||||
@ -301,7 +313,11 @@ class CreateEncodeResource(Resource):
|
|||||||
|
|
||||||
username = get_jwt_identity()
|
username = get_jwt_identity()
|
||||||
# username = "jozska"
|
# 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.owner_id = user.id
|
||||||
encoder.stream_key = str(uuid4())
|
encoder.stream_key = str(uuid4())
|
||||||
if 'inputNeighbour' in encoderobj:
|
if 'inputNeighbour' in encoderobj:
|
||||||
@ -349,8 +365,16 @@ class GetAllStreamResources(Resource):
|
|||||||
def get(self):
|
def get(self):
|
||||||
username = get_jwt_identity()
|
username = get_jwt_identity()
|
||||||
# username = "jozska"
|
# username = "jozska"
|
||||||
user = VideonUser.query.filter_by(name=username).first_or_404()
|
try:
|
||||||
streamreousrces = StreamResource.query.filter_by(owner_id=user.id).all()
|
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
|
return self.streamresourceschema.dump(streamreousrces), 200
|
||||||
|
|
||||||
|
|
||||||
@ -366,8 +390,16 @@ class ManipulateStreamResource(Resource):
|
|||||||
"""
|
"""
|
||||||
username = get_jwt_identity()
|
username = get_jwt_identity()
|
||||||
# username = "jozska"
|
# username = "jozska"
|
||||||
user = VideonUser.query.filter_by(name=username).first_or_404()
|
try:
|
||||||
streamreousrce = StreamResource.query.filter_by(id=UUID(resourceid), owner_id=user.id).first_or_404()
|
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
|
return self.streamresourceschema.dump(streamreousrce), 200
|
||||||
|
|
||||||
@jwt_required
|
@jwt_required
|
||||||
@ -379,9 +411,16 @@ class ManipulateStreamResource(Resource):
|
|||||||
"""
|
"""
|
||||||
username = get_jwt_identity()
|
username = get_jwt_identity()
|
||||||
# username = "jozska"
|
# username = "jozska"
|
||||||
user = VideonUser.query.filter_by(name=username).first_or_404()
|
try:
|
||||||
streamreousrce = StreamResource.query.filter_by(id=UUID(resourceid), owner_id=user.id).first_or_404()
|
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:
|
try:
|
||||||
db.session.delete(streamreousrce)
|
db.session.delete(streamreousrce)
|
||||||
Kubectl(name=streamreousrce.id, resourcetype=streamreousrce.resource_type).delete_resource()
|
Kubectl(name=streamreousrce.id, resourcetype=streamreousrce.resource_type).delete_resource()
|
||||||
@ -412,8 +451,16 @@ class ModifyIngressResource(Resource):
|
|||||||
|
|
||||||
username = get_jwt_identity()
|
username = get_jwt_identity()
|
||||||
# username = "jozska"
|
# username = "jozska"
|
||||||
user = VideonUser.query.filter_by(name=username).first_or_404()
|
try:
|
||||||
ingest = StreamResource.query.filter_by(id=resourceid, owner_id=user.id).first_or_404()
|
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.x = ingestobj['x']
|
||||||
ingest.y = ingestobj['y']
|
ingest.y = ingestobj['y']
|
||||||
|
|
||||||
@ -473,8 +520,16 @@ class ModifyRestreamResource(Resource):
|
|||||||
|
|
||||||
username = get_jwt_identity()
|
username = get_jwt_identity()
|
||||||
# username = "jozska"
|
# username = "jozska"
|
||||||
user = VideonUser.query.filter_by(name=username).first_or_404()
|
try:
|
||||||
restream = StreamResource.query.filter_by(id=resourceid, owner_id=user.id).first_or_404()
|
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.x = restreamobj['x']
|
||||||
restream.y = restreamobj['y']
|
restream.y = restreamobj['y']
|
||||||
|
|
||||||
@ -533,8 +588,16 @@ class ModifyEncodeResource(Resource):
|
|||||||
|
|
||||||
username = get_jwt_identity()
|
username = get_jwt_identity()
|
||||||
# username = "jozska"
|
# username = "jozska"
|
||||||
user = VideonUser.query.filter_by(name=username).first_or_404()
|
try:
|
||||||
encode = StreamResource.query.filter_by(id=resourceid, owner_id=user.id).first_or_404()
|
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.x = encodeobj['x']
|
||||||
encode.y = encodeobj['y']
|
encode.y = encodeobj['y']
|
||||||
|
|
||||||
@ -606,8 +669,16 @@ class CoordModifyResource(Resource):
|
|||||||
|
|
||||||
username = get_jwt_identity()
|
username = get_jwt_identity()
|
||||||
# username = "jozska"
|
# username = "jozska"
|
||||||
user = VideonUser.query.filter_by(name=username).first_or_404()
|
try:
|
||||||
resource = StreamResource.query.filter_by(id=resourceid, owner_id=user.id).first_or_404()
|
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.x = coordobj['x']
|
||||||
resource.y = coordobj['y']
|
resource.y = coordobj['y']
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user