From 60aec96ef812c7bd877d92b6bbc648ca68265427 Mon Sep 17 00:00:00 2001 From: Keloran Date: Thu, 19 Nov 2026 09:13:53 +0000 Subject: [PATCH] feat(projects): archive and restore projects; delete only unused ones (TL-907) Accidentally created projects had no way out but a hard-delete API that also wiped used projects. Delete is now limited to never-used projects (409 otherwise), and used ones are archived instead, keeping history. Co-Authored-By: Claude Opus 5.5 --- internal/mcp/tools.go | 2 +- .../000119_project_archive.down.sql | 14 +++++ .../migrations/000119_project_archive.up.sql | 23 +++++++ internal/projects/http.go | 25 ++++++-- internal/projects/postgres.go | 61 ++++++++++++++++--- internal/projects/postgres_test.go | 49 ++++++++++++++- internal/projects/security_test.go | 27 ++++++++ internal/service.go | 4 +- openapi.yaml | 40 ++++++++++-- 9 files changed, 225 insertions(+), 20 deletions(-) create mode 100644 internal/migrations/000119_project_archive.down.sql create mode 100644 internal/migrations/000119_project_archive.up.sql diff --git a/internal/mcp/tools.go b/internal/mcp/tools.go index 6b4a49c..fa2081d 100644 --- a/internal/mcp/tools.go +++ b/internal/mcp/tools.go @@ -35,7 +35,7 @@ var tools = []tool{ // reading {name: "whoami", title: "Who am I", description: "The caller's user id, active organization, whether they're an org admin, and the teams they lead.", method: "GET", path: "/api/organizations/me", readOnly: true}, - {name: "list_projects", title: "List projects", description: "Projects in the caller's organization, with board counts, open/done tickets and urgent counts.", + {name: "list_projects", title: "List projects", description: "Active (not archived) projects in the caller's organization, with board counts, open/done tickets and urgent counts.", method: "GET", path: "/api/projects", readOnly: true}, {name: "get_project", title: "Get project", description: "A project with its boards (and per-board progress) and roadmaps.", method: "GET", path: "/api/projects/{project_id}", props: map[string]any{"project_id": id("Project")}, required: []string{"project_id"}, readOnly: true}, diff --git a/internal/migrations/000119_project_archive.down.sql b/internal/migrations/000119_project_archive.down.sql new file mode 100644 index 0000000..71ba748 --- /dev/null +++ b/internal/migrations/000119_project_archive.down.sql @@ -0,0 +1,14 @@ +DROP TRIGGER queue_project ON projects; +CREATE OR REPLACE FUNCTION queue_project() RETURNS trigger LANGUAGE plpgsql AS $$ +BEGIN + IF TG_OP = 'INSERT' THEN + PERFORM audit_org(NEW.owner_clerk_id, 'project.created', 'project', NEW.id::text, NEW.id, jsonb_build_object('name', NEW.name)); + ELSIF TG_OP = 'DELETE' THEN + PERFORM audit_org(OLD.owner_clerk_id, 'project.deleted', 'project', OLD.id::text, NULL, jsonb_build_object('name', OLD.name)); + ELSIF OLD.name IS DISTINCT FROM NEW.name THEN + PERFORM audit_org(NEW.owner_clerk_id, 'project.renamed', 'project', NEW.id::text, NEW.id, audit_fromto(OLD.name, NEW.name)); + END IF; + RETURN NULL; +END $$; +CREATE TRIGGER queue_project AFTER INSERT OR UPDATE OF name OR DELETE ON projects FOR EACH ROW EXECUTE FUNCTION queue_project(); +ALTER TABLE projects DROP COLUMN archived_at; diff --git a/internal/migrations/000119_project_archive.up.sql b/internal/migrations/000119_project_archive.up.sql new file mode 100644 index 0000000..43da11b --- /dev/null +++ b/internal/migrations/000119_project_archive.up.sql @@ -0,0 +1,23 @@ +-- Used projects are archived rather than deleted: off the project lists, history kept (TL-907). +ALTER TABLE projects ADD COLUMN archived_at timestamptz; + +CREATE OR REPLACE FUNCTION queue_project() RETURNS trigger LANGUAGE plpgsql AS $$ +BEGIN + IF TG_OP = 'INSERT' THEN + PERFORM audit_org(NEW.owner_clerk_id, 'project.created', 'project', NEW.id::text, NEW.id, jsonb_build_object('name', NEW.name)); + ELSIF TG_OP = 'DELETE' THEN + PERFORM audit_org(OLD.owner_clerk_id, 'project.deleted', 'project', OLD.id::text, NULL, jsonb_build_object('name', OLD.name)); + ELSE + IF OLD.name IS DISTINCT FROM NEW.name THEN + PERFORM audit_org(NEW.owner_clerk_id, 'project.renamed', 'project', NEW.id::text, NEW.id, audit_fromto(OLD.name, NEW.name)); + END IF; + IF OLD.archived_at IS NULL AND NEW.archived_at IS NOT NULL THEN + PERFORM audit_org(NEW.owner_clerk_id, 'project.archived', 'project', NEW.id::text, NEW.id, jsonb_build_object('name', NEW.name)); + ELSIF OLD.archived_at IS NOT NULL AND NEW.archived_at IS NULL THEN + PERFORM audit_org(NEW.owner_clerk_id, 'project.restored', 'project', NEW.id::text, NEW.id, jsonb_build_object('name', NEW.name)); + END IF; + END IF; + RETURN NULL; +END $$; +DROP TRIGGER queue_project ON projects; +CREATE TRIGGER queue_project AFTER INSERT OR UPDATE OF name, archived_at OR DELETE ON projects FOR EACH ROW EXECUTE FUNCTION queue_project(); diff --git a/internal/projects/http.go b/internal/projects/http.go index 54ad294..42be41b 100644 --- a/internal/projects/http.go +++ b/internal/projects/http.go @@ -1,6 +1,7 @@ package projects import ( + "context" "errors" "net/http" "strings" @@ -34,7 +35,7 @@ func writeErr(w http.ResponseWriter, r *http.Request, err error) { http.Error(w, "not found", http.StatusNotFound) case errors.Is(err, ErrBadKeyPrefix): httpx.Error(w, r, http.StatusBadRequest, err) - case errors.Is(err, ErrKeyPrefixTaken): + case errors.Is(err, ErrKeyPrefixTaken), errors.Is(err, ErrProjectUsed): httpx.Error(w, r, http.StatusConflict, err) case errors.Is(err, ErrLimit): httpx.Error(w, r, http.StatusPaymentRequired, httpx.Code("project_limit", "your plan's project limit is reached — upgrade for more")) @@ -58,9 +59,16 @@ func (in *projectInput) valid(w http.ResponseWriter, r *http.Request) bool { return true } +// List: GET /api/projects, active projects; ?archived=true lists the archived ones instead (org admins). func (h System) List(w http.ResponseWriter, r *http.Request) { org := auth.OrgID(r.Context()) - out, err := h.store.List(r.Context(), org) + archived := r.URL.Query().Get("archived") == "true" + if archived { + if _, _, ok := h.admins.RequireAdmin(w, r); !ok { + return + } + } + out, err := h.store.List(r.Context(), org, archived) if err != nil { writeErr(w, r, err) return @@ -130,12 +138,21 @@ func (h System) Update(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusNoContent) } -func (h System) Delete(w http.ResponseWriter, r *http.Request) { +// Delete: DELETE /api/projects/{id} (org admins), only a never-used project (409 otherwise: archive it). +func (h System) Delete(w http.ResponseWriter, r *http.Request) { h.adminDo(w, r, h.store.Delete) } + +// Archive: POST /api/projects/{id}/archive (org admins). +func (h System) Archive(w http.ResponseWriter, r *http.Request) { h.adminDo(w, r, h.store.Archive) } + +// Restore: POST /api/projects/{id}/restore (org admins). +func (h System) Restore(w http.ResponseWriter, r *http.Request) { h.adminDo(w, r, h.store.Restore) } + +func (h System) adminDo(w http.ResponseWriter, r *http.Request, fn func(ctx context.Context, id, owner string) error) { org, _, ok := h.admins.RequireAdmin(w, r) if !ok { return } - if err := h.store.Delete(r.Context(), r.PathValue("id"), org); err != nil { + if err := fn(r.Context(), r.PathValue("id"), org); err != nil { writeErr(w, r, err) return } diff --git a/internal/projects/postgres.go b/internal/projects/postgres.go index d45595c..eecad3b 100644 --- a/internal/projects/postgres.go +++ b/internal/projects/postgres.go @@ -26,6 +26,8 @@ type Project struct { KeyPrefix string `json:"key_prefix"` // tickets are -, e.g. TL-123 CreatedAt string `json:"created_at"` UpdatedAt string `json:"updated_at"` + ArchivedAt *string `json:"archived_at"` // archived: off the project lists, history kept (TL-907) + Deletable bool `json:"deletable"` // never used (no tickets, no sprints): can be deleted instead of archived Boards []boards.Board `json:"boards,omitempty"` Roadmaps []roadmaps.Roadmap `json:"roadmaps,omitempty"` Stats *Stats `json:"stats,omitempty"` // List only @@ -47,11 +49,16 @@ type Store struct{ DB *pgxpool.Pool } const cols = `id, name, description, key_prefix, to_char(created_at AT TIME ZONE 'UTC', 'YYYY-MM-DD"T"HH24:MI:SS"Z"'), - to_char(updated_at AT TIME ZONE 'UTC', 'YYYY-MM-DD"T"HH24:MI:SS"Z"')` + to_char(updated_at AT TIME ZONE 'UTC', 'YYYY-MM-DD"T"HH24:MI:SS"Z"'), + to_char(archived_at AT TIME ZONE 'UTC', 'YYYY-MM-DD"T"HH24:MI:SS"Z"'), ` + unusedSQL + +// unusedSQL: a project nobody has worked in yet. Only those can be deleted; used ones are archived. +const unusedSQL = `NOT EXISTS (SELECT 1 FROM tickets t WHERE t.project_id = projects.id) + AND NOT EXISTS (SELECT 1 FROM sprints s JOIN boards b ON b.id = s.board_id WHERE b.project_id = projects.id)` func scan(row pgx.Row) (Project, error) { var p Project - err := row.Scan(&p.ID, &p.Name, &p.Description, &p.KeyPrefix, &p.CreatedAt, &p.UpdatedAt) + err := row.Scan(&p.ID, &p.Name, &p.Description, &p.KeyPrefix, &p.CreatedAt, &p.UpdatedAt, &p.ArchivedAt, &p.Deletable) return p, notFound(err) } @@ -93,7 +100,8 @@ func (s Store) Create(ctx context.Context, owner, name, desc string, limit int) return &p, nil } -func (s Store) List(ctx context.Context, owner string) ([]Project, error) { +// List returns the owner's active projects, or only the archived ones. +func (s Store) List(ctx context.Context, owner string, archived bool) ([]Project, error) { rows, err := s.DB.Query(ctx, `SELECT `+cols+`, (SELECT count(*) FROM boards b WHERE b.project_id = projects.id AND b.archived_at IS NULL), (SELECT count(*) FROM roadmaps r WHERE r.project_id = projects.id), @@ -105,13 +113,13 @@ func (s Store) List(ctx context.Context, owner string) ([]Project, error) { FROM projects LEFT JOIN LATERAL (SELECT t.id AS tid, t.board_id, t.priority, t.updated_at AS changed, `+boards.TicketDoneSQL+` AS done FROM tickets t WHERE t.project_id = projects.id) t ON true - WHERE owner_clerk_id = $1 GROUP BY projects.id ORDER BY created_at`, owner) + WHERE owner_clerk_id = $1 AND (archived_at IS NOT NULL) = $2 GROUP BY projects.id ORDER BY created_at`, owner, archived) if err != nil { return nil, err } out, err := pgx.CollectRows(rows, func(row pgx.CollectableRow) (Project, error) { p, st := Project{}, Stats{} - err := row.Scan(&p.ID, &p.Name, &p.Description, &p.KeyPrefix, &p.CreatedAt, &p.UpdatedAt, + err := row.Scan(&p.ID, &p.Name, &p.Description, &p.KeyPrefix, &p.CreatedAt, &p.UpdatedAt, &p.ArchivedAt, &p.Deletable, &st.Boards, &st.Roadmaps, &st.Open, &st.Done, &st.Backlog, &st.Urgent, &st.Active) p.Stats = &st return p, err @@ -163,9 +171,48 @@ func (s Store) SetKeyPrefix(ctx context.Context, id, owner, prefix string) error var keyPrefix = regexp.MustCompile(`^[A-Z][A-Z0-9]{1,5}$`) // same as projects_key_prefix_format -// Delete removes the project and (cascade) its boards, tickets and roadmaps. +var ErrProjectUsed = httpx.Code("project_used", "this project has been used; archive it instead, so its history is kept") + +// Delete removes a never-used project (and, by cascade, its empty boards and roadmaps); ErrProjectUsed otherwise. func (s Store) Delete(ctx context.Context, id, owner string) error { - return exec(s.DB.Exec(ctx, `DELETE FROM projects WHERE id = $1 AND owner_clerk_id = $2`, id, owner)) + tag, err := s.DB.Exec(ctx, `DELETE FROM projects WHERE id = $1 AND owner_clerk_id = $2 AND `+unusedSQL, id, owner) + if err != nil { + return notFound(err) + } + if tag.RowsAffected() > 0 { + return nil + } + if _, err := s.Get(ctx, id, owner); err != nil { + return err + } + return ErrProjectUsed +} + +// Archive takes a project off the project lists, history kept. Its boards' open sprints close with no +// successor and their planned sprints go (tickets back to the backlog unplanned), as when a board is archived. +func (s Store) Archive(ctx context.Context, id, owner string) error { + return pgx.BeginFunc(ctx, s.DB, func(tx pgx.Tx) error { + tag, err := tx.Exec(ctx, `UPDATE projects SET archived_at = coalesce(archived_at, now()) WHERE id = $1 AND owner_clerk_id = $2`, id, owner) + if err := exec(tag, err); err != nil { + return err + } + for _, q := range []string{ + `UPDATE sprints SET closed_at = now() WHERE closed_at IS NULL AND board_id IN (SELECT id FROM boards WHERE project_id = $1)`, + `UPDATE tickets SET planned_sprint_id = NULL, estimate = NULL, updated_at = now() + WHERE planned_sprint_id IN (SELECT ps.id FROM planned_sprints ps JOIN boards b ON b.id = ps.board_id WHERE b.project_id = $1)`, + `DELETE FROM planned_sprints WHERE board_id IN (SELECT id FROM boards WHERE project_id = $1)`, + } { + if _, err := tx.Exec(ctx, q, id); err != nil { + return err + } + } + return nil + }) +} + +// Restore puts an archived project back on the lists. Sprints start again by hand. +func (s Store) Restore(ctx context.Context, id, owner string) error { + return exec(s.DB.Exec(ctx, `UPDATE projects SET archived_at = NULL WHERE id = $1 AND owner_clerk_id = $2`, id, owner)) } func exec(tag pgconn.CommandTag, err error) error { diff --git a/internal/projects/postgres_test.go b/internal/projects/postgres_test.go index 2431758..de2e52a 100644 --- a/internal/projects/postgres_test.go +++ b/internal/projects/postgres_test.go @@ -65,7 +65,7 @@ func TestStore(t *testing.T) { if _, err := s.Create(ctx, "pr1", "second", "", -1); err != nil { t.Fatalf("paid unlimited: %v", err) } - list, _ := s.List(ctx, "pr1") + list, _ := s.List(ctx, "pr1", false) if len(list) != 2 { t.Fatalf("list: %+v", list) } @@ -94,7 +94,7 @@ func TestStore(t *testing.T) { if _, err := db.Exec(ctx, `INSERT INTO tickets (project_id, title, position, resolved_at) VALUES ($1, 'later', 0, NULL), ($1, 'resolved', 1, now())`, p.ID); err != nil { t.Fatal(err) } - list, _ = s.List(ctx, "pr1") + list, _ = s.List(ctx, "pr1", false) if st := list[0].Stats; st == nil || st.Active == "" || *st != (Stats{Boards: 3, Roadmaps: 1, Open: 1, Done: 2, Backlog: 1, Urgent: 1, Active: st.Active}) { t.Fatalf("stats: %+v", st) } @@ -113,7 +113,50 @@ func TestStore(t *testing.T) { if _, err := s.Get(ctx, "not-a-uuid", "pr1"); !errors.Is(err, ErrNotFound) { t.Fatalf("bad uuid: %v", err) } - if err := s.Delete(ctx, p.ID, "pr1"); err != nil { + // TL-907: a used project can't be deleted; it's archived instead, then restored + if err := s.Delete(ctx, p.ID, "pr1"); !errors.Is(err, ErrProjectUsed) { + t.Fatalf("delete used project: %v", err) + } + if err := s.Delete(ctx, p.ID, "pr2"); !errors.Is(err, ErrNotFound) { + t.Fatalf("non-owner delete: %v", err) + } + if err := s.Archive(ctx, p.ID, "pr2"); !errors.Is(err, ErrNotFound) { + t.Fatalf("non-owner archive: %v", err) + } + if _, err := db.Exec(ctx, `INSERT INTO sprints (board_id, number, length_days, ends_at) SELECT id, 99, 7, now() + interval '7 days' FROM boards WHERE project_id = $1 LIMIT 1`, p.ID); err != nil { + t.Fatal(err) + } + if err := s.Archive(ctx, p.ID, "pr1"); err != nil { + t.Fatal(err) + } + var openSprints int + _ = db.QueryRow(ctx, `SELECT count(*) FROM sprints s JOIN boards b ON b.id = s.board_id WHERE b.project_id = $1 AND s.closed_at IS NULL`, p.ID).Scan(&openSprints) + if openSprints != 0 { + t.Fatalf("archive left %d sprints open", openSprints) + } + active, _ := s.List(ctx, "pr1", false) + archived, _ := s.List(ctx, "pr1", true) + if len(active) != 1 || active[0].ID == p.ID || len(archived) != 1 || archived[0].ID != p.ID || archived[0].ArchivedAt == nil || archived[0].Deletable { + t.Fatalf("after archive: active %+v archived %+v", active, archived) + } + if got, _ := s.Get(ctx, p.ID, "pr1"); got == nil || got.ArchivedAt == nil { + t.Fatalf("archived project should still open: %+v", got) + } + if err := s.Restore(ctx, p.ID, "pr1"); err != nil { + t.Fatal(err) + } + if active, _ = s.List(ctx, "pr1", false); len(active) != 2 { + t.Fatalf("restore: %d active", len(active)) + } + // the empty project was never used: it deletes + if !active[1].Deletable { + t.Fatalf("empty project should be deletable: %+v", active[1]) + } + if err := s.Delete(ctx, active[1].ID, "pr1"); err != nil { + t.Fatal(err) + } + // a used one still goes when its tickets do (cascade), checked straight in SQL + if _, err := db.Exec(ctx, `DELETE FROM projects WHERE id = $1`, p.ID); err != nil { t.Fatal(err) } var left int diff --git a/internal/projects/security_test.go b/internal/projects/security_test.go index bc55f0a..5e7ad0b 100644 --- a/internal/projects/security_test.go +++ b/internal/projects/security_test.go @@ -67,6 +67,18 @@ func TestProjectSecurity(t *testing.T) { if got := call(as, http.MethodDelete, "", h.Delete).Code; got != http.StatusForbidden { t.Errorf("%s can delete project: got %d, want 403", name, got) } + if got := call(as, http.MethodPost, "", h.Archive).Code; got != http.StatusForbidden { + t.Errorf("%s can archive project: got %d, want 403", name, got) + } + if got := call(as, http.MethodPost, "", h.Restore).Code; got != http.StatusForbidden { + t.Errorf("%s can restore project: got %d, want 403", name, got) + } + r := httptest.NewRequest(http.MethodGet, "/?archived=true", nil).WithContext(as) + w := httptest.NewRecorder() + h.List(w, r) + if w.Code != http.StatusForbidden { + t.Errorf("%s can list archived projects: got %d, want 403", name, w.Code) + } } // TL-735: only admins create projects for name, as := range map[string]context.Context{"member": member, "API key": apiKey} { @@ -105,6 +117,21 @@ func TestProjectSecurity(t *testing.T) { if got := call(admin, http.MethodPatch, `{"name":"Protected","description":"","key_prefix":"NEW"}`, h.Update).Code; got != http.StatusNoContent { t.Fatalf("admin key-prefix change: got %d, want 204", got) } + // TL-907: a used project answers 409 to delete; archive and restore work for admins + if _, err := db.Exec(ctx, `INSERT INTO tickets (project_id, title, position) VALUES ($1, 'work', 0)`, project.ID); err != nil { + t.Fatal(err) + } + if got := call(admin, http.MethodDelete, "", h.Delete).Code; got != http.StatusConflict { + t.Fatalf("admin delete used project: got %d, want 409", got) + } + for _, fn := range []func(http.ResponseWriter, *http.Request){h.Archive, h.Restore} { + if got := call(admin, http.MethodPost, "", fn).Code; got != http.StatusNoContent { + t.Fatalf("admin archive/restore: got %d, want 204", got) + } + } + if _, err := db.Exec(ctx, `DELETE FROM tickets WHERE project_id = $1`, project.ID); err != nil { + t.Fatal(err) + } if got := call(admin, http.MethodDelete, "", h.Delete).Code; got != http.StatusNoContent { t.Fatalf("admin delete: got %d, want 204", got) } diff --git a/internal/service.go b/internal/service.go index 9d2778e..aace0e8 100644 --- a/internal/service.go +++ b/internal/service.go @@ -288,7 +288,9 @@ func (s *Service) Handler() http.Handler { mux.Handle("POST /api/projects", signedIn(p.Create)) mux.Handle("GET /api/projects/{id}", signedIn(p.Get)) mux.Handle("PATCH /api/projects/{id}", signedIn(p.Update)) - mux.Handle("DELETE /api/projects/{id}", signedIn(p.Delete)) + mux.Handle("DELETE /api/projects/{id}", signedIn(p.Delete)) // never-used projects only (TL-907) + mux.Handle("POST /api/projects/{id}/archive", signedIn(p.Archive)) // org admins + mux.Handle("POST /api/projects/{id}/restore", signedIn(p.Restore)) // org admins // Boards b := boards.NewSystem(s.DB, o.AdminModel()) diff --git a/openapi.yaml b/openapi.yaml index 5c8ef71..a1ecf66 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -574,7 +574,7 @@ paths: description: >- member.invited and member.invitation_revoked (scope, target); member.joined and member.removed (target: the user); admin.granted and admin.revoked (target: the user); api_key.created and api_key.revoked (kind, name, owner, read_only, expires_at); - project.created and project.deleted (name), project.renamed (from, to); board.created, board.archived, board.restored and + project.created, project.archived, project.restored and project.deleted (name), project.renamed (from, to); board.created, board.archived, board.restored and board.deleted (name), board.renamed (from, to); team.created and team.deleted (name), team.members_changed (name, user, change added/removed/made_leader/no_longer_leader, leader); sprint.started (board, board_name, number, length_days), sprint.closed (board, board_name, number); integration.connected and integration.disconnected (provider, and account, @@ -1219,7 +1219,9 @@ paths: tags: [Projects] operationId: listProjects summary: List projects accessible to this agent - description: Use a project's ID when creating a ticket directly in its backlog. + description: Use a project's ID when creating a ticket directly in its backlog. Archived projects are left out; archived=true lists only them (organization admins, 403 otherwise). + parameters: + - { name: archived, in: query, required: false, schema: { type: boolean } } responses: '200': description: Projects owned by the API key's owner. @@ -1288,16 +1290,43 @@ paths: delete: tags: [Projects] operationId: deleteProject - summary: Permanently delete a project and its boards, tickets, roadmaps, repos, and intake - description: This action cannot be undone and permanently deletes all work under the project. Organization admin session required. + summary: Permanently delete a never-used project + description: Only a project with no tickets and no sprints (deletable true); its empty boards, roadmaps, repos and intake go with it. A used project answers 409; archive it instead. Cannot be undone. Organization admin session required. security: - bearerAuth: [] responses: '204': { description: Project deleted. } '403': { description: Organization admin session required. } + '409': { description: The project has been used; archive it instead. } '401': { $ref: '#/components/responses/Unauthorized' } '404': { $ref: '#/components/responses/NotFound' } + /projects/{projectId}/archive: + parameters: + - $ref: '#/components/parameters/ProjectId' + post: + tags: [Projects] + operationId: archiveProject + summary: Archive a project (organization admins) + description: >- + Takes it off the project list; its boards, tickets and history stay, and it still opens by id. Its boards' + open sprints close with no next sprint, and their planned sprints are dropped (tickets back to the backlog unplanned). + It still counts towards the plan's project limit. + responses: + '204': { description: Archived. } + '403': { description: Organization admin session required. } + '404': { $ref: '#/components/responses/NotFound' } + /projects/{projectId}/restore: + parameters: + - $ref: '#/components/parameters/ProjectId' + post: + tags: [Projects] + operationId: restoreProject + summary: Put an archived project back on the project list (organization admins) + responses: + '204': { description: Restored. } + '403': { description: Organization admin session required. } + '404': { $ref: '#/components/responses/NotFound' } /projects/{projectId}/boards: parameters: - $ref: '#/components/parameters/ProjectId' @@ -6028,6 +6057,8 @@ components: key_prefix: { type: string, example: TL, description: "Ticket keys are -. Worked out from the name on create (its capitals, e.g. TrackLin.es → TL), unique in the org." } created_at: { type: string, format: date-time } updated_at: { type: string, format: date-time } + archived_at: { type: [string, 'null'], format: date-time, description: "Set when archived: off the project list, history kept." } + deletable: { type: boolean, description: "Never used (no tickets, no sprints), so it can be deleted rather than archived." } boards: type: array items: { $ref: '#/components/schemas/BoardSummary' } @@ -6995,6 +7026,7 @@ components: board_archived: "this board is archived; restore it first" board_update_empty: "name, estimate_scale, style, agent_review, dev_complete_column_id, review_column_id or when_sprint_ends is required" board_used: "this board has been used; archive it instead, so its history is kept" + project_used: "this project has been used; archive it instead, so its history is kept" builtin_template: "built-in templates can't be deleted" calendar_admin_email: "the admin email must be an address at {domain}" calendar_domain_required: "enter your Google Workspace domain, e.g. example.com"