import avesterra as av
"""
The lesson shows hot to create outlets on a Person.
:param name: The name of the person.
:param auth: The Orchestra server authorization that allows entity operations.
"""
[docs]
def outlet_connections(name: str, auth: av.AvAuthorization) -> av.AvEntity:
# Create person
person_entity = av.create_object(
name=name,
key=name.lower(),
context=av.AvContext.ORCHESTRA,
category=av.AvCategory.PERSON,
klass=av.AvClass.PERSON,
authorization=auth
)
# Add a few facts
av.set_fact(
entity=person_entity,
attribute=av.AvAttribute.ADDRESS,
value=av.AvValue.encode_string('101 South Home'),
authorization=auth,
)
av.set_fact(
entity=person_entity,
attribute=av.AvAttribute.OCCUPATION,
value=av.AvValue.encode_string('Software Engineer'),
authorization=auth,
)
av.set_fact(
entity=person_entity,
attribute=av.AvAttribute.COMPANY,
value=av.AvValue.encode_string('IBM'),
authorization=auth,
)
# Activate/Create an outlet on the person
av.activate_entity(
outlet=person_entity,
authorization=auth
)
# Establish a connection method. Null will accept any callback on the outlet.
av.connect_method(
entity=person_entity,
outlet=person_entity,
method=av.AvMethod.NULL, # Other method values are NULL, SET , NAME, GET, DELETE
precedence=2,
authorization=auth
)
# Establish another connection method using GET
av.connect_method(
entity=person_entity,
outlet=person_entity,
method=av.AvMethod.GET, # Other method values are NULL, SET , NAME, GET, DELETE
precedence=2,
authorization=auth
)
return person_entity