Metadata-Version: 2.4
Name: forester-client-http
Version: 0.6.0
Summary: Python HTTP client for the Forester behavior tree runtime.
Author-email: BorisZhguchev <zhguchev@hotmail.com>
License-Expression: Apache-2.0
Project-URL: Homepage, https://github.com/besok/forester
Project-URL: Repository, https://github.com/besok/forester
Project-URL: Documentation, https://github.com/besok/forester
Keywords: forester,behavior-tree,client,http
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests>=2.0
Provides-Extra: test
Requires-Dist: pytest>=7.0; extra == "test"
Dynamic: license-file

# Forester HTTP client (Python)

Python client for the **Forester** HTTP API. Forester embeds a small HTTP
server that exposes the **blackboard** and the **tracer** to remote actions.
This package talks to that server.

The client is generated from the OpenAPI specification produced by the
Forester `gen-openapi` binary (`cargo run --bin gen-openapi`). The source
specification is kept in `clients/http/openapi.json`.

## Installation

```shell
pip install forester-client-http
```

## Usage

```python
from forester_client_http import ForesterClient

client = ForesterClient("http://127.0.0.1:46123")

# health
print(client.health())  # "OK"

# blackboard
client.put("count", 42)
assert client.get("count") == 42
assert client.contains("count") is True

value = client.take("count")  # 42, and the key is removed

client.put("config", {"timeout": 5, "tags": ["a", "b"]})
client.lock("config")
assert client.is_locked("config") is True
client.unlock("config")

# tracer
client.trace("robot armed", tick=3)
print(client.print_trace())
```

## API

| Method | Endpoint |
| ------ | -------- |
| `health()` | `GET /` |
| `openapi()` | `GET /openapi.json` |
| `get(key)` | `GET /bb/{key}` |
| `put(key, value)` | `POST /bb/{key}` |
| `take(key)` | `GET /bb/{key}/take` |
| `lock(key)` | `GET /bb/{key}/lock` |
| `unlock(key)` | `GET /bb/{key}/unlock` |
| `is_locked(key)` | `GET /bb/{key}/locked` |
| `contains(key)` | `GET /bb/{key}/contains` |
| `trace(text, tick)` | `POST /tracer/custom` |
| `print_trace()` | `GET /tracer/print` |

## Development

```shell
pip install -e .[test]
pytest
```

## License

Apache-2.0
