diff --git a/docs/docs.go b/docs/docs.go index be2331b0..3682e386 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -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": [ diff --git a/docs/swagger.json b/docs/swagger.json index 9fa69897..1c81f68f 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -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": [ diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 41f85ff8..b6cdb571 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -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 diff --git a/http/handler/api/cluster.go b/http/handler/api/cluster.go index 351c912f..a500ade6 100644 --- a/http/handler/api/cluster.go +++ b/http/handler/api/cluster.go @@ -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 diff --git a/http/server.go b/http/server.go index b7d8dfed..6ec64353 100644 --- a/http/server.go +++ b/http/server.go @@ -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)