(username, password string)
| 159 | } |
| 160 | |
| 161 | func (repo CloudControllerUserRepository) Create(username, password string) (err error) { |
| 162 | uaaEndpoint, err := repo.getAuthEndpoint() |
| 163 | if err != nil { |
| 164 | return |
| 165 | } |
| 166 | |
| 167 | path := "/Users" |
| 168 | body, err := json.Marshal(resources.NewUAAUserResource(username, password)) |
| 169 | |
| 170 | if err != nil { |
| 171 | return |
| 172 | } |
| 173 | |
| 174 | createUserResponse := &resources.UAAUserFields{} |
| 175 | err = repo.uaaGateway.CreateResource(uaaEndpoint, path, bytes.NewReader(body), createUserResponse) |
| 176 | switch httpErr := err.(type) { |
| 177 | case nil: |
| 178 | case errors.HTTPError: |
| 179 | if httpErr.StatusCode() == http.StatusConflict { |
| 180 | err = errors.NewModelAlreadyExistsError("user", username) |
| 181 | return |
| 182 | } |
| 183 | return |
| 184 | default: |
| 185 | return |
| 186 | } |
| 187 | |
| 188 | path = "/v2/users" |
| 189 | body, err = json.Marshal(resources.Metadata{ |
| 190 | GUID: createUserResponse.ID, |
| 191 | }) |
| 192 | |
| 193 | if err != nil { |
| 194 | return |
| 195 | } |
| 196 | |
| 197 | return repo.ccGateway.CreateResource(repo.config.APIEndpoint(), path, bytes.NewReader(body)) |
| 198 | } |
| 199 | |
| 200 | func (repo CloudControllerUserRepository) Delete(userGUID string) (apiErr error) { |
| 201 | path := fmt.Sprintf("/v2/users/%s", userGUID) |
nothing calls this directly
no test coverage detected