Luna services clients description

Here presented possibilities of luna-services clients.

Events client

The luna-events client which allows to create events, get events and get events statistics

Module contains luna-events client adapted for usage in lambda

class luna_lambda_tools.public.clients.events.Events(eventsClient, accountId)[source]

Luna-events client

deleteEvents(target=None, handlerId=None, createTimeGte=None, createTimeLt=None, insertTimeGte=None, insertTimeLt=None, raiseError=True, **kwargs)[source]

Delete events by filters.

Parameters:
  • target (list[str] | None) – event deletion info targets

  • handlerId (str | None) – event handler id

  • createTimeGte (str | None) – lower including create time boundary

  • createTimeLt (str | None) – upper excluding create time boundary

  • insertTimeGte (str | None) – lower including insert time boundary

  • insertTimeLt (str | None) – upper excluding insert time boundary

  • raiseError (bool) – whether to raise LunaApiException in case of failure

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with events will be returned.

Return type:

class

getAddress()[source]

Get luna events address

Return type:

str

getEvent(eventId, target=None, raiseError=True, **kwargs)[source]

Get event by id.

Parameters:
  • eventId (str) – event id

  • target (list[Literal['account_id', 'create_time', 'end_time', 'event_id', 'handler_id', 'external_id', 'source', 'stream_id', 'top_match', 'match_result', 'face_detections', 'face_id', 'attach_result', 'gender', 'age', 'emotion', 'ethnic_group', 'liveness', 'deepfake', 'body_detections', 'body_basic_attributes', 'upper_body', 'lower_body', 'accessories', 'tags', 'user_data', 'location', 'mask', 'track_id', 'meta']] | None) – list of events’ fields to receive instead of full events

  • raiseError (bool) – whether to raise LunaApiException in case of failure

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with events will be returned.

Return type:

class

getEventDescriptor(eventId=None, descriptorVersion=None, descriptorType=None, raiseError=True, **kwargs)[source]

Get event descriptor by filters.

Parameters:
  • eventId (str | None) – event id

  • descriptorVersion (int | None) – descriptor version

  • descriptorType (str | None) – Kind of the descriptor (body or face)

  • raiseError – whether to raise LunaApiException in case of failure

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with event descriptor will be returned.

Return type:

class

getEvents(target=None, createTimeGte=None, createTimeLt=None, endTimeGte=None, endTimeLt=None, eventIds=None, eventIdGte=None, eventIdLt=None, handlerIds=None, externalIds=None, topMatchingCandidatesLabel=None, topSimilarObjectIds=None, topSimilarExternalIds=None, topSimilarObjectSimilarityGte=None, topSimilarObjectSimilarityLt=None, ageLt=None, ageGte=None, gender=None, emotions=None, masks=None, ethnicGroups=None, liveness=None, apparentAgeGte=None, apparentAgeLt=None, apparentGender=None, headwearStates=None, headwearApparentColors=None, sleeveLengths=None, upperClothingColors=None, lowerGarmentTypes=None, lowerGarmentColors=None, shoesApparentColors=None, backpackStates=None, faceIds=None, userData=None, page=1, pageSize=10, order='desc', sources=None, tags=None, cities=None, areas=None, districts=None, streets=None, houseNumbers=None, originLongitude=None, originLatitude=None, longitudeDelta=None, latitudeDelta=None, trackIds=None, meta=None, raiseError=True, **kwargs)[source]

Get events by filters.

Parameters:
  • target (list[Literal['account_id', 'create_time', 'end_time', 'event_id', 'handler_id', 'external_id', 'source', 'stream_id', 'top_match', 'match_result', 'face_detections', 'face_id', 'attach_result', 'gender', 'age', 'emotion', 'ethnic_group', 'liveness', 'deepfake', 'body_detections', 'body_basic_attributes', 'upper_body', 'lower_body', 'accessories', 'tags', 'user_data', 'location', 'mask', 'track_id', 'meta']] | None) – list of events’ fields to receive instead of full events

  • createTimeGte (str | None) – lower including create time boundary

  • createTimeLt (str | None) – upper excluding create time boundary

  • endTimeGte (str | None) – lower including end time boundary

  • endTimeLt (str | None) – upper excluding end time boundary

  • faceIds (list[str] | None) – ids of faces linked with an event

  • eventIds (list[str] | None) – event ids

  • eventIdGte (str | None) – event id lower including bound

  • eventIdLt (str | None) – event id upper excluding bound

  • handlerIds (list[str] | None) – handler ids

  • externalIds (list[str] | None) – external ids

  • userData (str | None) – event user data

  • sources (list[Union[str, Literal['null']]] | None) – list of source

  • tags (list[str] | None) – users tags

  • topMatchingCandidatesLabel (str | None) – top matching candidates label

  • topSimilarObjectIds (list[str] | None) – top similar object ids

  • topSimilarExternalIds (list[str] | None) – top similar external ids

  • topSimilarObjectSimilarityGte (float | None) – lower including top similarity boundary

  • topSimilarObjectSimilarityLt (float | None) – upper excluding top similarity boundary

  • ageLt (int | None) – upper excluding age boundary

  • ageGte (int | None) – lower including age boundary

  • gender (Union[int, Literal['null'], None]) – gender of event (0 or 1)

  • emotions (list[Union[int, Literal['null']]] | None) – dominant emotions in event (one of (1, 2, 3, 4, 5, 6, 7) - matches “anger”, “disgust”, “fear”, “happiness”, “neutral”, “sadness”, “surprise”)

  • masks (list[Union[int, Literal['null']]] | None) – dominant masks in event (one of (1, 2, 3) - matches “missing”, “medical_mask”, “occluded”)

  • ethnicGroups (list[Union[int, Literal['null']]] | None) – dominant ethnicity of the face ((1, 2, 3, 4) - means (indian, asian, african_american, caucasian)

  • liveness (list[Union[int, Literal['null']]] | None) – dominant liveness of the face ((0, 1, 2) - means (“spoof”, “real”, “unknown”))

  • apparentAgeLt (int | None) – apparent age upper excluding boundary

  • apparentAgeGte (int | None) – apparent age upper including boundary

  • apparentGender (Union[list[Literal[0, 1, 2]], Literal['null']]) – apparent gender estimation values (0 - female, 1 - male, 2 - undefined)

  • headwearStates (list[Union[Literal[0, 1, 2], Literal['null']]] | None) – headwear states (0 - absent, 1 - present, 2 - undefined)

  • headwearApparentColors (list[Union[Literal['undefined', 'black', 'white', 'other'], Literal['null']]] | None) – headwear apparent colors

  • sleeveLengths (list[Literal['short', 'long', 'undefined', 'null']] | None) – sleeve lengths

  • upperClothingColors (list[Union[Literal['black', 'blue', 'green', 'gray', 'orange', 'purple', 'red', 'white', 'yellow', 'pink', 'brown', 'beige', 'khaki', 'multicolored', 'undefined'], Literal['null']]] | None) – upper clothing colors

  • lowerGarmentTypes (list[Literal['undefined', 'trousers', 'shorts', 'skirt', 'null']] | None) – lower garment types

  • lowerGarmentColors (list[Union[Literal['black', 'blue', 'green', 'gray', 'orange', 'purple', 'red', 'white', 'yellow', 'pink', 'brown', 'beige', 'khaki', 'multicolored', 'undefined'], Literal['null']]] | None) – lower garment colors

  • shoesApparentColors (list[Union[Literal['undefined', 'black', 'white', 'other'], Literal['null']]] | None) – shoes apparent colors

  • backpackStates (list[Union[Literal[0, 1, 2], Literal['null']]] | None) – backpack states (0 - absent, 1 - present, 2 - undefined)

  • areas (list[Union[str, Literal['null']]] | None) – list of areas

  • streets (list[Union[str, Literal['null']]] | None) – list of streets

  • districts (list[Union[str, Literal['null']]] | None) – list of districts

  • cities (list[Union[str, Literal['null']]] | None) – list of cities

  • houseNumbers (list[Union[str, Literal['null']]] | None) – list of house numbers

  • originLongitude (Union[float, Literal['null'], None]) – origin longitude in degrees

  • originLatitude (Union[float, Literal['null'], None]) – origin latitude in degrees

  • longitudeDelta (float | None) – longitude delta in degrees

  • latitudeDelta (float | None) – latitude delta in degrees

  • trackIds (list[Union[str, Literal['null']]] | None) – list of track ids

  • meta (dict | None) – user-defined event meta’s filters in format {meta.<path.to.field>__<operator>:<type>: <value>}

  • page (int | None) – number of result page

  • pageSize (int | None) – count of results in page

  • order (str | None) – result sort order (ask or desc)

  • raiseError – whether to raise LunaApiException in case of failure

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with events will be returned.

Return type:

class

getEventsStats(query=<luna3.common.http_objs.StatQuery object>, raiseError=True, **kwargs)[source]

Get events statistics by aggregation (<aggregator> and <groupBy> on <target>) and filters.

Parameters:
  • query (StatQuery) – query object or query dict, contained in StatQuery object

  • raiseError (bool) – whether to raise LunaApiException in case of failure

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with event statistics will be returned.

Return type:

class

headEvent(eventId, raiseError=True, **kwargs)[source]

Check event existence by id.

Parameters:
  • eventId (str) – event id

  • raiseError (bool) – whether to raise LunaApiException in case of failure

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with events will be returned.

Return type:

class

saveEvents(events, waitEventsSaving=None, raiseError=True, **kwargs)[source]

Save events to luna-events.

Parameters:
  • events (list[Event]) – list of events

  • waitEventsSaving (bool | None) – whether to wait events saving (response will be received only after events will be saved)

  • raiseError – whether to raise LunaApiException in case of failure

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse.

Return type:

class

Faces client

The luna-faces client which allows to create/get/delete faces/attributes/lists

Module contains luna-faces client adapted for usage in lambda

class luna_lambda_tools.public.clients.faces.Faces(facesClient, accountId)[source]

Luna-faces client

createAttribute(basicAttributes=None, descriptors=None, descriptorSamples=None, basicAttributesSamples=None, xpk=None, ttl=None, raiseError=True, **kwargs)[source]

Create new attributes. Notice that XPK argument overwrites basic attributes and descriptors above.

Parameters:
  • descriptors (list[bytes | RawDescriptor] | None) – list of descriptors different versions

  • descriptorSamples (list[str]) – list of warp image id from which the attribute was extracted.

  • basicAttributes (dict | None) – dict with basic attributes (age, gender, ethnicity)

  • basicAttributesSamples (list[str]) – list of warp image id from which the basic attribute was extracted.

  • xpk (bytes) – SDKObject bytes to load attributes from

  • ttl (int | None) – temporary attribute ttl

  • raiseError – whether to raise LunaApiException in case of failure

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with attribute id.

Return type:

class

createFace(attributeId=None, basicAttributes=None, descriptors=None, descriptorSamples=None, basicAttributesSamples=None, eventId=None, userData='', externalId=None, avatar=None, listIds=None, raiseError=True, **kwargs)[source]

Create new face in luna-faces

Parameters:
  • attributeId (str | None) – attribute id

  • descriptors (list[bytes | RawDescriptor] | None) – list of descriptors different versions

  • descriptorSamples (list[str]) – list of warp image id from which the attribute was extracted.

  • basicAttributes (dict | None) – dict with basic attributes (age, gender, ethnicity)

  • basicAttributesSamples (list[str]) – list of warp image id from which the basic attribute was extracted.

  • eventId (str | None) – reference to event which created face

  • userData (str | None) – face user data

  • externalId (str | None) – external id of the face, if it has its own mapping in the system

  • avatar (str | None) – face avatar url

  • listIds (list[str] | None) – created face will be attach to these lists

  • raiseError – whether to raise LunaApiException in case of failure

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with created face id will be returned.

Return type:

class

createList(userData='', listId=None, raiseError=True, **kwargs)[source]

Create list.

Parameters:
  • userData (str) – user data

  • listId (str | None) – custom list id to create the list

  • raiseError – whether to raise LunaApiException in case of failure

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with created list id will be returned.

Return type:

class

deleteAttribute(attributeId, raiseError=True, **kwargs)[source]

Delete attribute with specifeid id

Parameters:
  • attributeId (str) – attribute id

  • raiseError – whether to raise LunaApiException in case of failure

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return response empty body.

Return type:

class

deleteFace(faceId, raiseError=True, **kwargs)[source]

Delete face. Optional you can set, that face must belong to account.

Parameters:
  • faceId (str) – face id

  • raiseError – whether to raise LunaApiException in case of failure

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse.

Return type:

class

deleteFaceAttributes(faceId, raiseError=True, **kwargs)[source]

Delete face attributes.

Parameters:
  • faceId (str) – face id

  • raiseError (bool) – whether to raise LunaApiException in case of failure

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse

Return type:

class

deleteFaces(faceIds, ignore=None, raiseError=True, **kwargs)[source]

Delete faces. Optional you can set, that faces must belong to account.

Parameters:
  • faceIds (list[str]) – face id list

  • ignore (int | None) – ignore non-existing faces

  • raiseError – whether to raise LunaApiException in case of failure

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse.

Return type:

class

deleteList(listId, withFaces=0, raiseError=True, **kwargs)[source]

Remove list. Optional you can set, that list must belong to account.

Parameters:
  • listId (str) – list id

  • withFaces (int) – remove lists and all faces witch is contained in the lists

  • raiseError (bool) – whether to raise LunaApiException in case of failure

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse.

Return type:

class

deleteLists(listIds, withFaces=None, raiseError=True, **kwargs)[source]

Delete lists. Optional you can set, that lists must belong to account.

Parameters:
  • listIds (list[str]) – ids of lists

  • withFaces (int) – remove lists and all the faces contained in the lists

  • raiseError – whether to raise LunaApiException in case of failure

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse.

Return type:

class

getAddress()[source]

Get luna-faces address

Return type:

str

getAttribute(attributeId, descriptorVersion=None, targets=None, raiseError=True, **kwargs)[source]

Retrieve a attribute by id.

Parameters:
  • attributeId (str) – attribute id

  • targets (list[str] | None) – Available targets: descriptor, basic_attributes, basic_attributes_samples, face_descriptors_samples, account_id, create_time

  • descriptorVersion (int) – descriptor version to receive

  • raiseError – whether to raise LunaApiException in case of failure

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with attribute.

Return type:

class

getAttributeIds(listId=None, timeLt=None, timeGte=None, page=1, pageSize=1000, raiseError=True, **kwargs)[source]

Get ids of attributes from list by period.

Parameters:
  • listId (str | None) – list id

  • timeLt (str | None) – upper bound of face update time

  • timeGte (str | None) – lower bound of face update time

  • page (int | None) – page, default 1

  • pageSize (int | None) – page size, default 1000, max 100000

  • raiseError – whether to raise LunaApiException in case of failure

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with attributes ids will be returned.

Return type:

class

getAttributeSamples(attributeId, raiseError=True, **kwargs)[source]

Retrieve a attribute by id.

Parameters:
  • attributeId (str) – attribute id

  • raiseError – whether to raise LunaApiException in case of failure

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with samples.

Return type:

class

getAttributes(attributeIds, descriptorVersion=None, targets=None, raiseError=True, **kwargs)[source]

Get list of attributes

Parameters:
  • attributeIds (list[str]) – list of attributes of interest

  • targets (list[str] | None) – Available targets: descriptor, basic_attributes, basic_attributes_samples, face_descriptors_samples, account_id, create_time

  • descriptorVersion (int) – descriptor version to receive

  • raiseError – whether to raise LunaApiException in case of failure

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with version.

Return type:

class

getAttributesFromList(listId, linkKeyLt=None, linkKeyGte=None, limit=1000, parity=None, raiseError=True, **kwargs)[source]

Get all attributes from list by period.

Parameters:
  • listId (str) – list id

  • linkKeyLt (str | None) – upper including link key boundary

  • linkKeyGte (str | None) – lower including link key boundary

  • limit (int | None) – limit

  • parity (int | None) – if 1 - get with even and odd max link keys else max link key

  • raiseError – whether to raise LunaApiException in case of failure

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with attributes will be returned.

Return type:

class

getFace(faceId, targets=None, raiseError=True, **kwargs)[source]

Get face by id. Optional you can set, that face must belong to account.

Parameters:
  • faceId (str) – face id

  • targets (list[str] | None) – targets to get face

  • raiseError – whether to raise LunaApiException in case of failure

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with face will be returned.

Return type:

class

getFaceAttributeSamples(faceId, raiseError=True, **kwargs)[source]

Get face attribute samples.

Parameters:
  • faceId (str) – face id

  • raiseError (bool) – whether to raise LunaApiException in case of failure

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with attribute samples will be returned.

Return type:

class

getFaceAttributes(faceId, targets=None, descriptorVersion=None, raiseError=True, **kwargs)[source]

Get face attributes.

Parameters:
  • faceId (str) – face id

  • targets (list[str] | None) – targets to get face attributes. Available targets: create_time, face_descriptor, basic_attributes, face_descriptor_samples, basic_attributes_samples.

  • descriptorVersion (int | None) – descriptor version

  • raiseError – whether to raise LunaApiException in case of failure

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with attributes will be returned.

Return type:

class

getFaces(userData=None, eventId=None, listId=None, faceIds=None, timeLt=None, timeGte=None, page=1, pageSize=10, attributeIds=None, externalIds=None, faceIdGte=None, faceIdLt=None, targets=None, raiseError=True, **kwargs)[source]

Get faces by filters. Optional you can set, that faces must belong to account.

Parameters:
  • userData (str | None) – user data, part of user data, case insensitive

  • eventId (str | None) – event id

  • listId (str | None) – list id

  • faceIds (list[str] | None) – face ids

  • timeLt (str | None) – upper bound of face create time

  • timeGte (str | None) – lower bound of face create time

  • page (int | None) – page count, default 1

  • pageSize (int | None) – page size, default 10, unlimited if -1

  • attributeIds (list[str] | None) – attributes ids

  • externalIds (list[str] | None) – list of external identifiers of persons, if they have their own mapping in the system

  • faceIdGte (str | None) – lower face id including boundary

  • faceIdLt (str | None) – upper face id excluding boundary

  • targets (list[str] | None) – targets to get faces

  • raiseError – whether to raise LunaApiException in case of failure

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with faces will be returned.

Return type:

class

getFacesAttributes(faceIds, raiseError=True, **kwargs)[source]

Return attributeId of faces from faceIds list

Parameters:
  • faceIds (list) – list of faceId for return their attributes

  • raiseError (bool) – whether to raise LunaApiException in case of failure

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with attributes ids will be returned.

Return type:

class

getFacesCount(userData=None, eventId=None, listId=None, faceIds=None, timeLt=None, timeGte=None, attributeIds=None, externalIds=None, faceIdGte=None, faceIdLt=None, raiseError=True, **kwargs)[source]

Count faces by filters. Optional you can set, that faces must belong to account.

Parameters:
  • userData (str | None) – user data, part of user data, case insensitive

  • eventId (str | None) – event id

  • listId (str | None) – list id

  • faceIds (list[str] | None) – face ids

  • timeLt (str | None) – upper bound of face create time

  • timeGte (str | None) – lower bound of face create time

  • attributeIds (list[str] | None) – attributes ids

  • externalIds (list[str] | None) – list of external identifiers of persons, if they have their own mapping in the system

  • faceIdGte (str | None) – lower face id including boundary

  • faceIdLt (str | None) – upper face id excluding boundary

  • raiseError – whether to raise LunaApiException in case of failure

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with number of faces will be returned.

Return type:

class

getList(listId, page=1, pageSize=10, raiseError=True, **kwargs)[source]

Get list. Optional you can set, that list must belong to account.

Parameters:
  • listId (str) – list id

  • page (int | None) – page count, default 1

  • pageSize (int | None) – page size, default 10

  • raiseError – whether to raise LunaApiException in case of failure

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with list will be returned.

Return type:

class

getLists(userData=None, userDataEq=None, createTimeLt=None, createTimeGte=None, lastUpdateTimeLt=None, lastUpdateTimeGte=None, listIds=None, listIdLt=None, listIdGte=None, page=1, pageSize=10, raiseError=True, **kwargs)[source]

Get lists. Optional you can set, that lists must belong to account.

Parameters:
  • userData (str | None) – user data, part of user data, case sensitive

  • userDataEq (str | None) – user data, case sensitive

  • createTimeLt (str | None) – upper bound of list create time

  • createTimeGte (str | None) – lower bound of list create time including boundary

  • lastUpdateTimeLt (str | None) – upper bound of list last update time

  • lastUpdateTimeGte (str | None) – lower bound of list last update time including boundary

  • listIdLt (str | None) – upper bound of list id

  • listIdGte (str | None) – lower bound of list id including boundary

  • listIds (list[str] | None) – list ids

  • page (int | None) – page, default 1

  • pageSize (int | None) – page size, default 10

  • raiseError – whether to raise LunaApiException in case of failure

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with lists will be returned.

Return type:

class

getListsCount(userData=None, userDataEq=None, createTimeLt=None, createTimeGte=None, lastUpdateTimeLt=None, lastUpdateTimeGte=None, listIds=None, listIdLt=None, listIdGte=None, raiseError=True, **kwargs)[source]

Get number of lists. Optional you can set, that lists must belong to account.

Parameters:
  • userData (str | None) – user data, part of user data, case sensitive

  • userDataEq (str | None) – user data

  • createTimeLt (str | None) – upper bound of list create time

  • createTimeGte (str | None) – lower bound of list create time including boundary

  • lastUpdateTimeLt (str | None) – upper bound of list last update time

  • lastUpdateTimeGte (str | None) – lower bound of list last update time including boundary

  • listIds (list[str] | None) – list ids

  • listIdLt (str | None) – upper bound of list id

  • listIdGte (str | None) – lower bound of list id including boundary

  • raiseError – whether to raise LunaApiException in case of failure

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with number of lists will be returned.

Return type:

class

headAttribute(attributeId, raiseError=True, **kwargs)[source]

Check attributes with attribute id exists.

Parameters:
  • attributeId (str) – attribute id

  • raiseError (bool) – whether to raise LunaApiException in case of failure

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with version.

Return type:

class

headFace(faceId, raiseError=True, **kwargs)[source]

Check face existence by id. Optional you can set, that face must belong to account.

Parameters:
  • faceId (str) – face id

  • raiseError (bool) – whether to raise LunaApiException in case of failure

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse.

Return type:

class

headList(listId, raiseError=True, **kwargs)[source]

Check list existence. Optional you can set, that list must belong to account.

Parameters:
  • listId (str) – list id

  • raiseError – whether to raise LunaApiException in case of failure

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse.

Return type:

class

linkFacesToList(listId, faceIds, raiseError=True, **kwargs)[source]

Attach faces to list.

Parameters:
  • listId (str) – list id

  • faceIds (list[str]) – face ids

  • raiseError – whether to raise LunaApiException in case of failure

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse.

Return type:

class

patchFace(faceId, eventId=None, userData=None, externalId=None, avatar=None, raiseError=True, **kwargs)[source]

Update face. You can update event id, user data, attribute id. Optional you can set, that face must belong to account.

Parameters:
  • faceId (str) – face id

  • eventId (str | None) – new event id

  • externalId (str | None) – external id of the face, if it has its own mapping in the system

  • userData (str | None) – new user data

  • avatar (str | None) – face avatar url

  • raiseError – whether to raise LunaApiException in case of failure

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse.

Return type:

class

patchList(listId, userData, raiseError=True, **kwargs)[source]

Update user data of list. Optional you can set, that list must belong to account.

Parameters:
  • listId (str) – list id

  • userData (str) – new user data

  • raiseError – whether to raise LunaApiException in case of failure

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse.

Return type:

class

putAttribute(attributeId, basicAttributes=None, descriptors=None, descriptorSamples=None, basicAttributesSamples=None, xpk=None, ttl=None, force=None, raiseError=True, **kwargs)[source]

Put attribute by id. Notice that XPK argument overwrites basic attributes and descriptors above.

Parameters:
  • attributeId (str) – attribute id

  • descriptors (list[bytes | RawDescriptor] | None) – list of descriptors different versions

  • descriptorSamples (list[str]) – list of warp image id from which the attribute was extracted.

  • basicAttributes (dict | None) – dict with basic attributes (age, gender, ethnicity)

  • basicAttributesSamples (list[str]) – list of warp image id from which the basic attribute was extracted.

  • xpk (bytes) – SDKObject bytes to load attributes from

  • ttl (int | None) – temporary attribute ttl

  • force (int | None) – replace or not existence attribute

  • raiseError – whether to raise LunaApiException in case of failure

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with version.

Return type:

class

putFace(faceId, externalId=None, attributeId=None, basicAttributes=None, descriptors=None, descriptorSamples=None, basicAttributesSamples=None, eventId=None, userData='', avatar=None, listIds=None, raiseError=True, **kwargs)[source]

Put face in luna-faces

Parameters:
  • faceId (str) – external face id

  • externalId (str | None) – external id of the face, if it has its own mapping in the system

  • attributeId (str | None) – attribute id

  • descriptors (list[bytes | RawDescriptor] | None) – list of descriptors different versions

  • descriptorSamples (list[str]) – list of warp image id from which the attribute was extracted.

  • basicAttributes (dict | None) – dict with basic attributes (age, gender, ethnicity)

  • basicAttributesSamples (list[str]) – list of warp image id from which the basic attribute was extracted.

  • eventId (str | None) – reference to event which created face

  • userData (str | None) – face user data

  • avatar (str | None) – face avatar url

  • listIds (list[str] | None) – created face will be attach to these lists

  • raiseError – whether to raise LunaApiException in case of failure

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with face id will be returned.

Return type:

class

putFaceAttributes(faceId, attributeId=None, basicAttributes=None, descriptors=None, basicAttributesSamples=None, descriptorSamples=None, raiseError=True, **kwargs)[source]

Put face attributes.

Parameters:
  • faceId (str) – face id

  • attributeId (str | None) – attribute id

  • descriptors (list[bytes | RawDescriptor] | None) – list of descriptors different versions

  • descriptorSamples (list[str]) – list of warp image id from which the attribute was extracted.

  • basicAttributes (dict | None) – dict with basic attributes (age, gender, ethnicity)

  • basicAttributesSamples (list[str]) – list of warp image id from which the basic attribute was extracted.

  • raiseError – whether to raise LunaApiException in case of failure

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse

Return type:

class

unlinkFacesFromList(listId, faceIds, raiseError=True, **kwargs)[source]

Detach faces to list.

Parameters:
  • listId (str) – list id

  • faceIds (list[str]) – face ids

  • raiseError – whether to raise LunaApiException in case of failure

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse.

Return type:

class

updateFaceAttributes(faceId, attributeId=None, basicAttributes=None, descriptors=None, basicAttributesSamples=None, descriptorSamples=None, raiseError=True, **kwargs)[source]

Update face attributes.

Parameters:
  • faceId (str) – face id

  • attributeId (str | None) – attribute id

  • descriptors (list[bytes | RawDescriptor] | None) – list of descriptors different versions

  • descriptorSamples (list[str]) – list of warp image id from which the attribute was extracted.

  • basicAttributes (dict | None) – dict with basic attributes (age, gender, ethnicity)

  • basicAttributesSamples (list[str]) – list of warp image id from which the basic attribute was extracted.

  • raiseError – whether to raise LunaApiException in case of failure

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse

Return type:

class

Luna Image Store client

The luna-image-store client which allows to create/get/delete images and objects

Module contains luna-image-store client adapted for usage in lambda

class luna_lambda_tools.public.clients.lis.LIS(lisClient, accountId, bucket)[source]

Luna-image-store client

deleteImage(imageId, raiseError=True, **kwargs)[source]

Delete image from bucket.

Parameters:
  • imageId (str) – image id to delete

  • raiseError (bool) – whether to raise LunaApiException in case of failure

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with version.

Return type:

class

deleteImages(imageIds, raiseError=True, **kwargs)[source]

Delete images from bucket.

Parameters:
  • imageIds (list[str]) – images ids to delete

  • raiseError (bool) – whether to raise LunaApiException in case of failure

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with version.

Return type:

class

deleteObject(objectId, raiseError=True, **kwargs)[source]

Delete object from bucket.

Parameters:
  • objectId (str) – object id

  • raiseError (bool) – whether to raise LunaApiException in case of failure

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with version.

Return type:

class

deleteObjects(objectIds, raiseError=True, **kwargs)[source]

Delete objects from bucket.

Parameters:
  • objectIds (list[str]) – objects ids to delete

  • raiseError (bool) – whether to raise LunaApiException in case of failure

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with version.

Return type:

class

getAddress()[source]

Get luna-image-store address

Return type:

str

getImage(imageId, withMeta=None, raiseError=True, **kwargs)[source]

Get image from bucket.

Parameters:
  • imageId (str) – external image id

  • withMeta (bool) – whether to retrieve user-defined image metadata

  • raiseError (bool) – whether to raise LunaApiException in case of failure

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with version.

Return type:

class

getObject(objectId, raiseError=True, **kwargs)[source]

Get object from bucket.

Parameters:
  • objectId (str) – object id

  • raiseError (bool) – whether to raise LunaApiException in case of failure

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with version.

Return type:

class

headImage(imageId, withMeta=None, raiseError=True, **kwargs)[source]

Check image existence in bucket.

Parameters:
  • imageId (str) – external image id

  • withMeta (bool) – whether to retrieve user-defined image metadata

  • raiseError – whether to raise LunaApiException in case of failure

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with version.

Return type:

class

headObject(objectId, raiseError=True, **kwargs)[source]

Check object existence in bucket.

Parameters:
  • objectId (str) – object id

  • raiseError (bool) – whether to raise LunaApiException in case of failure

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with version.

Return type:

class

postImage(imageInBytes, contentType='image/jpeg', raiseError=True, **kwargs)[source]

Post an image to bucket.

Parameters:
  • imageInBytes (bytes | bytearray) – byte’s array (image)

  • contentType (str) – content-type of image or image/jpeg for default

  • raiseError – whether to raise LunaApiException in case of failure

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with version.

Return type:

class

postObject(objectBody, contentType='application/json', raiseError=True, **kwargs)[source]

Post object to bucket.

Parameters:
  • objectBody (str) – object, available: text, json

  • contentType (str) – content-type of object or application/json for default

  • raiseError (bool) – whether to raise LunaApiException in case of failure

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with version.

Return type:

class

putImage(imageInBytes, imageId, contentType='image/jpeg', raiseError=True, **kwargs)[source]

Put an image to bucket.

Parameters:
  • imageInBytes (bytes | bytearray) – byte’s array (image)

  • imageId (str) – image id

  • contentType (str) – content-type of image or image/jpeg for default

  • raiseError – whether to raise LunaApiException in case of failure

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with version.

Return type:

class

putObject(objectBody, objectId, contentType='application/json', raiseError=True, **kwargs)[source]

Put object to bucket.

Parameters:
  • objectBody (str) – object, available: text, json

  • objectId (str) – object id

  • contentType (str | None) – content-type of object or application/json for default

  • raiseError (bool) – whether to raise LunaApiException in case of failure

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with version.

Return type:

class

Luna Python Matcher client

The luna-python-matcher client which allows to match/crossmatch faces/bodies

Module contains luna-python-matcher client adapted for usage in lambda

class luna_lambda_tools.public.clients.lpm.LPM(lpmClient, accountId)[source]

Luna-python-matcher client

crossmatchBodies(candidateFilters, referenceFilters, limit=None, threshold=None, sorting=None, raiseError=True, **kwargs)[source]

Cross Matcher API allows to submit tasks to a service that searches for events by given filters and matches them with each other. Resource implements body descriptors matching.

Parameters:
  • candidateFilters (EventFilters) – candidate events filters

  • referenceFilters (EventFilters) – reference events filters

  • limit (int | None) – matching limit

  • threshold (int | None) – matching threshold

  • sorting (int | None) – whether to sort match results

  • raiseError – whether to raise LunaApiException in case of failure

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse: results of matching (failed and succeeded matches)

Return type:

class

crossmatchFaces(candidateFilters, referenceFilters, limit=None, threshold=None, sorting=None, raiseError=True, **kwargs)[source]

Cross Matcher API allows to submit tasks to a service that searches for faces/events by given filters and matches them with each other. Resource implements face descriptors matching.

Parameters:
  • candidateFilters (FaceFilters | EventFilters | AttributeFilters) – candidate filters

  • referenceFilters (FaceFilters | EventFilters | AttributeFilters) – reference filters

  • limit (int | None) – matching limit

  • threshold (int | None) – matching threshold

  • sorting (int | None) – whether to sort match results

  • raiseError – whether to raise LunaApiException in case of failure

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse: results of matching (failed and succeeded matches)

Return type:

class

getAddress()[source]

Get luna-python-matcher address

Return type:

str

matchBodies(candidates, references, raiseError=True, **kwargs)[source]

Matcher API allows to submit tasks to a service that searches for faces similar to a given reference(s) by matching them. An attribute descriptor should be extracted for reference(s) and candidate(s). A source for references are events, attributes and faces. A source for candidates are faces and lists.

Parameters:
  • candidates (list[Candidates]) – Candidates object with info about candidates (possible type variants: events)

  • references (list[Reference | BinaryReference]) – list of Reference objects. Each object has entity id and it type (possible type variants: events, raw descriptors)

  • raiseError – whether to raise LunaApiException in case of failure

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse: results of matching (failed and succeeded matches)

Return type:

class

matchFaces(candidates, references, raiseError=True, **kwargs)[source]

Matcher API allows to submit tasks to a service that searches for faces similar to a given reference(s) by matching them. An attribute descriptor should be extracted for reference(s) and candidate(s). A source for references are events, attributes and faces. A source for candidates are faces and lists.

Parameters:
  • candidates (list[Candidates]) – Candidates object with info about candidates

  • references (list[Reference | BinaryReference]) – list of Reference objects. Each object has entity id and it type (possible type variants: events, attributes, faces, raw descriptors)

  • raiseError – whether to raise LunaApiException in case of failure

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse: results of matching (failed and succeeded matches)

Return type:

class

matchRaw(candidates, references, raiseError=True, **kwargs)[source]

Matcher raw API allows to match each candidate with each reference descriptors.

Parameters:
  • candidates (list[BinaryReference]) – list of BinaryReference objects for candidates

  • references (list[BinaryReference]) – list of BinaryReference objects for references

  • raiseError – whether to raise LunaApiException in case of failure

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse: results of matching for each reference

Return type:

class

Luna Remote SDK client

The luna-remote-sdk client which allows to detect faces/bodies on images, extract descriptors and estimate several parameters

Module contains luna-remote-sdk client adapted for usage in lambda

class luna_lambda_tools.public.clients.lrs.LRS(lrsClient, accountId)[source]

Luna-remote-sdk client

getAddress()[source]

Get luna-remote-sdk address

Return type:

str

sdk(inputData, multifacePolicy=1, detectFace=None, detectBody=None, estimateHeadPose=None, estimateLandmarks68=None, estimateLandmarks5=None, estimateQuality=None, estimateGaze=None, estimateEyesAttributes=None, estimateEmotions=None, estimateMouthAttributes=None, estimateMask=None, estimateGlasses=None, estimateLiveness=None, estimateFaceWarp=None, estimateBodyWarp=None, aggregateAttributes=None, estimateBasicAttributes=None, estimateBodyDescriptor=None, estimateFaceDescriptor=None, estimateUpperBody=None, estimateLowerBody=None, estimateBodyBasicAttributes=None, estimateAccessories=None, pitchThreshold=None, rollThreshold=None, yawThreshold=None, scoreThreshold=None, maskStates=None, livenessStates=None, imageType=None, useExifInfo=None, extractExif=None, raiseError=True, **kwargs)[source]

Detect faces on input images.

Parameters:
  • inputData (BinaryImage | list[BinaryImage] | list[UrlForDetection] | list[str]) – one of: - Single image or images list for extraction (supported formats “jpeg, png, tif, ppm, bmp”). - list of urls with images - list of images’ ids

  • multifacePolicy (int) – multiple face detection policy: 0 - multiple face detection not allowed, 1 - multiple face detection allowed, 2 - get best detection from the image

  • detectFace (int | None) – detect faces

  • detectBody (int | None) – detect human bodies

  • estimateHeadPose (int | None) – Available values : 0, 1

  • estimateLandmarks5 (int | None) – Available values : 0, 1

  • estimateLandmarks68 (int | None) – Available values : 0, 1

  • estimateQuality (int | None) – Available values : 0, 1

  • estimateGaze (int | None) – Available values : 0, 1

  • estimateEyesAttributes (int | None) – Available values : 0, 1

  • estimateMouthAttributes (int | None) – Available values : 0, 1

  • estimateEmotions (int | None) – Available values : 0, 1

  • estimateMask (int | None) – Available values: 0, 1

  • estimateGlasses (int | None) – Available values: 0, 1

  • estimateLiveness (int | None) – Available values: 0, 1

  • estimateFaceDescriptor (int | None) – Available values : 0, 1

  • estimateBodyDescriptor (int | None) – Available values : 0, 1

  • estimateBasicAttributes (int | None) – Available values : 0, 1

  • estimateBodyWarp (int | None) – Available values : 0, 1

  • estimateFaceWarp (int | None) – Available values : 0, 1

  • estimateUpperBody (int | None) – Available values : 0, 1

  • estimateLowerBody (int | None) – Available values : 0, 1

  • estimateBodyBasicAttributes (int | None) – Available values : 0, 1

  • estimateAccessories (int | None) – Available values : 0, 1

  • pitchThreshold (int | None) – maximum deviation pitch angle from 0

  • rollThreshold (int | None) – maximum deviation roll angle from 0

  • yawThreshold (int | None) – maximum deviation yaw angle from 0

  • scoreThreshold (float) – descriptor garbage score

  • maskStates (list[int] | None) – Array of integer (filter by mask state) (Items Enum:1 2 3)

  • livenessStates (list[int] | None) – Array of integer (filter by liveness state) (Items Enum:0 1 2)

  • aggregateAttributes (int | None) – Available values : 0, 1

  • imageType (int | None) – image type (0 - raw image, 1 - face warped image, 2 - body warped image)

  • useExifInfo (int | None) – whether to use exif info for auto orientation

  • extractExif (int | None) – extract EXIF meta information from images

  • raiseError (bool) – whether to raise LunaApiException in case of failure

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with samples, exif, filename for succeeded images and errors for failed images will be returned.

Return type:

class

Luna Sender client

The luna-sender client which allows to send custom events to luna-sender

Module contains luna-sender client adapted for usage in lambda

class luna_lambda_tools.public.clients.sender.Sender(senderClient, accountId)[source]

Luna-sender client

getAddress()[source]

Get luna sender address

Return type:

str

publish(events, *, handlerId, eventCreateTime, eventEndTime, raiseError=True, **kwargs)[source]

Publish user generated events. :type events: list[dict] :param events: user generated events to be published :type handlerId: str :param handlerId: event handler id :type eventCreateTime: str :param eventCreateTime: event creation time :type eventEndTime: str :param eventEndTime: event end time :type raiseError: :param raiseError: whether to raise LunaApiException in case of failure

Luna Handlers client

The luna-handlers client which allows to send custom events to luna-handlers

Module contains luna-handlers client adapted for usage in lambda

class luna_lambda_tools.public.clients.handlers.Handlers(handlersClient, accountId)[source]

Luna-handlers client

checkHandlerById(handlerId, **kwargs)[source]

Check whether handler exists by its id

Parameters:

handlerId (str) – handler id (uuid4)

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse: no text returns

Return type:

class

checkVerifier(verifierId, **kwargs)[source]

Check verifier existence

Parameters:

verifierId (str) – verifier id

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse: no text returns

Return type:

class

createHandler(policies=None, handlerType=None, lambdaId=None, description=None, **kwargs)[source]

Create new handler. Handler determinate a list of rules for proccessing input images. You can set parameters for detecting faces, extracting attributes. You can set rules for matching attributes and creating faces from them.

Parameters:
  • policies (Policies | None) – object with policies information

  • handlerType (int | None) – handler type (0 - static, 1 - dynamic, 2 - lambda)

  • lambdaId (str | None) – lambda id

  • description (str | None) – user description

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json new handler id and url

Return type:

class

createVerifier(policies=None, description=None, **kwargs)[source]

Create new verifier. Verifier determinate a list of rules for processing & verification of input images. You can set parameters for detecting faces, extracting attributes. You can set rules for matching attributes and creating faces from them.

Parameters:
  • policies (VerifierPolicies | None) – object with policies information

  • description (str | None) – user description

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json new verifier id and url

Return type:

class

deleteHandlerById(handlerId, **kwargs)[source]

Remove handler by id

Parameters:

handlerId (str) – handler id (uuid4)

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse: no text returns

Return type:

class

deleteVerifier(verifierId, **kwargs)[source]

Remove verifier :rtype: Union[Awaitable[LunaResponse], LunaResponse]

Args:

verifierId: verifier id

Returns:

class:~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse: no text returns

detectFaces(inputData, multifacePolicy=1, estimateHeadPose=0, detectLandmarks68=0, extractExif=0, estimateQuality=0, estimateGaze=0, estimateEyesAttributes=0, estimateEmotions=0, estimateMask=0, estimateMouthAttributes=0, pitchThreshold=None, rollThreshold=None, yawThreshold=None, warpedImage=0, useExifInfo=None, estimateFaceQuality=0, **kwargs)[source]

Detect faces on input images.

Parameters:
  • inputData (BinaryImage | list[BinaryImage] | list[UrlForDetection] | list[str]) – one of: - Single image or images list for extraction (supported formats “jpeg, png, tif, ppm, bmp”). - list of urls with images - list of images’ ids

  • multifacePolicy (int) – multiple face detection policy: 0 - multiple face detection not allowed, 1 - multiple face detection allowed, 2 - get best detection from the image

  • estimateHeadPose (int) – Available values : 0, 1

  • detectLandmarks68 (int) – Available values : 0, 1

  • extractExif (int) – Available values : 0, 1

  • estimateQuality (int) – Available values : 0, 1

  • estimateGaze (int) – Available values : 0, 1

  • estimateEyesAttributes (int) – Available values : 0, 1

  • estimateMouthAttributes (int) – Available values : 0, 1

  • estimateEmotions (int) – Available values : 0, 1

  • estimateMask (int) – Available values : 0, 1

  • pitchThreshold (int | None) – maximum deviation pitch angle from 0

  • rollThreshold (int | None) – maximum deviation roll angle from 0

  • yawThreshold (int | None) – maximum deviation yaw angle from 0

  • warpedImage (int) – Whether input image is a warped or arbitrary image.

  • useExifInfo (int | None) – whether to use exif info for auto orientation

  • estimateFaceQuality (int) – whether to estimate face quality

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with samples, exif, filename for succeeded images and errors for failed images will be returned.

Return type:

class

emitEvents(handlerId, inputData, policies=None, externalId=None, userData=None, aggregateAttributes=None, source=None, streamId=None, city=None, street=None, district=None, area=None, houseNumber=None, tags=None, latitude=None, longitude=None, imageType=None, lunaEventTime=None, lunaEventEndTime=None, trackId=None, useExifInfo=None, meta=None, **kwargs)[source]

Emit input events.

Parameters:
  • handlerId (str) – handler id

  • inputData (BinaryImage | list[BinaryImage] | list[UrlForDetection] | list[str] | list[SampleForDetection]) – one of: - Single image or images list for extraction (supported formats “jpeg, png, tif, ppm, bmp”). - list of urls with images - list of images’ ids

  • policies (Policies | dict | None) – object with policies information for dynamic handler

  • externalId (str | None) – external id

  • userData (str | None) – user data

  • aggregateAttributes (int | None) – aggregate all attributes (descriptot, age, gender) or not (0 or 1)

  • source (str | None) – source

  • streamId (str | None) – stream id

  • city (str | None) – event city

  • street (str | None) – event street

  • area (str | None) – event area

  • district (str | None) – event district

  • houseNumber (str | None) – event house number

  • tags (str | None) – tags

  • latitude (float | None) – event latitude in degrees

  • longitude (float | None) – event longitude in degrees

  • imageType (int) – image type (0 - raw image, 1 - face warped image, 2 - body warped image)

  • lunaEventTime (str | None) – user defined event create time

  • lunaEventEndTime (str | None) – user defined event end time

  • trackId (str | None) – (str) event track id

  • useExifInfo (int | None) – whether to use exif info for auto orientation

  • meta (dict | None) – user-defined event metadata

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json new handler id and url

Return type:

class

emitStreamEvents(handlerId, inputData, **kwargs)[source]

Emit stream events.

Parameters:
  • handlerId (str) – handler id

  • inputData (StreamEventsSource) – structure with stream event(s) source

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json new handler id and url

Return type:

class

extractAttrFromSample(sampleIds, scoreThreshold=0, extractDescriptor=1, extractBasicAttributes=0, aggregateAttributes=0, ttl=None, **kwargs)[source]

Extract attributes from samples.

Parameters:
  • sampleIds (list[str]) – list of samples

  • scoreThreshold (float) – number [ 0 .. 1 ]; example: 0.99; descriptor quality score threshold. All the attributes with quality score below the threshold will be ignored (and not stored in the DB). The function will proceed as usual with all the remaining descriptors (if left).

  • extractDescriptor (int) – Available values : 0, 1; whether to extract face descriptor(s)

  • extractBasicAttributes (int) – Available values : 0, 1; whether to extract basic attributes (gender, age, ethnicity)

  • aggregateAttributes (int) – Available values : 0, 1; whether to aggregate face descriptor(s); If true, all extracted attributes will be aggregated and stored in as a single attribute. Otherwise, all attributes will be stored for every sample.

  • ttl (int | None) – temporary attribute ttl

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse: json with attributes info

Return type:

class

getAddress()[source]

Get luna-handlers address

Return type:

str

getHandlerById(handlerId, **kwargs)[source]

Get handler by its id

Parameters:

handlerId (str) – handler id (uuid4)

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse: json with handler info

Return type:

class

getHandlers(description=None, handlerType=None, page=1, pageSize=10, **kwargs)[source]

Get handlers by filters

Parameters:
  • description (str | None) – Find all handlers with description which “like” of this parameter

  • handlerType (int | None) – handler type (0 - static, 1 - dynamic, 2 - lambda)

  • page (int) – The number of page

  • pageSize (int) – The numbers of items on page

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse: json with handlers info

Return type:

class

getHandlersCount(description=None, handlerType=None, **kwargs)[source]

Get handlers count by filters

Parameters:
  • description (str | None) – Find all handlers with description which “like” of this parameter

  • handlerType (int | None) – handler type (0 - static, 1 - dynamic, 2 - lambda)

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse: handlers count

Return type:

class

getVerifier(verifierId, **kwargs)[source]

Get verifier

Parameters:

verifierId (str) – verifier id

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse: json with verifier info

Return type:

class

getVerifiers(description=None, page=1, pageSize=10, **kwargs)[source]

Get verifiers by filters

Parameters:
  • description (str | None) – verifier description (“like” parameter)

  • page (int) – The number of page

  • pageSize (int) – The numbers of items on page

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse: json with verifiers info

Return type:

class

getVerifiersCount(description=None, **kwargs)[source]

Count verifiers that satisfy the filters

Parameters:

description (str | None) – verifier description (“like” parameter)

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse: verifier count

Return type:

class

putVerifier(verifierId, policies=None, description=None, **kwargs)[source]

Replace verifier

Parameters:
  • verifierId (str) – verifier id

  • policies (VerifierPolicies | None) – object with policies information

  • description (str | None) – user description

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse: no text returns

Return type:

class

saveEvent(handlerId, event, waitSaving=None, **kwargs)[source]

Save raw event.

Parameters:
  • handlerId (str) – handler id

  • event (RawEvent | dict[str, Any]) – raw event

  • waitSaving (int | None) – whether to wait for event saving

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse.

Return type:

class

updateHandler(handlerId, policies=None, handlerType=None, lambdaId=None, description=None, **kwargs)[source]

Update a handler. You can not update a part of handler.

Parameters:
  • handlerId (str) – handler id

  • policies (Policies | None) – object with policies information

  • handlerType (int | None) – handler type (0 - static, 1 - dynamic, 2 - lambda)

  • lambdaId (str | None) – lambda id

  • description (str | None) – user description

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return nothing in text field

Return type:

class

upgradeObjectFromSample(data, **kwargs)[source]

Upgrade basic attributes and/or descriptor in a object using samples.

Parameters:

data (FaceAttributeUpgrade | EventAttributeUpgrade) – face or attribute upgrade object

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse: json with attributes info

Return type:

class

validateHandler(policies, **kwargs)[source]

Validate handler policies.

Parameters:

policies (Policies | dict) – object with policies information

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse.

Return type:

class

verifyData(verifierId, inputData, eventIds=None, externalIds=None, faceIds=None, attributeIds=None, imageType=None, useExifInfo=None, **kwargs)[source]

Perform data verification against specified objects. Only one objects set is allowed.

Parameters:
  • verifierId (str) – verifier id

  • inputData (BinaryImage | BinaryDescriptorData | list[BinaryImage | BinaryDescriptorData]) – one of: - Single image - Single descriptor - List of images and descriptors

  • faceIds (list[str] | None) – faces ids to verify against

  • eventIds (list[str] | None) – event ids to verify against

  • externalIds (list[str] | None) – external ids to verify against

  • attributeIds (list[str] | None) – temporary attribute ids to verify against

  • imageType (int | None) – image type (0 - raw image, 1 - face warped image)

  • useExifInfo (int | None) – whether to use exif info for auto orientation

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse: json with verifications info

Return type:

class

verifyRaw(candidates, references, verifierId, **kwargs)[source]

Verify raw API allows to match each candidate with each reference descriptors.

Parameters:
  • verifierId (str) – verifier id

  • candidates (list[BinaryReference]) – list of BinaryReference objects for candidates

  • references (list[BinaryReference]) – list of BinaryReference objects for references verifierId: verifier id

Returns:

~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse: results of matching

Return type:

class