Handler events handler

Receive events on handler

class luna_handlers.app.handlers.handler_events_handler.HandlerEventsHandler(request)[source]

Receiver of events.

Resource: “/{api_version}/handlers/{handlerId}/events”

checkPolicyLicensing(policies)[source]

Check handler policies licensing :param policies: handler policies

async getDataFromMultipart(imageType=ImageType.IMAGE)[source]

Get data from multipart request :param imageType: image type

Returns:

list of Images or list warps and optionally dict with policies (for multipart request with policies)

Return type:

Tuple[List[InputImage], Optional[dict]]

getEventTimes()[source]

Get event times from header.

Supported headers:

Luna-Event-Time - event creation time Luna-Event-End-Time - event end time

Returns:

tuple with create and end event times

Return type:

tuple[str, str]

async getInputEstimationData(request, validationModel, imageType=ImageType.IMAGE, allowRawDescriptors=True)[source]

Get images from request body to detect faces and, optionally, policies for a dynamic handler. :param request: request :param imageType: imageType :param validationModel: validation model :param allowRawDescriptors: whether raw descriptor mimetypes allowed or not

Returns:

list of Images or list warps and, optionally, policies for a dynamic handler.

Return type:

Tuple[List[InputImage], Optional[dict]]

async loadHandlerAndInputImages(handlerId)[source]

Prepare handler and input images for processing.

If handler is static, policies are loaded from the database. If handler is dynamic, policies are required to be in the input request (multipart).

Parameters:

handlerId – handler id

Returns:

tuple with handler object, input images, version of cached handler or None

Return type:

tuple[CachedHandlerModel, List[InputImage], datetime]

loadLocation()[source]

Load location data from the query parameters.

Returns:

location

Return type:

Location

parseTimeFromHeader(name, defaultTime)[source]

Parse datetime from header by name.

Parameters:
  • name – header name

  • defaultTime – default time

Returns:

user datetime if correct header or default datetime

Return type:

datetime

async post(handlerId)[source]

Receive events handler. See spec receive_events.

Parameters:

handlerId – handler id

Returns:

Response with events and detections

Raises:

VLException(Error.BadMultipartInput, 400, isCriticalError=False) – if failed to read multipart

Return type:

HTTPResponse

preparePolicyConfig()[source]

Prepare config container for policies.