Metadata-Version: 2.4
Name: kadi-apy-helper
Version: 0.1.0
Summary: Contains a set of functions and helper scripts to ease the usage and interaction with Kadi4mat through the Kadi-APY / Kadi CLI manager.
Keywords: kadi,kadi4mat,kadi-apy
Author: Adam Reupert
Author-email: Adam Reupert <adam.reupert@kit.edu>
License-Expression: MIT
License-File: LICENSE
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.14
Classifier: Operating System :: OS Independent
Requires-Dist: kadi-apy>=0.51.0
Requires-Python: >=3.14
Description-Content-Type: text/markdown

# Kadi-APY Helper

A lightweight Python package for simplified management of users, groups, collections, and records in **Kadi4Mat** based on `kadi-apy`.

## Installation

Install the package in your project via `uv`:

```bash
uv add kadi-apy-helper
```

Alternatively, you can install the package traditionally via `pip`:

```bash
pip install kadi-apy-helper
```

## Setup (One-Time)

Before you can access Kadi4Mat, the local configuration file must be created with your instance URL (host) and your Personal Access Token (PAT):

```python
from kadi_apy_helper import setup_kadi_apy

setup_kadi_apy(
    host_info="https://your-institution.edu",
    pat_token="YOUR_PERSONAL_ACCESS_TOKEN"
)
```

## Quickstart & Usage

### 1. Load and Manage Elements

Use `create_kadi_elements()` to set up a structured dictionary for your loaded objects:

```python
from kadi_apy_helper import (
    create_kadi_elements,
    load_users,
    load_groups,
    load_records,
    load_collections,
    print_loaded_elements,
)

# Initialize empty structure for elements
elements = create_kadi_elements()

# Load existing elements from Kadi4mat by their identifiers
load_users(user_ids=["jdoe"], kadi_elements=elements)
load_groups(group_ids=["research_group_xy"], kadi_elements=elements)
load_collections(collection_ids=["project-2026"], kadi_elements=elements)
load_records(record_ids=["measurement-series-01"], kadi_elements=elements)

# Print loaded elements clearly
print_loaded_elements(elements)
```

### 2. Create New Groups, Collections, and Records

```python
from kadi_apy_helper import add_group, add_collection, add_record

# Create a new group
group = add_group(
    identifier="new-group",
    title="My Research Group",
    description="Description of the group",
    users=[("jdoe", "member")]
)

# Create a new collection
collection = add_collection(
    identifier="new-collection",
    title="Measurement Campaign 2026",
    description="All datasets of the measurement campaign",
    add_tags=["experiment", "2026"]
)

# Create a new record and upload files
record = add_record(
    identifier="measurement-001",
    title="First Test Run",
    record_type="dataset",
    description="Raw data of the first test run",
    add_tags=["raw-data"],
    fileloc=["./data/measurement.csv"],
    filedesc=["Measurement data as CSV"],
    collection_link=[collection.id]
)
```

### 3. Use a Custom `KadiManager` Instance (Optional)

By default, all functions use the locally stored configuration file (`~/.kadi-apy.cfg`). If you want to work with multiple Kadi4Mat instances in parallel, you can pass your own `KadiManager` instance to any function:

```python
from kadi_apy import KadiManager
from kadi_apy_helper import add_group

custom_manager = KadiManager(
    host="https://demo-kadi4mat.iam.kit.edu/",
    pat="ANOTHER_TOKEN"
)

add_group(
    identifier="test-group",
    title="Test Group",
    description="Created via custom manager",
    manager=custom_manager
)
```

## Requirements

* Python >= 3.14
* kadi-apy >= 0.51.0
