def post_sync_started_event(instance, serialized_event_request): request = None if serialized_event_request: request = EventRequest.deserialize(serialized_event_request) metadata = EventMetadata(request=request) event = WSOneInstanceSyncStarted( metadata, {"instance": instance.serialize_for_event()}) event.post()
def post_sync_finished_event(instance, serialized_event_request, result): request = None if serialized_event_request: request = EventRequest.deserialize(serialized_event_request) metadata = EventMetadata(request=request) event = WSOneInstanceSyncFinished( metadata, { "instance": instance.serialize_for_event(), "sync": result }) event.post()
def _deserialize_event(self, doc): doc.pop('stored_at') event_type = doc.pop('event_type') payload = doc.pop('payload') request_d = { k: v for k, v in ((a, doc.pop(a)) for a in ('user_agent', 'ip', 'user')) if v } if request_d: doc['request'] = EventRequest.deserialize(request_d) else: doc['request'] = None event_cls = event_cls_from_type(event_type) event = event_cls(EventMetadata(event_type, **doc), payload) return event
def post_cleanup_finished_event(payload, serialized_event_request): request = EventRequest.deserialize(serialized_event_request) metadata = EventMetadata(request=request) event = InventoryCleanupFinished(metadata, {"cleanup": payload}) event.post()