Source code for module.utils.how_to_get_frames_from_entity

from typing import List, Dict
import avesterra as av



[docs] def examples_of_get_frames_by_retrieve(report_entity: av.AvEntity, auth: av.AvAuthorization): """ This function shows how to get frames from an entity. :param report_entity: The entity ID of the entity wich holds the frames. :param auth: The Orchestra server authorization that allows entity operations. """ # Get the count of the number of fields (columns). Need this for iterating field_count = av.field_count(entity=report_entity, authorization=auth) field_list: List[str] = [] # Loop through the fields (columns) and store the name and store. # Note that Orchestra indexes always start at 1. for i in range(1, field_count + 1): field_list.append( av.field_name( entity=report_entity, attribute=av.AvAttribute.LIST, index=i, authorization=auth ) ) # Now that we have the list of field names (columns), we can use it # to get the value of each field by iterating over each frame frame_count = av.frame_count(entity=report_entity, attribute=av.AvAttribute.LIST, authorization=auth) print("---------------------------------------------------------------------------------------------------") print("----------------These are the frames/field values retrieved from the report entity-----------------") for i in range(1, + frame_count + 1): frame_values: Dict = {} for field in field_list: frame_values[field] = av.get_frame(entity=report_entity, attribute=av.AvAttribute.LIST, index=i, name=field, authorization=auth).decode() print(frame_values) print("---------------------------------------------------------------------------------------------------")
[docs] def examples_of_get_frames_by_brute_force(report_entity: av.AvEntity, person_entity: av.AvEntity, auth: av.AvAuthorization): """ :param report_entity: The entity containing the frames. :param person_entity: The entity to get the frane data for. :param auth: The Orchestra server authorization that allows entity operations. """ print("") print("------------------------------------------------------------------------------") print("----------------Brute force retrievals from the report entity-----------------") person_eid = av.get_frame(entity=report_entity, attribute=av.AvAttribute.LIST, name="PersonEID", key=str(person_entity), authorization=auth).decode() name = av.get_frame(entity=report_entity, attribute=av.AvAttribute.LIST, name="Name", key=str(person_entity), authorization=auth).decode() occupation = av.get_frame(entity=report_entity, attribute=av.AvAttribute.LIST, name="Occupation", key=str(person_entity), authorization=auth).decode() company = av.get_frame(entity=report_entity, attribute=av.AvAttribute.LIST, name="Company", key=str(person_entity), authorization=auth).decode() print(f"PersonEID: {person_eid}, Name: {name}, Occupation: {occupation}, Company: {company}") print("------------------------------------------------------------------------------")