backend.api.log

Contains the API routes to handle logs and log-related operations.

This module defines the FastAPI routes for managing logs, including retrieving logs, filtering logs by date, and deleting logs. It also includes utility functions for handling log data and formatting responses. In case of and log upload, it also includes the necessary metadata to create a celonis connection.

Attributes

Functions

upload_log(→ Dict[str, List[str]])

Uploads an event log file and retrieves its columns.

commit_log_to_celonis() → Dict[str, str])

Uploads the log file to Celonis and creates a table.

Module Contents

backend.api.log.router
async backend.api.log.upload_log(file: fastapi.UploadFile, request: fastapi.Request) Dict[str, List[str]]

Uploads an event log file and retrieves its columns.

The file gets stored in a temporary file for the later upload to Celonis.

Parameters:
  • file – The event log file to be uploaded. This should be a .csv or .xes file.

  • request – The FastAPI request object. This is used to access the application state via request.app.state.

Returns:

The columns of the uploaded log file as a dictionary.

Raises:
  • HTTPException – If the file name is not provided or if the file type is

  • invalid, or if there is an error processing the file.

async backend.api.log.commit_log_to_celonis(request: fastapi.Request, payload: backend.api.models.schemas.setup_models.ColumnMapping | None = None, celonis: backend.celonis_connection.celonis_connection_manager.CelonisConnectionManager = Depends(get_celonis_connection)) Dict[str, str]

Uploads the log file to Celonis and creates a table.

Parameters:
  • payload (optional) – The column mapping for the event log. This should be a ColumnMapping object containing the case ID, activity, and timestamp columns. It is only needed if the log is a csv file.

  • request – The FastAPI request object. This is used to access the application state via request.app.state.

  • celonis (optional) – The Celonis Connection DI. Defaults to Depends(get_celonis_connection).

Raises:
  • HTTPException – If no log file is found in the app state, or if there is an

  • error processing the file.

Returns:

A dictionary containing a message indicating the success of the operation.