MCPcopy Index your code
hub / github.com/cloudfoundry/cli / FindAllByUsername

Method FindAllByUsername

cf/api/users.go:85–108  ·  view source on GitHub ↗
(username string)

Source from the content-addressed store, hash-verified

83}
84
85func (repo CloudControllerUserRepository) FindAllByUsername(username string) (users []models.UserFields, apiErr error) {
86 uaaEndpoint, apiErr := repo.getAuthEndpoint()
87 if apiErr != nil {
88 return users, apiErr
89 }
90
91 usernameFilter := neturl.QueryEscape(fmt.Sprintf(`userName Eq "%s"`, username))
92 path := fmt.Sprintf("%s/Users?attributes=id,userName&filter=%s", uaaEndpoint, usernameFilter)
93 users, apiErr = repo.updateOrFindUsersWithUAAPath([]models.UserFields{}, path)
94
95 if apiErr != nil {
96 errType, ok := apiErr.(errors.HTTPError)
97 if ok {
98 if errType.StatusCode() == 403 {
99 return users, errors.NewAccessDeniedError()
100 }
101 }
102 return users, apiErr
103 } else if len(users) == 0 {
104 return users, errors.NewModelNotFoundError("User", username)
105 }
106
107 return users, apiErr
108}
109
110func (repo CloudControllerUserRepository) ListUsersInOrgForRoleWithNoUAA(orgGUID string, roleName models.Role) (users []models.UserFields, apiErr error) {
111 return repo.listUsersWithPathWithNoUAA(fmt.Sprintf("/v2/organizations/%s/%s", orgGUID, orgRoleToPathMap[roleName]))

Callers 1

FindByUsernameMethod · 0.95

Calls 5

getAuthEndpointMethod · 0.95
NewAccessDeniedErrorFunction · 0.92
NewModelNotFoundErrorFunction · 0.92
StatusCodeMethod · 0.65

Tested by

no test coverage detected