Skip to content

Commit fe42ff7

Browse files
committed
feat: add workspaces/acl [delete] endpoint
1 parent d9d3935 commit fe42ff7

File tree

5 files changed

+111
-0
lines changed

5 files changed

+111
-0
lines changed

coderd/apidoc/docs.go

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/apidoc/swagger.json

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/coderd.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1457,6 +1457,7 @@ func New(options *Options) *API {
14571457

14581458
r.Get("/", api.workspaceACL)
14591459
r.Patch("/", api.patchWorkspaceACL)
1460+
r.Delete("/", api.deleteWorkspaceACL)
14601461
})
14611462
})
14621463
})

coderd/workspaces.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2356,6 +2356,38 @@ type workspaceData struct {
23562356
allowRenames bool
23572357
}
23582358

2359+
// @Summary Completely clears the workspace's user and group ACLs.
2360+
// @ID completely-clears-the-workspaces-user-and-group-acls
2361+
// @Security CoderSessionToken
2362+
// @Tags Workspaces
2363+
// @Param workspace path string true "Workspace ID" format(uuid)
2364+
// @Success 204
2365+
// @Router /workspaces/{workspace}/acl [delete]
2366+
func (api *API) deleteWorkspaceACL(rw http.ResponseWriter, r *http.Request) {
2367+
var (
2368+
ctx = r.Context()
2369+
workspace = httpmw.WorkspaceParam(r)
2370+
auditor = api.Auditor.Load()
2371+
aReq, commitAuditor = audit.InitRequest[database.WorkspaceTable](rw, &audit.RequestParams{
2372+
Audit: *auditor,
2373+
Log: api.Logger,
2374+
Request: r,
2375+
Action: database.AuditActionWrite,
2376+
OrganizationID: workspace.OrganizationID,
2377+
})
2378+
)
2379+
defer commitAuditor()
2380+
aReq.Old = workspace.WorkspaceTable()
2381+
2382+
err := api.Database.DeleteWorkspaceACLByID(ctx, workspace.ID)
2383+
if err != nil {
2384+
httpapi.InternalServerError(rw, err)
2385+
return
2386+
}
2387+
2388+
httpapi.Write(ctx, rw, http.StatusNoContent, nil)
2389+
}
2390+
23592391
// workspacesData only returns the data the caller can access. If the caller
23602392
// does not have the correct perms to read a given template, the template will
23612393
// not be returned.

docs/reference/api/workspaces.md

Lines changed: 26 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)