Blob
1 package icinga3 import "encoding/json"5 // User represents a User object.6 // Note that this is different from an ApiUser.7 type User struct {8 Name string9 Email string10 Groups []string11 }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.Name35 }37 func (u User) path() string {38 return "/objects/users/" + u.Name39 }
