Skip to content

Releases: giswater/api

v1.5.0

Choose a tag to compare

@smaspons smaspons released this 19 Jun 11:23
0f679bc

What's Changed

Added

  • Service layer (app/services/): business logic extracted from FastAPI routes into HTTP-agnostic services (ServiceContext, domain services for basic/CRM/OM/EPA/routing/system/admin). HTTP handlers and the CLI share the same code path.
  • giswater-api CLI (app/cli/, Click): console script entry point after pip install -e .. Commands:
    • admin tenants list|get — platform tenant registry
    • admin users list|create — gwapi user management (basic-auth tenants)
    • tenant --tenant … --schema … ready — tenant readiness probe (exit code 1 when not ready)
    • tenant … crm insert-hydrometer — example tenant-scoped CRM operation
    • Global --tenants-dir overrides TENANTS_DIR outside the FastAPI lifespan
  • app/api/exception_handlers.py: centralized mapping of service-layer exceptions to HTTP responses (replaces per-route error handling).
  • docs/ARCHITECTURE.md (package map, dependency rules, where to add code) and docs/VERSIONING.md (API/DB versioning policy).
  • CLI smoke test (tests/test_cli_smoke.py).

Changed

  • FastAPI-aligned internal layout (no HTTP path, env var, or behavior changes). app/ is now split into standard subpackages:
    • app/api/deps.py (was dependencies.py), v1/ (router.py wiring + endpoints/ tenant routers), and admin/ (tenants.py, users.py, router.py).
    • app/core/config.py, constants.py, exceptions.py (dependency-free leaf). AUTH_MODES / DEPRECATED_KEYCLOAK_ENABLED_ISSUE now live in core/config.py, fixing a latent config<=>auth import cycle.
    • app/auth/session.py (was auth.py), keycloak.py, users.py (was gwapi_users.py), schemas.py (ApiUser + gwapi user DTOs), constants.py.
    • app/db/manager.py (was database.py), context.py, execution.py, version.py, log_store.py, and bootstrap/{log,gwapi}.py (the old app/schemas.py DDL).
    • app/tenancy/registry.py (was tenant.py), state.py, host_middleware.py.
    • app/middleware/request_logging.py (was app/logging.py, no longer shadows stdlib logging).
    • app/schemas/ now holds all Pydantic request/response models (was app/models/).
    • app/utils/ slimmed into focused modules: body.py, version.py (merges giswater_version.py), rate_limit.py, plugins.py, log_setup.py, routing.py.
  • All v1 and admin route handlers are now thin wrappers: CommonsDepget_service_context() → service method → JSON response.
  • OpenAPI description metadata added or improved across admin, system, and tenant endpoints.
  • README updated with CLI usage examples and the new package layout.

Fixed

  • Service-layer exceptions are re-raised after handling so FastAPI's registered exception handlers produce the correct HTTP status and body (instead of being swallowed or mapped inline in routes).

Removed

  • app/api/http_errors.py (superseded by exception_handlers.py).

Pull Requests

  • refactor: Tidy up code layout for a FastAPI-aligned app by @smaspons in #25

Full Changelog: v1.4.0...v1.5.0

v1.4.0

Choose a tag to compare

@smaspons smaspons released this 12 Jun 07:50
32f19bf

What's Changed

Added

  • Per-tenant AUTH_MODE (none | basic | keycloak) for tenant API authentication.
  • basic mode: HTTP Basic auth backed by the gwapi schema (gwapi.users, roles, user CRUD via admin API).
  • Unified ApiUser identity with require_role() FastAPI dependency.
  • app/schemas.py centralizes DDL bootstrap for log and gwapi schemas.
  • Install script for production deployment (single-tenant)

Deprecated

  • KEYCLOAK_ENABLED per-tenant env var (shim maps to AUTH_MODE; removal in 2.0.0, # DEPRECATED #22).
  • Admin API top-level keycloak block (use auth.mode + auth.keycloak).

Pull Requests

  • refactor(auth): add basic authentication by @smaspons in #24

Full Changelog: v1.3.2...v1.4.0

v1.3.2

Choose a tag to compare

@smaspons smaspons released this 08 Jun 14:04
c278297

What's Changed?

Fixed

  • Sector and expl ID fields are lists of integers

Full Changelog: v1.3.1...v1.3.2

v1.3.1

Choose a tag to compare

@smaspons smaspons released this 28 May 13:54
17376d7

What's Changed?

Fixed

  • Skip DB logging for tenant health probes (${API_ROOT}/v1/health), matching global and admin health.

Full Changelog: v1.3.0...v1.3.1

v1.3.0

Choose a tag to compare

@smaspons smaspons released this 19 May 15:33
b3f5473

What's Changed?

Added

  • LOG_DB_RESPONSE_MAX_BYTES (default 8192): truncate the raw DB function payload stored in log.gw_api_logs_db.response_json (captured by execute_procedure). Prevents huge JSON responses from bloating the API DB log table. Set to 0 to disable truncation. Independent from LOG_DB_MAX_BODY_BYTES, which only caps HTTP request/response bodies in log.gw_api_logs.

Full Changelog: v1.2.0...v1.3.0

v1.2.0

Choose a tag to compare

@smaspons smaspons released this 19 May 11:48
837bdaf

What's changed?

Added

  • Single-tenant routing mode (SINGLE_TENANT_ID): when set, all ${API_ROOT}/v1/* requests resolve to that tenant regardless of Host, and ${API_ROOT}/admin/* is reachable on the same host/IP. Enables IP-only or single-host production deployments without DNS or fake Host headers. BASE_DOMAIN is ignored for routing in this mode. When unset, DNS-based multi-tenant routing via BASE_DOMAIN is unchanged.

Changed

  • Configurable API root: all surfaces now live under a single env-driven prefix (API_ROOT, default /giswater). Tenant API at ${API_ROOT}/v1, admin at ${API_ROOT}/admin, global health at ${API_ROOT}/health, static at ${API_ROOT}/static. Set API_ROOT=/gw-api to keep legacy v1.1 URLs.
  • Log viewer (/logs/ui) now resolves its static asset URLs from STATIC_PREFIX instead of hardcoded /gw-api/static.
  • deploy/nginx.conf.example, scripts/smoke_test.sh, and docker-compose.yml healthcheck updated to use ${API_ROOT} (default /giswater).
  • Public URLs moved from /gw-api/... to /giswater/... by default. Deployments that need the old paths must set API_ROOT=/gw-api; clients, Keycloak callbacks, probes, and any hardcoded URLs must be updated accordingly.

Full Changelog: v1.1.0...v1.2.0

v1.1.0

Choose a tag to compare

@smaspons smaspons released this 11 May 11:20
f0303a2

What's changed?

Changed

  • Serve everything under /gw-api.

Full Changelog: v1.0.0...v1.1.0

v1.0.0

Choose a tag to compare

@smaspons smaspons released this 07 May 11:20
55f4505

What's Changed

Added

  • Production runtime: gunicorn + uvicorn.workers.UvicornWorker with gunicorn.conf.py (workers from WEB_CONCURRENCY, timeouts, max-requests).
  • Logging defaults: LOG_HTTP_BODY_CAPTURE default on (bodies truncated via LOG_DB_MAX_BODY_BYTES); LOG_DB_SAMPLE_RATE default 1.0 for full request audit; response buffering only when capture enabled.
  • DB compatibility gate: GISWATER_DB_VERSION_CHECK / GISWATER_DB_MIN_VERSION integrated into tenant GET /gw-api/v1/ready.
  • Golden prod env: .env.prod.example; deployment checklist docs/DEPLOYMENT_CHECKLIST.md.
  • Post-deploy smoke: scripts/smoke_test.sh; pytest operability smoke (tests/test_operability.py).
  • Version parsing helper: app/giswater_version.py.

Changed

  • Dockerfile CMD uses Gunicorn instead of bare uvicorn.
  • Hot paths: narrower psycopg.Error handling in DB/SQL utilities and admin log queries; routing/Valhalla helpers avoid bare except.
  • Documentation: README deployment, compatibility table for 1.x, logging and probe guidance.

Security

  • Payload retention is truncated and skippable: set LOG_HTTP_BODY_CAPTURE=false for metadata-only, or lower LOG_DB_SAMPLE_RATE if the DB log table is under pressure.

Removed

  • Runtime print(...) usage in favor of structured logging.

Pull requests

Full Changelog: v0.9.0...v1.0.0

v0.9.0

v0.9.0 Pre-release
Pre-release

Choose a tag to compare

@danimarinBG danimarinBG released this 08 Apr 15:02

What's Changed

Added

  • Keycloak admin client id
  • Add execute upsert on utils and new upsert endpoint for dscenario objects

Full Changelog: v0.8.3...v0.9.0

v0.8.2

v0.8.2 Pre-release
Pre-release

Choose a tag to compare

@smaspons smaspons released this 25 Mar 11:55
87a5a4d

What's Changed

Changed

  • Dscenario object_id management & various fixes
  • App icon

Full Changelog: v0.8.1...v0.8.2