Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit66d05d7

Browse files
committed
feat: add workspaces/acl [delete] endpoint
1 parentdb76496 commit66d05d7

File tree

5 files changed

+126
-0
lines changed

5 files changed

+126
-0
lines changed

‎coderd/apidoc/docs.go‎

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing 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 aboutcustomizing 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: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2356,6 +2356,53 @@ type workspaceData struct {
23562356
allowRenamesbool
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+
2380+
defercommitAuditor()
2381+
aReq.Old=workspace.WorkspaceTable()
2382+
2383+
err:=api.Database.InTx(func(tx database.Store)error {
2384+
err:=tx.DeleteWorkspaceACLByID(ctx,workspace.ID)
2385+
iferr!=nil {
2386+
returnxerrors.Errorf("delete workspace by ID: %w",err)
2387+
}
2388+
2389+
workspace,err=tx.GetWorkspaceByID(ctx,workspace.ID)
2390+
iferr!=nil {
2391+
returnxerrors.Errorf("get updated workspace by ID: %w",err)
2392+
}
2393+
2394+
returnnil
2395+
},nil)
2396+
iferr!=nil {
2397+
httpapi.InternalServerError(rw,err)
2398+
return
2399+
}
2400+
2401+
aReq.New=workspace.WorkspaceTable()
2402+
2403+
httpapi.Write(ctx,rw,http.StatusNoContent,nil)
2404+
}
2405+
23592406
// workspacesData only returns the data the caller can access. If the caller
23602407
// does not have the correct perms to read a given template, the template will
23612408
// not be returned.

‎docs/reference/api/workspaces.md‎

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp