Metadata-Version: 2.4
Name: opendecree
Version: 0.4.0a1
Summary: Python SDK for OpenDecree — schema-driven configuration management (alpha)
Author: Zeev Dreifuss
License-Expression: Apache-2.0
Project-URL: Homepage, https://github.com/opendecree/decree-python
Project-URL: Documentation, https://opendecree.github.io/decree-python
Project-URL: Repository, https://github.com/opendecree/decree-python
Project-URL: Issues, https://github.com/opendecree/decree-python/issues
Keywords: config,configuration,decree,grpc,schema,management
Classifier: Development Status :: 3 - Alpha
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Typing :: Typed
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.11
Description-Content-Type: text/markdown
Requires-Dist: grpcio<2,>=1.81.1
Requires-Dist: protobuf<7,>=6.33.6
Requires-Dist: googleapis-common-protos<2,>=1.75.0
Provides-Extra: otel
Requires-Dist: opentelemetry-instrumentation-grpc>=0.63b1; extra == "otel"
Provides-Extra: docs
Requires-Dist: mkdocs-material>=9.7.6; extra == "docs"
Requires-Dist: mkdocstrings[python]>=1.0.4; extra == "docs"
Provides-Extra: dev
Requires-Dist: pytest>=9.1.0; extra == "dev"
Requires-Dist: pytest-cov>=7.1.0; extra == "dev"
Requires-Dist: pytest-asyncio>=1.4.0; extra == "dev"
Requires-Dist: mypy>=2.1.0; extra == "dev"
Requires-Dist: mypy-protobuf>=5.1.0; extra == "dev"
Requires-Dist: ruff>=0.15.17; extra == "dev"
Requires-Dist: grpcio-tools>=1.81.1; extra == "dev"

# OpenDecree Python SDK

[![CI](https://github.com/opendecree/decree-python/actions/workflows/ci.yml/badge.svg)](https://github.com/opendecree/decree-python/actions/workflows/ci.yml)
[![PyPI](https://img.shields.io/pypi/v/opendecree)](https://pypi.org/project/opendecree/)
[![Python](https://img.shields.io/pypi/pyversions/opendecree)](https://pypi.org/project/opendecree/)
[![Coverage](https://img.shields.io/badge/coverage-98%25-brightgreen)](https://github.com/opendecree/decree-python)
[![License](https://img.shields.io/github/license/opendecree/decree-python)](https://github.com/opendecree/decree-python/blob/main/LICENSE)

Python SDK for [OpenDecree](https://github.com/opendecree/decree) — schema-driven configuration management.

> **Alpha** — This SDK is under active development. APIs and behavior may change without notice between versions.

## Install

```bash
pip install opendecree
```

## Quick Start

```python
from opendecree import ConfigClient

with ConfigClient("localhost:9090", subject="myapp") as client:
    # Get config values (default: string)
    fee = client.get("tenant-id", "payments.fee")

    # Typed gets via overload
    retries = client.get("tenant-id", "payments.retries", int)
    enabled = client.get("tenant-id", "payments.enabled", bool)

    # Set values
    client.set("tenant-id", "payments.fee", "0.5%")
```

## Watch for Changes

```python
with ConfigClient("localhost:9090", subject="myapp") as client:
    with client.watch("tenant-id") as watcher:
        fee = watcher.field("payments.fee", float, default=0.01)
        enabled = watcher.field("payments.enabled", bool, default=False)

        if enabled:
            print(f"Current fee: {fee.value}")

        @fee.on_change
        def on_fee_change(old: float, new: float):
            print(f"Fee changed: {old} -> {new}")
```

## Async

```python
from opendecree import AsyncConfigClient

async with AsyncConfigClient("localhost:9090", subject="myapp") as client:
    val = await client.get("tenant-id", "payments.fee")
    retries = await client.get("tenant-id", "payments.retries", int)
```

## Documentation

Full documentation, including guides and the API reference, is published at
**[opendecree.github.io/decree-python](https://opendecree.github.io/decree-python)**:

- [Connecting](https://opendecree.github.io/decree-python/guide/connect/) — client options (auth, TLS, retry, timeouts, error handling)
- [Watching](https://opendecree.github.io/decree-python/guide/watch/) — live subscriptions and change patterns
- [Async Usage](https://opendecree.github.io/decree-python/guide/async/) — async client and watcher
- [API Reference](https://opendecree.github.io/decree-python/api/) — full auto-generated API docs

For detailed concepts (schemas, typed values, versioning, auth), see the [main OpenDecree docs](https://github.com/opendecree/decree).

## Typing

This package is fully typed. It ships a `py.typed` marker and `.pyi` stub files for the generated gRPC layer, so mypy, pyright, and similar tools work without additional configuration.

## Requirements

- Python 3.11+
- A running OpenDecree server (v0.8.0 – v0.x, pre-1.0)

## License

Apache License 2.0 — see [LICENSE](https://github.com/opendecree/decree-python/blob/main/LICENSE).
