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 (UnionType[list[str], None]) – event deletion info targets

  • handlerId (UnionType[str, None]) – event handler id

  • createTimeGte (UnionType[str, None]) – lower including create time boundary

  • createTimeLt (UnionType[str, None]) – upper excluding create time boundary

  • insertTimeGte (UnionType[str, None]) – lower including insert time boundary

  • insertTimeLt (UnionType[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 (UnionType[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’, ‘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 (UnionType[str, None]) – event id

  • descriptorVersion (UnionType[int, None]) – descriptor version

  • descriptorType (UnionType[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 (UnionType[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’, ‘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 (UnionType[str, None]) – lower including create time boundary

  • createTimeLt (UnionType[str, None]) – upper excluding create time boundary

  • endTimeGte (UnionType[str, None]) – lower including end time boundary

  • endTimeLt (UnionType[str, None]) – upper excluding end time boundary

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

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

  • eventIdGte (UnionType[str, None]) – event id lower including bound

  • eventIdLt (UnionType[str, None]) – event id upper excluding bound

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

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

  • userData (UnionType[str, None]) – event user data

  • sources (UnionType[list[Union[str, Literal[‘null’]]], None]) – list of source

  • tags (UnionType[list[str], None]) – users tags

  • topMatchingCandidatesLabel (UnionType[str, None]) – top matching candidates label

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

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

  • topSimilarObjectSimilarityGte (UnionType[float, None]) – lower including top similarity boundary

  • topSimilarObjectSimilarityLt (UnionType[float, None]) – upper excluding top similarity boundary

  • ageLt (UnionType[int, None]) – upper excluding age boundary

  • ageGte (UnionType[int, None]) – lower including age boundary

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

  • emotions (UnionType[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 (UnionType[list[Union[int, Literal[‘null’]]], None]) – dominant masks in event (one of (1, 2, 3) - matches “missing”, “medical_mask”, “occluded”)

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

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

  • apparentAgeLt (UnionType[int, None]) – apparent age upper excluding boundary

  • apparentAgeGte (UnionType[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 (UnionType[list[Union[Literal[0, 1, 2], Literal[‘null’]]], None]) – headwear states (0 - absent, 1 - present, 2 - undefined)

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

  • sleeveLengths (UnionType[list[Literal[‘short’, ‘long’, ‘undefined’, ‘null’]], None]) – sleeve lengths

  • upperClothingColors (UnionType[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 (UnionType[list[Literal[‘undefined’, ‘trousers’, ‘shorts’, ‘skirt’, ‘null’]], None]) – lower garment types

  • lowerGarmentColors (UnionType[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 (UnionType[list[Union[Literal[‘undefined’, ‘black’, ‘white’, ‘other’], Literal[‘null’]]], None]) – shoes apparent colors

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

  • areas (UnionType[list[Union[str, Literal[‘null’]]], None]) – list of areas

  • streets (UnionType[list[Union[str, Literal[‘null’]]], None]) – list of streets

  • districts (UnionType[list[Union[str, Literal[‘null’]]], None]) – list of districts

  • cities (UnionType[list[Union[str, Literal[‘null’]]], None]) – list of cities

  • houseNumbers (UnionType[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 (UnionType[float, None]) – longitude delta in degrees

  • latitudeDelta (UnionType[float, None]) – latitude delta in degrees

  • trackIds (UnionType[list[Union[str, Literal[‘null’]]], None]) – list of track ids

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

  • page (UnionType[int, None]) – number of result page

  • pageSize (UnionType[int, None]) – count of results in page

  • order (UnionType[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 (UnionType[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 (UnionType[list[UnionType[bytes, RawDescriptor]], None]) – list of descriptors different versions

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

  • basicAttributes (UnionType[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 (UnionType[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 (UnionType[str, None]) – attribute id

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

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

  • basicAttributes (UnionType[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 (UnionType[str, None]) – reference to event which created face

  • userData (UnionType[str, None]) – face user data

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

  • avatar (UnionType[str, None]) – face avatar url

  • listIds (UnionType[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 (UnionType[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 (UnionType[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 (UnionType[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 (UnionType[str, None]) – list id

  • timeLt (UnionType[str, None]) – upper bound of face update time

  • timeGte (UnionType[str, None]) – lower bound of face update time

  • page (UnionType[int, None]) – page, default 1

  • pageSize (UnionType[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 (UnionType[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 (UnionType[str, None]) – upper including link key boundary

  • linkKeyGte (UnionType[str, None]) – lower including link key boundary

  • limit (UnionType[int, None]) – limit

  • parity (UnionType[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 (UnionType[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 (UnionType[list[str], None]) – targets to get face attributes. Available targets: create_time, face_descriptor, basic_attributes, face_descriptor_samples, basic_attributes_samples.

  • descriptorVersion (UnionType[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 (UnionType[str, None]) – user data, part of user data, case insensitive

  • eventId (UnionType[str, None]) – event id

  • listId (UnionType[str, None]) – list id

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

  • timeLt (UnionType[str, None]) – upper bound of face create time

  • timeGte (UnionType[str, None]) – lower bound of face create time

  • page (UnionType[int, None]) – page count, default 1

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

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

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

  • faceIdGte (UnionType[str, None]) – lower face id including boundary

  • faceIdLt (UnionType[str, None]) – upper face id excluding boundary

  • targets (UnionType[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 (UnionType[str, None]) – user data, part of user data, case insensitive

  • eventId (UnionType[str, None]) – event id

  • listId (UnionType[str, None]) – list id

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

  • timeLt (UnionType[str, None]) – upper bound of face create time

  • timeGte (UnionType[str, None]) – lower bound of face create time

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

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

  • faceIdGte (UnionType[str, None]) – lower face id including boundary

  • faceIdLt (UnionType[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 (UnionType[int, None]) – page count, default 1

  • pageSize (UnionType[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 (UnionType[str, None]) – user data, part of user data, case sensitive

  • userDataEq (UnionType[str, None]) – user data, case sensitive

  • createTimeLt (UnionType[str, None]) – upper bound of list create time

  • createTimeGte (UnionType[str, None]) – lower bound of list create time including boundary

  • lastUpdateTimeLt (UnionType[str, None]) – upper bound of list last update time

  • lastUpdateTimeGte (UnionType[str, None]) – lower bound of list last update time including boundary

  • listIdLt (UnionType[str, None]) – upper bound of list id

  • listIdGte (UnionType[str, None]) – lower bound of list id including boundary

  • listIds (UnionType[list[str], None]) – list ids

  • page (UnionType[int, None]) – page, default 1

  • pageSize (UnionType[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 (UnionType[str, None]) – user data, part of user data, case sensitive

  • userDataEq (UnionType[str, None]) – user data

  • createTimeLt (UnionType[str, None]) – upper bound of list create time

  • createTimeGte (UnionType[str, None]) – lower bound of list create time including boundary

  • lastUpdateTimeLt (UnionType[str, None]) – upper bound of list last update time

  • lastUpdateTimeGte (UnionType[str, None]) – lower bound of list last update time including boundary

  • listIds (UnionType[list[str], None]) – list ids

  • listIdLt (UnionType[str, None]) – upper bound of list id

  • listIdGte (UnionType[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 (UnionType[str, None]) – new event id

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

  • userData (UnionType[str, None]) – new user data

  • avatar (UnionType[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 (UnionType[list[UnionType[bytes, RawDescriptor]], None]) – list of descriptors different versions

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

  • basicAttributes (UnionType[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 (UnionType[int, None]) – temporary attribute ttl

  • force (UnionType[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 (UnionType[str, None]) – external id of the face, if it has its own mapping in the system

  • attributeId (UnionType[str, None]) – attribute id

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

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

  • basicAttributes (UnionType[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 (UnionType[str, None]) – reference to event which created face

  • userData (UnionType[str, None]) – face user data

  • avatar (UnionType[str, None]) – face avatar url

  • listIds (UnionType[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 (UnionType[str, None]) – attribute id

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

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

  • basicAttributes (UnionType[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 (UnionType[str, None]) – attribute id

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

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

  • basicAttributes (UnionType[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 (UnionType[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 (UnionType[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 (UnionType[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 (UnionType[int, None]) – matching limit

  • threshold (UnionType[int, None]) – matching threshold

  • sorting (UnionType[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 (UnionType[FaceFilters, EventFilters, AttributeFilters]) – candidate filters

  • referenceFilters (UnionType[FaceFilters, EventFilters, AttributeFilters]) – reference filters

  • limit (UnionType[int, None]) – matching limit

  • threshold (UnionType[int, None]) – matching threshold

  • sorting (UnionType[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[UnionType[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[UnionType[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 (UnionType[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 (UnionType[int, None]) – detect faces

  • detectBody (UnionType[int, None]) – detect human bodies

  • estimateHeadPose (UnionType[int, None]) – Available values : 0, 1

  • estimateLandmarks5 (UnionType[int, None]) – Available values : 0, 1

  • estimateLandmarks68 (UnionType[int, None]) – Available values : 0, 1

  • estimateQuality (UnionType[int, None]) – Available values : 0, 1

  • estimateGaze (UnionType[int, None]) – Available values : 0, 1

  • estimateEyesAttributes (UnionType[int, None]) – Available values : 0, 1

  • estimateMouthAttributes (UnionType[int, None]) – Available values : 0, 1

  • estimateEmotions (UnionType[int, None]) – Available values : 0, 1

  • estimateMask (UnionType[int, None]) – Available values: 0, 1

  • estimateGlasses (UnionType[int, None]) – Available values: 0, 1

  • estimateLiveness (UnionType[int, None]) – Available values: 0, 1

  • estimateFaceDescriptor (UnionType[int, None]) – Available values : 0, 1

  • estimateBodyDescriptor (UnionType[int, None]) – Available values : 0, 1

  • estimateBasicAttributes (UnionType[int, None]) – Available values : 0, 1

  • estimateBodyWarp (UnionType[int, None]) – Available values : 0, 1

  • estimateFaceWarp (UnionType[int, None]) – Available values : 0, 1

  • estimateUpperBody (UnionType[int, None]) – Available values : 0, 1

  • estimateLowerBody (UnionType[int, None]) – Available values : 0, 1

  • estimateBodyBasicAttributes (UnionType[int, None]) – Available values : 0, 1

  • estimateAccessories (UnionType[int, None]) – Available values : 0, 1

  • pitchThreshold (UnionType[int, None]) – maximum deviation pitch angle from 0

  • rollThreshold (UnionType[int, None]) – maximum deviation roll angle from 0

  • yawThreshold (UnionType[int, None]) – maximum deviation yaw angle from 0

  • scoreThreshold (float) – descriptor garbage score

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

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

  • aggregateAttributes (UnionType[int, None]) – Available values : 0, 1

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

  • useExifInfo (UnionType[int, None]) – whether to use exif info for auto orientation

  • extractExif (UnionType[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 :param raiseError: whether to raise LunaApiException in case of failure