in compliance/kibana.go [377:408]
func (k *Kibana) getDashboard(dashboardID string) (*dashboardResponse, error) {
apiPath, err := url.JoinPath(apiGetDashboardPath, dashboardID)
if err != nil {
return nil, err
}
req, err := k.newRequest(http.MethodGet, apiPath, nil)
if err != nil {
return nil, err
}
resp, err := k.client.Do(req)
if err != nil {
return nil, err
}
defer resp.Body.Close()
if resp.StatusCode >= 400 {
respBody, err := io.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("failed to read response body (status: %d)", resp.StatusCode)
}
return nil, fmt.Errorf("request failed with status %d, body: %s", resp.StatusCode, string(respBody))
}
var dashboard dashboardResponse
err = json.NewDecoder(resp.Body).Decode(&dashboard)
if err != nil {
return nil, err
}
return &dashboard, nil
}