portier/source/portier/api.py

37 lines
1.4 KiB
Python

from ninja import NinjaAPI, ModelSchema, Router
from ninja.security import django_auth
from django.contrib.auth.models import User
import config.api as config_api
#from config.api import router as config_router
#from config.api.recorder import router as config_recorder_router
#from config.api.recorder import router as config_recorder_router
from concierge.api import router as concierge_router
core_router = Router()
class UserSchema(ModelSchema):
class Meta:
model = User
fields = ["id", "username", "email", "is_staff", "is_superuser", "first_name", "last_name"]
@core_router.get("/me", response=UserSchema)
def me(request):
return request.user
api = NinjaAPI(
title="Portier API",
version="2.0.0",
description="HTTP API for Portier. Use this to interact with the Portier backend.",
csrf=False, # Disable CSRF for now
)
api.add_router("/", core_router, auth=django_auth, tags=["Core API"])
api.add_router("/config/recorder/", config_api.recorder.router, auth=django_auth, tags=["Recorder Configuration API"])
api.add_router("/config/pull/", config_api.pull.router, auth=django_auth, tags=["Pull Configuration API"])
api.add_router("/config/stream/", config_api.stream.router, auth=django_auth, tags=["Stream Configuration API"])
api.add_router("/config/restream/", config_api.restream.router, auth=django_auth, tags=["Resteam Configuration API"])
api.add_router("/concierge/", concierge_router, auth=None, tags=["Concierge API"])