opentofu/vendor/github.com/apparentlymart/go-grafana-api/user.go
Martin Atkins 158a90b25b Grafana Provider, with Data Source and Dashboard resources (#6206)
* Grafana provider

* grafana_data_source resource.

Allows data sources to be created in Grafana. Supports all data source
types that are accepted in the current version of Grafana, and will
support any future ones that fit into the existing structure.

* Vendoring of apparentlymart/go-grafana-api

This is in anticipation of adding a Grafana provider plugin.

* grafana_dashboard resource

* Website documentation for the Grafana provider.
2016-05-20 10:20:17 +01:00

40 lines
639 B
Go

package gapi
import (
"encoding/json"
"errors"
"io/ioutil"
)
type User struct {
Id int64
Email string
Name string
Login string
IsAdmin bool
}
func (c *Client) Users() ([]User, error) {
users := make([]User, 0)
req, err := c.newRequest("GET", "/api/users", nil)
if err != nil {
return users, err
}
resp, err := c.Do(req)
if err != nil {
return users, err
}
if resp.StatusCode != 200 {
return users, errors.New(resp.Status)
}
data, err := ioutil.ReadAll(resp.Body)
if err != nil {
return users, err
}
err = json.Unmarshal(data, &users)
if err != nil {
return users, err
}
return users, err
}