* Wire up to full alert rule struct * Extract group change detection logic to dedicated file * GroupDiff -> GroupDelta for consistency * Calculate deltas and handle backwards compatible requests * Separate changes and insert/update/delete as needed * Regenerate files * Don't touch the DB if there are no changes * Quota checking, delete unused file * Mark modified records as provisioned * Validation + a couple API layer tests * Address linter errors * Fix issue with UID assignment and rule creation * Propagate top level group fields to all rules * Tests for repeated updates and versioning * Tests for quota and provenance checks * Fix linter errors * Regenerate * Factor out some shared logic * Drop unnecessary multiple nilchecks * Use alternative strategy for rolling UIDs on inserted rules * Fix tests, add back nilcheck, refresh UIDs during test * Address feedback * Add missing nil-check |
||
---|---|---|
.. | ||
cmd/clean-swagger | ||
definitions | ||
swagger-codegen/templates | ||
.gitignore | ||
api.json | ||
index.html | ||
Makefile | ||
post.json | ||
README.md | ||
spec.json |
What
This aims to define the unified alerting API as code. It generates OpenAPI definitions from go structs. It also generates server/route stubs based on our documentation.
Running
make
- regenerate everything - documentation and server stubs.
make serve
- regenerate the Swagger document, and host rendered docs on port 80. view api
Requires
Why
The current state of Swagger extraction from golang is relatively limited. It's easier to generate server stubs from an existing Swagger doc, as there are limitations with producing a Swagger doc from a hand-written API stub. The current extractor instead relies on comments describing the routes, but the comments and actual implementation may drift, which we don't want to allow.
Instead, we use a hybrid approach - we define the types in Golang, with comments describing the routes, in a standalone package with minimal dependencies. From this, we produce a Swagger doc, and then turn the Swagger doc back into a full-blown server stub.
Stability
We have some endpoints that we document publically as being stable, and others that we consider unstable. The stable endpoints are documented in api.json
, where all endpoints are available in post.json
.
To stabilize an endpoint, add the stable
tag to its route comment:
// swagger:route GET /api/provisioning/contact-points provisioning stable RouteGetContactpoints