import json
import avesterra as av
[docs]
def examples_of_get_facts_by_retrieve(entity: av.AvEntity, auth: av.AvAuthorization):
"""
This function shows how to get facts from an entity. Its extremely helpful
when you don't actually know what facts are in an entity or need to
iterate though the facts.
:param entity: The entity ID of the entity to get the facts.
:param auth: The Orchestra server authorization that allows entity operations.
"""
facts_as_json = json.loads(av.retrieve_facts(entity, auth))
print("")
print("----------------Examples of get facts by retrieve:----------------")
for fact in facts_as_json['Facts']:
attribute = fact[0] # This is the key (e.g., 'ADDRESS_ATTRIBUTE')
value = fact[1].get('STRING', None) # Extract the 'STRING' value from the dictionary
print(f"Attribute: {attribute}, Value: {value}")
print("------------------------------------------------------------------\n")
[docs]
def examples_of_get_facts_by_brute_force(entity: av.AvEntity, auth: av.AvAuthorization):
"""
This function shows how to get facts from an entity, by specifying which
attributes you want to get.
:param entity: The entity ID of the entity to get the facts.
:param auth: The Orchestra server authorization that allows entity operations.
"""
address = av.get_fact(entity, av.AvAttribute.ADDRESS, auth)
occupation = av.get_fact(entity, av.AvAttribute.OCCUPATION, auth)
company = av.get_fact(entity, av.AvAttribute.COMPANY, auth)
print("")
print("----------------Examples of get facts by brute force:----------------")
print(f"Entity: address: {address} occupation: {occupation} company: {company}")
print("------------------------------------------------------------------\n")