Skip to content

Interfaces

flowtask.interfaces

Interfaces.

Services and methods covered by Flowtask. Support interfaces for many options on Task Components.

ClientInterface

ClientInterface(credentials=None, host=None, port=None, **kwargs)

Bases: CredentialsInterface

close abstractmethod async

close(timeout=5)

close. Closing the connection.

open abstractmethod async

open(host=None, port=None, credentials=None, **kwargs)

open. Starts (open) a connection to external resource.

DBInterface

DBInterface(*args, driver=None, **kwargs)

Bases: CredentialsInterface

DBInterface.

Abstract Interface for Database-based connectors.

DBSupport

DBSupport(*args, **kwargs)

Bases: CredentialsInterface

DBSupport.

Interface for adding AsyncbDB-based Database Support to Components.

default_connection

default_connection(driver)

default_connection.

Default Connection to Database.

get_default_driver

get_default_driver(driver)

get_default_driver.

Getting a default connection based on driver's name.

FuncSupport

FuncSupport(*args, **kwargs)

Bases: ABC

Interface for adding Add Support for Function Replacement.

HTTPService

HTTPService(*args, **kwargs)

Bases: CredentialsInterface, PandasDataframe

HTTPService.

Overview

    Interface for making connections to HTTP services.

api_get async

api_get(url, cookies=None, params=None, headers=None, use_proxy=None, free_proxy=False, use_http2=True)

Make an asynchronous HTTP GET request.

Parameters:

Name Type Description Default
url str

The URL to send the GET request to.

required
cookies Cookies

Cookies to include in the request.

None
params dict

Dictionary of query parameters to include in the URL.

None

Returns:

Name Type Description
dict Dict[str, Any]

The JSON response from the API if the request is successful.

Dict[str, Any]

Returns an empty dictionary if the request fails.

async_request async

async_request(url, method='GET', data=None, use_json=False, use_proxy=False, accept=None)

Asynchronously sends an HTTP request using aiohttp.

:param url: The URL to send the request to. :param method: The HTTP method to use (e.g., 'GET', 'POST'). :param data: The data to send in the request body. :param use_json: Whether to send the data as JSON. :param use_proxy: force proxy usage. :return: A tuple containing the result and any error information.

build_url

build_url(url, queryparams='', args=None)

Constructs a full URL with optional query parameters and arguments.

:param url: The base URL to be formatted. :param queryparams: Additional query parameters to be appended to the URL. :param args: Arguments to format within the URL. :return: The fully constructed URL.

evaluate_error async

evaluate_error(response, message)

evaluate_response.

Check Response status and available payloads. Args: response (type): description url (str): description

Returns:

Name Type Description
tuple tuple

description

get_proxies async

get_proxies(session_time=0.4, free_proxy=False)

Asynchronously retrieves a list of free proxies. TODO: SELECT or rotate the free/paid proxies.

process_request async

process_request(future, url)

Processes the result of an asynchronous HTTP request.

:param future: The future object representing the asynchronous operation. :param url: The URL that was requested. :return: A tuple containing the result and any error information.

process_response async

process_response(response, url)

Processes the response from an HTTP request.

:param response: The response object from aiohttp. :param url: The URL that was requested. :return: A tuple containing the processed result and any error information.

refresh_proxies async

refresh_proxies()

Asynchronously refreshes the list of proxies if proxy usage is enabled.

request async

request(url, method='GET', data=None, use_proxy=False, accept=None)

Sends an HTTP request using the requests library.

:param url: The URL to send the request to. :param method: The HTTP method to use (e.g., 'GET', 'POST'). :param data: The data to send in the request body. :return: A tuple containing the result and any error information.

session async

session(url, method='get', data=None, cookies=None, headers=None, use_json=False, follow_redirects=False, use_proxy=False, accept=None, return_response=False)

Asynchronously sends an HTTP request using HTTPx.

:param url: The URL to send the request to. :param method: The HTTP method to use (e.g., 'GET', 'POST'). :param data: The data to send in the request body. :param use_json: Whether to send the data as JSON. :param cookies: A dictionary of cookies to send with the request. :param headers: A dictionary of headers to send with the request. :return: A tuple containing the result and any error information.

LocaleSupport

LocaleSupport(*args, **kwargs)

Bases: ABC

LocaleSupport.

Adding Support for Encoding and Locale to every Component in FlowTask.

LogSupport

LogSupport(*args, **kwargs)

Bases: ABC

LogSupport.

Adding Logging support to every FlowTask Component.

MaskSupport

MaskSupport(*args, **kwargs)

Bases: ABC

MaskSupport.

Processing Masks Support.

mask_replacement

mask_replacement(obj)

mask_replacement.

Replacing occurrences of Masks into an String. Args: obj (Any): Any kind of object.

Returns:

Name Type Description
Any

Object with replaced masks.

mask_replacement_recursively

mask_replacement_recursively(obj)

This function replaces all occurrences of "{key}" in the obj structure with the corresponding value from the replacements dictionary, recursively.

Parameters:

Name Type Description Default
obj Any

an object to process.

required

Returns:

Type Description

The modified obj structure with curly brace replacements.

ResultSupport

ResultSupport(*args, **kwargs)

Bases: ABC

Support for manipulating the results of Components.

StatSupport

StatSupport(*args, **kwargs)

Bases: ABC

StatSupport.

Adding Support for Task Monitor (Statistics Collector.)

TemplateSupport

TemplateSupport(*args, **kwargs)

Bases: ABC

TemplateSupport.

Adding Support for Jinja2 Template parser on Components.

open_templatefile async

open_templatefile(file, program=None, from_templates_dir=False, folder='templates', **kwargs)

Open a file, replace masks and parse template if needed.

template_exists

template_exists(template)

Check if the template file exists.

AzureClient

AzureClient

AzureClient(tenant_id=None, client_id=None, client_secret=None, scopes=None, **kwargs)

Bases: ClientInterface

AzureClient

Overview

The `AzureClient` class handles authentication and authorization for Azure Active Directory using the Microsoft
Authentication Library (MSAL). This class provides methods to acquire tokens for secure API requests, particularly
for the Microsoft Graph API. It supports both confidential client applications and user authentication.

.. table:: Properties :widths: auto

+------------------+----------+-----------+--------------------------------------------------------------------------------------+
| Name             | Required | Description                                                                                      |
+------------------+----------+-----------+--------------------------------------------------------------------------------------+
| tenant_id        |   Yes    | The Azure AD tenant ID. Defaults to AZURE_ADFS_TENANT_ID from the configuration.                |
+------------------+----------+-----------+--------------------------------------------------------------------------------------+
| client_id        |   Yes    | The client ID of the Azure AD application. Defaults to AZURE_ADFS_CLIENT_ID from the config.    |
+------------------+----------+-----------+--------------------------------------------------------------------------------------+
| client_secret    |   Yes    | The client secret of the Azure AD application. Defaults to AZURE_ADFS_CLIENT_SECRET.            |
+------------------+----------+-----------+--------------------------------------------------------------------------------------+
| scopes           |   No     | A list of scopes for the token request. Defaults to Microsoft Graph API scopes.                 |
+------------------+----------+-----------+--------------------------------------------------------------------------------------+
| authority        |   Yes    | The authority URL for Azure AD authentication. Defaults to Azure AD instance authority.         |
+------------------+----------+-----------+--------------------------------------------------------------------------------------+
| credentials      |   Yes    | A dictionary containing the credentials for Azure AD authentication.                            |
+------------------+----------+-----------+--------------------------------------------------------------------------------------+

Return

The methods in this class handle the acquisition of access tokens and the configuration of MSAL clients for
interacting with Azure services. The tokens acquired can be used for authenticating API requests to services
like Microsoft Graph.

AzureGraph

AzureGraph

AzureGraph(tenant_id=None, client_id=None, client_secret=None, scopes=None, **kwargs)

Bases: ClientInterface

AzureGraph

Overview

    Authentication and authorization Using Azure Identity and Microsoft Graph.
find_chat_by_name async
find_chat_by_name(chat_name, user=None)

Finds a chat by its name (topic) and returns its chat_id.

Parameters:

Name Type Description Default
chat_name str

The name of the chat to find.

required

Returns:

Type Description
Optional[str]

Optional[str]: The chat_id if found, else None.

find_one_on_one_chat async
find_one_on_one_chat(user_id_1, user_id_2)

Find the one-on-one chat between two users by their object IDs. Returns the chat_id or None if it doesn't exist.

get_channel_details async
get_channel_details(team_id, channel_id)

Fetches details of a Teams channel.

Parameters:

Name Type Description Default
team_id str

The ID of the team.

required
channel_id str

The ID of the channel.

required

Returns:

Name Type Description
Dict Dict

A dictionary containing channel details.

get_channel_members async
get_channel_members(team_id, channel_id)

Fetches the list of members in a Teams channel.

Parameters:

Name Type Description Default
team_id str

The ID of the team.

required
channel_id str

The ID of the channel.

required

Returns:

Type Description
List[Dict]

List[Dict]: A list of member objects.

get_chat_messages async
get_chat_messages(chat_id, start_time=None, end_time=None, messages_per_page=50, max_messages=None)

Get chat messages.

Parameters:

Name Type Description Default
chat_id str

Id of Chat

required

Returns:

Type Description
Optional[List]

Optional[List]: All Chat Messages based on criteria.

get_msteams_channel_messages async
get_msteams_channel_messages(team_id, channel_id, start_time=None, end_time=None, max_messages=None)

Fetches messages from a Teams channel.

Parameters:

Name Type Description Default
team_id str

The ID of the team.

required
channel_id str

The ID of the channel.

required
start_time str

ISO 8601 formatted start time to filter messages.

None
end_time str

ISO 8601 formatted end time to filter messages.

None
max_messages int

Maximum number of messages to retrieve.

None

Returns:

Type Description
List[Dict]

List[Dict]: A list of message objects.

get_token async
get_token()

Retrieves an access token for Microsoft Graph API using ClientSecretCredential.

get_user async
get_user(user_id)

Fetches user information from Microsoft Graph API based on user ID.

Parameters:

Name Type Description Default
user_id str

The Azure AD object ID of the user.

required

Returns:

Name Type Description
Dict Dict

User information as a dictionary.

get_user_info async
get_user_info(user_principal_name)

Fetches user information from Microsoft Graph API basado en el userPrincipalName o ID.

Parameters:

Name Type Description Default
user_principal_name str

the UPN (email) or the objectId of the user.

required

Returns:

Name Type Description
dict dict

Información del usuario.

list_chats async
list_chats(user)

Lists all chats accessible to the application or user.

Returns:

Type Description
List[Dict]

List[Dict]: A list of chat objects.

list_user_chats async
list_user_chats(user_id)

List all chats where user_id participates.

open
open(**kwargs)

Initializes the Microsoft Graph client using: - MSAL + StaticTokenCredential if user+password is provided (delegated flow). - ClientSecretCredential for app-only in other cases.

user_chat_messages async
user_chat_messages(user, chat_id, start_time=None, end_time=None, messages_per_page=50, max_messages=None, max_retries=3)

Get User chat messages.

Parameters:

Name Type Description Default
chat_id str

Id of Chat

required

Returns:

Type Description
Optional[List]

Optional[List]: All Chat Messages based on criteria.

Boto3Client

Boto3Client

Boto3Client(*args, **kwargs)

Bases: ClientInterface

Boto3 AWS Client.

Overview

Abstract class for interaction with Boto3 (AWS).

.. table:: Properties
:widths: auto

+------------------------+----------+-----------+-------------------------------------------------------+ | Name | Required | Summary | +------------------------+----------+-----------+-------------------------------------------------------+ |credentials | Yes | The function is loaded and then we define the necessary code to | | | | call the script | +------------------------+----------+-----------+-------------------------------------------------------+ | _init | Yes | Component for Data Integrator | +------------------------+----------+-----------+-------------------------------------------------------+ | _host | Yes | The IPv4 or domain name of the server | +------------------------+----------+-----------+-------------------------------------------------------+ | get_client | Yes | Gets the client access credentials, by which the user logs in to | | | | perform an action | +------------------------+----------+-----------+-------------------------------------------------------+ | print | Yes | Print message to display | +------------------------+----------+-----------+-------------------------------------------------------+ | get_env_value | Yes | Get env value policies for setting virtual environment | +------------------------+----------+-----------+-------------------------------------------------------+ | processing_credentials | Yes | client credentials configured for used of the app | +------------------------+----------+-----------+-------------------------------------------------------+

    Return the list of arbitrary days
get_s3_object async
get_s3_object(bucket, filename)

Retrieve an object from an S3 bucket.

Parameters

bucket: str The name of the S3 bucket. filename: str The name of the file (key) in the S3 bucket.

Returns

dict A dictionary containing the object data and metadata.

Raises

FileNotFound If the object is not found in the bucket. ComponentError If there is an issue with retrieving the object.

DropboxClient

DropboxClient

DropboxClient(*args, access_key=None, **kwargs)

Bases: ABC

Dropbox Client for downloading and uploading files and folders to/from Dropbox.

download_file async
download_file(source_filename, destination_dir='.')

Download a file from Dropbox by its name.

download_folder async
download_folder(folder_name, destination_dir='.')

Download all files within a specified Dropbox folder by name.

upload_file async
upload_file(source_filepath, destination_path='/')

Upload a file to Dropbox.

upload_folder async
upload_folder(source_dir, destination_path='/')

Upload all files within a specified local folder to Dropbox.

ExcelHandler

ExcelHandler

append_data_to_excel
append_data_to_excel(df, file_path, sheet_name, start_row=None, start_col=1, include_header=False)

Append data from a DataFrame to an existing Excel file.

:param df: DataFrame containing data to append. :param file_path: Path to the Excel file. :param sheet_name: Name of the sheet to append data to. :param start_row: Starting row to append data (default is after last row). :param start_col: Starting column to append data. :param include_header: Whether to include the DataFrame's header.

create_excel_from_template
create_excel_from_template(template_path, new_file_path)

Create a new Excel file from a template.

:param template_path: Path to the Excel template. :param new_file_path: Path where the new Excel file will be saved.

create_new_excel_file
create_new_excel_file(file_path)

Create a new Excel file.

:param file_path: Path where the new Excel file will be saved.

edit_excel
edit_excel(file_path, edit_func)

Edit an existing Excel file using a provided function.

:param file_path: Path to the Excel file. :param edit_func: Function that takes a Workbook object and edits it.

pandas_to_excel
pandas_to_excel(df, file_path, **kwargs)

Save a pandas DataFrame to an Excel file.

:param df: DataFrame to save. :param file_path: Path to save the Excel file. :param kwargs: Additional keyword arguments for pandas' to_excel method.

FTPClient

FTP Client.

Overview

This class provides functionalities for asynchronous operations with an FTP server, including establishing connections, checking directory existence, changing working directories, and downloading files.

FTPClient

FTPClient(credentials=None, host=None, port=None, **kwargs)

Bases: ClientInterface

close async
close()

Close Method.

download_file async
download_file(file, destination, rewrite=False)

download_file

Download a File from FTP based on Path. Args: file (str): file to be downloaded destination (str): path to destination rewrite (bool): file if exists, will be overwrite TODO: Support for write_into and Renaming Files.

init_connection async
init_connection(host, port, credentials, ssl=None)

init an FTP connection

GoogleCalendar

GoogleCalendarClient

GoogleCalendarClient(*args, credentials=None, **kwargs)

Bases: GoogleClient, ABC

Google Calendar Client for managing calendar events.

check_event_start_time async
check_event_start_time(event_start_time)

Check if the current time has reached or passed the event's start time and trigger an action if so.

Parameters:

Name Type Description Default
event_start_time datetime

The start time of the event to check.

required
create_event async
create_event(calendar_id, event)

Create an event in the specified Google Calendar.

Parameters:

Name Type Description Default
calendar_id str

The ID of the calendar to add the event to.

required
event dict

The event details.

required

Returns:

Name Type Description
dict Dict

Details of the created event.

create_subscription async
create_subscription(webhook_url, client_state='secret_string', expiration_hours=1)

Create a subscription to receive notifications when events are created, updated, or deleted in the calendar.

Parameters:

Name Type Description Default
webhook_url str

The webhook URL that will receive the notifications.

required
client_state str

A client secret string for verifying notifications.

'secret_string'
expiration_hours int

Duration for which the subscription should be valid (maximum is 4230 minutes or 7 days).

1

Returns:

Name Type Description
dict dict

The response from Microsoft Graph API with subscription details.

delete_event async
delete_event(calendar_id, event_id)

Delete an event from the specified calendar.

Parameters:

Name Type Description Default
calendar_id str

The ID of the calendar.

required
event_id str

The ID of the event to delete.

required
get_client async
get_client()

Get the Google Calendar client, with caching.

get_event async
get_event(calendar_id, event_id)

Retrieve details of a specific event.

Parameters:

Name Type Description Default
calendar_id str

The ID of the calendar.

required
event_id str

The ID of the event.

required

Returns:

Name Type Description
dict Dict

Details of the event.

list_events async
list_events(calendar_id, time_min, time_max, max_results=10)

List events in a specified time range.

Parameters:

Name Type Description Default
calendar_id str

The ID of the calendar to list events from.

required
time_min datetime

Start time to retrieve events.

required
time_max datetime

End time to retrieve events.

required
max_results int

Maximum number of events to retrieve (default is 10).

10

Returns:

Name Type Description
list List[Dict]

List of events within the time range.

setup_watch async
setup_watch(calendar_id, webhook_url, channel_id)

Sets up a watch on the specified calendar to receive notifications when events are created, updated, or deleted.

Parameters:

Name Type Description Default
calendar_id str

The ID of the calendar to monitor.

required
webhook_url str

The URL of the webhook endpoint to receive notifications.

required
channel_id str

Unique ID for this notification channel.

required

Returns:

Name Type Description
dict Dict

The response from the Google Calendar API containing the channel information.

update_event async
update_event(calendar_id, event_id, updated_event)

Update an existing event in the calendar.

Parameters:

Name Type Description Default
calendar_id str

The ID of the calendar containing the event.

required
event_id str

The ID of the event to update.

required
updated_event dict

The updated event details.

required

Returns:

Name Type Description
dict Dict

Details of the updated event.

GoogleClient

GoogleClient

GoogleClient(*args, credentials=None, **kwargs)

Bases: ABC

Google Client Client.

Managing Authentication and resources from Google Apps.

close
close()

Clears cached credentials and services.

get_drive_client
get_drive_client()

Shortcut for accessing the Google Drive client.

get_search(query, version='v1', cse_id=None, **kwargs)

Get a cached Google API service instance or create one if not cached.

Args:

query (str): The search query.
version (str): Version of the API (default: 'v1').
cse_id (str): The Custom Search Engine ID.
**kwargs: Additional arguments for the API request.

Returns:

Type Description

googleapiclient.discovery.Resource: The requested Google API service client.

get_service
get_service(service, version='v3')

Get a cached Google API service instance or create one if not cached.

Parameters:

Name Type Description Default
service str

Name of the Google service (e.g., 'drive', 'sheets').

required
version str

Version of the API (default: 'v3').

'v3'

Returns:

Type Description

googleapiclient.discovery.Resource: The requested Google API service client.

get_sheets_client
get_sheets_client()

Shortcut for accessing the Google Sheets client.

GoogleDrive

GoogleDriveClient

GoogleDriveClient(*args, credentials=None, **kwargs)

Bases: GoogleClient, ABC

Google Drive Client for downloading files from Google Drive.

download_file async
download_file(source_filename, destination_dir='.')

Download a file from Google Drive by its name.

Parameters:

Name Type Description Default
source_filename str

The name of the file to download.

required
destination_dir str or Path

Directory where the file will be saved (default is current directory).

'.'

Returns:

Name Type Description
str PurePath

Path to the downloaded file.

download_folder async
download_folder(folder_name, destination_dir='.')

Download all files within a specified Google Drive folder by name.

Parameters:

Name Type Description Default
folder_name str

The name of the folder to download.

required
destination_dir str or Path

Directory where the files will be saved.

'.'

Returns:

Type Description
None

None

GoogleGCS

GoogleCloudStorageClient

GoogleCloudStorageClient(*args, bucket_name, **kwargs)

Bases: GoogleClient, ABC

Google Cloud Storage Client for interacting with Google Cloud Storage (GCS). Provides methods for file and folder operations.

create_folder async
create_folder(folder_name)

Create a folder in GCS by creating an empty blob with a trailing '/'.

delete_file async
delete_file(file_path)

Delete a file from GCS.

download_file async
download_file(source_path, destination_dir)

Download a file from GCS.

download_folder async
download_folder(source_folder, destination_folder)

Download all files from a GCS folder to a local folder.

get_bucket async
get_bucket()

Get the GCS bucket, with caching.

upload_file async
upload_file(source_path, destination_path)

Upload a file to GCS.

upload_folder async
upload_folder(source_folder, destination_folder)

Upload all files from a local folder to a GCS folder.

GoogleGeocoding

GoogleMapsGeocodingClient

GoogleMapsGeocodingClient(*args, api_key, **kwargs)

Bases: GoogleClient, ABC

Google Maps Geocoding Client for location-based tasks including geocoding, reverse geocoding, distance calculation, and place details.

calculate_distance async
calculate_distance(origin, destination)

Calculate the distance between two locations.

Parameters:

Name Type Description Default
origin str

Starting location (address or coordinates).

required
destination str

Ending location (address or coordinates).

required

Returns:

Name Type Description
dict Dict

Distance and duration between the origin and destination.

geocode_address async
geocode_address(address)

Geocode an address to retrieve latitude and longitude.

Parameters:

Name Type Description Default
address str

The address to geocode.

required

Returns:

Name Type Description
dict Dict

Geocoded location with latitude and longitude.

get_client async
get_client()

Get the Google Maps client, with caching.

get_place_details async
get_place_details(place_id)

Get detailed information about a place by its place ID.

Parameters:

Name Type Description Default
place_id str

The place ID of the location.

required

Returns:

Name Type Description
dict Dict

Detailed information about the place.

reverse_geocode async
reverse_geocode(lat, lng)

Reverse geocode coordinates to retrieve address information.

Parameters:

Name Type Description Default
lat float

Latitude of the location.

required
lng float

Longitude of the location.

required

Returns:

Name Type Description
list List[Dict]

List of addresses for the location.

GoogleLang

GoogleLanguage

GoogleLanguage(*args, **kwargs)

Bases: GoogleClient, ABC

Google Cloud Natural Language Client for analyzing text for sentiment, entities, syntax, and content classification.

analyze_entities async
analyze_entities(text)

Analyze entities in the provided text.

Parameters:

Name Type Description Default
text str

The text to analyze.

required

Returns:

Name Type Description
list

A list of entities with their types and salience scores.

analyze_sentiment async
analyze_sentiment(text)

Analyze the sentiment of the provided text.

Parameters:

Name Type Description Default
text str

The text to analyze.

required

Returns:

Name Type Description
dict

Sentiment score and magnitude.

analyze_syntax async
analyze_syntax(text)

Analyze syntax of the provided text.

Parameters:

Name Type Description Default
text str

The text to analyze.

required

Returns:

Name Type Description
list

A list of tokens with their parts of speech and dependency relationships.

classify_text async
classify_text(text)

Classify the content of the provided text into categories.

Parameters:

Name Type Description Default
text str

The text to classify.

required

Returns:

Name Type Description
list

A list of categories with confidence scores.

get_client async
get_client()

Get the Natural Language client, with caching.

GooglePub

GooglePubSubClient

GooglePubSubClient(*args, project_id, **kwargs)

Bases: GoogleClient

Google Pub/Sub Client for managing topics, subscriptions, and message handling.

GoogleSheet

GoogleSheetsClient

GoogleSheetsClient(*args, credentials=None, **kwargs)

Bases: GoogleClient, ABC

Google Sheets Client for downloading and interacting with Google Sheets.

download_file async
download_file(sheet_id, worksheet_name=None, file_type='dataframe')

Download the content of a Google Sheet in various formats.

Parameters:

Name Type Description Default
sheet_id str

The ID of the Google Sheet.

required
worksheet_name str

The name of the worksheet (optional, defaults to the first sheet).

None
file_type str

Desired format - 'dataframe', 'json', 'excel', or 'csv'.

'dataframe'

Returns:

Type Description
Union[DataFrame, str]

pd.DataFrame or str: DataFrame if requested, or the file path for other formats.

IMAPClient

IMAP/POP Client.

Class for operations with IMAP Mailboxes.

IMAPClient

IMAPClient(*args, host=None, port=None, **kwargs)

Bases: ClientInterface

IMAPClient

Overview

The IMAPClient class provides operations for interacting with IMAP mailboxes.
It supports both SSL and non-SSL
connections and uses XOAUTH2 authentication by default.

.. table:: Properties :widths: auto

+------------------+----------+------------------------------------------------------------------------------------------+
| Name             | Required | Description                                                                              |
+------------------+----------+------------------------------------------------------------------------------------------+
| use_ssl          |   No     | Boolean flag to specify whether to use SSL, defaults to True.                            |
+------------------+----------+------------------------------------------------------------------------------------------+
| mailbox          |   No     | The mailbox to access, defaults to "Inbox".                                              |
+------------------+----------+------------------------------------------------------------------------------------------+
| overwrite        |   No     | Boolean flag to specify whether to overwrite existing configurations, defaults to False. |
+------------------+----------+------------------------------------------------------------------------------------------+

Return

The methods in this class manage the connection to the IMAP server and perform authentication and closure of
the connection.

O365Calendar

OutlookCalendarClient

OutlookCalendarClient(*args, **kwargs)

Bases: O365Client

Outlook Calendar Client for managing calendar events through Microsoft Graph API.

create_event async
create_event(calendar_id, event)

Create an event in the specified Outlook calendar.

Parameters:

Name Type Description Default
calendar_id str

The ID of the calendar.

required
event dict

The event details.

required

Returns:

Name Type Description
dict Dict

Details of the created event.

delete_event async
delete_event(calendar_id, event_id)

Delete an event from the specified calendar.

Parameters:

Name Type Description Default
calendar_id str

The ID of the calendar.

required
event_id str

The ID of the event to delete.

required
get_client async
get_client()

Ensure that the Graph client is initialized and ready to use.

get_event async
get_event(calendar_id, event_id)

Retrieve details of a specific event.

Parameters:

Name Type Description Default
calendar_id str

The ID of the calendar.

required
event_id str

The ID of the event.

required

Returns:

Name Type Description
dict Dict

Details of the retrieved event.

list_events async
list_events(calendar_id, start_datetime, end_datetime, max_results=10)

List events in a specified time range in the specified calendar.

Parameters:

Name Type Description Default
calendar_id str

The ID of the calendar.

required
start_datetime datetime

Start time for retrieving events.

required
end_datetime datetime

End time for retrieving events.

required
max_results int

Maximum number of events to retrieve (default: 10).

10

Returns:

Name Type Description
list List[Dict]

List of events in the specified time range.

update_event async
update_event(calendar_id, event_id, updated_event)

Update an existing event in the specified calendar.

Parameters:

Name Type Description Default
calendar_id str

The ID of the calendar.

required
event_id str

The ID of the event.

required
updated_event dict

Updated event details.

required

Returns:

Name Type Description
dict Dict

Details of the updated event.

O365Client

O365Client

O365Client(*args, **kwargs)

Bases: CredentialsInterface

O365Client

Overview

The O365Client class is an abstract base class for managing connections to Office 365 services.
It handles authentication, credential processing, and provides a method for obtaining the
Office 365 context. It uses the Office 365 Python SDK for authentication and context management.

.. table:: Properties :widths: auto

+------------------+----------+--------------------------------------------------------------------------------------------------+
| Name             | Required | Description                                                                                      |
+------------------+----------+--------------------------------------------------------------------------------------------------+
| url              |   No     | The base URL for the Office 365 service.                                                         |
+------------------+----------+--------------------------------------------------------------------------------------------------+
| tenant           |   Yes    | The tenant ID for the Office 365 service.                                                        |
+------------------+----------+--------------------------------------------------------------------------------------------------+
| site             |   No     | The site URL for the Office 365 service.                                                         |
+------------------+----------+--------------------------------------------------------------------------------------------------+
| auth_context     |   Yes    | The authentication context for Office 365.                                                       |
+------------------+----------+--------------------------------------------------------------------------------------------------+
| context          |   Yes    | The context object for Office 365 operations.                                                    |
+------------------+----------+--------------------------------------------------------------------------------------------------+
| credentials      |   Yes    | A dictionary containing the credentials for authentication.                                      |
+------------------+----------+--------------------------------------------------------------------------------------------------+

Return

The methods in this class manage the authentication and connection setup for Office 365 services,
providing an abstract base for subclasses to implement specific service interactions.
acquire_token
acquire_token(scopes=None)

Acquire a Token via MSAL.

run_in_executor async
run_in_executor(fn, *args, **kwargs)

Calling any blocking process in an executor.

OneDrive

OneDriveClient

OneDriveClient(*args, **kwargs)

Bases: O365Client

OneDrive Client.

Interface for Managing connections to OneDrive resources.

Methods:

Name Description
file_list

Lists files in a specified OneDrive folder.

file_search

Searches for files matching a query.

file_download

Downloads a single file by its item ID.

download_files

Downloads multiple files provided as a list of dictionaries containing file info.

folder_download

Downloads a folder and its contents recursively.

file_delete

Deletes a file or folder by its item ID.

upload_files

Uploads multiple files to a specified OneDrive folder.

upload_file

Uploads a single file to OneDrive.

upload_folder

Uploads a local folder and its contents to OneDrive recursively.

download_excel_file async
download_excel_file(item_id, destination=None, as_pandas=False)

Download an Excel file from OneDrive by item ID. If as_pandas is True, return as a pandas DataFrame. If as_pandas is False, save to the destination path.

download_files async
download_files(items, destination_folder)

Download multiple files from OneDrive.

file_delete async
file_delete(item_id)

Delete a file or folder in OneDrive by item ID.

file_download async
file_download(item_id, destination)

Download a file from OneDrive by item ID.

file_list async
file_list(folder_path=None)

List files in a given OneDrive folder.

file_search(search_query)

Search for files in OneDrive matching the search query.

folder_download async
folder_download(folder_id, destination_folder)

Download a folder and its contents from OneDrive.

upload_dataframe_as_excel async
upload_dataframe_as_excel(df, file_name, destination_folder=None)

Upload a pandas DataFrame as an Excel file to OneDrive.

upload_file async
upload_file(file_path, destination_folder=None)

Upload a single file to OneDrive.

upload_files async
upload_files(files, destination_folder=None)

Upload multiple files to OneDrive.

upload_folder async
upload_folder(local_folder, destination_folder=None)

Upload a local folder and its contents to OneDrive.

Outlook

OutlookClient

OutlookClient(*args, **kwargs)

Bases: O365Client

Outlook Client.

Managing connections to Outlook Mail API.

download_message async
download_message(message_id, destination)

Download a message by its ID.

list_messages async
list_messages(folder='Inbox', top=10, filter_query=None, select_fields=None)

List messages in a specified folder.

move_message async
move_message(message_id, destination_folder_id)

Move a message to a different folder.

search_messages async
search_messages(search_query, top=10)

Search for messages matching the search query.

send_message async
send_message(subject, body, to_recipients, cc_recipients=None, bcc_recipients=None, attachments=None, from_address=None)

Send a message with optional attachments and optional 'on behalf of' another user.

ParrotBot

ParrotBot

ParrotBot(*args, **kwargs)

ParrotBot.

Interface for creating new chatbots to be used directly as Flowtask Components

bot_evaluation async
bot_evaluation()

bot_evaluation

Overview

The run method is a method for running the ParrotBot component.

Return

A Pandas Dataframe with the IA-based statistics.
start async
start(**kwargs)

start

Overview

The start method is a method for starting the CustomerSatisfaction component.

Parameters

kwargs: dict
    A dictionary containing the parameters for the CustomerSatisfaction component.

Return

True if the CustomerSatisfaction component started successfully.

SOAPClient

NoProxyAsyncTransport

NoProxyAsyncTransport(client, cache=None, timeout=300, operation_timeout=None)

Bases: AsyncTransport

Zeep AsyncTransport subclass that: - Omits 'proxies=' when building the sync httpx.Client (avoids httpx>=0.28 errors). - Provides the attributes Zeep expects (client, logger, _close_session). - Disables automatic session close in destructor to avoid AsyncClient.close errors.

SOAPClient

SOAPClient(*, credentials, httpx_client=None, redis_url='redis://localhost:6379/0', redis_key='soap:access_token', timeout=30, **kwargs)

Bases: ABC

SOAPClient

Overview

    The SOAPClient class is a generic asynchronous base for SOAP integrations.
    It provides OAuth2 refresh_token grant, Redis caching of access_token, and
    customizable httpx.AsyncClient for Zeep. Designed for easy extension to
    specific SOAP APIs.

.. table:: Properties
:widths: auto

    +-------------------+----------+-----------+---------------------------------------------------------------+
    | Name              | Required | Summary                                                           |
    +-------------------+----------+-----------+---------------------------------------------------------------+
    | credentials       |   Yes    | Dict with client_id, client_secret, token_url, wsdl_path, refresh_token |
    | httpx_client      |   No     | Optionally inject a configured AsyncClient                        |
    | redis_url         |   No     | Redis DSN for token cache                                         |
    | redis_key         |   No     | Key under which to cache the access token                         |
    | timeout           |   No     | HTTP request timeout (seconds)                                    |
    +-------------------+----------+-----------+---------------------------------------------------------------+

Returns

    This component provides an async interface to SOAP APIs, handling authentication,
    caching, and Zeep client/service setup. Subclasses should implement specific
    SOAP operations.

Example:

```python
class MyClient(SOAPClient):
    ...
```
"client_secret": str,
"token_url": str,
"wsdl_path": Union[str, Path],
"refresh_token": str

} :param httpx_client: optionally inject a configured AsyncClient :param redis_url: Redis DSN for token cache :param redis_key: key under which to cache the access token :param timeout: HTTP request timeout (seconds)

bind_service
bind_service()

Return the bound service proxy from Zeep.

close async
close()

Cleanup HTTP session and Redis connection.

get_client
get_client()

Instantiate the Zeep AsyncClient for our WSDL.

get_settings
get_settings()

Zeep settings: non-strict, support huge XML trees.

get_transport
get_transport()

Wrap an AsyncClient in our NoProxyAsyncTransport.

run async
run(operation, **kwargs)

Invoke a named SOAP operation with kwargs.

start async
start()

1) Connect to Redis 2) Get or refresh the bearer token 3) Build Zeep transport, client, and bind the service

SSHClient

SSHClient

SSHClient(*args, tunnel=None, **kwargs)

Bases: ClientInterface

SSHClient

Overview

The SSHClient class is a component for managing SSH and SFTP connections. It provides methods for establishing connections,
running commands, downloading, uploading, and copying files using SFTP. It supports various SSH algorithms and handles
errors gracefully.

.. table:: Properties :widths: auto

+------------------+----------+-----------+--------------------------------------------------------------------------------------+
| Name             | Required | Description                                                                                      |
+------------------+----------+-----------+--------------------------------------------------------------------------------------+
| block_size       |   No     | The block size for file transfers, defaults to 16384 bytes.                                      |
+------------------+----------+-----------+--------------------------------------------------------------------------------------+
| max_requests     |   No     | The maximum number of concurrent requests, defaults to 128.                                      |
+------------------+----------+-----------+--------------------------------------------------------------------------------------+
| algorithms       |   No     | A list of supported SSH algorithms.                                                              |
+------------------+----------+-----------+--------------------------------------------------------------------------------------+
| commands         |   No     | A list of commands to run over SSH.                                                              |
+------------------+----------+-----------+--------------------------------------------------------------------------------------+
| only_sftp        |   No     | A flag indicating if only SFTP connections are allowed.                                          |
+------------------+----------+-----------+--------------------------------------------------------------------------------------+
| tunnel           |   Yes    | Describes an SSH tunnel connection                                                               |
+------------------+----------+-----------+--------------------------------------------------------------------------------------+
| _connection      |   Yes    | The current SSH connection object.                                                               |
+------------------+----------+-----------+--------------------------------------------------------------------------------------+
| _clientargs      |   Yes    | Arguments for the SSH client configuration.                                                      |
+------------------+----------+-----------+--------------------------------------------------------------------------------------+
| client_keys      |   Yes    | SSH public key                                                                                   |
+------------------+----------+--------------------------------------------------------------------------------------------------+
| source           |   Yes    | List of algorithms to be used in connection encryption                                           |
+------------------+----------+--------------------------------------------------------------------------------------------------+

Return

The methods in this class facilitate SSH and SFTP operations, including establishing connections, 
file transfers, command execution, and handling SSH tunnels. The class also manages environment settings 
and provides error handling mechanisms specific to SSH and SFTP operations.
close async
close(timeout=1, reason='Connection Ended.')

Close Method.

copy_files async
copy_files(file, destination, preserve=False, recurse=False)

copy_files.

Use can copy/move one or more files (or directories) in server. Args: file (Union[str,List[PurePath]]): Path (purepath) or list of paths for files or directories destination (Purepath or str): remote destination of upload preserve (bool, optional): preserve the original attributes. Defaults False. recurse (bool, optional): copy recursively all directories. Defaults False. Returns: bool: file(s) or directorires were uploaded or not.

download_files async
download_files(file, destination, preserve=False, recurse=False)

download_file

Download a File from sFTP based on Path. Args: path (str): file to be downloaded TODO: Support for write_into and Renaming Files.

open async
open(host, port, credentials, **kwargs)

init an SSH connection

sftp_client async
sftp_client()

sftp_client. Starts a SFTP client connection.

upload_files async
upload_files(file, destination, preserve=False, recurse=False)

upload_files.

Use can upload one or more files (or directories) recursively. Args: file (Union[str,List[PurePath]]): Path (purepath) or list of paths for files or directories destination (Purepath or str): remote destination of upload preserve (bool, optional): preserve the original attributes. Defaults False. recurse (bool, optional): copy recursively all directories. Defaults False. Returns: bool: file(s) or directorires were uploaded or not.

Sharepoint

SharepointClient

SharepointClient(*args, **kwargs)

Bases: O365Client

Sharepoint Client.

Managing connections to MS Sharepoint Resources.

create_subscription async
create_subscription(library_id, webhook_url, client_state='secret_string', expiration_days=1)

Create a webhook subscription to receive notifications when files are added, updated, or deleted in a SharePoint document library.

Parameters:

Name Type Description Default
library_id str

The ID of the SharePoint document library to subscribe to.

required
webhook_url str

The webhook URL to receive notifications.

required
client_state str

A secret string to verify notifications.

'secret_string'
expiration_days int

Duration in days for the subscription to be valid (maximum is 180 days).

1

Returns:

Name Type Description
dict dict

The response from Microsoft Graph API containing the subscription details.

download_files async
download_files(files, destination_dir)

Download a list of files from SharePoint to a specified destination directory.

Parameters:

Name Type Description Default
files List[dict]

A list of dictionaries with 'directory' and 'filename' keys.

required
destination_dir str

The local directory where files will be downloaded.

required

Returns:

Name Type Description
List List

A list of paths to the downloaded files.

get_library_id
get_library_id(absolute_url)

Extracts the Library ID of a SharePoint document library from an absolute URL.

Parameters:

Name Type Description Default
absolute_url str

The absolute URL of the SharePoint resource.

required

Returns:

Name Type Description
str str

The ID of the document library.

Raises:

Type Description
RuntimeError

If the library ID could not be retrieved.

upload_files async
upload_files(filenames=None, sharepoint_folder=None)

Upload files to a SharePoint folder using a resumable upload for large files.

cache

CacheSupport

CacheSupport(*args, **kwargs)

Bases: ABC

Very Basic Cache Support using Redis

parse_duration
parse_duration(duration)

Parse a duration string and return its value in seconds.

Supported formats: - "Xs" for seconds - "Xm" for minutes - "Xh" for hours

setex async
setex(key, value, timeout=None)

setex Set the value and expiration of a Key params: key: key Name value: value of the key timeout: expiration time in seconds

setexp
setexp(key, value, timeout=None)

setexp Set the value and expiration of a Key params: key: key Name value: value of the key timeout: expiration time in seconds

client

ClientInterface

ClientInterface(credentials=None, host=None, port=None, **kwargs)

Bases: CredentialsInterface

close abstractmethod async
close(timeout=5)

close. Closing the connection.

open abstractmethod async
open(host=None, port=None, credentials=None, **kwargs)

open. Starts (open) a connection to external resource.

compress

CompressSupport

CompressSupport(*args, **kwargs)

Bases: ABC

CompressSupport.

Overview

This component handles compressing and uncompressing files and folders into various formats. Supported formats: - ZIP (.zip and .jar) - TAR (.tar) - GZ (.gz) - BZIP2 (.bz2) - XZ (.xz) - 7z (.7z) - RAR (.rar)

Methods:

Name Description
- compress

Compress files/folders into various formats.

- uncompress

Uncompress files/folders from various formats.

- zip_file

Compress a single file into a zip file.

- unzip_file

Uncompress a single file from a zip archive.

- zip_folder

Compress a folder into a zip file.

- unzip_folder

Uncompress files from a zip archive to a folder.

Parameters: - source: Path to the file or folder to be compressed or uncompressed. - destination: Path where the compressed/uncompressed file should be saved. - remove_source: Boolean to remove the source file/folder after operation.

compress async
compress(source, destination, format='zip', remove_source=False, **kwargs)

Compress the given source into the destination file in the specified format.

compress_7z async
compress_7z(source, destination, remove_source=False)

Compress files/folders into a 7z archive.

compress_gzip async
compress_gzip(source, destination, extension='.gz', remove_source=False)

Compress a file or folder into a gzip file. If the extension indicates a tarball format (e.g., .tar.gz, .tar.bz2, .tar.xz), compress as a tarball; otherwise, compress as a simple .gz file.

Parameters:

Name Type Description Default
source Union[str, PosixPath]

The file or folder to compress.

required
destination Union[str, PosixPath]

The destination path for the compressed file.

required
extension str

The desired extension (e.g., .gz, .tar.gz, .tar.bz2, .tar.xz).

'.gz'
remove_source bool

Whether to remove the source file/folder after compression.

False

Returns:

Type Description
str

The path of the compressed file.

compress_rar async
compress_rar(source, destination, remove_source=False, **kwargs)

Compress files/folders into a rar archive.

compress_tar async
compress_tar(source, destination, compress_type='w:gz', remove_source=False)

Compress files/folders into a tar archive.

compress_zip async
compress_zip(source, destination, compress_type=ZIP_DEFLATED, compress_level=9, remove_source=False)

Compress files/folders into a zip archive.

uncompress async
uncompress(source, destination, format='zip', remove_source=False)

Uncompress the given source file into the destination folder.

uncompress_7z async
uncompress_7z(source, destination, remove_source=False)

Uncompress files from a 7z archive.

uncompress_gzip async
uncompress_gzip(source, destination, remove_source=False)

Uncompress a Gzip file or tarball and return the list of uncompressed files.

uncompress_rar async
uncompress_rar(source, destination, remove_source=False)

Uncompress files from a rar archive.

uncompress_tar async
uncompress_tar(source, destination, remove_source=False)

Uncompress files from a tar archive.

uncompress_zip async
uncompress_zip(source, destination, source_files=None, password=None, remove_source=False)

Uncompress files from a zip archive.

unzip_file async
unzip_file(source, destination)

Uncompress a single file from a zip archive.

unzip_folder async
unzip_folder(source, destination, remove_source=False)

Uncompress files from a zip archive into a folder.

zip_file async
zip_file(source, destination, remove_source=False)

Compress a single file into a zip file.

zip_folder async
zip_folder(source, destination, remove_source=False, **kwargs)

Compress a folder into a zip file.

credentials

CredentialsInterface

CredentialsInterface(*args, **kwargs)

Bases: ABC

get_env_value
get_env_value(key, default=None, expected_type=None)

Retrieves a value from the environment variables or the configuration.

:param key: The key for the environment variable. :param default: The default value to return if the key is not found. :return: The value of the environment variable or the default value.

d2l

D2L.

Making operations over D2L.

D2LClient

D2LClient(*args, **kwargs)

Bases: CacheSupport, HTTPService

Manage Connection to D2L

databases

DBSupport

DBSupport(*args, **kwargs)

Bases: CredentialsInterface

DBSupport.

Interface for adding AsyncbDB-based Database Support to Components.

default_connection
default_connection(driver)

default_connection.

Default Connection to Database.

get_default_driver
get_default_driver(driver)

get_default_driver.

Getting a default connection based on driver's name.

db

DBSupport
DBSupport(*args, **kwargs)

Bases: CredentialsInterface

DBSupport.

Interface for adding AsyncbDB-based Database Support to Components.

default_connection
default_connection(driver)

default_connection.

Default Connection to Database.

get_default_driver
get_default_driver(driver)

get_default_driver.

Getting a default connection based on driver's name.

documentdb

DocumentDBSupport
DocumentDBSupport(*args, **kwargs)

Bases: DBSupport

DocumentDBSupport.

Interface for adding AWS DocumentDB Database Support to Components.

default_connection
default_connection(driver='mongo', credentials=None)

default_connection.

Default Connection to RethinkDB.

rethink

RethinkDBSupport
RethinkDBSupport(*args, **kwargs)

Bases: DBSupport

RethinkDBSupport.

Interface for adding RethinkDB-based Database Support to Components.

default_connection
default_connection(driver='rethink')

default_connection.

Default Connection to RethinkDB.

dataframes

ArrowDataframe

Bases: BaseDataframe

ArrowDataframe.

Converts any result into a Arrow DataFrame.

create_dataframe async
create_dataframe(result, *args, **kwargs)

Converts any result into a Arrow DataFrame.

:param result: The result data to be converted into a Arrow DataFrame. :return: A DataFrame containing the result data.

DtDataframe

Bases: BaseDataframe

DtDataframe.

Converts any result into a Datatable DataFrame.

create_dataframe async
create_dataframe(result, *args, **kwargs)

Converts any result into a Datatable DataFrame.

:param result: The result data to be converted into a Datatable DataFrame. :return: A DataFrame containing the result data.

PandasDataframe

Bases: BaseDataframe

PandasDataframe.

Converts any result into a Pandas DataFrame.

column_exists
column_exists(column)

Returns True if the column exists in the DataFrame.

create_dataframe async
create_dataframe(result, *args, **kwargs)

Converts any result into a Pandas DataFrame.

:param result: The result data to be converted into a Pandas DataFrame. :return: A DataFrame containing the result data.

from_csv async
from_csv(result, *args, **kwargs)

Converts a Comma-Separated CSV into a Pandas DataFrame.

:param result: The result data to be converted into a Pandas DataFrame. :return: A DataFrame containing the result data.

PolarsDataframe

Bases: BaseDataframe

PolarsDataframe.

Converts any result into a Polars DataFrame.

create_dataframe async
create_dataframe(result, *args, **kwargs)

Converts any result into a Polars DataFrame.

:param result: The result data to be converted into a Polars DataFrame. :return: A DataFrame containing the result data.

abstract

BaseDataframe

Bases: ABC

create_dataframe abstractmethod async
create_dataframe(result, *args, **kwargs)

Converts any result into a DataFrame.

:param result: The result data to be converted into a DataFrame. :return: A DataFrame containing the result data.

arrow

ArrowDataframe

Bases: BaseDataframe

ArrowDataframe.

Converts any result into a Arrow DataFrame.

create_dataframe async
create_dataframe(result, *args, **kwargs)

Converts any result into a Arrow DataFrame.

:param result: The result data to be converted into a Arrow DataFrame. :return: A DataFrame containing the result data.

is_empty
is_empty(obj)

check_empty. Check if a basic object, a Apache Arrow Table is empty or not.

dt

DtDataframe

Bases: BaseDataframe

DtDataframe.

Converts any result into a Datatable DataFrame.

create_dataframe async
create_dataframe(result, *args, **kwargs)

Converts any result into a Datatable DataFrame.

:param result: The result data to be converted into a Datatable DataFrame. :return: A DataFrame containing the result data.

is_empty
is_empty(obj)

check_empty. Check if a basic object, a Polars DataFrame, an Apache Arrow Table, or a Python DataTable Frame is empty or not.

pandas

PandasDataframe

Bases: BaseDataframe

PandasDataframe.

Converts any result into a Pandas DataFrame.

column_exists
column_exists(column)

Returns True if the column exists in the DataFrame.

create_dataframe async
create_dataframe(result, *args, **kwargs)

Converts any result into a Pandas DataFrame.

:param result: The result data to be converted into a Pandas DataFrame. :return: A DataFrame containing the result data.

from_csv async
from_csv(result, *args, **kwargs)

Converts a Comma-Separated CSV into a Pandas DataFrame.

:param result: The result data to be converted into a Pandas DataFrame. :return: A DataFrame containing the result data.

is_empty
is_empty(obj)

check_empty. Check if a basic object is empty or not.

polars

PolarsDataframe

Bases: BaseDataframe

PolarsDataframe.

Converts any result into a Polars DataFrame.

create_dataframe async
create_dataframe(result, *args, **kwargs)

Converts any result into a Polars DataFrame.

:param result: The result data to be converted into a Polars DataFrame. :return: A DataFrame containing the result data.

is_empty
is_empty(obj)

check_empty. Check if a basic object or a DataFrame (Pandas or Polars) is empty or not.

db

DBInterface

DBInterface(*args, driver=None, **kwargs)

Bases: CredentialsInterface

DBInterface.

Abstract Interface for Database-based connectors.

env

EnvSupport

EnvSupport(*args, **kwargs)

Bases: ABC

EnvSupport.

Support for Environment Variables

get_env_value
get_env_value(key, default=None, expected_type=None)

Retrieves a value from the environment variables or the configuration.

:param key: The key for the environment variable. :param default: The default value to return if the key is not found. :param expected_type: the data type to be expected. :return: The value of the environment variable or the default value.

func

FuncSupport

FuncSupport(*args, **kwargs)

Bases: ABC

Interface for adding Add Support for Function Replacement.

http

HTTPService

HTTPService(*args, **kwargs)

Bases: CredentialsInterface, PandasDataframe

HTTPService.

Overview

    Interface for making connections to HTTP services.
api_get async
api_get(url, cookies=None, params=None, headers=None, use_proxy=None, free_proxy=False, use_http2=True)

Make an asynchronous HTTP GET request.

Parameters:

Name Type Description Default
url str

The URL to send the GET request to.

required
cookies Cookies

Cookies to include in the request.

None
params dict

Dictionary of query parameters to include in the URL.

None

Returns:

Name Type Description
dict Dict[str, Any]

The JSON response from the API if the request is successful.

Dict[str, Any]

Returns an empty dictionary if the request fails.

async_request async
async_request(url, method='GET', data=None, use_json=False, use_proxy=False, accept=None)

Asynchronously sends an HTTP request using aiohttp.

:param url: The URL to send the request to. :param method: The HTTP method to use (e.g., 'GET', 'POST'). :param data: The data to send in the request body. :param use_json: Whether to send the data as JSON. :param use_proxy: force proxy usage. :return: A tuple containing the result and any error information.

build_url
build_url(url, queryparams='', args=None)

Constructs a full URL with optional query parameters and arguments.

:param url: The base URL to be formatted. :param queryparams: Additional query parameters to be appended to the URL. :param args: Arguments to format within the URL. :return: The fully constructed URL.

evaluate_error async
evaluate_error(response, message)

evaluate_response.

Check Response status and available payloads. Args: response (type): description url (str): description

Returns:

Name Type Description
tuple tuple

description

get_proxies async
get_proxies(session_time=0.4, free_proxy=False)

Asynchronously retrieves a list of free proxies. TODO: SELECT or rotate the free/paid proxies.

process_request async
process_request(future, url)

Processes the result of an asynchronous HTTP request.

:param future: The future object representing the asynchronous operation. :param url: The URL that was requested. :return: A tuple containing the result and any error information.

process_response async
process_response(response, url)

Processes the response from an HTTP request.

:param response: The response object from aiohttp. :param url: The URL that was requested. :return: A tuple containing the processed result and any error information.

refresh_proxies async
refresh_proxies()

Asynchronously refreshes the list of proxies if proxy usage is enabled.

request async
request(url, method='GET', data=None, use_proxy=False, accept=None)

Sends an HTTP request using the requests library.

:param url: The URL to send the request to. :param method: The HTTP method to use (e.g., 'GET', 'POST'). :param data: The data to send in the request body. :return: A tuple containing the result and any error information.

session async
session(url, method='get', data=None, cookies=None, headers=None, use_json=False, follow_redirects=False, use_proxy=False, accept=None, return_response=False)

Asynchronously sends an HTTP request using HTTPx.

:param url: The URL to send the request to. :param method: The HTTP method to use (e.g., 'GET', 'POST'). :param data: The data to send in the request body. :param use_json: Whether to send the data as JSON. :param cookies: A dictionary of cookies to send with the request. :param headers: A dictionary of headers to send with the request. :return: A tuple containing the result and any error information.

bad_gateway_exception

bad_gateway_exception(exc)

Check if the exception is a 502 Bad Gateway error.

locale

LocaleSupport

LocaleSupport(*args, **kwargs)

Bases: ABC

LocaleSupport.

Adding Support for Encoding and Locale to every Component in FlowTask.

log

LogSupport

LogSupport(*args, **kwargs)

Bases: ABC

LogSupport.

Adding Logging support to every FlowTask Component.

mask

MaskSupport

MaskSupport(*args, **kwargs)

Bases: ABC

MaskSupport.

Processing Masks Support.

mask_replacement
mask_replacement(obj)

mask_replacement.

Replacing occurrences of Masks into an String. Args: obj (Any): Any kind of object.

Returns:

Name Type Description
Any

Object with replaced masks.

mask_replacement_recursively
mask_replacement_recursively(obj)

This function replaces all occurrences of "{key}" in the obj structure with the corresponding value from the replacements dictionary, recursively.

Parameters:

Name Type Description Default
obj Any

an object to process.

required

Returns:

Type Description

The modified obj structure with curly brace replacements.

notification

Interface for sending messages using Notify.

parrot

Parrot-ai Interfaces for creating Chatbots and IA-Agents integrated with FlowTask.

agent

Create a Parrot AI Agent for FlowTask.

AgentBase
AgentBase(*args, **kwargs)

Bases: ABC

AgentBase.

Interface for creating new Parrot AI Agents to be used directly as Flowtask Components.

ask_agent async
ask_agent(userid, query=None, prompt_file=None, *args, **kwargs)

Asks the agent a question and returns an Object response.

create_agent async
create_agent(llm=None, model=None, tools=None, backstory=None)

Create and configure a BasicAgent instance.

db_connection
db_connection(driver='pg', dsn=None, credentials=None)

Return a database connection.

open_file async
open_file(file, prefix='files')

Opens a prompt file and returns its content.

open_prompt async
open_prompt(prompt_file=None, base_dir=None)

Opens a prompt file and returns its content.

start async
start(**kwargs)

Check for File and Directory information.

tools

models
EmployeeInput

Bases: BaseModel

Input schema for employee-related operations requiring an Employee ID.

ManagerInput

Bases: BaseModel

Input schema for manager-related operations requiring a Manager ID.

NextStopStore

Bases: Model

Model representing Table for the NextStop system.

Meta

Meta class for NextStopStore model.

StoreInfoInput

Bases: BaseModel

Input schema for store-related operations requiring a Store ID.

today_date
today_date()

Returns today's date.

store
StoreInfo

Bases: BaseToolkit

Comprehensive toolkit for store information and demographic analysis.

This toolkit provides tools to: 1. Get detailed visit information for specific stores including recent visit history 2. Retrieve comprehensive store information including location and visit statistics 3. Foot traffic analysis for stores, providing insights into customer behavior

All tools are designed to work asynchronously with database connections and external APIs.

Tools included: - get_visit_info: Retrieves the last visits for a specific store - get_foot_traffic: Fetches foot traffic data for a store - get_store_information: Gets complete store details and aggregate visit metrics - get_employee_sales: Fetches Employee Sales data and ranked performance.

get_by_employee_visits async
get_by_employee_visits(employee_id)

Get visits information for a specific employee.

This coroutine retrieves the most recent visits made by the specified employee, including detailed visit metrics and questions answered during those visits.

Parameters:

Name Type Description Default
employee_id str

The unique identifier of the employee.

required

Returns:

Name Type Description
dict dict

Data containing the last visits with detailed information.

get_dataset async
get_dataset(query, output='pandas')

Fetch a dataset based on the provided query.

Parameters:

Name Type Description Default
query str

The query string to fetch the dataset.

required

Returns:

Type Description
DataFrame

pd.DataFrame: A pandas DataFrame containing the dataset.

get_employee_sales async
get_employee_sales(manager_id)

Get foot traffic data for a specific store. This coroutine retrieves the foot traffic data for the specified store, including the number of visitors and average visits per day.

Parameters:

Name Type Description Default
manager str

The unique identifier of the Manager (Associate OID).

required

Returns: str: Data containing employee sales data and rankings.

get_employee_visits async
get_employee_visits(manager_id)

Get Employee Visits data for a specific Manager. This coroutine retrieves the visit data for employees under a specific manager, including the number of visits, average visit duration, and most frequent visit hours. Args: manager (str): The unique identifier of the Manager (Associate OID). Returns: str: Data containing employee sales data and rankings.

get_foot_traffic async
get_foot_traffic(store_id)

Get foot traffic data for a specific store. This coroutine retrieves the foot traffic data for the specified store, including the number of visitors and average visits per day.

Parameters:

Name Type Description Default
store_id str

The unique identifier of the store.

required

Returns: str: JSON string containing foot traffic data for the store.

get_store_information async
get_store_information(store_id)

Get comprehensive store information for a specific store.

This coroutine retrieves complete store details including location, contact information, operating schedule, and aggregate visit metrics.

Parameters:

Name Type Description Default
store_id str

The unique identifier of the store.

required

Returns:

Name Type Description
str str

JSON string containing comprehensive store information and visit statistics.

get_tools
get_tools()

Get all available tools in the toolkit.

Returns:

Type Description
List[BaseTool]

List[BaseTool]: A list of configured Langchain tools ready for agent use.

get_visit_info async
get_visit_info(store_id)

Get visit information for a specific store.

This coroutine retrieves the most recent visits for the specified store, including detailed visit metrics and questions answered during those visits.

Parameters:

Name Type Description Default
store_id str

The unique identifier of the store.

required

Returns:

Type Description
List[dict]

List[dict]: Data containing the last visits with detailed information.

playwright

PlaywrightService

PlaywrightService(*args, **kwargs)

Bases: ABC

PlaywrightService

An interface for making HTTP connections using Playwright, analogous to your SeleniumService.

check_by_attribute
check_by_attribute(attribute)

Convert a tuple (attribute, value) into a Playwright selector. For example, ('id', 'submit') becomes '#submit' and ('xpath', '//button') becomes 'xpath=//button'.

close_driver async
close_driver()

Close the page, browser context, browser, and stop Playwright.

get_driver async
get_driver()

Initialize Playwright, launch a browser (with proxy and/or mobile emulation if configured), and return a new Page instance.

get_etree async
get_etree()

Return a tuple of lxml etree objects (using etree.fromstring and html.fromstring) for the current page content.

get_page async
get_page(url, cookies=None, retries=3, backoff_delay=2)

Navigate to a given URL, optionally set cookies, wait for page load, and optionally handle any cookie-acceptance banners.

get_soup async
get_soup(parser='html.parser')

Return a BeautifulSoup object for the current page content.

parse_cookies
parse_cookies(cookie_pair)

Parse a cookie string into a dictionary.

proxy_playwright
proxy_playwright(user, password, endpoint)

Return a proxy configuration dictionary for Playwright.

save_screenshot async
save_screenshot(filename)

Save a screenshot of the entire page or of a specific element if configured.

search_google_cse async
search_google_cse(query, max_results=5)

Perform a Google Custom Search Engine (CSE) search using Playwright. Returns a list of results where each result is a dict with 'title' and 'link'.

powerpoint

PowerPointClient

Bases: ABC

append_slides_to_presentation staticmethod
append_slides_to_presentation(file_path, slide_contents)

Edit a PowerPoint file to append more slides from an iterator.

:param file_path: Path to the existing PowerPoint file. :param slide_contents: An iterator where each item is a dict with content for a slide.

create_empty_presentation staticmethod
create_empty_presentation(file_path)

Create an empty PowerPoint presentation.

:param file_path: Path where the new PowerPoint file will be saved.

create_presentation_from_template
create_presentation_from_template(template_path, slide_contents, file_path, default_master_index=0, default_layout_index=1)

Create a presentation from a template, adding texts or images per slide.

:param template_path: Path to the PowerPoint template file. :param slide_contents: An iterator where each item is a dict with content for a slide. :param file_path: Path where the new PowerPoint file will be saved. :param default_layout_index: Default slide layout index to use if not specified per slide.

create_presentation_from_text_list staticmethod
create_presentation_from_text_list(text_list, file_path)

Create a PowerPoint file where each slide contains text from a list.

:param text_list: List of texts to add to slides. :param file_path: Path where the new PowerPoint file will be saved.

create_slide staticmethod
create_slide(text_content=None, image_path=None, image_size=None, font_size=18, font_color='000000', font_name='Calibri', layout_index=None)

Create a slide content dictionary.

:param text_content: Text to include in the slide. :param image_path: Path to the image file to include in the slide. :param image_size: Tuple of three elements (left, top, width) for image positioning. :param font_size: Font size for the text. :param font_color: Font color for the text in hex format (e.g., 'FF0000' for red). :param font_name: Font name for the text. :param layout_index: Optional index of the slide layout to use for this slide. :return: A dictionary representing the slide content.

qs

QS Support.

Adding support for Querysource related functions as datasource support to components.

QSSupport

Bases: ABC

QSSupport.

Adding Support for Querysource parameters.

get_connection
get_connection(driver='pg', dsn=None, params=None, **kwargs)

Useful for internal connections of QS.

get_datasource async
get_datasource(name)

get_datasource.

Get the datasource from the database.

get_driver
get_driver(driver)

Getting a Database Driver from Datasource Drivers.

result

ResultSupport

ResultSupport(*args, **kwargs)

Bases: ABC

Support for manipulating the results of Components.

sassie

Sassie.

Making operations over Sassie API.

SassieClient

SassieClient(*args, **kwargs)

Bases: CacheSupport, HTTPService

Manage Connection to Sassie

selenium_service

SeleniumService

SeleniumService(*args, **kwargs)

Bases: ABC

SeleniumService.

Interface for making HTTP connections using Selenium.

get_driver async
get_driver()

Return a Selenium Driver instance for Firefox, Edge, Safari, WebKitGTK or Chrome.

This method configures the browser based on instance flags (such as: - self.use_firefox, self.use_edge, self.use_safari, self.use_webkit - self.use_proxy, self._free_proxy, self.use_undetected - self.as_mobile for mobile emulation (Chrome-only) - self.enable_http2 (if False, HTTP/2 will be disabled)

It applies a common set of options (stored in self.chrome_options) to all browsers and adds proxy settings (if configured) to the options and/or desired capabilities.

Returns:

Type Description

A Selenium WebDriver instance.

get_page async
get_page(url, cookies=None, retries=3, backoff_delay=2)

get_page with selenium.

Get one page using Selenium.

get_soup
get_soup(content, parser='html.parser')

Get a BeautifulSoup Object.

parse_cookies
parse_cookies(cookie_pair)

Parse the Cookies.

save_screenshot
save_screenshot(filename)

Saving and Screenshot of entire Page.

search_google_cse async
search_google_cse(query, max_results=5)

Search Google Custom Search Engine (CSE) using Selenium.

Parameters:

Name Type Description Default
query str

The search query.

required
max_results int

Maximum number of search results to return.

5

Returns:

Type Description

list[dict]: A list of search results with 'title' and 'link'.

smartsheet

SmartSheet.

Making operations over an Smartsheet Service.

SmartSheetClient

SmartSheetClient(*args, **kwargs)

Bases: CredentialsInterface

http_get async
http_get(url=None, credentials=None, headers={}, accept='application/vnd.ms-excel', destination=None)

session. connect to an http source using aiohttp

stat

StatSupport

StatSupport(*args, **kwargs)

Bases: ABC

StatSupport.

Adding Support for Task Monitor (Statistics Collector.)

task

Flowtask Task Execution.

template

TemplateSupport

TemplateSupport(*args, **kwargs)

Bases: ABC

TemplateSupport.

Adding Support for Jinja2 Template parser on Components.

open_templatefile async
open_templatefile(file, program=None, from_templates_dir=False, folder='templates', **kwargs)

Open a file, replace masks and parse template if needed.

template_exists
template_exists(template)

Check if the template file exists.

vectorstores

abstract

AbstractStore
AbstractStore(*args, **kwargs)

Bases: ABC

AbstractStore class.

Parameters:

Name Type Description Default
embedding_model dict

Embeddings.

required

milvus

MilvusStore
MilvusStore(*args, **kwargs)

Bases: AbstractStore, CredentialsInterface

Interface for managing document storage in Milvus using LangChain.

connect async
connect(alias=None)

Connects to the Milvus database.

create_collection async
create_collection(collection_name, origin=None, dimension=768, index_type='HNSW', metric_type='L2', **kwargs)

Create a Milvus collection based on an origin.

Parameters:

Name Type Description Default
collection_name str

Name of the Milvus collection.

required
origin Union[str, Path, Any]

None for minimal schema, Path for Avro file, or dataclass for schema.

None
dimension int

Dimension of the vector field. Defaults to 768.

768
index_type str

Index type for vector field. Defaults to "HNSW".

'HNSW'
metric_type str

Metric type for vector index. Defaults to "L2".

'L2'

Returns:

Name Type Description
dict dict

Result of the collection creation.

create_default_collection async
create_default_collection(collection_name, document=None, dimension=768, index_type=None, metric_type=None, schema_type='default', database=None, metadata_field=None, **kwargs)

create_collection.

Create a Schema (Milvus Collection) on the Current Database.

Parameters:

Name Type Description Default
collection_name str

Collection Name.

required
document Any

List of Documents.

None
dimension int

Vector Dimension. Defaults to 768.

768
index_type str

Default index type of Vector Field. Defaults to "HNSW".

None
metric_type str

Default Metric for Vector Index. Defaults to "L2".

None
schema_type str

Description of Model. Defaults to 'default'.

'default'

Returns:

Name Type Description
dict dict

description

delete_documents_by_attr async
delete_documents_by_attr(collection_name, attribute_name, attribute_value)

Deletes documents in the Milvus collection that match a specific attribute.

This asynchronous method removes documents from a specified Milvus collection where the given attribute matches the provided value.

Parameters:

Name Type Description Default
collection_name str

The name of the Milvus collection to delete from.

required
attribute_name str

The name of the attribute to filter on.

required
attribute_value str

The value of the attribute to match for deletion.

required

Raises:

Type Description
Exception

If the deletion operation fails, the error is logged and re-raised.

Returns:

Type Description

None

Note

The method logs a notice with the number of deleted documents upon successful deletion.

load_documents async
load_documents(documents, upsert=True, collection=None, pk='source_type', dimension=768, index_type='HNSW', metric_type='L2', **kwargs)

Loads LangChain documents into the Milvus collection.

Parameters:

Name Type Description Default
documents List[Document]

List of LangChain Document objects.

required
upsert bool

If True, delete existing documents with matching attributes before inserting.

True
pk str

str: If upsert True, Key to be used for deleting documents before inserting.

'source_type'
collection str

Name of the collection.

None

zammad

zammad

zammad(**kwargs)

Bases: HTTPService

zammad

Overview

The `zammad` class provides a generic interface for managing Zammad instances via its RESTful API.
It extends the HTTPService class and offers methods for creating users and generating user tokens with
specific permissions in a Zammad instance. This class is pre-configured with the necessary Zammad instance
settings, such as tokens and default roles, making it easier to interact with the Zammad API.

.. table:: Properties :widths: auto

+------------------+----------+-----------+--------------------------------------------------------------------------------------+
| Name             | Required | Description                                                                                      |
+------------------+----------+-----------+--------------------------------------------------------------------------------------+
| credentials      |   No     | A dictionary holding authentication credentials.                                                 |
+------------------+----------+-----------+--------------------------------------------------------------------------------------+
| auth             |   Yes    | Authentication token for the Zammad API, derived from the ZAMMAD_TOKEN configuration.            |
+------------------+----------+-----------+--------------------------------------------------------------------------------------+
| article_base     |   No     | Default base dictionary for articles, specifying type and visibility.                            |
+------------------+----------+-----------+--------------------------------------------------------------------------------------+
| permissions_base |   No     | Base permissions for creating user tokens.                                                       |
+------------------+----------+-----------+--------------------------------------------------------------------------------------+

Return

The methods in this class facilitate interaction with the Zammad API, including creating users and generating
user access tokens. Each method returns the relevant response from the Zammad API, or an error if the operation fails.
create_user async
create_user(**kwargs)

create_user.

Create a new User.

TODO: Adding validation with dataclasses.

get_user_token async
get_user_token(**kwargs)

get_user_token.

Usage: using X-On-Behalf-Of to getting User Token.