github.com/mook-as/cf-cli@v7.0.0-beta.28.0.20200120190804-b91c115fae48+incompatible/cf/api/resources/users.go (about) 1 package resources 2 3 import "code.cloudfoundry.org/cli/cf/models" 4 5 type UserResource struct { 6 Resource 7 Entity UserEntity 8 } 9 10 type UserEntity struct { 11 Name string `json:"username,omitempty"` 12 Admin bool 13 } 14 15 type UAAUserResources struct { 16 Resources []struct { 17 ID string 18 Username string 19 } 20 } 21 22 func (resource UserResource) ToFields() models.UserFields { 23 return models.UserFields{ 24 GUID: resource.Metadata.GUID, 25 IsAdmin: resource.Entity.Admin, 26 Username: resource.Entity.Name, 27 } 28 } 29 30 type UAAUserResourceEmail struct { 31 Value string `json:"value"` 32 } 33 34 type UAAUserResourceName struct { 35 GivenName string `json:"givenName"` 36 FamilyName string `json:"familyName"` 37 } 38 39 type UAAUserResource struct { 40 Username string `json:"userName"` 41 Emails []UAAUserResourceEmail `json:"emails"` 42 Password string `json:"password"` 43 Name UAAUserResourceName `json:"name"` 44 } 45 46 func NewUAAUserResource(username, password string) UAAUserResource { 47 return UAAUserResource{ 48 Username: username, 49 Emails: []UAAUserResourceEmail{{Value: username}}, 50 Password: password, 51 Name: UAAUserResourceName{ 52 GivenName: username, 53 FamilyName: username, 54 }, 55 } 56 } 57 58 type UAAUserFields struct { 59 ID string 60 }