Skip to content

event

event object

Event

a representation of an json event to use

from_json(self, json_msg)

set this event from json_msg

Parameters:

Name Type Description Default
json_msg

loaded json

required
Source code in event_stream/event.py
def from_json(self, json_msg):
    """set this event from json_msg

    Arguments:
        json_msg: loaded json
    """
    self.data = json_msg

get(self, key)

this will get a value to a given key in the data of this event this is equal to data['key'] if access to nested properties is needed use data directly

Parameters:

Name Type Description Default
key

a valid key for the data of this event

required
Source code in event_stream/event.py
def get(self, key):
    """this will get a value to a given key in the data of this event
    this is equal to data['key']
    if access to nested properties is needed use data directly

    Arguments:
        key: a valid key for the data of this event
    """
    return self.data[key]

get_json(self)

return this event as json equal to json.dumps(data)

Source code in event_stream/event.py
def get_json(self):
    """return this event as json
        equal to json.dumps(data)
    """
    return json.dumps(self.data)

set(self, key, value)

this will set a value to a given key in the data of this event this is equal to data['key'] = value if setting nested properties use data directly

Parameters:

Name Type Description Default
key

a valid key for the data of this event

required
value

the value to store

required
Source code in event_stream/event.py
def set(self, key, value):
    """this will set a value to a given key in the data of this event
    this is equal to data['key'] = value
    if setting nested properties use data directly

    Arguments:
        key: a valid key for the data of this event
        value: the value to store
    """
    self.data[key] = value