add coord modify resource
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -9,7 +9,7 @@ from flask import request, current_app, abort
|
||||
from db import db
|
||||
from models import VideonUser, StreamResource, StreamResourceTypeEnum, OutputUrls
|
||||
from schemas import UserSchema, UserMetadataSchema, StreamResourceSchema, IngestInputSchema, EncodeInputSchema, \
|
||||
RestreamInputSchema
|
||||
RestreamInputSchema, CoordInputSchema
|
||||
from config import REGISTER_DISABLED
|
||||
import listdiffer
|
||||
from kuberclient import Kubectl
|
||||
@@ -526,5 +526,36 @@ class ModifyEncodeResource(Resource):
|
||||
current_app.logger.warning(e)
|
||||
abort(503, "could not remove neighbourhood")
|
||||
|
||||
childurls = []
|
||||
for child in encode.children:
|
||||
childurls.append(child.url)
|
||||
|
||||
Kubectl(name=encode.id, resourcetype="encoder",
|
||||
stream_key=encode.stream_key, encode_push_urls=str(childurls)).update_resource()
|
||||
|
||||
db.session.commit()
|
||||
return self.streamresourceschema.dump(encode), 200
|
||||
|
||||
|
||||
class CoordModifyResource(Resource):
|
||||
"""
|
||||
See: https://swagger.kmlabz.com/?urls.primaryName=videON%20Backend#/backend/editCoords
|
||||
"""
|
||||
coordinputschema = CoordInputSchema(many=False)
|
||||
streamresourceschema = StreamResourceSchema(many=False)
|
||||
|
||||
def put(self, resourceid: str):
|
||||
body = request.get_json()
|
||||
|
||||
try:
|
||||
coordobj = self.coordinputschema.load(body)
|
||||
except Exception as e:
|
||||
current_app.logger.warning(e)
|
||||
abort(417, INVALID_JSON_SCHEMA_MSG)
|
||||
|
||||
resource = StreamResource.query.filter_by(id=resourceid).first_or_404()
|
||||
resource.x = coordobj['x']
|
||||
resource.y = coordobj['y']
|
||||
|
||||
db.session.commit()
|
||||
return self.streamresourceschema.dump(resource), 200
|
||||
|
||||
Reference in New Issue
Block a user