airflow-provider-qlik-sense-nprinting 0.0.1
Airflow package provider to perform action into Qlik Sense NPrinting (reload apps, tasks ...).
License: Apache License 2.0
Requires Python: ~=3.7

<p align="center" style="vertical-align:center;">
  <a href="https://www.qlik.com/us/products/qlik-sense">
    <img alt="Qlik Sense Client Managed" src="https://mace-solutions.fr/wp-content/uploads/2022/02/qlik-square.png" width="80", height="80" />
  </a>
</p>

<h1 align="center">
  Airflow: Qlik Sense NPrinitng Provider
</h1>
  <h3 align="center">
    Qlik Sense NPrinting Provider to reload tasks from Airflow.
</h3>

<br/>

This repository provides basic Qlik NPrinting hooks and operators to trigger reloads of tasks available in a Qlik Sense NPrinting Site.

## Requirements

The package has been tested with Python 3.7, Python 3.8.

|  Package  |  Version  |
|-----------|---------------|
| apache-airflow | >2.0 |
| requests_ntlm2 | >=2 6.5.2 |

## How to install it ?


To install it, download and unzip source and launch the following pip install command: 

```bash
pip install .
```

You can also use 

```bash
python setup.py install
```

## How to use it ?
<br/>

On this provider, you can use three way to let Airflow connecting to your Qlik Sense NPrinting Site.

<div>â€¢ NTLM Authentification: Authentification with a username and password used in Qlik NPrinting in everyday life. Warning: Airflow will have the same rights of the user you provide.</div>

<br/>

<div>â€¢ JWT Authentification <b>(Not Available in development)</b>: Authentification with a jwt token that you provide to Airflow. </div>

<br/>
<div>â€¢ Certificates Authentification <b>(Not Available in development)</b>: Authentification with Certificates. Warning: In this case, you'll have to take client certificate generated by your Qlik Sense site during installation.</div>
<br/>

### 1. NTLM Authentification Example
<br/>

**Prerequisites**:  
<br>
â€¢ A login account with password
â€¢ URI of your Qlik Sense NPrinting Site 

**Step 1**: Login in your Airflow Server. 

**Step 2**: Go into Admin > Connections > Add A New Record. 

**Step 3**: Select [NTLM] Qlik Sense NPrinting.

**Step 4** Provide following informations:
    
           â€¢ Connection Id of your choice
           â€¢ Qlik Sense NPrinting URL without any port
           â€¢ Qlik Username (example: DOMAIN\\USERNAME)
           â€¢ Qlik Password of the account used

Be careful this Qlik NPrinting Account must have privilieges to trigger the task.

**Step 5** Save and your connection to Qlik Client NPrinting using NTLM auth is ready to use !

### 2. JWT Authentification Example
<br/>

**Prerequisites**:  
<br>
Builing the section. No available yet.

### 3. Certificate Authentifcation Example
<br/>
Builing the section. No available yet.


### 4. Example: Creating a DAG with Qlik Sense NPrinting to reload tasks 

You can now use the operators in your dags to trigger a reload of an app in Qlik Sense from Airflow

Example: 

```python

from airflow.providers.qlik_sense_nprinting.operators.reload_task_operator import QlikNPrintingReloadTaskOperator
from airflow import DAG
from airflow.utils.dates import days_ago
from datetime import timedelta

default_args = {
    'owner': 'airflow',
    'depends_on_past': False,
    'email': ['airflow@example.com'],
    'email_on_failure': False,
    'email_on_retry': False,
    'retries': 1,
    'retry_delay': timedelta(minutes=5)
}


with DAG(
    'QlikSenseTriggerTaskExample',
    default_args=default_args,
    description='A simple tutorial DAG reloading Qlik Sense NPrinting Task',
    schedule_interval=timedelta(days=1),
    start_date=days_ago(2),
    tags=['QlikNPrinting', 'Example'],
) as dag:
    
    nprintingTask = QlikNPrintingReloadTaskOperator(taskId="uiidofyournprintingtask", conn_id="hookNPrintingHook", task_id="MyHelloWorldNPrintingTask", waitUntilFinished=True)
    
    nprintingTask

```

<br/>