From 57ba312941921ba9934ff50d01ebb7b2e07f885c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kiss=20Gy=C3=B6rgy?= Date: Mon, 5 Jun 2017 17:00:45 +0200 Subject: [PATCH] Add Health() method to Sys client (#2805) --- api/sys_health.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 api/sys_health.go diff --git a/api/sys_health.go b/api/sys_health.go new file mode 100644 index 000000000000..5c0884a4153b --- /dev/null +++ b/api/sys_health.go @@ -0,0 +1,24 @@ +package api + +func (c *Sys) Health() (*HealthResponse, error) { + r := c.c.NewRequest("GET", "/v1/sys/health") + resp, err := c.c.RawRequest(r) + if err != nil { + return nil, err + } + defer resp.Body.Close() + + var result HealthResponse + err = resp.DecodeJSON(&result) + return &result, err +} + +type HealthResponse struct { + Initialized bool `json:"initialized"` + Sealed bool `json:"sealed"` + Standby bool `json:"standby"` + ServerTimeUTC int64 `json:"server_time_utc"` + Version string `json:"version"` + ClusterName string `json:"cluster_name,omitempty"` + ClusterID string `json:"cluster_id,omitempty"` +}