MCPcopy Create free account
hub / github.com/PerpetualSoftware/pad / handleUpdateWorkspace

Method handleUpdateWorkspace

internal/server/handlers_workspaces.go:548–580  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

546}
547
548func (s *Server) handleUpdateWorkspace(w http.ResponseWriter, r *http.Request) {
549 if !requireMinRole(w, r, "owner") {
550 return
551 }
552 existing, ok := s.getWorkspace(w, r)
553 if !ok {
554 return
555 }
556
557 var input models.WorkspaceUpdate
558 if err := decodeJSON(r, &input); err != nil {
559 writeError(w, http.StatusBadRequest, "bad_request", err.Error())
560 return
561 }
562 if err := normalizeWorkspaceUpdateInput(&input); err != nil {
563 writeError(w, http.StatusBadRequest, "bad_request", err.Error())
564 return
565 }
566
567 ws, err := s.store.UpdateWorkspace(existing.Slug, input)
568 if err != nil {
569 writeInternalError(w, err)
570 return
571 }
572 if ws == nil {
573 writeError(w, http.StatusNotFound, "not_found", "Workspace not found")
574 return
575 }
576
577 s.publishEvent(events.WorkspaceUpdated, ws.ID, "", ws.Name, "", "", "")
578
579 writeJSON(w, http.StatusOK, ws)
580}
581
582func (s *Server) handleDeleteWorkspace(w http.ResponseWriter, r *http.Request) {
583 if !requireMinRole(w, r, "owner") {

Callers

nothing calls this directly

Calls 10

getWorkspaceMethod · 0.95
publishEventMethod · 0.95
requireMinRoleFunction · 0.85
decodeJSONFunction · 0.85
writeErrorFunction · 0.85
writeInternalErrorFunction · 0.85
writeJSONFunction · 0.85
ErrorMethod · 0.45
UpdateWorkspaceMethod · 0.45

Tested by

no test coverage detected