Skip to content

Services

flowtask.services

bots

telegram

TelegramBot
TelegramBot(bot_token=None, **kwargs)

Bases: ABC

Telegram bot.

This class is a wrapper for the aiogram.Bot class, it provides a simple way to create new Telegram Bots.

Parameters:

Name Type Description Default
bot_token str

Telegram Bot Token.

None
get_arguments
get_arguments(message, command)

Get the arguments passed after the command (e.g., after /echo).

run_in_thread async
run_in_thread(fn, *args, executor=None, **kwargs)

_execute.

Returns a future to be executed into a Thread Pool.

files

Files.

File Management Infraestructure

FileManager

FileManager(request, *args, **kwargs)

Bases: BaseView

API View for managing Files.

delete async
delete()

DELETe Method. description: Deletes a File (if exists) on Directory tags: - files - File Manager - filesystem - file consumes: - application/json produces: - application/json

get async
get()
GET Method.

description: Managing Files. tags: - File Manager consumes: - application/json produces: - application/json

get_response async
get_response(headers)

Returns a valid Web.Response

head async
head()

HEAD Method. description: Sent response about file exists or not. tags: - files - File Manager - filesystem - file consumes: - application/json produces: - application/json

post async
post()

POST Method. description: upload a file onto repository directory. tags: - files - File Manager - filesystem - file consumes: - application/json produces: - application/json

put async
put()

PUT Method. description: Create a new directory. tags: - files - File Manager - filesystem - file consumes: - application/json produces: - application/json

return_file async
return_file(filename, **kwargs)

Returns a File based on a Stream Response

FileService

Bases: BaseView

get async
get()

description: Get all the Files objects in the current scope and program summary: get the files information and attributes tags: - FileService produces: - application/json parameters: - name: user_id description: user id to filter in: path required: true type: integer - name: file_slug description: file slug in: path required: true type: string responses: "200": description: returns valid data "204": description: No data "403": description: Forbidden Call "404": description: Program o File not found "406": description: Query Error

put async
put()

PUT FileService. description: Upload a File and, optionally, running an associated Task Parameters: file_slug: slug of the file in TROC files table program_slug: associated program mimetype: optional mime-type, default csv module_id: optional module ID task: boolean in query-params to disable running task. long_running: query-param to attach a Task in a Thread Pool

valid_permission async
valid_permission(user_id, codename)

valid_permission. Check if the user have permission for one func on the system.

manager

FileManager.

Works with files, download, upload and delete files over FS using an API.

TODO: Send a data-preview (first 10 rows) of uploaded file TODO: html-template for Uploader preview with "back" button.

FileManager
FileManager(request, *args, **kwargs)

Bases: BaseView

API View for managing Files.

delete async
delete()

DELETe Method. description: Deletes a File (if exists) on Directory tags: - files - File Manager - filesystem - file consumes: - application/json produces: - application/json

get async
get()
GET Method.

description: Managing Files. tags: - File Manager consumes: - application/json produces: - application/json

get_response async
get_response(headers)

Returns a valid Web.Response

head async
head()

HEAD Method. description: Sent response about file exists or not. tags: - files - File Manager - filesystem - file consumes: - application/json produces: - application/json

post async
post()

POST Method. description: upload a file onto repository directory. tags: - files - File Manager - filesystem - file consumes: - application/json produces: - application/json

put async
put()

PUT Method. description: Create a new directory. tags: - files - File Manager - filesystem - file consumes: - application/json produces: - application/json

return_file async
return_file(filename, **kwargs)

Returns a File based on a Stream Response

model

FileService DB Model.

Database Object Model for FileServices.

service

FileService.

Work with slug-based file definitions, upload, download, enable tasks, etc.

FileService

Bases: BaseView

get async
get()

description: Get all the Files objects in the current scope and program summary: get the files information and attributes tags: - FileService produces: - application/json parameters: - name: user_id description: user id to filter in: path required: true type: integer - name: file_slug description: file slug in: path required: true type: string responses: "200": description: returns valid data "204": description: No data "403": description: Forbidden Call "404": description: Program o File not found "406": description: Query Error

put async
put()

PUT FileService. description: Upload a File and, optionally, running an associated Task Parameters: file_slug: slug of the file in TROC files table program_slug: associated program mimetype: optional mime-type, default csv module_id: optional module ID task: boolean in query-params to disable running task. long_running: query-param to attach a Task in a Thread Pool

valid_permission async
valid_permission(user_id, codename)

valid_permission. Check if the user have permission for one func on the system.

FileUploaded
FileUploaded(post, mimetype=None)

FileUploaded. processing a FileField

valid_content
valid_content(**kwargs)

valid_content. check if is a valid content-type ex: if is a csv, json or excel, open with pandas, if txt with stream, if image, etc

jira

JiraActions

JiraActions(server, email, token)

:param server: Server URL. :param email: User Email. :param token: API token of Jira.

add_comment
add_comment(issue_key, comment)

Adds a comment to a Jira issue.

:param issue_key: Key of the issue to add the comment to. :param comment: The comment to be added. :return: Returns the added comment or raises an exception in case of error.

add_worklog
add_worklog(issue_key, time_spent, comment=None, started=None)

Adds a worklog entry to a Jira issue.

:param issue_key: Key of the issue to which the worklog will be added. :param time_spent: Time spent on the issue (e.g., '2h', '3d', '1w'). :param comment: Optional comment to add with the worklog. :param started: Date and time the work started (optional, format: 'YYYY-MM-DDTHH:MM:SS.000+0000'). :return: The worklog entry that was added, or raises an exception in case of error.

assign_issue
assign_issue(issue_key, assignee)

Assigns a Jira issue to a specified user.

:param issue_key: Key of the issue to be assigned (e.g., 'PROJ-123'). :param assignee: Username or email of the user to whom the issue will be assigned. :return: The updated issue after the assignment.

create_issue
create_issue(project_key, summary, description, issue_type='Bug')

Creates a new Jira issue in the specified project.

:param project_key: Key of the project in which the ticket is to be created. :param summary: Summary or title of the ticket. :param description: Description of the ticket. :param issue_type: Type of ticket (default 'Task'). :return: Returns the ticket created.

handle_jira_error staticmethod
handle_jira_error(e, action)

Handles errors and exceptions that occur during interactions with Jira.

This function captures exceptions thrown during Jira operations and raises appropriate errors with relevant messages based on the type of exception (e.g., JIRAError, connection issues).

:param e: Exception object. This can be a JIRAError or other types of exceptions (e.g., connection errors). :param action: A string describing the action that was being attempted when the error occurred (e.g., 'creating an issue', 'adding a comment').

:raises ValueError: If there is a validation error (e.g., incorrect data in Jira fields). :raises PermissionError: If the user does not have sufficient permissions for the Jira operation. :raises ConnectionError: If there is a problem connecting to the Jira server or if the requested resource was not found. :raises TimeoutError: If the operation timed out while connecting to the Jira server. :raises Exception: For any other unexpected errors that occur during the Jira operation.

list_issues
list_issues()

Return a list of Jira issues.

:return: The list of closed issues assigned to user.

list_transitions
list_transitions(issue_key)

Return a list of a valid transitions of a issue.

:param issue_key: Key of the issue to transition. :return: Returns the list of a valid transitions of a issue.

transition_issue
transition_issue(issue_key, transition_name, comment=None)

Transitions a Jira issue to a new status based on the transition name. If the transition name is invalid, provides a list of valid transitions for the issue.

:param issue_key: Key of the issue to transition. :param transition_name: Name of the transition to perform (e.g., 'Start Progress', 'Close Issue'). :param comment: Optional comment to add during the transition. :return: Returns the issue after the transition or raises an exception in case of error.

jira_actions

JiraActions
JiraActions(server, email, token)

:param server: Server URL. :param email: User Email. :param token: API token of Jira.

add_comment
add_comment(issue_key, comment)

Adds a comment to a Jira issue.

:param issue_key: Key of the issue to add the comment to. :param comment: The comment to be added. :return: Returns the added comment or raises an exception in case of error.

add_worklog
add_worklog(issue_key, time_spent, comment=None, started=None)

Adds a worklog entry to a Jira issue.

:param issue_key: Key of the issue to which the worklog will be added. :param time_spent: Time spent on the issue (e.g., '2h', '3d', '1w'). :param comment: Optional comment to add with the worklog. :param started: Date and time the work started (optional, format: 'YYYY-MM-DDTHH:MM:SS.000+0000'). :return: The worklog entry that was added, or raises an exception in case of error.

assign_issue
assign_issue(issue_key, assignee)

Assigns a Jira issue to a specified user.

:param issue_key: Key of the issue to be assigned (e.g., 'PROJ-123'). :param assignee: Username or email of the user to whom the issue will be assigned. :return: The updated issue after the assignment.

create_issue
create_issue(project_key, summary, description, issue_type='Bug')

Creates a new Jira issue in the specified project.

:param project_key: Key of the project in which the ticket is to be created. :param summary: Summary or title of the ticket. :param description: Description of the ticket. :param issue_type: Type of ticket (default 'Task'). :return: Returns the ticket created.

handle_jira_error staticmethod
handle_jira_error(e, action)

Handles errors and exceptions that occur during interactions with Jira.

This function captures exceptions thrown during Jira operations and raises appropriate errors with relevant messages based on the type of exception (e.g., JIRAError, connection issues).

:param e: Exception object. This can be a JIRAError or other types of exceptions (e.g., connection errors). :param action: A string describing the action that was being attempted when the error occurred (e.g., 'creating an issue', 'adding a comment').

:raises ValueError: If there is a validation error (e.g., incorrect data in Jira fields). :raises PermissionError: If the user does not have sufficient permissions for the Jira operation. :raises ConnectionError: If there is a problem connecting to the Jira server or if the requested resource was not found. :raises TimeoutError: If the operation timed out while connecting to the Jira server. :raises Exception: For any other unexpected errors that occur during the Jira operation.

list_issues
list_issues()

Return a list of Jira issues.

:return: The list of closed issues assigned to user.

list_transitions
list_transitions(issue_key)

Return a list of a valid transitions of a issue.

:param issue_key: Key of the issue to transition. :return: Returns the list of a valid transitions of a issue.

transition_issue
transition_issue(issue_key, transition_name, comment=None)

Transitions a Jira issue to a new status based on the transition name. If the transition name is invalid, provides a list of valid transitions for the issue.

:param issue_key: Key of the issue to transition. :param transition_name: Name of the transition to perform (e.g., 'Start Progress', 'Close Issue'). :param comment: Optional comment to add during the transition. :return: Returns the issue after the transition or raises an exception in case of error.

tasks

Tasks.

Task-based management, creation and execution of tasks.

TaskLauncher

Bases: BaseView

post async
post()

POST Method. description: Executing a Task tags: - tasks - DataIntegration consumes: - application/json produces: - application/json responses: "200": description: Existing Task was updated or executed. "201": description: New Task was inserted "202": description: Task was accepted to run "400": description: Task Failed to execute "403": description: Forbidden Call "404": description: No Data was found "406": description: Query Error "409": description: Conflict, a constraint was violated

TaskManager

Bases: BaseView

TaskManager.

description: API Endpoint for Task Management (creation of Tasks).

delete async
delete()

DELETE Method. description: remove resource. tags: - tasks - DataIntegration produces: - application/json responses: "200": description: Existing Task was updated. "201": description: New Task was inserted "403": description: Forbidden Call "404": description: No Data was found "406": description: Query Error "409": description: Conflict, a constraint was violated

get async
get()
GET Method.

description: get all tasks, or a task by ID (or get status of execution) tags: - tasks - DataIntegration consumes: - application/json produces: - application/json responses: "200": description: Existing Task was retrieved. "403": description: Forbidden Call "404": description: No Task(s) were found "406": description: Query Error

patch async
patch()

PATCH Method. description: updating partially info about a Task tags: - tasks - DataIntegration produces: - application/json responses: "200": description: Existing Task was updated. "201": description: New Task was inserted "304": description: Task not modified, its currently the actual version of Task "403": description: Forbidden Call "404": description: No Data was found "406": description: Query Error "409": description: Conflict, a constraint was violated

post async
post()

PATCH Method. description: updating or creating tasks tags: - tasks - DataIntegration produces: - application/json responses: "200": description: Existing Task was updated. "201": description: New Task was inserted "304": description: Task not modified, its currently the actual version of Task "403": description: Forbidden Call "404": description: No Data was found "406": description: Query Error "409": description: Conflict, a constraint was violated

put async
put()

PUT Method. description: Send a Task as Code directly to Task Executor. tags: - tasks - DataIntegration produces: - application/json consumes: - application/merge-patch+json - application/json responses: "200": description: Task Executed "204": description: success execution but no content on return (resource was deleted) "400": description: Invalid resource according data schema "403": description: Forbidden Call "404": description: No Data was found "406": description: Query Error "409": description: Conflict, a constraint was violated

TaskService

Bases: BaseView

TaskService.

Task As a Service: launch data-based tasks and returning the resultset in useful formats. Args: BaseView (type): description

get async
get()

GET Method. description: Executing a Task and returning the result tags: - tasks - DataIntegration consumes: - application/json produces: - application/json responses: "200": description: Existing Task was executed. "202": description: Task was accepted to queue (no return) "204": description: No data was found "400": description: Task Failed to execute "403": description: Forbidden Call "404": description: no Task was found. "406": description: Query Error "409": description: Task Conflict, a constraint was violated

post async
post()

GET Method. description: Executing a Task and returning the result tags: - tasks - DataIntegration consumes: - application/json produces: - application/json responses: "200": description: Existing Task was executed. "202": description: Task was accepted to queue (no return) "204": description: No data was found "400": description: Task Failed to execute "403": description: Forbidden Call "404": description: no Task was found. "406": description: Query Error "409": description: Task Conflict, a constraint was violated

launch_task async

launch_task(program_slug, task_id, loop=None, task_uuid=None, queued=False, no_worker=False, priority='low', userid=None, **kwargs)

launch_task. Runs (or queued) a Task from Task Monitor.

launcher

TaskService.

Work with managing tasks, creation, deleting, listing, etc.

TaskLauncher

Bases: BaseView

post async
post()

POST Method. description: Executing a Task tags: - tasks - DataIntegration consumes: - application/json produces: - application/json responses: "200": description: Existing Task was updated or executed. "201": description: New Task was inserted "202": description: Task was accepted to run "400": description: Task Failed to execute "403": description: Forbidden Call "404": description: No Data was found "406": description: Query Error "409": description: Conflict, a constraint was violated

manager

TaskManager.

Task Management: creation, deleting, listing, etc.

TaskManager

Bases: BaseView

TaskManager.

description: API Endpoint for Task Management (creation of Tasks).

delete async
delete()

DELETE Method. description: remove resource. tags: - tasks - DataIntegration produces: - application/json responses: "200": description: Existing Task was updated. "201": description: New Task was inserted "403": description: Forbidden Call "404": description: No Data was found "406": description: Query Error "409": description: Conflict, a constraint was violated

get async
get()
GET Method.

description: get all tasks, or a task by ID (or get status of execution) tags: - tasks - DataIntegration consumes: - application/json produces: - application/json responses: "200": description: Existing Task was retrieved. "403": description: Forbidden Call "404": description: No Task(s) were found "406": description: Query Error

patch async
patch()

PATCH Method. description: updating partially info about a Task tags: - tasks - DataIntegration produces: - application/json responses: "200": description: Existing Task was updated. "201": description: New Task was inserted "304": description: Task not modified, its currently the actual version of Task "403": description: Forbidden Call "404": description: No Data was found "406": description: Query Error "409": description: Conflict, a constraint was violated

post async
post()

PATCH Method. description: updating or creating tasks tags: - tasks - DataIntegration produces: - application/json responses: "200": description: Existing Task was updated. "201": description: New Task was inserted "304": description: Task not modified, its currently the actual version of Task "403": description: Forbidden Call "404": description: No Data was found "406": description: Query Error "409": description: Conflict, a constraint was violated

put async
put()

PUT Method. description: Send a Task as Code directly to Task Executor. tags: - tasks - DataIntegration produces: - application/json consumes: - application/merge-patch+json - application/json responses: "200": description: Task Executed "204": description: success execution but no content on return (resource was deleted) "400": description: Invalid resource according data schema "403": description: Forbidden Call "404": description: No Data was found "406": description: Query Error "409": description: Conflict, a constraint was violated

service

TaskService.

Service for running tasks.

TaskService

Bases: BaseView

TaskService.

Task As a Service: launch data-based tasks and returning the resultset in useful formats. Args: BaseView (type): description

get async
get()

GET Method. description: Executing a Task and returning the result tags: - tasks - DataIntegration consumes: - application/json produces: - application/json responses: "200": description: Existing Task was executed. "202": description: Task was accepted to queue (no return) "204": description: No data was found "400": description: Task Failed to execute "403": description: Forbidden Call "404": description: no Task was found. "406": description: Query Error "409": description: Task Conflict, a constraint was violated

post async
post()

GET Method. description: Executing a Task and returning the result tags: - tasks - DataIntegration consumes: - application/json produces: - application/json responses: "200": description: Existing Task was executed. "202": description: Task was accepted to queue (no return) "204": description: No data was found "400": description: Task Failed to execute "403": description: Forbidden Call "404": description: no Task was found. "406": description: Query Error "409": description: Task Conflict, a constraint was violated

task_manager

TaskManager.

Work with managing tasks, creation, deleting, listing, etc.

TaskManager

Bases: DataView

delete async
delete()

DELETE Method. description: remove resource. tags: - tasks - DataIntegration produces: - application/json responses: "200": description: Existing Task was updated. "201": description: New Task was inserted "403": description: Forbidden Call "404": description: No Data was found "406": description: Query Error "409": description: Conflict, a constraint was violated

get async
get()
GET Method.

description: get all tasks, or a task by ID (or get status of execution) tags: - tasks - DataIntegration consumes: - application/json produces: - application/json responses: "200": description: Existing Task was retrieved. "403": description: Forbidden Call "404": description: No Task(s) were found "406": description: Query Error

patch async
patch()

PATCH Method. description: updating partially info about a Task tags: - tasks - DataIntegration produces: - application/json responses: "200": description: Existing Task was updated. "201": description: New Task was inserted "304": description: Task not modified, its currently the actual version of Task "403": description: Forbidden Call "404": description: No Data was found "406": description: Query Error "409": description: Conflict, a constraint was violated

post async
post()

POST Method. description: inserting or updating a Task or executing a Task tags: - tasks - DataIntegration consumes: - application/json produces: - application/json responses: "200": description: Existing Task was updated or executed. "201": description: New Task was inserted "202": description: Task was accepted to run "400": description: Task Failed to execute "403": description: Forbidden Call "404": description: No Data was found "406": description: Query Error "409": description: Conflict, a constraint was violated

put async
put()

PUT Method. description: inserting or updating a Task tags: - tasks - DataIntegration produces: - application/json consumes: - application/merge-patch+json - application/json responses: "200": description: Existing Task was updated. "201": description: New Task was inserted "204": description: success execution but no content on return (resource was deleted) "400": description: Invalid resource according data schema "403": description: Forbidden Call "404": description: No Data was found "406": description: Query Error "409": description: Conflict, a constraint was violated

tasks

launch_task async
launch_task(program_slug, task_id, loop=None, task_uuid=None, queued=False, no_worker=False, priority='low', userid=None, **kwargs)

launch_task. Runs (or queued) a Task from Task Monitor.