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:
parent
5e8f235857
commit
4a7bd11324
@ -11,7 +11,6 @@ data:
|
||||
RELEASE_ID: kmlabz-k8s
|
||||
RELEASEMODE: release
|
||||
JWT_SECRET_KEY: hzukalkhsdgsbnakdjaksdghikyxbhhatzig
|
||||
REGISTER_DISABLED: "False"
|
||||
SQLALCHEMY_DATABASE_URI: postgresql://username:password@server/database?sslmode=require
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
|
@ -15,7 +15,7 @@ from marshm import ma
|
||||
from healthchecks import health_database_status
|
||||
from resources import SignupApi, LoginApi, UsersApi, UserParameterApi, CreateIngestResource, CreateEncodeResource, \
|
||||
CreateRestreamResource, ManipulateStreamResource, GetAllStreamResources, ModifyEncodeResource, \
|
||||
ModifyIngressResource, ModifyRestreamResource
|
||||
ModifyIngressResource, ModifyRestreamResource, CoordModifyResource
|
||||
|
||||
"""
|
||||
Main Flask RESTful API
|
||||
@ -49,7 +49,6 @@ ma.init_app(app)
|
||||
bcrypt.init_app(app)
|
||||
jwtman.init_app(app)
|
||||
|
||||
# api.add_resource(SampleResource, "/sample")
|
||||
api.add_resource(SignupApi, '/api/auth/signup')
|
||||
api.add_resource(LoginApi, '/api/auth/login')
|
||||
api.add_resource(UsersApi, '/api/users')
|
||||
@ -62,6 +61,7 @@ api.add_resource(GetAllStreamResources, '/api/objects/streamerobjects')
|
||||
api.add_resource(ModifyEncodeResource, '/api/objects/streamerobjects/encode/<resourceid>')
|
||||
api.add_resource(ModifyIngressResource, '/api/objects/streamerobjects/ingest/<resourceid>')
|
||||
api.add_resource(ModifyRestreamResource, '/api/objects/streamerobjects/restream/<resourceid>')
|
||||
api.add_resource(CoordModifyResource, '/api/objects/streamerobjects/coordmodify/<resourceid>')
|
||||
|
||||
health.add_check(health_database_status)
|
||||
app.add_url_rule("/healthz", "healthcheck", view_func=lambda: health.run())
|
||||
|
@ -20,5 +20,3 @@ RELEASEMODE = os.environ.get("RELEASEMODE", "dev")
|
||||
SQLALCHEMY_DATABASE_URI = os.getenv("SQLALCHEMY_DATABASE_URI", "sqlite://")
|
||||
|
||||
JWT_SECRET_KEY = os.getenv("JWT_SECRET_KEY", str(uuid4()))
|
||||
|
||||
REGISTER_DISABLED = os.getenv("REGISTER_DISABLED", "FALSE").upper() == "TRUE"
|
||||
|
@ -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
|
||||
|
@ -65,6 +65,11 @@ class RestreamInputSchema(ma.Schema):
|
||||
y = fields.Integer(required=True)
|
||||
|
||||
|
||||
class CoordInputSchema(ma.Schema):
|
||||
x = fields.Integer(required=True)
|
||||
y = fields.Integer(required=True)
|
||||
|
||||
|
||||
class OutputUrlSchema(ma.SQLAlchemyAutoSchema):
|
||||
"""
|
||||
Marshmallow schema generated
|
||||
|
Loading…
Reference in New Issue
Block a user