-
Notifications
You must be signed in to change notification settings - Fork 33
/
users.go
33 lines (28 loc) · 943 Bytes
/
users.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package mackerel
import "fmt"
// User information
type User struct {
ID string `json:"id,omitempty"`
ScreenName string `json:"screenName,omitempty"`
Email string `json:"email,omitempty"`
Authority string `json:"authority,omitempty"`
IsInRegistrationProcess bool `json:"isInRegistrationProcess,omitempty"`
IsMFAEnabled bool `json:"isMFAEnabled,omitempty"`
AuthenticationMethods []string `json:"authenticationMethods,omitempty"`
JoinedAt int64 `json:"joinedAt,omitempty"`
}
// FindUsers finds users.
func (c *Client) FindUsers() ([]*User, error) {
data, err := requestGet[struct {
Users []*User `json:"users"`
}](c, "/api/v0/users")
if err != nil {
return nil, err
}
return data.Users, nil
}
// DeleteUser deletes a user.
func (c *Client) DeleteUser(userID string) (*User, error) {
path := fmt.Sprintf("/api/v0/users/%s", userID)
return requestDelete[User](c, path)
}