Blob


1 package icinga
3 import "encoding/json"
5 // User represents a User object.
6 // Note that this is different from an ApiUser.
7 type User struct {
8 Name string
9 Email string
10 Groups []string
11 }
13 var testUser = User{
14 Name: "testUser",
15 Email: "test@example.com",
16 }
18 func (u User) MarshalJSON() ([]byte, error) {
19 type attrs struct {
20 Email string `json:"email"`
21 Groups []string `json:"groups,omitempty"`
22 }
23 return json.Marshal(&struct {
24 Attrs attrs `json:"attrs"`
25 }{
26 Attrs: attrs{
27 Email: u.Email,
28 Groups: u.Groups,
29 },
30 })
31 }
33 func (u User) name() string {
34 return u.Name
35 }
37 func (u User) path() string {
38 return "/objects/users/" + u.Name
39 }