Source code for luna_faces.app.handlers.attribute_samples_handler

"""
Module realize handler for getting attribute samples.
"""
from itertools import chain

from sanic.response import HTTPResponse

from app.handlers.base_handler import AttributesBaseRequestHandler
from crutches_on_wheels.web.query_getters import uuidGetter


[docs]class AttributeSamplesHandler(AttributesBaseRequestHandler): """ Handler for getting all attribute samples. Resource: "/{api_version}/attributes/{attributeId}/samples" """
[docs] async def get(self, attributeId: str) -> HTTPResponse: """ Get temporary attribute. See `spec_get_attribute_samples`_. .. _spec_get_attribute_samples: _static/api.html#operation/getAttributeSamples Returns: response json samples """ accountId = self.getQueryParam("account_id", uuidGetter) attributes = await self.attributesContext.get(attributeId=attributeId, accountId=accountId) samples = {"samples": list(set(chain(attributes.basicAttributesSamples, attributes.descriptorSamples)))} return self.success(200, outputJson=samples)