🚀 feat(custom_component.py): add methods to retrieve flow by name and flow by id for CustomComponent

🐛 fix(custom_component.py): fix indentation issue in CustomComponent class
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-07-31 10:26:27 -03:00
commit 9acb6fef36

View file

@ -158,5 +158,15 @@ class CustomComponent(Component, extra=Extra.allow):
flows = session.query(Flow).all()
return flows
def get_flow(self, flow_name: str) -> Flow:
with session_getter() as session:
flow = session.query(Flow).filter(Flow.name == flow_name).first()
return flow
def get_flow_by_id(self, flow_id: str) -> Flow:
with session_getter() as session:
flow = session.query(Flow).filter(Flow.id == flow_id).first()
return flow
def build(self):
raise NotImplementedError