|
| 1 | +package sdk |
| 2 | + |
| 3 | +/* |
| 4 | + Copyright 2016 Alexander I.Grafov <[email protected]> |
| 5 | + Copyright 2016-2019 The Grafana SDK authors |
| 6 | +
|
| 7 | + Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | + you may not use this file except in compliance with the License. |
| 9 | + You may obtain a copy of the License at |
| 10 | +
|
| 11 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | +
|
| 13 | + Unless required by applicable law or agreed to in writing, software |
| 14 | + distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | + See the License for the specific language governing permissions and |
| 17 | + limitations under the License. |
| 18 | +
|
| 19 | + ॐ तारे तुत्तारे तुरे स्व |
| 20 | +*/ |
| 21 | + |
| 22 | +import ( |
| 23 | + "encoding/json" |
| 24 | +) |
| 25 | + |
| 26 | +// HealthResponse represents the health of grafana server |
| 27 | +type HealthResponse struct { |
| 28 | + Commit string `json:"commit"` |
| 29 | + Database string `json:"database"` |
| 30 | + Version string `json:"version"` |
| 31 | +} |
| 32 | + |
| 33 | +// GetHealth retrieves the health of the grafana server |
| 34 | +// Reflects GET BaseURL API call. |
| 35 | +func (r *Client) GetHealth() (HealthResponse, error) { |
| 36 | + var ( |
| 37 | + raw []byte |
| 38 | + err error |
| 39 | + ) |
| 40 | + if raw, _, err = r.get("/api/health", nil); err != nil { |
| 41 | + return HealthResponse{}, err |
| 42 | + } |
| 43 | + |
| 44 | + health := HealthResponse{} |
| 45 | + if err := json.Unmarshal(raw, &health); err != nil { |
| 46 | + return HealthResponse{}, err |
| 47 | + } |
| 48 | + return health, nil |
| 49 | +} |
0 commit comments