Source code for luna_handlers.classes.schemas.sdk

"""
Module contains schemas for sdk handler
"""
from typing import Optional

from pydantic import conlist, root_validator

from classes.schemas.base_schema import BaseSchema
from classes.schemas.handler import SamplesIDs, UrlsWithFaceAndBodyBBox
from classes.schemas.simple_schemas import BoundingBoxSchema
from classes.schemas.types import OptionalNotNullable
from classes.schemas.validators import checkRequiredImageMimetype, validateOneOfStrParams


[docs]class SDKInputEstimationsModel(BaseSchema): """SDK model for incoming estimations: urls, samples or image with/without face/body bounding boxes""" # image (base64) image: Optional[str] # image mimetype mimetype: Optional[str] # face bounding box list faceBoundingBoxes: conlist(BoundingBoxSchema, min_items=1) = OptionalNotNullable() # body bounding box list bodyBoundingBoxes: conlist(BoundingBoxSchema, min_items=1) = OptionalNotNullable() # url list urls: UrlsWithFaceAndBodyBBox = OptionalNotNullable() # sample ids samples: SamplesIDs = OptionalNotNullable()
[docs] @root_validator(skip_on_failure=True) def validateHandler(cls, values: dict) -> dict: """Validate handler model""" validateOneOfStrParams(values, params=["urls", "samples", "image"]) checkRequiredImageMimetype(values) return values