Esempio n. 1
0
def create_notifications(pipeline_):
    if notifies := pipeline_.config.get("notifications"):
        pipeline_.notifications = PiplineNotifications()
        if no_data_notification := notifies.get('no_data'):
            pipeline_.notifications.no_data_notification = NoDataNotifications(
                pipeline_,
                no_data_notification,
            )
            Session.add(pipeline_.notifications.no_data_notification)
Esempio n. 2
0
class SessionManager:
    def __init__(self, entity):
        self.entity = entity
        self.session = Session()
        if not self.session.object_session(self.entity):
            self.session.add(self.entity)

    def __enter__(self):
        return self.session

    def __exit__(self, exc_type, exc_value, exc_traceback):
        if exc_value:
            self.session.expunge(self.entity)
            return False
        self.session.commit()
        return True
Esempio n. 3
0
from agent.pipeline.notifications import PiplineNotifications, NoDataNotifications
from agent.modules.db import Session


def create_notifications(pipeline_):
    if notifies := pipeline_.config.get("notifications"):
        pipeline_.notifications = PiplineNotifications()
        if no_data_notification := notifies.get('no_data'):
            pipeline_.notifications.no_data_notification = NoDataNotifications(
                pipeline_,
                no_data_notification,
            )
            Session.add(pipeline_.notifications.no_data_notification)
        Session.add(pipeline_.notifications)
Esempio n. 4
0
def save(streamsets: StreamSets):
    if not Session.object_session(streamsets):
        Session.add(streamsets)
    Session.commit()
Esempio n. 5
0
def save(source_: Source):
    if not Session.object_session(source_):
        Session.add(source_)
    Session.commit()
Esempio n. 6
0
def save_auth_token(token: AuthenticationToken):
    if not Session.object_session(token):
        Session.add(token)
    Session.commit()
Esempio n. 7
0
def save(destination_: HttpDestination):
    if not Session.object_session(destination_):
        Session.add(destination_)
    Session.commit()
Esempio n. 8
0
def save(entity: Entity):
    if not Session.object_session(entity):
        Session.add(entity)
    Session.commit()