"""
Module contains request class for agent lambda
"""
from luna_lambda_tools.private.request import BaseLambdaRequest, ClientsKwargsMixin
from ..clients import LIS, LRS, LVA, AgentClients, Api, Events, Handlers, Sender
[docs]
class AgentLambdaRequest(BaseLambdaRequest, ClientsKwargsMixin):
"""Base lambda request"""
[docs]
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.external = self.app.ctx.external
self._clients: AgentClients | None = None
def _getClients(self):
"""Get lambda agent clients. External or internal"""
if self.external:
return AgentClients(
api=Api.fromCommonClient(self._session.apiSession.getClient(self.requestId)),
faces=None,
events=None,
matcher=None,
objectOriginStore=None,
faceSamplesStore=None,
bodySamplesStore=None,
imageOriginStore=None,
sdk=None,
videoAgent=None,
sender=None,
handlers=None,
)
eventsKw = self._getEventsClientKwargs()
faceSamplesKw = self._getFacesSamplesClientKwargs()
bodySamplesKw = self._getBodySamplesClientKwargs()
imageOriginKw = self._getImageOriginClientKwargs()
lvaKw = self._getLVAClientKwargs()
senderKw = self._getSenderClientKwargs()
handlersKw = self._getHandlersClientKwargs()
lrsKw = self._getLRSClientKwargs()
return AgentClients(
faces=None,
events=Events(**eventsKw) if eventsKw else None,
matcher=None,
objectOriginStore=None,
faceSamplesStore=LIS(**faceSamplesKw) if faceSamplesKw else None,
bodySamplesStore=LIS(**bodySamplesKw) if bodySamplesKw else None,
imageOriginStore=LIS(**imageOriginKw) if imageOriginKw else None,
sdk=LRS(**lrsKw) if lrsKw else None,
videoAgent=LVA(**lvaKw) if lvaKw else None,
sender=Sender(**senderKw) if senderKw else None,
handlers=Handlers(**handlersKw) if handlersKw else None,
)
@property
def clients(self):
if self._clients is None:
self._clients = self._getClients()
return self._clients