Metadata-Version: 2.4
Name: ssb-collector-client
Version: 0.0.3
Summary: SSB Collector Client
License-Expression: MIT
License-File: LICENSE
Author: Rupinder Kaur
Author-email: rpk@ssb.no
Requires-Python: >=3.10,<4.0
Classifier: Development Status :: 5 - Production/Stable
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Dist: click (>=8.0.1)
Requires-Dist: dapla-auth-client (>=1.2.0,<2.0.0)
Project-URL: Changelog, https://github.com/statisticsnorway/ssb-collector-client/releases
Project-URL: Documentation, https://statisticsnorway.github.io/ssb-collector-client
Project-URL: Homepage, https://github.com/statisticsnorway/ssb-collector-client
Project-URL: Repository, https://github.com/statisticsnorway/ssb-collector-client
Description-Content-Type: text/markdown

# SSB Collector Client

[![PyPI](https://img.shields.io/pypi/v/ssb-collector-client.svg)][pypi status]
[![Status](https://img.shields.io/pypi/status/ssb-collector-client.svg)][pypi status]
[![Python Version](https://img.shields.io/pypi/pyversions/ssb-collector-client)][pypi status]
[![License](https://img.shields.io/pypi/l/ssb-collector-client)][license]

[![Documentation](https://github.com/statisticsnorway/ssb-collector-client/actions/workflows/docs.yml/badge.svg)][documentation]
[![Tests](https://github.com/statisticsnorway/ssb-collector-client/actions/workflows/tests.yml/badge.svg)][tests]
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=statisticsnorway_ssb-collector-client&metric=coverage)][sonarcov]
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=statisticsnorway_ssb-collector-client&metric=alert_status)][sonarquality]

[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)][pre-commit]
[![Black](https://img.shields.io/badge/code%20style-black-000000.svg)][black]
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![Poetry](https://img.shields.io/endpoint?url=https://python-poetry.org/badge/v0.json)][poetry]

[pypi status]: https://pypi.org/project/ssb-collector-client/
[documentation]: https://statisticsnorway.github.io/ssb-collector-client
[tests]: https://github.com/statisticsnorway/ssb-collector-client/actions?workflow=Tests
[sonarcov]: https://sonarcloud.io/summary/overall?id=statisticsnorway_ssb-collector-client
[sonarquality]: https://sonarcloud.io/summary/overall?id=statisticsnorway_ssb-collector-client
[pre-commit]: https://github.com/pre-commit/pre-commit
[black]: https://github.com/psf/black
[poetry]: https://python-poetry.org/

## Features

- Start new data collector tasks with custom specifications
- List all running collector tasks
- Stop running collector tasks by ID
- Built-in authentication using Dapla Auth Client
- Simple function-based API for easy integration

## Requirements

- Python 3.10 or higher
- Access to a Data Collector service
- Dapla authentication credentials

## Installation

You can install _SSB Collector Client_ via [pip] from [PyPI]:

```console
pip install ssb-collector-client
```

## Usage

The SSB Collector Client provides three main functions for interacting with a Data Collector service:

### Starting a Collector Task

```python
from ssb_collector_client import start

# Define your collector specification
specification = {
    "type": "your-collector-type",
    # ... other specification parameters
}

# Start the task
response = start(
    collector_url="https://your-collector-service.no/tasks",
    specification=specification
)
```

### Listing Running Tasks

```python
from ssb_collector_client import running_tasks

# Get all running tasks
response = running_tasks(
    collector_url="https://your-collector-service.no/tasks"
)

# The response contains information about all running tasks
print(response.json())
```

### Stopping a Task

```python
from ssb_collector_client import stop

# Stop a specific task by ID
response = stop(
    collector_url="https://your-collector-service.no/tasks",
    task_id=1234
)
```

### Complete Example

```python
from ssb_collector_client import start, running_tasks, stop

collector_url = "https://your-collector-service.no/tasks"

# Start a new task
specification = {"type": "example-type"}
start_response = start(collector_url, specification)

# Check running tasks
tasks = running_tasks(collector_url)
print(f"Running tasks: {tasks.json()}")

# Stop a task if needed
stop_response = stop(collector_url, task_id=1234)
```

Please see the [Reference Guide] for details.

## Contributing

Contributions are very welcome.
To learn more, see the [Contributor Guide].

## License

Distributed under the terms of the [MIT license][license],
_SSB Collector Client_ is free and open source software.

## Issues

If you encounter any problems,
please [file an issue] along with a detailed description.

## Credits

This project was generated from [Statistics Norway]'s [SSB PyPI Template].

[statistics norway]: https://www.ssb.no/en
[pypi]: https://pypi.org/
[ssb pypi template]: https://github.com/statisticsnorway/ssb-pypitemplate
[file an issue]: https://github.com/statisticsnorway/ssb-collector-client/issues
[pip]: https://pip.pypa.io/

<!-- github-only -->

[license]: https://github.com/statisticsnorway/ssb-collector-client/blob/main/LICENSE
[contributor guide]: https://github.com/statisticsnorway/ssb-collector-client/blob/main/CONTRIBUTING.md
[reference guide]: https://statisticsnorway.github.io/ssb-collector-client/reference.html

