Metadata-Version: 2.4
Name: fiware_fundamentals
Version: 1.0.0
Summary: A collection of fundamental functions for FIWARE at ICE-1, but easily usable for others as well
Author-email: Sascha Johnen <sa.johnen@fz-juelich.de>
Project-URL: Homepage, https://jugit.fz-juelich.de/iek-10/public/ict-platform/fiware-applications/fiware-fundamentals
Project-URL: Repository, https://jugit.fz-juelich.de/iek-10/public/ict-platform/fiware-applications/fiware-fundamentals
Project-URL: Issues, https://jugit.fz-juelich.de/iek-10/public/ict-platform/fiware-applications/fiware-fundamentals/-/issues
Keywords: FIWARE,IoT,OAuth2
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Operating System :: OS Independent
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: pydantic>=2.0.0
Requires-Dist: filip>=0.7.5
Requires-Dist: requests<3,>=2.32
Provides-Extra: tests
Requires-Dist: pytest; extra == "tests"
Requires-Dist: pytest-cov; extra == "tests"
Requires-Dist: semantic-version; extra == "tests"

# FIWARE Fundamentals

FIWARE Fundamentals adds OAuth-aware Orion Context Broker and IoT Agent
clients on top of [FILIP](https://github.com/RWTH-EBC/FiLiP). It centralizes
token injection, manages background token renewal, applies explicit HTTP
timeouts, and retries only operations that are safe to repeat automatically.

The project requires Python 3.10 or newer and is currently under active
development.

## Installation

From a checkout of this repository, install the package in editable mode:

```powershell
python -m pip install -e .
```

## OAuth quick start

The smallest runnable workflow is
[`examples/01_minimal_context_broker_oauth.py`](examples/01_minimal_context_broker_oauth.py). It
uses a `PasswordGrantHandler` to obtain and renew Keycloak tokens, then gives
an `OAuthContextBrokerClient` ownership of that handler:

```python
from fiware_fundamentals.clients.auth_handler import PasswordGrantHandler
from fiware_fundamentals.clients.oauth_ocb import OAuthContextBrokerClient

auth_handler = PasswordGrantHandler(
    auth_url=token_url,
    refresh_url=token_url,
    client_id=client_id,
    username=username,
    password=password,
)

with OAuthContextBrokerClient(
    url=orion_url,
    auth_handler=auth_handler,
) as context_broker:
    print("Connected to Orion:", context_broker.base_url)
```

Credentials and deployment URLs should come from environment variables or an
approved secret store, never from source code.

The complete [OAuth examples guide](examples/README.md) starts with setup for
beginners and progresses through:

- FIWARE tenant headers;
- timeout, retry, and worker-health configuration;
- sharing one authentication worker between clients; and
- extending central OAuth handling to another FILIP HTTP client.

All supplied examples perform read-only requests.

## Architecture and extension

The architecture guides separate the two network paths:

- The [`AuthHandler` lifecycle and extension guide](docs/auth-handler.md)
  documents token acquisition, renewal, failure, shutdown, and the contract
  for another authentication-handler subclass.
- The [`OAuthRequestMixin` request pipeline](docs/oauth-request.md) documents
  method interception, header and origin handling, protected-service retries,
  and the contract for another OAuth-enabled client.

## Development

Install the test dependencies and run the checks from the repository root:

```powershell
python -m pip install -e ".[tests]" black ruff
python -m pytest
python -m ruff check src tests examples
python -m black --check src tests examples
```

The project issue tracker is available at the
[GitLab repository](https://gitlab.fz-juelich.de/sa.johnen/fiware-fundament/-/issues).
