MCPcopy Index your code
hub / github.com/coder/coder / deleteWorkspaceProxy

Method deleteWorkspaceProxy

enterprise/coderd/workspaceproxy.go:247–289  ·  view source on GitHub ↗

@Summary Delete workspace proxy @ID delete-workspace-proxy @Security CoderSessionToken @Produce json @Tags Enterprise @Param workspaceproxy path string true "Proxy ID or name" format(uuid) @Success 200 {object} codersdk.Response @Router /api/v2/workspaceproxies/{workspaceproxy} [delete]

(rw http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

245// @Success 200 {object} codersdk.Response
246// @Router /api/v2/workspaceproxies/{workspaceproxy} [delete]
247func (api *API) deleteWorkspaceProxy(rw http.ResponseWriter, r *http.Request) {
248 var (
249 ctx = r.Context()
250 proxy = httpmw.WorkspaceProxyParam(r)
251 auditor = api.AGPL.Auditor.Load()
252 aReq, commitAudit = audit.InitRequest[database.WorkspaceProxy](rw, &audit.RequestParams{
253 Audit: *auditor,
254 Log: api.Logger,
255 Request: r,
256 Action: database.AuditActionDelete,
257 })
258 )
259 aReq.Old = proxy
260 defer commitAudit()
261
262 if proxy.IsPrimary() {
263 httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{
264 Message: "Cannot delete primary proxy",
265 })
266 return
267 }
268
269 err := api.Database.UpdateWorkspaceProxyDeleted(ctx, database.UpdateWorkspaceProxyDeletedParams{
270 ID: proxy.ID,
271 Deleted: true,
272 })
273 if httpapi.Is404Error(err) {
274 httpapi.ResourceNotFound(rw)
275 return
276 }
277 if err != nil {
278 httpapi.InternalServerError(rw, err)
279 return
280 }
281
282 aReq.New = database.WorkspaceProxy{}
283 httpapi.Write(ctx, rw, http.StatusOK, codersdk.Response{
284 Message: "Proxy has been deleted!",
285 })
286
287 // Update the proxy health cache to remove this proxy.
288 go api.forceWorkspaceProxyHealthUpdate(api.ctx)
289}
290
291// @Summary Get workspace proxy
292// @ID get-workspace-proxy

Callers

nothing calls this directly

Calls 11

WorkspaceProxyParamFunction · 0.92
InitRequestFunction · 0.92
WriteFunction · 0.92
Is404ErrorFunction · 0.92
ResourceNotFoundFunction · 0.92
InternalServerErrorFunction · 0.92
IsPrimaryMethod · 0.80
ContextMethod · 0.65
LoadMethod · 0.45

Tested by

no test coverage detected