def get_changed_keys(self): """Get flattened dict of {old_key:key_key}.""" changed_keys = {} if Conf.get(NEW_CONF, CHANGED): for changed_key in Conf.get(NEW_CONF, CHANGED): changed_key_payload = KvPayload(changed_key) key = changed_key_payload.get_keys()[0] changed_keys[key] = changed_key_payload.get(key) return changed_keys
def __init__(self, payload: KvPayload = KvPayload()): """Initialize event object with header and payload attributes.""" super().__init__() # Set Header _now = str(time.time()) _uuid = str(uuid.uuid4().hex) _event_id = _now.split('.')[0] + _uuid super().set(f'header>{EventAttr.VERSION}', VERSION) super().set(f'header>{EventAttr.TIMESTAMP}', _now) super().set(f'header>{EventAttr.EVENT_ID}', _event_id) # Set payload if required for key in payload.get_keys(): super().set(f'payload>{key}', payload.get(key))
def set_specific_info(self, spec_info: dict): """Set payload attribute of key/value pairs specific to the resource type.""" specific_info = KvPayload(spec_info) for key in specific_info.get_keys(): super().set_payload_attr(f'specific_info>{key}', specific_info.get(key))
def set_payload(self, payload: KvPayload): for key in payload.get_keys(): super().set(f'payload>{key}', payload.get(key))