====================
LEXIS Airflow Plugin
====================

Plugins are used to customize the Airflow installation. The definition is the following:

    Airflow offers a generic toolbox for working with data. Different organizations have different stacks and different needs. Using Airflow plugins can be a way 
    for companies to customize their Airflow installation to reflect their ecosystem.

    Plugins can be used as an easy way to write, share and activate new sets of features.

    There's also a need for a set of more complex applications to interact with different flavors of data and metadata.

The LEXIS Airflow plugin provides two base features: manage user's permissions based on OpenID tokens, and manage (create, modify, delete) of DAGs to the LEXIS Airflow instance via REST API.


Templating
===========
LEXIS Platform supports three basic templates for the workflow creation: 

- `Container <https://api.lexis.tech/airflow/api/lexis/openapi/swagger#/Containers>`_ to execute a job containing apptainer (singularity) container, 
- `HPC Command Application <https://api.lexis.tech/airflow/api/lexis/openapi/swagger#/HPC%20Command%20App>`_ to execute predefined HEAppE Command Template (job script),
- `Custom Job Script <https://api.lexis.tech/airflow/api/lexis/openapi/swagger#/Custom%20Job%20Scripts>`_ to execute custom (user defined) job script.

Anyway, as mentioned above, the user can specify the computational workflow using `LWD <https://api.lexis.tech/airflow/api/lexis/lwd-workflows/v1/user_guide>`_ YAML specification. 
It allows to create a custom (arbitrary) workflow in a user-friendly way while ensuring the security as described few lines above.
Thus, the user can define as arbitrary workflow as possible. 
The example :ref:`simple_HPC_workflow` demonstrates simple HPC workflow with data transfer.

LEXIS API View
--------------
The class **PluginLexisAPIView** extends the Airflow REST API by the following endpoints:

* "/" -- endpoint to check if the Airflow is alive.
* "/create-dag" -- endpoint to register new DAGs.

User authentization
-------------------
Within the LEXIS Airflow Plugin, user authentization backend is implemented. It is stored within the Python module **lexis\_api.auth.lexis_token**. Given custom security manager 
(methods/decorators) takes care of users' autorization to provide an action in Airflow instance against UserOrg (see :ref:`userorg`), e.g. check if the user is permitted to create 
a new container workflow using custom Airflow API endpoint mentioned above.