Skip to content

Types

flowtask.hooks.types

Hook Types.

Hook Types are triggers that can be executed when an event is triggered.

  1. FSWatchdog: Watches a specified directory for changes.

base

BaseTrigger

BaseTrigger(*args, actions=None, **kwargs)

Bases: MaskSupport, LogSupport, LocaleSupport, ABC

BaseTrigger.

Base class for all Triggers in FlowTask.

setup
setup(app)

setup.

Configuration of Trigger when started.

Args: app (aiohttp.web.Application): Web Application.

brokers

Message Brokers.

Message Brokers are services that allow applications to send and receive messages.

Supported Message Brokers on Flowtask are: - MQTT - SQS - Redis - RabbitMQ

base

BaseMQTrigger
BaseMQTrigger(*args, actions=None, **kwargs)

Bases: BaseTrigger

connect abstractmethod async
connect()

Establish the connection.

disconnect abstractmethod async
disconnect()

Disconnect the connection.

start_consuming abstractmethod async
start_consuming()

Start consuming messages.

rabbitmq

RabbitMQTrigger
RabbitMQTrigger(*args, queue_name, routing_key='', exchange_name='', exchange_type='topic', credentials=None, actions=None, **kwargs)

Bases: BaseMQTrigger

redis

RedisTrigger
RedisTrigger(*args, stream_name, group_name='default_group', consumer_name='default_consumer', credentials=None, actions=None, **kwargs)

Bases: BaseMQTrigger

Redis Trigger.

Trigger that listens to a Redis Stream and calls actions based on the received messages.

fs

FSWatchdog

FSWatchdog(*args, **kwargs)

Bases: BaseWatchdog

FSWatchdog. Checking for changes in the filesystem and dispatch events.

FsHandler

FsHandler(parent, patterns=None, *args, **kwargs)

Bases: PatternMatchingEventHandler

on_modified
on_modified(event)

Handle file modification events.

This method is called when a file modification event is detected. It processes the event and calls the appropriate actions if the event meets certain criteria.

event (FileSystemEvent): The event object containing information about the file modification.

Returns: None

Note: - The method returns early if the event is for a directory or if 'modified' is not in the parent's events list. - It also returns early if the file was recently created to avoid duplicate processing. - If the file has zero size, a warning is logged. - The event is processed and actions are called twice with the same arguments.

process
process(event)

Process the event if it matches the patterns and isn't a directory.

zero_size
zero_size(filepath)

Check if the file is of zero size.

http

HTTPHook

HTTPHook(*args, **kwargs)

Bases: BaseTrigger, BaseHandler

HTTPHook.

Base Hook for all HTTP-based hooks.

jira

JiraIssue

Bases: BaseModel

JiraIssue.

A BaseModel to represent a Jira Issue.

JiraTrigger

JiraTrigger(*args, secret_token=None, **kwargs)

Bases: HTTPHook

JiraTrigger.

A Trigger that handles Jira webhooks for issue events.

mail

EmailTrigger

EmailTrigger(*args, webhook_url, tenant_id=None, client_id=None, client_secret=None, resource=None, **kwargs)

Bases: HTTPHook

authenticate async
authenticate()

Authenticates the client with Azure AD and initializes the Graph client.

This method creates a ClientSecretCredential using the tenant ID, client ID, and client secret. It then sets up an AzureIdentityAuthenticationProvider, initializes a GraphRequestAdapter, and finally creates a GraphServiceClient.

The method doesn't take any parameters as it uses the instance variables for authentication details.

Returns:

Type Description

None

postgres

PostgresTrigger

PostgresTrigger(*args, dsn=None, channel='notifications', **kwargs)

Bases: BaseTrigger

PostgresTrigger.

Trigger that listens for PostgreSQL events and sends notifications. Using LISTEN/NOTIFY Infraestructure.

responses

Responses.

Pre-defined responses for Hooks.

TriggerResponse

Basic Response.

Basic Reponse dispatched by a Hook.

base

TriggerResponse

Basic Response.

Basic Reponse dispatched by a Hook.

sharepoint

SharePointTrigger

SharePointTrigger(*args, webhook_url, tenant_id=None, client_id=None, client_secret=None, resource=None, **kwargs)

Bases: HTTPHook

authenticate async
authenticate()

Authenticates the client with Azure AD and initializes the Graph client.

This method creates a ClientSecretCredential using the tenant ID, client ID, and client secret. It then sets up an AzureIdentityAuthenticationProvider, initializes a GraphRequestAdapter, and finally creates a GraphServiceClient.

The method doesn't take any parameters as it uses the instance variables for authentication details.

Returns:

Type Description

None

ssh

SFTPWatcher

SFTPWatcher(host, port, username, password, path, interval=300, max_retries=5, retry_delay=60, **kwargs)

Bases: BaseWatcher

upload

UploadHook

UploadHook(*args, allowed_mime_types=None, allowed_file_names=None, **kwargs)

Bases: HTTPHook

UploadHook.

A Trigger that handles file uploads via HTTP POST/PUT requests.

watch

BaseWatchdog

BaseWatchdog(*args, **kwargs)

Bases: BaseTrigger

BaseWatchdog. Checking for changes in the filesystem and dispatch events.

web

WebHook

WebHook(*args, **kwargs)

Bases: HTTPHook

WebHook.

Can be used to receive data from a web URL.