Esempio n. 1
0
 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
Esempio n. 2
0
 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))
Esempio n. 3
0
 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))
Esempio n. 4
0
 def set_data(self, payload: KvPayload):
     """ Updates input payload and writes into backend """
     p_payload = self.load()
     _ = map(lambda x: p_payload.set(x, payload.get[x]), payload.get_keys())
     self.dump(p_payload)
Esempio n. 5
0
 def set_payload(self, payload: KvPayload):
     for key in payload.get_keys():
         super().set(f'payload>{key}', payload.get(key))