api: deprecate legacy endpoints used by pycore; drop other legacy endpoints; enable DRF/OpenAPI api - #454
Merged
Conversation
- Drink.cancel_drink deletes the record and returns nothing, but the view tried to serialize its return value; serialize the drink before canceling instead
- pins the exact legacy-api surface kegbot-pycore (and the fullscreen page) depend on, ahead of deprecating everything else
- legacy responses are now built as plain dicts (pykeg.web.api.serialize) with the same field names and presence rules the proto encoding produced; fields the old encoding marked deprecated are dropped - api exceptions move to pykeg.web.api.exceptions; pykeg.proto is gone and the protobuf dependency (and last tie to kegbot-api) with it
- only the endpoints kegbot-pycore calls remain (status, taps, record/cancel drink, thermo logging, auth-token lookup, controller and flow-meter creation), plus the events feed the fullscreen page polls; every other route answers 410 Gone - the device-link flow (api + kegadmin page) is removed along with the other app-only endpoints
- every v1 response carries a Deprecation header - changelog notes the trim, the 410s, and the mobile-app impact
- the drf api is always enabled (KEGBOT_ENABLE_V2_API is gone) and owns the /api/ namespace - the deprecated legacy api moves exclusively to /api/v1/; pycore installs must configure their api url accordingly - privacy, setup-gate, and slash-rewrite middleware follow the new prefixes
- close write-permission holes: users and invitations are read-only, beverages/producers need admin to write, notification settings are scoped to the caller, plugin data (may hold plugin credentials) is admin-only, thermologs are read-only - fix InvitationViewSet serving the wrong serializer - api keys created via the api bind to the caller; key value is server-generated (read-only) - nested and method-sourced serializer fields are marked read-only; beverages accept producer_id on write - login goes through django authenticate(), honoring auth backends and inactive-user checks
- schema served at /api/schema, interactive docs at /api/docs (swagger ui assets bundled via the sidecar package; no cdn) - schema validates with --fail-on-warn: auth scheme described via an extension, method fields carry type hints - pykeg.api is now a proper installed app (label pykeg_api; the label 'api' belongs to the legacy pykeg.web.api)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #452 and the goal of moving us to a cleaner, easier to use & maintain API.
This removes and 401s a bunch of endpoints that were only in use by the Kegbot Android app, which will no longer be supported. A replacement app could someday be built against the new APIs, but I have no current plans to.
It continues support for endpoints which are needed by @kegbot/kegbot-pycore, as a transitional aid.
It enables the django-rest-framework API and mounts it at
/api/, and with OpenAPI docs at/api/docs