forked from cloudfoundry/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
users.go
60 lines (50 loc) · 1.21 KB
/
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package resources
import "code.cloudfoundry.org/cli/cf/models"
type UserResource struct {
Resource
Entity UserEntity
}
type UserEntity struct {
Name string `json:"username,omitempty"`
Admin bool
}
type UAAUserResources struct {
Resources []struct {
ID string
Username string
}
}
func (resource UserResource) ToFields() models.UserFields {
return models.UserFields{
GUID: resource.Metadata.GUID,
IsAdmin: resource.Entity.Admin,
Username: resource.Entity.Name,
}
}
type UAAUserResourceEmail struct {
Value string `json:"value"`
}
type UAAUserResourceName struct {
GivenName string `json:"givenName"`
FamilyName string `json:"familyName"`
}
type UAAUserResource struct {
Username string `json:"userName"`
Emails []UAAUserResourceEmail `json:"emails"`
Password string `json:"password"`
Name UAAUserResourceName `json:"name"`
}
func NewUAAUserResource(username, password string) UAAUserResource {
return UAAUserResource{
Username: username,
Emails: []UAAUserResourceEmail{{Value: username}},
Password: password,
Name: UAAUserResourceName{
GivenName: username,
FamilyName: username,
},
}
}
type UAAUserFields struct {
ID string
}