3
0
mirror of https://github.com/grafana/grafana.git synced 2025-02-25 18:55:37 -06:00
grafana/pkg/services/ngalert/api/tooling
Yuri Tseretyan f0cabe14d5
Alerting: import Grafana alerting package and update usages ()
* update remaining notifiers to use alerting package
2022-12-19 10:53:58 -05:00
..
cmd/clean-swagger Handle ioutil deprecations () 2022-08-10 15:37:51 +02:00
definitions Alerting: import Grafana alerting package and update usages () 2022-12-19 10:53:58 -05:00
swagger-codegen/templates Alerting: Refactor API types generation with different names. () 2022-07-18 03:08:08 -04:00
.gitignore Alerting: Add support for documenting which alerting APIs are stable () 2022-05-23 14:08:27 -05:00
api.json Alerting: rule backtesting API () 2022-12-14 09:44:14 -05:00
index.html Swagger: Add integrity attributes () 2022-05-02 09:49:49 +02:00
Makefile Rename Acl to ACL () 2022-07-18 15:14:58 +02:00
post.json Alerting: rule backtesting API () 2022-12-14 09:44:14 -05:00
README.md Alerting: Add support for documenting which alerting APIs are stable () 2022-05-23 14:08:27 -05:00
spec.json Alerting: rule backtesting API () 2022-12-14 09:44:14 -05:00

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