diff --git a/coderd/apidoc/docs.go b/coderd/apidoc/docs.go index 0382ab967dcd4..fb51f553e7524 100644 --- a/coderd/apidoc/docs.go +++ b/coderd/apidoc/docs.go @@ -4705,9 +4705,6 @@ const docTemplate = `{ "CoderSessionToken": [] } ], - "produces": [ - "application/json" - ], "tags": [ "Users" ], @@ -4723,11 +4720,8 @@ const docTemplate = `{ } ], "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/codersdk.User" - } + "204": { + "description": "No Content" } } } diff --git a/coderd/apidoc/swagger.json b/coderd/apidoc/swagger.json index 0c44ef0f255ed..fa5ed4b12ca11 100644 --- a/coderd/apidoc/swagger.json +++ b/coderd/apidoc/swagger.json @@ -4147,7 +4147,6 @@ "CoderSessionToken": [] } ], - "produces": ["application/json"], "tags": ["Users"], "summary": "Delete user", "operationId": "delete-user", @@ -4161,11 +4160,8 @@ } ], "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/codersdk.User" - } + "204": { + "description": "No Content" } } } diff --git a/coderd/apikey.go b/coderd/apikey.go index fe32b771e61ef..8676b5e1ba6c0 100644 --- a/coderd/apikey.go +++ b/coderd/apikey.go @@ -333,7 +333,7 @@ func (api *API) deleteAPIKey(rw http.ResponseWriter, r *http.Request) { return } - httpapi.Write(ctx, rw, http.StatusNoContent, nil) + rw.WriteHeader(http.StatusNoContent) } // @Summary Get token config diff --git a/coderd/debug.go b/coderd/debug.go index b1f17f29e0102..f13656886295e 100644 --- a/coderd/debug.go +++ b/coderd/debug.go @@ -235,7 +235,7 @@ func (api *API) putDeploymentHealthSettings(rw http.ResponseWriter, r *http.Requ if bytes.Equal(settingsJSON, []byte(currentSettingsJSON)) { // See: https://www.rfc-editor.org/rfc/rfc7231#section-6.3.5 - httpapi.Write(r.Context(), rw, http.StatusNoContent, nil) + rw.WriteHeader(http.StatusNoContent) return } diff --git a/coderd/externalauth.go b/coderd/externalauth.go index 8f8514fa17442..25f362e7372cf 100644 --- a/coderd/externalauth.go +++ b/coderd/externalauth.go @@ -197,7 +197,7 @@ func (api *API) postExternalAuthDeviceByID(rw http.ResponseWriter, r *http.Reque return } } - httpapi.Write(ctx, rw, http.StatusNoContent, nil) + rw.WriteHeader(http.StatusNoContent) } // @Summary Get external auth device by ID. diff --git a/coderd/identityprovider/revoke.go b/coderd/identityprovider/revoke.go index cddc150bbe364..78acb9ea0de22 100644 --- a/coderd/identityprovider/revoke.go +++ b/coderd/identityprovider/revoke.go @@ -39,6 +39,6 @@ func RevokeApp(db database.Store) http.HandlerFunc { httpapi.InternalServerError(rw, err) return } - httpapi.Write(ctx, rw, http.StatusNoContent, nil) + rw.WriteHeader(http.StatusNoContent) } } diff --git a/coderd/oauth2.go b/coderd/oauth2.go index ef68e93a1fc47..da102faf9138c 100644 --- a/coderd/oauth2.go +++ b/coderd/oauth2.go @@ -207,7 +207,7 @@ func (api *API) deleteOAuth2ProviderApp(rw http.ResponseWriter, r *http.Request) }) return } - httpapi.Write(ctx, rw, http.StatusNoContent, nil) + rw.WriteHeader(http.StatusNoContent) } // @Summary Get OAuth2 application secrets. @@ -324,7 +324,7 @@ func (api *API) deleteOAuth2ProviderAppSecret(rw http.ResponseWriter, r *http.Re }) return } - httpapi.Write(ctx, rw, http.StatusNoContent, nil) + rw.WriteHeader(http.StatusNoContent) } // @Summary OAuth2 authorization request. diff --git a/coderd/templates.go b/coderd/templates.go index 78f821a382a8d..5bf32871dcbc1 100644 --- a/coderd/templates.go +++ b/coderd/templates.go @@ -791,7 +791,7 @@ func (api *API) patchTemplateMeta(rw http.ResponseWriter, r *http.Request) { if updated.UpdatedAt.IsZero() { aReq.New = template - httpapi.Write(ctx, rw, http.StatusNotModified, nil) + rw.WriteHeader(http.StatusNotModified) return } aReq.New = updated diff --git a/coderd/users.go b/coderd/users.go index 4372a4f7ded33..0cfcc63f9a3ed 100644 --- a/coderd/users.go +++ b/coderd/users.go @@ -501,10 +501,9 @@ func (api *API) postUser(rw http.ResponseWriter, r *http.Request) { // @Summary Delete user // @ID delete-user // @Security CoderSessionToken -// @Produce json // @Tags Users // @Param user path string true "User ID, name, or me" -// @Success 200 {object} codersdk.User +// @Success 204 // @Router /users/{user} [delete] func (api *API) deleteUser(rw http.ResponseWriter, r *http.Request) { ctx := r.Context() @@ -558,9 +557,7 @@ func (api *API) deleteUser(rw http.ResponseWriter, r *http.Request) { } user.Deleted = true aReq.New = user - httpapi.Write(ctx, rw, http.StatusOK, codersdk.Response{ - Message: "User has been deleted!", - }) + rw.WriteHeader(http.StatusNoContent) } // Returns the parameterized user requested. All validation @@ -1013,7 +1010,7 @@ func (api *API) putUserPassword(rw http.ResponseWriter, r *http.Request) { newUser.HashedPassword = []byte(hashedPassword) aReq.New = newUser - httpapi.Write(ctx, rw, http.StatusNoContent, nil) + rw.WriteHeader(http.StatusNoContent) } // @Summary Get user roles diff --git a/coderd/workspaces.go b/coderd/workspaces.go index bed982d5e2511..9f1ca970e609e 100644 --- a/coderd/workspaces.go +++ b/coderd/workspaces.go @@ -927,9 +927,7 @@ func (api *API) putWorkspaceDormant(rw http.ResponseWriter, r *http.Request) { // If the workspace is already in the desired state do nothing! if workspace.DormantAt.Valid == req.Dormant { - httpapi.Write(ctx, rw, http.StatusNotModified, codersdk.Response{ - Message: "Nothing to do!", - }) + rw.WriteHeader(http.StatusNotModified) return } diff --git a/codersdk/users.go b/codersdk/users.go index dd6779e3a0342..e56c9cc90d1c7 100644 --- a/codersdk/users.go +++ b/codersdk/users.go @@ -308,7 +308,7 @@ func (c *Client) DeleteUser(ctx context.Context, id uuid.UUID) error { return err } defer res.Body.Close() - if res.StatusCode != http.StatusOK { + if res.StatusCode != http.StatusNoContent { return ReadBodyAsError(res) } return nil diff --git a/docs/api/users.md b/docs/api/users.md index 22d1c7b9cfca8..ac3305af96c86 100644 --- a/docs/api/users.md +++ b/docs/api/users.md @@ -410,7 +410,6 @@ To perform this operation, you must be authenticated. [Learn more](authenticatio ```shell # Example request using curl curl -X DELETE http://coder-server:8080/api/v2/users/{user} \ - -H 'Accept: application/json' \ -H 'Coder-Session-Token: API_KEY' ``` @@ -422,38 +421,11 @@ curl -X DELETE http://coder-server:8080/api/v2/users/{user} \ | ------ | ---- | ------ | -------- | -------------------- | | `user` | path | string | true | User ID, name, or me | -### Example responses - -> 200 Response - -```json -{ - "avatar_url": "http://example.com", - "created_at": "2019-08-24T14:15:22Z", - "email": "user@example.com", - "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", - "last_seen_at": "2019-08-24T14:15:22Z", - "login_type": "", - "name": "string", - "organization_ids": ["497f6eca-6276-4993-bfeb-53cbbbba6f08"], - "roles": [ - { - "display_name": "string", - "name": "string", - "organization_id": "string" - } - ], - "status": "active", - "theme_preference": "string", - "username": "string" -} -``` - ### Responses -| Status | Meaning | Description | Schema | -| ------ | ------------------------------------------------------- | ----------- | ---------------------------------------- | -| 200 | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK | [codersdk.User](schemas.md#codersdkuser) | +| Status | Meaning | Description | Schema | +| ------ | --------------------------------------------------------------- | ----------- | ------ | +| 204 | [No Content](https://tools.ietf.org/html/rfc7231#section-6.3.5) | No Content | | To perform this operation, you must be authenticated. [Learn more](authentication.md).