Metadata-Version: 2.4
Name: honua-admin
Version: 0.4.1
Summary: Admin / control-plane client for Honua geospatial server
Project-URL: Homepage, https://honua.io
Project-URL: Documentation, https://honua-io.github.io/honua-sdk-python/latest/
Project-URL: Repository, https://github.com/honua-io/honua-sdk-python
Project-URL: Issues, https://github.com/honua-io/honua-sdk-python/issues
Author: Honua
License-Expression: Apache-2.0
License-File: LICENSE
Keywords: admin,control-plane,geospatial,gis,honua
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: GIS
Classifier: Typing :: Typed
Requires-Python: >=3.11
Requires-Dist: honua-sdk~=0.4.1
Description-Content-Type: text/markdown

# honua-admin

> **Native application path:** [gRPC for live data and edits; PMTiles, GeoParquet and COG through the CDN](https://github.com/honua-io/honua-sdk-python/blob/trunk/docs/native-data-paths.md). Start there for browser gRPC-Web setup, signed private URLs and regeneration after changes. OGC API and GeoServices REST examples below are compatibility workflows.

Admin / control-plane client for
[Honua Server](https://github.com/honua-io/honua-server), the multi-protocol
geospatial server behind [Honua](https://honua.io) -- inspect and configure
services, connections, layers, folders, and styles from Python, and invoke any
pinned Admin OpenAPI operation through `honua_admin.raw`. Sync
(`HonuaAdminClient`) and async (`AsyncHonuaAdminClient`) clients included.

> **Status: Beta (`0.x`).** APIs may change before 1.0. Breaking changes to
> the public API are gated by a
> [compatibility snapshot](https://github.com/honua-io/honua-sdk-python/blob/trunk/docs/compatibility.md),
> and the client checks server compatibility at runtime via
> `check_compatibility()`.

## What it does

- **Compatibility-first**: `check_compatibility()` and
  `get_capability_flags()` read the server's `/api/v1/admin/capabilities`
  contract, so callers can gate control-plane calls on what the connected
  server actually supports (`manifest_apply`, `manifest_dry_run`,
  `metadata_resources`, ...).
- **Services**: `list_services()`, `list_services_page()`, `get_service_settings()`,
  `update_protocols()`, `update_mapserver_settings()`.
- **Layers and data**: `list_layers()`, `list_layers_page()`, `publish_layer()`,
  `set_layer_enabled()` / `set_service_layers_enabled()`, and
  `discover_tables()` for source-database table discovery.
- **Connections**: typed CRUD plus `test_connection()` /
  `test_draft_connection()`, `validate_encryption()`, and
  `rotate_encryption_key()`.
- **Styles**: OGC Styles API (`list_styles()`, `get_stylesheet()`,
  `update_style()`) and per-layer styles (`get_layer_style()`,
  `update_layer_style()`).
- **Full OpenAPI parity (`honua_admin.raw`)**: generated operation catalog
  (`ADMIN_OPERATIONS`) and raw sync/async clients (`admin.raw.call(...)`,
  `RawAdminClient`, `AsyncRawAdminClient`) covering every operation in the
  pinned `admin-api.json` contract.
- Reuses `honua-sdk`'s retry transport, auth providers, and
  `HonuaHttpError` envelopes, so data-plane and control-plane code share one
  error-handling surface.

## Install

```bash
pip install honua-admin
```

Installs a compatible `honua-sdk` automatically (shared HTTP, auth, and
error utilities). Requires Python 3.11+.

The supported server baseline and release gate policy are documented in the
monorepo
[compatibility guide](https://github.com/honua-io/honua-sdk-python/blob/trunk/docs/compatibility.md).

## Minimal Example

```python
from honua_admin import HonuaAdminClient

with HonuaAdminClient("https://your-honua-server.com", api_key="honua-api-key") as admin:
    compatibility = admin.check_compatibility()
    if not compatibility.supported:
        raise RuntimeError("; ".join(compatibility.reasons))

    services = admin.list_services()
    for svc in services:
        print(f"{svc.service_name}: {svc.layer_count} layers")
```

Always use the `with HonuaAdminClient(...) as admin:` form -- it guarantees
the underlying `httpx` connections are returned to the pool on exit, even when
a request raises. The same `auth_provider=` argument the data-plane client
accepts (e.g. `RefreshableBearerTokenProvider`) works here unchanged.

### Async

```python
import asyncio

from honua_admin import AsyncHonuaAdminClient


async def main() -> None:
    async with AsyncHonuaAdminClient(
        "https://your-honua-server.com",
        api_key="honua-api-key",
    ) as admin:
        compatibility = await admin.check_compatibility()
        if not compatibility.supported:
            raise RuntimeError("; ".join(compatibility.reasons))

        services = await admin.list_services()
        for svc in services:
            print(f"{svc.service_name}: {svc.layer_count} layers")


asyncio.run(main())
```

The async client mirrors the sync method surface (CRUD helpers, manifest
operations, migration scans, capability checks) and shares the same retry
transport, auth providers, and `HonuaHttpError` envelopes.

## Folder management

Both clients support typed Folder listing, creation, rename, empty deletion
and Service moves with snapshot ETags. Publishing preserves omitted versus
explicit Root selection. See the [Folder client reference](../../docs/reference/honua-admin/clients.md#folders)
for concurrency, namespace, display metadata and approval behavior.

## Documentation

Rendered docs site:
[honua-io.github.io/honua-sdk-python](https://honua-io.github.io/honua-sdk-python/latest/).
Platform docs: [honua.io](https://honua.io) and
[honua.gitbook.io/honuaio](https://honua.gitbook.io/honuaio/).

- [Compatibility policy](https://github.com/honua-io/honua-sdk-python/blob/trunk/docs/compatibility.md)
- [Authentication](https://github.com/honua-io/honua-sdk-python/blob/trunk/docs/auth.md)
- [Monorepo README](https://github.com/honua-io/honua-sdk-python) -- install matrix and package overview

Related: [honua-sdk](https://github.com/honua-io/honua-sdk-python/tree/trunk/packages/honua-sdk)
(the data-plane client this package builds on),
[honua-sdk-js](https://github.com/honua-io/honua-sdk-js) (JS/TS SDKs + MCP server),
[honua-sdk-dotnet](https://github.com/honua-io/honua-sdk-dotnet) (.NET SDKs).

## Verify a release

From 0.2.1, each PyPI release is built by this repository's publication workflow, which attaches
the same wheel and sdist to the matching GitHub release and records a build-provenance attestation
for them. 0.2.0 was published without an attestation; use 0.2.1 or later when you need to verify
provenance. The example verifies the 0.3.3 wheel from PyPI using public attestations.
Run it in Bash with Python 3, pip, and GitHub CLI (tested with 2.103.3).
No GitHub login or token is required. For another release, update both the
version and the expected source commit to match that release.

<!-- BEGIN GENERATED ATTESTATION EXAMPLE -->
```bash
(
  set -eu
  workdir="$(mktemp -d)"
  trap 'rm -r "$workdir"' EXIT
  cd "$workdir"

  version=0.3.3
  repo=honua-io/honua-sdk-python
  source=21a9ecb952e43ecc1450384e595259b1912f27b3
  wheel="honua_admin-${version}-py3-none-any.whl"
  python3 -m pip download --only-binary=:all: --no-deps "honua-admin==$version"

  python3 - "$wheel" "$repo" <<'PYTHON' > attestations.jsonl
import hashlib
import json
import sys
from pathlib import Path
from urllib.request import urlopen

wheel, repo = sys.argv[1:]
digest = hashlib.sha256(Path(wheel).read_bytes()).hexdigest()
with urlopen(f"https://api.github.com/repos/{repo}/attestations/sha256:{digest}", timeout=30) as response:
    attestations = json.load(response)["attestations"]
for attestation in attestations:
    print(json.dumps(attestation["bundle"]))
PYTHON

  gh attestation verify "$wheel" --bundle attestations.jsonl --repo "$repo" --source-digest "$source"
)
```
<!-- END GENERATED ATTESTATION EXAMPLE -->

## License

Apache-2.0
