Metadata-Version: 2.4
Name: huwise-utils-py
Version: 1.3.2
Summary: A Python wrapper library for the Huwise Automation API
Project-URL: Homepage, https://github.com/opendatabs/huwise-utils-py
Project-URL: Documentation, https://opendatabs.github.io/huwise-utils-py
Project-URL: Repository, https://github.com/opendatabs/huwise-utils-py.git
Project-URL: Issues, https://github.com/opendatabs/huwise-utils-py/issues
Project-URL: Coding Standards, https://dcc-bs.github.io/documentation/coding/python.html
Author-email: Open Data Basel-Stadt <opendata@bs.ch>, Renato Farruggio <renato.farruggio@bs.ch>, Rstam Alosuh <rstam.aloush@bs.ch>, Orhan Saeedi <orhan.saeedi@bs.ch>
License: MIT License
        
        Copyright (c) 2024 Open Data Basel-Stadt
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.12
Requires-Dist: httpx>=0.27.0
Requires-Dist: pydantic>=2.0.0
Requires-Dist: rich>=14.3.2
Description-Content-Type: text/markdown

# huwise-utils-py

A Python library for the Huwise Automation API.

[![PyPI version](https://badge.fury.io/py/huwise-utils-py.svg)](https://badge.fury.io/py/huwise-utils-py)
[![Python 3.12+](https://img.shields.io/badge/python-3.12+-blue.svg)](https://www.python.org/downloads/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

## Features

- **Type-safe configuration** with Pydantic-based `HuwiseConfig`
- **Object-oriented API** with `HuwiseDataset` class and method chaining
- **Async support** for high-performance bulk operations
- **Airflow-friendly logging** via Python stdlib logging
- **Dependency injection** support for testable code
- **Backwards compatible** function-based API available

## Installation

Using `uv` (recommended):

```bash
uv add huwise-utils-py
```

Or via `pip`:

```bash
pip install huwise-utils-py
```

## Requirements

- **Python Version:** 3.12 or higher
- **Domain:** Optional (defaults to `data.bs.ch`; set `HUWISE_DOMAIN` for other portals)
- **API Key:** Optional for public read endpoints, required for write/restricted operations

## Quick Start

### Configuration

Create a `.env` file:

```bash
HUWISE_API_TYPE=automation/v1.0
```

If your portal is not `data.bs.ch`, also set:

```bash
HUWISE_DOMAIN=your-portal.example.org
```

If you need write access (publish/update metadata), also add:

```bash
HUWISE_API_KEY=your-api-key
```

### Using HuwiseDataset (Recommended)

```python
from huwise_utils_py import HuwiseDataset

# Create a dataset instance from its ID
dataset = HuwiseDataset.from_id("100123")

# Read metadata
title = dataset.get_title()
description = dataset.get_description()

# Update with method chaining
dataset.set_title("New Title", publish=False).set_description("New description").publish()
```

### Using Functions

```python
from huwise_utils_py import get_dataset_title, set_dataset_title

# Read
title = get_dataset_title(dataset_id="100123")

# Write
set_dataset_title("New Title", dataset_id="100123")
```

### Bulk Operations

```python
from huwise_utils_py import bulk_get_metadata, bulk_get_metadata_async
import asyncio

# Synchronous
metadata = bulk_get_metadata(dataset_ids=["100123", "100456", "100789"])

# Asynchronous (10-100x faster for many datasets)
metadata = asyncio.run(bulk_get_metadata_async(dataset_ids=["100123", "100456", "100789"]))
```

## API Key Setup

To use `huwise-utils-py`, create an API key with these permissions:

- Browse all datasets
- Create new datasets
- Edit all datasets
- Publish own datasets

[For OGD Basel, create your API key here](https://data.bs.ch/account/api-keys/).

**Important:** Add `**/.env` to your `.gitignore` to protect your credentials.

## Documentation

Full documentation is available at [opendatabs.github.io/huwise-utils-py](https://opendatabs.github.io/huwise-utils-py).

## API Reference

This library is a Python client for the [Huwise Automation API](https://help.opendatasoft.com/apis/ods-automation-v1/). The Automation API enables programmatic management of datasets, metadata, resources, security, and more on Huwise (ex Opendatasoft) portals.

For the complete API specification including all available endpoints, request/response schemas, and authentication details, see the [official Automation API documentation](https://help.opendatasoft.com/apis/ods-automation-v1/).

## Related Projects

- **[odsAutomationR](https://github.com/ogdtg/odsAutomationR)** - An R package for accessing the Automation API, developed by the Canton of Thurgau. If you're working in R, this package provides similar functionality.

## Further Links

- [GitHub Repository](https://github.com/opendatabs/huwise-utils-py)
- [PyPI Package](https://pypi.org/project/huwise-utils-py/)
- [Huwise Automation API Documentation](https://help.opendatasoft.com/apis/ods-automation-v1/)
- [DCC Python Coding Standards](https://dcc-bs.github.io/documentation/coding/python.html)

## License

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
