Source code for luna_lambda_tools.public.clients.faces

"""
Module contains luna-faces client adapted for usage in lambda
"""

from typing import Awaitable

from luna3.common.http_objs import RawDescriptor
from luna3.common.luna_response import LunaResponse
from luna3.faces.faces import FacesApi


[docs] class Faces: """Luna-faces client"""
[docs] def __init__(self, facesClient: FacesApi, accountId: str): self._accountId = accountId self._facesClient = facesClient
[docs] def getAddress(self) -> str: """Get luna-faces address""" return self._facesClient.baseUri
[docs] def createFace( self, attributeId: str | None = None, basicAttributes: dict | None = None, descriptors: list[bytes | RawDescriptor] | None = None, descriptorSamples: list[str] = None, basicAttributesSamples: list[str] = None, eventId: str | None = None, userData: str | None = "", externalId: str | None = None, avatar: str | None = None, listIds: list[str] | None = None, raiseError=True, **kwargs, ) -> Awaitable[LunaResponse] | LunaResponse: """ Create new face in luna-faces Args: attributeId: attribute id descriptors: list of descriptors different versions descriptorSamples: list of warp image id from which the attribute was extracted. basicAttributes: dict with basic attributes (age, gender, ethnicity) basicAttributesSamples: list of warp image id from which the basic attribute was extracted. eventId: reference to event which created face userData: face user data externalId: external id of the face, if it has its own mapping in the system avatar: face avatar url listIds: created face will be attach to these lists raiseError: whether to raise LunaApiException in case of failure Returns: class:`~.LunaResponse` or *asyncio coroutine* with *LunaResponse*. In body of :class: `~.LunaResponse` json with created face id will be returned. """ return self._facesClient.createFace( accountId=self._accountId, attributeId=attributeId, basicAttributes=basicAttributes, descriptors=descriptors, descriptorSamples=descriptorSamples, basicAttributesSamples=basicAttributesSamples, eventId=eventId, userData=userData, externalId=externalId, avatar=avatar, listIds=listIds, raiseError=raiseError, **kwargs, )
[docs] def putFace( self, faceId: str, externalId: str | None = None, attributeId: str | None = None, basicAttributes: dict | None = None, descriptors: list[bytes | RawDescriptor] | None = None, descriptorSamples: list[str] = None, basicAttributesSamples: list[str] = None, eventId: str | None = None, userData: str | None = "", avatar: str | None = None, listIds: list[str] | None = None, raiseError=True, **kwargs, ) -> Awaitable[LunaResponse] | LunaResponse: """ Put face in luna-faces Args: faceId: external face id externalId: external id of the face, if it has its own mapping in the system attributeId: attribute id descriptors: list of descriptors different versions descriptorSamples: list of warp image id from which the attribute was extracted. basicAttributes: dict with basic attributes (age, gender, ethnicity) basicAttributesSamples: list of warp image id from which the basic attribute was extracted. eventId: reference to event which created face userData: face user data avatar: face avatar url listIds: created face will be attach to these lists raiseError: whether to raise LunaApiException in case of failure Returns: class:`~.LunaResponse` or *asyncio coroutine* with *LunaResponse*. In body of :class: `~.LunaResponse` json with face id will be returned. """ return self._facesClient.putFace( accountId=self._accountId, faceId=faceId, externalId=externalId, attributeId=attributeId, basicAttributes=basicAttributes, descriptors=descriptors, descriptorSamples=descriptorSamples, basicAttributesSamples=basicAttributesSamples, eventId=eventId, userData=userData, avatar=avatar, listIds=listIds, raiseError=raiseError, **kwargs, )
[docs] def patchFace( self, faceId: str, eventId: str | None = None, userData: str | None = None, externalId: str | None = None, avatar: str | None = None, raiseError=True, **kwargs, ) -> Awaitable[LunaResponse] | LunaResponse: """ Update face. You can update event id, user data, attribute id. Optional you can set, that face must belong to account. Args: faceId: face id eventId: new event id externalId: external id of the face, if it has its own mapping in the system userData: new user data avatar: face avatar url raiseError: whether to raise LunaApiException in case of failure Returns: class:`~.LunaResponse` or *asyncio coroutine* with *LunaResponse*. """ return self._facesClient.updateFace( faceId=faceId, accountId=self._accountId, eventId=eventId, userData=userData, externalId=externalId, avatar=avatar, raiseError=raiseError, **kwargs, )
[docs] def getFace( self, faceId: str, targets: list[str] | None = None, raiseError=True, **kwargs, ) -> Awaitable[LunaResponse] | LunaResponse: """ Get face by id. Optional you can set, that face must belong to account. Args: faceId: face id targets: targets to get face raiseError: whether to raise LunaApiException in case of failure Returns: class:`~.LunaResponse` or *asyncio coroutine* with *LunaResponse*. In body of :class: `~.LunaResponse` json with face will be returned. """ return self._facesClient.getFace( faceId=faceId, accountId=self._accountId, targets=targets, raiseError=raiseError, **kwargs, )
[docs] def getFaces( self, userData: str | None = None, eventId: str | None = None, listId: str | None = None, faceIds: list[str] | None = None, timeLt: str | None = None, timeGte: str | None = None, page: int | None = 1, pageSize: int | None = 10, attributeIds: list[str] | None = None, externalIds: list[str] | None = None, faceIdGte: str | None = None, faceIdLt: str | None = None, targets: list[str] | None = None, raiseError=True, **kwargs, ) -> Awaitable[LunaResponse] | LunaResponse: """ Get faces by filters. Optional you can set, that faces must belong to account. Args: userData: user data, part of user data, case insensitive eventId: event id listId: list id faceIds: face ids timeLt: upper bound of face create time timeGte: lower bound of face create time page: page count, default 1 pageSize: page size, default 10, unlimited if -1 attributeIds: attributes ids externalIds: list of external identifiers of persons, if they have their own mapping in the system faceIdGte: lower face id including boundary faceIdLt: upper face id excluding boundary targets: targets to get faces raiseError: whether to raise LunaApiException in case of failure Returns: class:`~.LunaResponse` or *asyncio coroutine* with *LunaResponse*. In body of :class: `~.LunaResponse` json with faces will be returned. """ return self._facesClient.getFaces( userData=userData, accountId=self._accountId, eventId=eventId, listId=listId, faceIds=faceIds, timeLt=timeLt, timeGte=timeGte, page=page, pageSize=pageSize, attributeIds=attributeIds, externalIds=externalIds, faceIdGte=faceIdGte, faceIdLt=faceIdLt, targets=targets, raiseError=raiseError, **kwargs, )
[docs] def headFace(self, faceId: str, raiseError: bool = True, **kwargs) -> Awaitable[LunaResponse] | LunaResponse: """ Check face existence by id. Optional you can set, that face must belong to account. Args: faceId: face id raiseError: whether to raise LunaApiException in case of failure Returns: class:`~.LunaResponse` or *asyncio coroutine* with *LunaResponse*. """ return self._facesClient.checkFace( faceId=faceId, accountId=self._accountId, raiseError=raiseError, **kwargs, )
[docs] def getFacesCount( self, userData: str | None = None, eventId: str | None = None, listId: str | None = None, faceIds: list[str] | None = None, timeLt: str | None = None, timeGte: str | None = None, attributeIds: list[str] | None = None, externalIds: list[str] | None = None, faceIdGte: str | None = None, faceIdLt: str | None = None, raiseError=True, **kwargs, ) -> Awaitable[LunaResponse] | LunaResponse: """ Count faces by filters. Optional you can set, that faces must belong to account. Args: userData: user data, part of user data, case insensitive eventId: event id listId: list id faceIds: face ids timeLt: upper bound of face create time timeGte: lower bound of face create time attributeIds: attributes ids externalIds: list of external identifiers of persons, if they have their own mapping in the system faceIdGte: lower face id including boundary faceIdLt: upper face id excluding boundary raiseError: whether to raise LunaApiException in case of failure Returns: class:`~.LunaResponse` or *asyncio coroutine* with *LunaResponse*. In body of :class: `~.LunaResponse` json with number of faces will be returned. """ return self._facesClient.getFacesCount( userData=userData, accountId=self._accountId, eventId=eventId, listId=listId, faceIds=faceIds, timeLt=timeLt, timeGte=timeGte, attributeIds=attributeIds, externalIds=externalIds, faceIdGte=faceIdGte, faceIdLt=faceIdLt, raiseError=raiseError, **kwargs, )
[docs] def deleteFace( self, faceId: str, raiseError=True, **kwargs, ) -> Awaitable[LunaResponse] | LunaResponse: """ Delete face. Optional you can set, that face must belong to account. Args: faceId: face id raiseError: whether to raise LunaApiException in case of failure Returns: class:`~.LunaResponse` or *asyncio coroutine* with *LunaResponse*. """ return self._facesClient.deleteFace( faceId=faceId, accountId=self._accountId, raiseError=raiseError, **kwargs, )
[docs] def deleteFaces( self, faceIds: list[str], ignore: int | None = None, raiseError=True, **kwargs, ) -> Awaitable[LunaResponse] | LunaResponse: """ Delete faces. Optional you can set, that faces must belong to account. Args: faceIds: face id list ignore: ignore non-existing faces raiseError: whether to raise LunaApiException in case of failure Returns: class:`~.LunaResponse` or *asyncio coroutine* with *LunaResponse*. """ return self._facesClient.deleteFaces( faceIds=faceIds, accountId=self._accountId, ignore=ignore, raiseError=raiseError, **kwargs, )
[docs] def createList( self, userData: str = "", listId: str | None = None, raiseError=True, **kwargs, ) -> Awaitable[LunaResponse] | LunaResponse: """ Create list. Args: userData: user data listId: custom list id to create the list raiseError: whether to raise LunaApiException in case of failure Returns: class:`~.LunaResponse` or *asyncio coroutine* with *LunaResponse*. In body of :class: `~.LunaResponse` json with created list id will be returned. """ return self._facesClient.createList( accountId=self._accountId, userData=userData, listId=listId, raiseError=raiseError, **kwargs, )
[docs] def patchList( self, listId: str, userData: str, raiseError=True, **kwargs, ) -> Awaitable[LunaResponse] | LunaResponse: """ Update user data of list. Optional you can set, that list must belong to account. Args: listId: list id userData: new user data raiseError: whether to raise LunaApiException in case of failure Returns: class:`~.LunaResponse` or *asyncio coroutine* with *LunaResponse*. """ return self._facesClient.updateListUserData( listId=listId, userData=userData, accountId=self._accountId, raiseError=raiseError, **kwargs, )
[docs] def headList( self, listId: str, raiseError=True, **kwargs, ) -> Awaitable[LunaResponse] | LunaResponse: """ Check list existence. Optional you can set, that list must belong to account. Args: listId: list id raiseError: whether to raise LunaApiException in case of failure Returns: class:`~.LunaResponse` or *asyncio coroutine* with *LunaResponse*. """ return self._facesClient.checkList( listId=listId, accountId=self._accountId, raiseError=raiseError, **kwargs, )
[docs] def getList( self, listId: str, page: int | None = 1, pageSize: int | None = 10, raiseError=True, **kwargs, ) -> Awaitable[LunaResponse] | LunaResponse: """ Get list. Optional you can set, that list must belong to account. Args: listId: list id page: page count, default 1 pageSize: page size, default 10 raiseError: whether to raise LunaApiException in case of failure Returns: class:`~.LunaResponse` or *asyncio coroutine* with *LunaResponse*. In body of :class: `~.LunaResponse` json with list will be returned. """ return self._facesClient.getList( listId=listId, accountId=self._accountId, page=page, pageSize=pageSize, raiseError=raiseError, **kwargs, )
[docs] def getLists( self, userData: str | None = None, userDataEq: str | None = None, createTimeLt: str | None = None, createTimeGte: str | None = None, lastUpdateTimeLt: str | None = None, lastUpdateTimeGte: str | None = None, listIds: list[str] | None = None, listIdLt: str | None = None, listIdGte: str | None = None, page: int | None = 1, pageSize: int | None = 10, raiseError=True, **kwargs, ) -> Awaitable[LunaResponse] | LunaResponse: """ Get lists. Optional you can set, that lists must belong to account. Args: userData: user data, part of user data, case sensitive userDataEq: user data, case sensitive createTimeLt: upper bound of list create time createTimeGte: lower bound of list create time including boundary lastUpdateTimeLt: upper bound of list last update time lastUpdateTimeGte: lower bound of list last update time including boundary listIdLt: upper bound of list id listIdGte: lower bound of list id including boundary listIds: list ids page: page, default 1 pageSize: page size, default 10 raiseError: whether to raise LunaApiException in case of failure Returns: class:`~.LunaResponse` or *asyncio coroutine* with *LunaResponse*. In body of :class: `~.LunaResponse` json with lists will be returned. """ return self._facesClient.getLists( userData=userData, userDataEq=userDataEq, accountId=self._accountId, createTimeLt=createTimeLt, createTimeGte=createTimeGte, lastUpdateTimeLt=lastUpdateTimeLt, lastUpdateTimeGte=lastUpdateTimeGte, listIds=listIds, listIdLt=listIdLt, listIdGte=listIdGte, page=page, pageSize=pageSize, raiseError=raiseError, **kwargs, )
[docs] def getListsCount( self, userData: str | None = None, userDataEq: str | None = None, createTimeLt: str | None = None, createTimeGte: str | None = None, lastUpdateTimeLt: str | None = None, lastUpdateTimeGte: str | None = None, listIds: list[str] | None = None, listIdLt: str | None = None, listIdGte: str | None = None, raiseError=True, **kwargs, ) -> Awaitable[LunaResponse] | LunaResponse: """ Get number of lists. Optional you can set, that lists must belong to account. Args: userData: user data, part of user data, case sensitive userDataEq: user data createTimeLt: upper bound of list create time createTimeGte: lower bound of list create time including boundary lastUpdateTimeLt: upper bound of list last update time lastUpdateTimeGte: lower bound of list last update time including boundary listIds: list ids listIdLt: upper bound of list id listIdGte: lower bound of list id including boundary raiseError: whether to raise LunaApiException in case of failure Returns: class:`~.LunaResponse` or *asyncio coroutine* with *LunaResponse*. In body of :class: `~.LunaResponse` json with number of lists will be returned. """ return self._facesClient.getListsCount( userData=userData, userDataEq=userDataEq, accountId=self._accountId, createTimeLt=createTimeLt, createTimeGte=createTimeGte, lastUpdateTimeLt=lastUpdateTimeLt, lastUpdateTimeGte=lastUpdateTimeGte, listIds=listIds, listIdLt=listIdLt, listIdGte=listIdGte, raiseError=raiseError, **kwargs, )
[docs] def deleteList( self, listId: str, withFaces: int = 0, raiseError: bool = True, **kwargs ) -> Awaitable[LunaResponse] | LunaResponse: """ Remove list. Optional you can set, that list must belong to account. Args: listId: list id withFaces: remove lists and all faces witch is contained in the lists raiseError: whether to raise LunaApiException in case of failure Returns: class:`~.LunaResponse` or *asyncio coroutine* with *LunaResponse*. """ return self._facesClient.deleteList( listId=listId, accountId=self._accountId, withFaces=withFaces, raiseError=raiseError, **kwargs, )
[docs] def deleteLists( self, listIds: list[str], withFaces: int = None, raiseError=True, **kwargs, ) -> Awaitable[LunaResponse] | LunaResponse: """ Delete lists. Optional you can set, that lists must belong to account. Args: listIds: ids of lists withFaces: remove lists and all the faces contained in the lists raiseError: whether to raise LunaApiException in case of failure Returns: class:`~.LunaResponse` or *asyncio coroutine* with *LunaResponse*. """ return self._facesClient.deleteLists( listIds=listIds, accountId=self._accountId, withFaces=withFaces, raiseError=raiseError, **kwargs, )
[docs] def linkFacesToList( self, listId: str, faceIds: list[str], raiseError=True, **kwargs, ) -> Awaitable[LunaResponse] | LunaResponse: """ Attach faces to list. Args: listId: list id faceIds: face ids raiseError: whether to raise LunaApiException in case of failure Returns: class:`~.LunaResponse` or *asyncio coroutine* with *LunaResponse*. """ return self._facesClient.link( listId=listId, faceIds=faceIds, action="attach", accountId=self._accountId, raiseError=raiseError, **kwargs, )
[docs] def unlinkFacesFromList( self, listId: str, faceIds: list[str], raiseError=True, **kwargs, ) -> Awaitable[LunaResponse] | LunaResponse: """ Detach faces to list. Args: listId: list id faceIds: face ids raiseError: whether to raise LunaApiException in case of failure Returns: class:`~.LunaResponse` or *asyncio coroutine* with *LunaResponse*. """ return self._facesClient.link( listId=listId, faceIds=faceIds, action="detach", accountId=self._accountId, raiseError=raiseError, **kwargs, )
[docs] def getAttributesFromList( self, listId: str, linkKeyLt: str | None = None, linkKeyGte: str | None = None, limit: int | None = 1000, parity: int | None = None, raiseError=True, **kwargs, ) -> Awaitable[LunaResponse] | LunaResponse: """ Get all attributes from list by period. Args: listId: list id linkKeyLt: upper including link key boundary linkKeyGte: lower including link key boundary limit: limit parity: if 1 - get with even and odd max link keys else max link key raiseError: whether to raise LunaApiException in case of failure Returns: class:`~.LunaResponse` or *asyncio coroutine* with *LunaResponse*. In body of :class: `~.LunaResponse` json with attributes will be returned. """ return self._facesClient.getAttributesFromList( listId=listId, linkKeyLt=linkKeyLt, linkKeyGte=linkKeyGte, limit=limit, parity=parity, raiseError=raiseError, **kwargs, )
[docs] def getFacesAttributes( self, faceIds: list, raiseError: bool = True, **kwargs, ) -> Awaitable[LunaResponse] | LunaResponse: """ Return attributeId of faces from faceIds list Args: faceIds: list of faceId for return their attributes raiseError: whether to raise LunaApiException in case of failure Returns: class:`~.LunaResponse` or *asyncio coroutine* with *LunaResponse*. In body of :class: `~.LunaResponse` json with attributes ids will be returned. """ return self._facesClient.facesAttributes( faceIds=faceIds, accountId=self._accountId, raiseError=raiseError, **kwargs, )
[docs] def getFaceAttributes( self, faceId: str, targets: list[str] | None = None, descriptorVersion: int | None = None, raiseError=True, **kwargs, ) -> Awaitable[LunaResponse] | LunaResponse: """ Get face attributes. Args: faceId: face id targets: targets to get face attributes. Available targets: `create_time`, `face_descriptor`, `basic_attributes`, `face_descriptor_samples`, `basic_attributes_samples`. descriptorVersion: descriptor version raiseError: whether to raise LunaApiException in case of failure Returns: class:`~.LunaResponse` or *asyncio coroutine* with *LunaResponse*. In body of :class: `~.LunaResponse` json with attributes will be returned. """ return self._facesClient.getFaceAttributes( faceId=faceId, targets=targets, descriptorVersion=descriptorVersion, accountId=self._accountId, raiseError=raiseError, **kwargs, )
[docs] def putFaceAttributes( self, faceId: str, attributeId: str | None = None, basicAttributes: dict | None = None, descriptors: list[bytes | RawDescriptor] | None = None, basicAttributesSamples: list[str] = None, descriptorSamples: list[str] = None, raiseError=True, **kwargs, ) -> Awaitable[LunaResponse] | LunaResponse: """ Put face attributes. Args: faceId: face id attributeId: attribute id descriptors: list of descriptors different versions descriptorSamples: list of warp image id from which the attribute was extracted. basicAttributes: dict with basic attributes (age, gender, ethnicity) basicAttributesSamples: list of warp image id from which the basic attribute was extracted. raiseError: whether to raise LunaApiException in case of failure Returns: class:`~.LunaResponse` or *asyncio coroutine* with *LunaResponse*. In body of :class: `~.LunaResponse` """ return self._facesClient.putFaceAttributes( faceId=faceId, attributeId=attributeId, basicAttributes=basicAttributes, descriptors=descriptors, basicAttributesSamples=basicAttributesSamples, descriptorSamples=descriptorSamples, raiseError=raiseError, **kwargs, )
[docs] def updateFaceAttributes( self, faceId: str, attributeId: str | None = None, basicAttributes: dict | None = None, descriptors: list[bytes | RawDescriptor] | None = None, basicAttributesSamples: list[str] = None, descriptorSamples: list[str] = None, raiseError=True, **kwargs, ) -> Awaitable[LunaResponse] | LunaResponse: """ Update face attributes. Args: faceId: face id attributeId: attribute id descriptors: list of descriptors different versions descriptorSamples: list of warp image id from which the attribute was extracted. basicAttributes: dict with basic attributes (age, gender, ethnicity) basicAttributesSamples: list of warp image id from which the basic attribute was extracted. raiseError: whether to raise LunaApiException in case of failure Returns: class:`~.LunaResponse` or *asyncio coroutine* with *LunaResponse*. In body of :class: `~.LunaResponse` """ return self._facesClient.updateFaceAttributes( faceId=faceId, attributeId=attributeId, basicAttributes=basicAttributes, descriptors=descriptors, basicAttributesSamples=basicAttributesSamples, descriptorSamples=descriptorSamples, raiseError=raiseError, **kwargs, )
[docs] def deleteFaceAttributes( self, faceId: str, raiseError: bool = True, **kwargs, ) -> Awaitable[LunaResponse] | LunaResponse: """ Delete face attributes. Args: faceId: face id raiseError: whether to raise LunaApiException in case of failure Returns: class:`~.LunaResponse` or *asyncio coroutine* with *LunaResponse*. In body of :class: `~.LunaResponse` """ return self._facesClient.deleteFaceAttributes( faceId=faceId, accountId=self._accountId, raiseError=raiseError, **kwargs, )
[docs] def getFaceAttributeSamples( self, faceId: str, raiseError: bool = True, **kwargs, ) -> Awaitable[LunaResponse] | LunaResponse: """ Get face attribute samples. Args: faceId: face id raiseError: whether to raise LunaApiException in case of failure Returns: class:`~.LunaResponse` or *asyncio coroutine* with *LunaResponse*. In body of :class: `~.LunaResponse` json with attribute samples will be returned. """ return self._facesClient.getFaceAttributeSamples( faceId=faceId, accountId=self._accountId, raiseError=raiseError, **kwargs, )
[docs] def getAttributeIds( self, listId: str | None = None, timeLt: str | None = None, timeGte: str | None = None, page: int | None = 1, pageSize: int | None = 1000, raiseError=True, **kwargs, ) -> Awaitable[LunaResponse] | LunaResponse: """ Get ids of attributes from list by period. Args: listId: list id timeLt: upper bound of face update time timeGte: lower bound of face update time page: page, default 1 pageSize: page size, default 1000, max 100000 raiseError: whether to raise LunaApiException in case of failure Returns: class:`~.LunaResponse` or *asyncio coroutine* with *LunaResponse*. In body of :class: `~.LunaResponse` json with attributes ids will be returned. """ return self._facesClient.getAttributeIds( accountId=self._accountId, listId=listId, timeLt=timeLt, timeGte=timeGte, page=page, pageSize=pageSize, raiseError=raiseError, **kwargs, )
[docs] def getAttributes( self, attributeIds: list[str], descriptorVersion: int = None, targets: list[str] | None = None, raiseError=True, **kwargs, ) -> Awaitable[LunaResponse] | LunaResponse: """ Get list of attributes Args: attributeIds: list of attributes of interest targets: Available targets: `descriptor`, `basic_attributes`, `basic_attributes_samples`, `face_descriptors_samples`, `account_id`, `create_time` descriptorVersion: descriptor version to receive raiseError: whether to raise LunaApiException in case of failure Returns: class:`~.LunaResponse` or *asyncio coroutine* with *LunaResponse*. In body of :class: `~.LunaResponse` will return json with version. """ return self._facesClient.getAttributes( attributeIds=attributeIds, descriptorVersion=descriptorVersion, targets=targets, accountId=self._accountId, raiseError=raiseError, **kwargs, )
[docs] def createAttribute( self, basicAttributes: dict | None = None, descriptors: list[bytes | RawDescriptor] | None = None, descriptorSamples: list[str] = None, basicAttributesSamples: list[str] = None, xpk: bytes = None, ttl: int | None = None, raiseError=True, **kwargs, ) -> Awaitable[LunaResponse] | LunaResponse: """ Create new attributes. Notice that XPK argument overwrites basic attributes and descriptors above. Args: descriptors: list of descriptors different versions descriptorSamples: list of warp image id from which the attribute was extracted. basicAttributes: dict with basic attributes (age, gender, ethnicity) basicAttributesSamples: list of warp image id from which the basic attribute was extracted. xpk: SDKObject bytes to load attributes from ttl: temporary attribute ttl raiseError: whether to raise LunaApiException in case of failure Returns: class:`~.LunaResponse` or *asyncio coroutine* with *LunaResponse*. In body of :class: `~.LunaResponse` will return json with attribute id. """ return self._facesClient.createAttribute( basicAttributes=basicAttributes, descriptors=descriptors, descriptorSamples=descriptorSamples, basicAttributesSamples=basicAttributesSamples, xpk=xpk, ttl=ttl, accountId=self._accountId, raiseError=raiseError, **kwargs, )
[docs] def putAttribute( self, attributeId: str, basicAttributes: dict | None = None, descriptors: list[bytes | RawDescriptor] | None = None, descriptorSamples: list[str] = None, basicAttributesSamples: list[str] = None, xpk: bytes = None, ttl: int | None = None, force: int | None = None, raiseError=True, **kwargs, ) -> Awaitable[LunaResponse] | LunaResponse: """ Put attribute by id. Notice that XPK argument overwrites basic attributes and descriptors above. Args: attributeId: attribute id descriptors: list of descriptors different versions descriptorSamples: list of warp image id from which the attribute was extracted. basicAttributes: dict with basic attributes (age, gender, ethnicity) basicAttributesSamples: list of warp image id from which the basic attribute was extracted. xpk: SDKObject bytes to load attributes from ttl: temporary attribute ttl force: replace or not existence attribute raiseError: whether to raise LunaApiException in case of failure Returns: class:`~.LunaResponse` or *asyncio coroutine* with *LunaResponse*. In body of :class: `~.LunaResponse` will return json with version. """ return self._facesClient.putAttribute( attributeId=attributeId, force=force, basicAttributes=basicAttributes, descriptors=descriptors, descriptorSamples=descriptorSamples, basicAttributesSamples=basicAttributesSamples, xpk=xpk, ttl=ttl, accountId=self._accountId, raiseError=raiseError, **kwargs, )
[docs] def headAttribute( self, attributeId: str, raiseError: bool = True, **kwargs, ) -> Awaitable[LunaResponse] | LunaResponse: """ Check attributes with attribute id exists. Args: attributeId: attribute id raiseError: whether to raise LunaApiException in case of failure Returns: class:`~.LunaResponse` or *asyncio coroutine* with *LunaResponse*. In body of :class: `~.LunaResponse` will return json with version. """ return self._facesClient.checkAttribute( attributeId=attributeId, accountId=self._accountId, raiseError=raiseError, **kwargs, )
[docs] def getAttribute( self, attributeId: str, descriptorVersion: int = None, targets: list[str] | None = None, raiseError=True, **kwargs, ) -> Awaitable[LunaResponse] | LunaResponse: """ Retrieve a attribute by id. Args: attributeId: attribute id targets: Available targets: `descriptor`, `basic_attributes`, `basic_attributes_samples`, `face_descriptors_samples`, `account_id`, `create_time` descriptorVersion: descriptor version to receive raiseError: whether to raise LunaApiException in case of failure Returns: class:`~.LunaResponse` or *asyncio coroutine* with *LunaResponse*. In body of :class: `~.LunaResponse` will return json with attribute. """ return self._facesClient.getAttribute( attributeId=attributeId, accountId=self._accountId, descriptorVersion=descriptorVersion, targets=targets, raiseError=raiseError, **kwargs, )
[docs] def getAttributeSamples( self, attributeId: str, raiseError=True, **kwargs, ) -> Awaitable[LunaResponse] | LunaResponse: """ Retrieve a attribute by id. Args: attributeId: attribute id raiseError: whether to raise LunaApiException in case of failure Returns: class:`~.LunaResponse` or *asyncio coroutine* with *LunaResponse*. In body of :class: `~.LunaResponse` will return json with samples. """ return self._facesClient.getAttributeSamples( attributeId=attributeId, accountId=self._accountId, raiseError=raiseError, **kwargs, )
[docs] def deleteAttribute( self, attributeId: str, raiseError=True, **kwargs, ) -> Awaitable[LunaResponse] | LunaResponse: """ Delete attribute with specifeid id Args: attributeId: attribute id raiseError: whether to raise LunaApiException in case of failure Returns: class:`~.LunaResponse` or *asyncio coroutine* with *LunaResponse*. In body of :class: `~.LunaResponse` will return response empty body. """ return self._facesClient.deleteAttribute( attributeId=attributeId, accountId=self._accountId, raiseError=raiseError, **kwargs, )