github.com/liamawhite/cli-with-i18n@v6.32.1-0.20171122084555-dede0a5c3448+incompatible/cf/models/role.go (about) 1 package models 2 3 import "errors" 4 5 type Role int 6 7 const ( 8 RoleUnknown Role = iota - 1 9 RoleOrgUser 10 RoleOrgManager 11 RoleBillingManager 12 RoleOrgAuditor 13 RoleSpaceManager 14 RoleSpaceDeveloper 15 RoleSpaceAuditor 16 ) 17 18 var ErrUnknownRole = errors.New("Unknown Role") 19 20 func RoleFromString(roleString string) (Role, error) { 21 switch roleString { 22 case "OrgManager": 23 return RoleOrgManager, nil 24 case "BillingManager": 25 return RoleBillingManager, nil 26 case "OrgAuditor": 27 return RoleOrgAuditor, nil 28 case "SpaceManager": 29 return RoleSpaceManager, nil 30 case "SpaceDeveloper": 31 return RoleSpaceDeveloper, nil 32 case "SpaceAuditor": 33 return RoleSpaceAuditor, nil 34 default: 35 return RoleUnknown, ErrUnknownRole 36 } 37 } 38 39 func (r Role) ToString() string { 40 switch r { 41 case RoleUnknown: 42 return "RoleUnknown" 43 case RoleOrgUser: 44 return "RoleOrgUser" 45 case RoleOrgManager: 46 return "RoleOrgManager" 47 case RoleBillingManager: 48 return "RoleBillingManager" 49 case RoleOrgAuditor: 50 return "RoleOrgAuditor" 51 case RoleSpaceManager: 52 return "RoleSpaceManager" 53 case RoleSpaceDeveloper: 54 return "RoleSpaceDeveloper" 55 case RoleSpaceAuditor: 56 return "RoleSpaceAuditor" 57 default: 58 return "" 59 } 60 }