Source code for luna_api.app.handlers.liveness_handler

from sanic.views import HTTPMethodView

from crutches_on_wheels.errors.errors import Error
from crutches_on_wheels.errors.exception import VLException

from ..app import ApiRequest
from .liveness_v1_handler import LivenessV1Handler
from .liveness_v2_handler import LivenessV2Handler


[docs]class LivenessHandler(HTTPMethodView): """ Liveness handler. """
[docs] def post(self, request: ApiRequest): """ Process post request according to service settings. """ if not request.app.ctx.licenseChecker.licenseState.liveness.value: raise VLException(Error.LicenseProblem.format("Liveness feature disabled"), 403, False) if request.config.additionalServicesUsage.liveness: if request.app.ctx.licenseChecker.licenseState.liveness.value != 1: raise VLException( Error.LicenseProblem.format("Liveness v.1 feature disabled"), 403, False, ) reply = LivenessV1Handler(request).post() else: if request.app.ctx.licenseChecker.licenseState.liveness.value != 2: raise VLException( Error.LicenseProblem.format("Liveness v.2 feature disabled"), 403, False, ) reply = LivenessV2Handler(request).post() return reply