Backend for portal#77: the registry keeps a tenant's managed services (v0: Managed Git, one Gitea instance per customer, provisioned by hand) so the portal can show them under "Verwaltete Infrastruktur" and staff can maintain them in the admin area.
Schema
0012_managed_services: id, tenant_id → tenants ON DELETE CASCADE, kind ('git'), name, url, sku, status ('provisioning'|'active'|'restricted'|'halted', default provisioning), instance_id, notes, created_at, updated_at, UNIQUE (tenant_id, kind, url), index on tenant_id. The memory store mirrors the cascade in DeleteTenant.
API
Route
Who
Response
GET /v1/tenants/{id}/managed-services
tenant users with IT_ADMIN, OWNER or CXO (others 403 FORBIDDEN_ROLE, another tenant 404); service clients with tenants.read
{"items":[ManagedService]} by created_at, noinstance_id/notes
Validation (400): invalid_kind (git only), invalid_name (1–100 after trim), invalid_url (absolute https with host, ≤ 300), invalid_sku (^INF-GIT-(CLD|OPR)-(STD|BUS|ENT)$), invalid_status, invalid_instance_id (≤ 100, ^[a-z0-9-]*$), invalid_notes (≤ 2000). Duplicate (tenant, kind, url) → 409 duplicate on create and on a PATCH of the url.
Audit with the staff member (X-Staff-Subject/X-Staff-Email) as actor: managed_service.created, managed_service.updated (metadata changed and, when the status moves, old_status/new_status; notes text is not copied), managed_service.deleted.
Notes
The tenant list is served through the existing GET /v1/tenants/{id}/{sub} dispatcher (ServeMux conflict with by-slug/{slug}), like documents/projects.
Staff read-only (SUPPORT_ENGINEER) is decided by the portal (canStaffWrite); the registry has no staff-role concept and only sees the admin client. Tests cover that a client without the admin group gets FORBIDDEN_CLIENT on every admin route.
Inputs are trimmed; kind/status are lower-cased and sku upper-cased before validation.
Tests
gofmt, go vet ./..., golangci-lint (0 issues), go test ./... all green locally with Docker (memory + postgres harness, migrations incl. unique/check/cascade on 0012).
Backend for portal#77: the registry keeps a tenant's managed services (v0: Managed Git, one Gitea instance per customer, provisioned by hand) so the portal can show them under "Verwaltete Infrastruktur" and staff can maintain them in the admin area.
## Schema
`0012_managed_services`: `id, tenant_id → tenants ON DELETE CASCADE, kind ('git'), name, url, sku, status ('provisioning'|'active'|'restricted'|'halted', default provisioning), instance_id, notes, created_at, updated_at`, `UNIQUE (tenant_id, kind, url)`, index on `tenant_id`. The memory store mirrors the cascade in `DeleteTenant`.
## API
| Route | Who | Response |
|---|---|---|
| `GET /v1/tenants/{id}/managed-services` | tenant users with IT_ADMIN, OWNER or CXO (others 403 `FORBIDDEN_ROLE`, another tenant 404); service clients with `tenants.read` | `{"items":[ManagedService]}` by created_at, **no** `instance_id`/`notes` |
| `GET /v1/admin/tenants/{id}/managed-services` | admin group | `{"items":[admin view]}` by created_at |
| `POST /v1/admin/tenants/{id}/managed-services` | admin group | 201 admin view |
| `PATCH /v1/admin/tenants/{id}/managed-services/{sid}` | admin group | 200 admin view; 404 if `sid` is not the tenant's; kind is fixed |
| `DELETE /v1/admin/tenants/{id}/managed-services/{sid}` | admin group | 204 |
Validation (400): `invalid_kind` (git only), `invalid_name` (1–100 after trim), `invalid_url` (absolute https with host, ≤ 300), `invalid_sku` (`^INF-GIT-(CLD|OPR)-(STD|BUS|ENT)$`), `invalid_status`, `invalid_instance_id` (≤ 100, `^[a-z0-9-]*$`), `invalid_notes` (≤ 2000). Duplicate (tenant, kind, url) → 409 `duplicate` on create and on a PATCH of the url.
Audit with the staff member (`X-Staff-Subject`/`X-Staff-Email`) as actor: `managed_service.created`, `managed_service.updated` (metadata `changed` and, when the status moves, `old_status`/`new_status`; notes text is not copied), `managed_service.deleted`.
## Notes
- The tenant list is served through the existing `GET /v1/tenants/{id}/{sub}` dispatcher (ServeMux conflict with `by-slug/{slug}`), like documents/projects.
- Staff read-only (SUPPORT_ENGINEER) is decided by the portal (`canStaffWrite`); the registry has no staff-role concept and only sees the admin client. Tests cover that a client without the `admin` group gets `FORBIDDEN_CLIENT` on every admin route.
- Inputs are trimmed; `kind`/`status` are lower-cased and `sku` upper-cased before validation.
## Tests
`gofmt`, `go vet ./...`, golangci-lint (0 issues), `go test ./...` all green locally with Docker (memory + postgres harness, migrations incl. unique/check/cascade on 0012).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
Managed Git (one Gitea instance per customer, INF-GIT-{CLD,OPR}-{STD,BUS,ENT})
is provisioned by hand; the registry now keeps the record so the portal can
show it under "Verwaltete Infrastruktur" and staff can maintain it.
- 0012_managed_services: table with kind/status checks, UNIQUE (tenant_id,
kind, url), FK cascade on tenant delete (mirrored in the memory store).
- GET /v1/tenants/{id}/managed-services: tenant view without instance_id and
notes; user tokens need IT_ADMIN, OWNER or CXO (else FORBIDDEN_ROLE).
- GET/POST /v1/admin/tenants/{id}/managed-services and PATCH/DELETE
.../{sid}: staff view and maintenance, validation codes invalid_kind,
invalid_name, invalid_url, invalid_sku, invalid_status,
invalid_instance_id, invalid_notes; 409 duplicate.
- Audit managed_service.created/updated/deleted with the staff actor;
updated carries the changed fields and old/new status.
- OpenAPI spec and tests.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
sharang
merged commit 85934567f1 into main2026-10-04 19:33:21 +00:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Backend for portal#77: the registry keeps a tenant's managed services (v0: Managed Git, one Gitea instance per customer, provisioned by hand) so the portal can show them under "Verwaltete Infrastruktur" and staff can maintain them in the admin area.
Schema
0012_managed_services:id, tenant_id → tenants ON DELETE CASCADE, kind ('git'), name, url, sku, status ('provisioning'|'active'|'restricted'|'halted', default provisioning), instance_id, notes, created_at, updated_at,UNIQUE (tenant_id, kind, url), index ontenant_id. The memory store mirrors the cascade inDeleteTenant.API
GET /v1/tenants/{id}/managed-servicesFORBIDDEN_ROLE, another tenant 404); service clients withtenants.read{"items":[ManagedService]}by created_at, noinstance_id/notesGET /v1/admin/tenants/{id}/managed-services{"items":[admin view]}by created_atPOST /v1/admin/tenants/{id}/managed-servicesPATCH /v1/admin/tenants/{id}/managed-services/{sid}sidis not the tenant's; kind is fixedDELETE /v1/admin/tenants/{id}/managed-services/{sid}Validation (400):
invalid_kind(git only),invalid_name(1–100 after trim),invalid_url(absolute https with host, ≤ 300),invalid_sku(^INF-GIT-(CLD|OPR)-(STD|BUS|ENT)$),invalid_status,invalid_instance_id(≤ 100,^[a-z0-9-]*$),invalid_notes(≤ 2000). Duplicate (tenant, kind, url) → 409duplicateon create and on a PATCH of the url.Audit with the staff member (
X-Staff-Subject/X-Staff-Email) as actor:managed_service.created,managed_service.updated(metadatachangedand, when the status moves,old_status/new_status; notes text is not copied),managed_service.deleted.Notes
GET /v1/tenants/{id}/{sub}dispatcher (ServeMux conflict withby-slug/{slug}), like documents/projects.canStaffWrite); the registry has no staff-role concept and only sees the admin client. Tests cover that a client without theadmingroup getsFORBIDDEN_CLIENTon every admin route.kind/statusare lower-cased andskuupper-cased before validation.Tests
gofmt,go vet ./..., golangci-lint (0 issues),go test ./...all green locally with Docker (memory + postgres harness, migrations incl. unique/check/cascade on 0012).🤖 Generated with Claude Code
https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
Managed Git (one Gitea instance per customer, INF-GIT-{CLD,OPR}-{STD,BUS,ENT}) is provisioned by hand; the registry now keeps the record so the portal can show it under "Verwaltete Infrastruktur" and staff can maintain it. - 0012_managed_services: table with kind/status checks, UNIQUE (tenant_id, kind, url), FK cascade on tenant delete (mirrored in the memory store). - GET /v1/tenants/{id}/managed-services: tenant view without instance_id and notes; user tokens need IT_ADMIN, OWNER or CXO (else FORBIDDEN_ROLE). - GET/POST /v1/admin/tenants/{id}/managed-services and PATCH/DELETE .../{sid}: staff view and maintenance, validation codes invalid_kind, invalid_name, invalid_url, invalid_sku, invalid_status, invalid_instance_id, invalid_notes; 409 duplicate. - Audit managed_service.created/updated/deleted with the staff actor; updated carries the changed fields and old/new status. - OpenAPI spec and tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB