Add /v3/cluster/healthy endpoint

This commit is contained in:
Ingo Oppermann
2023-06-29 22:08:47 +02:00
parent d66bd61746
commit d6a88cb0c5
5 changed files with 84 additions and 0 deletions

View File

@@ -375,6 +375,32 @@ const docTemplate = `{
}
}
},
"/api/v3/cluster/healthy": {
"get": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "Whether the cluster is healthy",
"produces": [
"application/json"
],
"tags": [
"v16.?.?"
],
"summary": "Whether the cluster is healthy",
"operationId": "cluster-3-healthy",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "bool"
}
}
}
}
},
"/api/v3/cluster/iam/policies": {
"get": {
"security": [

View File

@@ -367,6 +367,32 @@
}
}
},
"/api/v3/cluster/healthy": {
"get": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "Whether the cluster is healthy",
"produces": [
"application/json"
],
"tags": [
"v16.?.?"
],
"summary": "Whether the cluster is healthy",
"operationId": "cluster-3-healthy",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "bool"
}
}
}
}
},
"/api/v3/cluster/iam/policies": {
"get": {
"security": [

View File

@@ -2628,6 +2628,22 @@ paths:
summary: List of identities in the cluster
tags:
- v16.?.?
/api/v3/cluster/healthy:
get:
description: Whether the cluster is healthy
operationId: cluster-3-healthy
produces:
- application/json
responses:
"200":
description: OK
schema:
type: bool
security:
- ApiKeyAuth: []
summary: Whether the cluster is healthy
tags:
- v16.?.?
/api/v3/cluster/iam/policies:
get:
description: List of policies IAM

View File

@@ -100,6 +100,21 @@ func (h *ClusterHandler) About(c echo.Context) error {
return c.JSON(http.StatusOK, about)
}
// Healthy returns whether the cluster is healthy
// @Summary Whether the cluster is healthy
// @Description Whether the cluster is healthy
// @Tags v16.?.?
// @ID cluster-3-healthy
// @Produce json
// @Success 200 {bool} bool
// @Security ApiKeyAuth
// @Router /api/v3/cluster/healthy [get]
func (h *ClusterHandler) Healthy(c echo.Context) error {
degraded, _ := h.cluster.IsDegraded()
return c.JSON(http.StatusOK, !degraded)
}
// Leave the cluster gracefully
// @Summary Leave the cluster gracefully
// @Description Leave the cluster gracefully

View File

@@ -689,6 +689,7 @@ func (s *server) setRoutesV3(v3 *echo.Group) {
// v3 Cluster
if s.v3handler.cluster != nil {
v3.GET("/cluster", s.v3handler.cluster.About)
v3.GET("/cluster/healthy", s.v3handler.cluster.Healthy)
v3.GET("/cluster/snapshot", s.v3handler.cluster.GetSnapshot)