The **Extractor Task** plugin allows you to define a set of users, user groups, or dynamic groups to extract data into a specific format.
For now, only **CSV** is available, but additional formats will be supported in the future.
The CSV file adapts its headers based on the attributes collected among the users listed, ensuring proper formatting even if some users have undefined attributes compared to others.
.. note::
It must be used with FusionDirectory Orchestrator and requires the `--extract` option.
CSV Header Behavior
-------------------
The **Extractor Task** dynamically generates the headers of the CSV file based on the attributes collected from the selected users, user groups, or dynamic groups.
- If some users have attributes that others do not, the CSV file will adapt by including all attributes as headers, leaving empty values for undefined attributes.
- This ensures that the CSV file is properly formatted and contains all relevant data, even when the attributes vary between users.
File Generation Behavior
------------------------
The **Extractor Task** generates files based on the hour of the day. Each task execution during the same hour appends data to the same file, ensuring no duplication.
- Files are named in the format `NameOfTheTask-date+hour.format` (e.g., `MyTask-20250407-14.csv`).
- If the task is executed multiple times within the same hour, existing UIDs in the file are updated rather than duplicated.
- A new file is created for each subsequent hour if the task is executed again.
This behavior ensures efficient data management and prevents duplication while maintaining up-to-date information in the generated files.
Task Setup
----------
Creating the Task
-----------------
- Open the **Tasks** section of FusionDirectory.
- Define the task’s schedule and repetition interval.
.. image:: images/extractor-p1.png
:alt: Extractor - Task creation step 1
:width: 600px
Configuring Extractor Task
--------------------------
- **Navigate** to the **Tasks Extractor** tab.
- **Select** the output format desired (e.g., CSV).
- **List** the users, static groups, or dynamic groups requiring data extraction.
- **Optionally define** the output directory. By default, files are saved in `/srv/orchestrator`.
- **Assign** the relevant members.
.. note::
You can select either a **static group** or a **dynamic group** for greater flexibility.
.. image:: images/extractor-p2.png
:alt: Extractor - Task creation step 2
:width: 600px
Task Execution
--------------
For your configured task to be executed, you need to configure your `fusiondirectory-orchestrator-client` with the `--extract` option.
See :ref:`Extractor Task Execution <extractor-task-execution-label>` for more information.
Summary
-------
The **Extractor Task**, when configured as described, will:
- **Analyze** the selected users, groups, or dynamic groups.
- **Generate** a CSV file containing the collected attributes as headers.
- **Adapt** the headers dynamically to account for undefined attributes.
- **Ensure** no duplication by appending data to the same file during the same hour and updating existing UIDs.
.. note::
This ensures efficient data extraction and up-to-date file generation.