def if_(self, condition: Callable[[Any, StepExecutionContext], bool]): new_step = WorkflowStep(If) new_step.body = If self.workflow_builder.add_step(new_step) step_builder = StepBuilder[TStep](new_step, self.workflow_builder) step_builder.input('condition', condition) outcome = StepOutcome() outcome.next_step = new_step.id self.step.outcomes.append(outcome) return step_builder
def for_each(self, collection: Callable[[Any, StepExecutionContext], List]): new_step = WorkflowStep(Foreach) new_step.body = Foreach self.workflow_builder.add_step(new_step) step_builder = StepBuilder[TStep](new_step, self.workflow_builder) step_builder.input('collection', collection) outcome = StepOutcome() outcome.next_step = new_step.id self.step.outcomes.append(outcome) return step_builder
def wait_for( self, event_name: str, event_key: Callable[[Any, StepExecutionContext], Any], effective_date=lambda data, context: datetime.utcnow() ) -> 'StepBuilder[WaitFor]': new_step = WorkflowStep(WaitFor) new_step.body = WaitFor self.workflow_builder.add_step(new_step) step_builder = StepBuilder[TStep](new_step, self.workflow_builder) step_builder.input('event_name', lambda data, context: event_name) step_builder.input('event_key', event_key) step_builder.input('effective_date', effective_date) outcome = StepOutcome() outcome.next_step = new_step.id self.step.outcomes.append(outcome) return step_builder
def start_with(self, body: TStep) -> StepBuilder[TStep]: new_step = WorkflowStep(body) new_step.body = body self.add_step(new_step) return StepBuilder[TStep](new_step, self)