Commit c15b2b0
committed
Migrate admin endpoints and core Projects API
This commit migrates 4 major endpoint groups (24 endpoints total) from Tornado
to FastAPI, completing all core admin entities and the central Projects API.
New Models (Piccolo ORM):
1. ProjectType (models/project_type.py):
- Categories for projects (HTTP API, Library, Web App, etc.)
- Fields: name, slug, plural_name, icon_class, environment_urls
- Audit trail: created/modified timestamps and users
2. Environment (models/environment.py):
- Deployment environments (production, staging, development)
- Fields: name, icon_class, description
- Audit trail fields
3. Project (models/project.py) - CENTRAL ENTITY:
- Core fields: name, slug, description, namespace_id, project_type_id
- Integration fields: sentry_project_slug, sonarqube_project_key, pagerduty_service_id
- Configuration: configuration_type, environments (array)
- Lifecycle: archived (boolean)
- Removed: gitlab_project_id (GitLab support dropped)
- Foreign keys: namespace_id, project_type_id
- Unique constraints: (namespace_id, name), (namespace_id, slug)
Pydantic Schemas:
1. ProjectType schemas (schemas/project_type.py):
- ProjectTypeCreate, ProjectTypeUpdate, ProjectTypeResponse
- Validation: name/slug uniqueness, required fields
2. Environment schemas (schemas/environment.py):
- EnvironmentCreate, EnvironmentUpdate, EnvironmentResponse
- Validation: name uniqueness
3. Group schemas (schemas/group.py):
- GroupCreate, GroupUpdate, GroupResponse
- GroupMemberAdd, GroupMemberResponse
- Supports group member management
4. Project schemas (schemas/project.py):
- ProjectCreate, ProjectUpdate, ProjectResponse
- ProjectListResponse (with pagination metadata)
- Computed fields: namespace/project_type names, project_score
- Complex validation: foreign key existence, unique constraints
API Routers:
1. Project Types (routers/project_types.py) - 5 endpoints:
- GET /api/project-types - List all
- GET /api/project-types/{id} - Get one
- POST /api/project-types - Create (admin only)
- PATCH /api/project-types/{id} - Update (admin only)
- DELETE /api/project-types/{id} - Delete (admin only)
2. Environments (routers/environments.py) - 5 endpoints:
- GET /api/environments - List all
- GET /api/environments/{id} - Get one
- POST /api/environments - Create (admin only)
- PATCH /api/environments/{id} - Update (admin only)
- DELETE /api/environments/{id} - Delete (admin only)
3. Groups (routers/groups.py) - 7 endpoints:
- GET /api/groups - List all
- GET /api/groups/{name} - Get one
- POST /api/groups - Create (admin only)
- PATCH /api/groups/{name} - Update (admin only)
- DELETE /api/groups/{name} - Delete (admin only)
- GET /api/groups/{name}/members - List group members
- POST /api/groups/{name}/members - Add member (admin only)
- DELETE /api/groups/{name}/members/{username} - Remove member (admin only)
4. Projects (routers/projects.py) - 4 endpoints:
- GET /api/projects - List with filtering/sorting/pagination
- GET /api/projects/{id} - Get one with related data
- POST /api/projects - Create (authenticated)
- PATCH /api/projects/{id} - Update (authenticated)
- DELETE /api/projects/{id} - Delete (admin only)
Project Features:
- Filtering: namespace_id, project_type_id, name search, archived status
- Sorting: name, namespace, project_type, project_score (asc/desc)
- Pagination: limit, offset with total count
- Foreign key validation: Validates namespace and project_type exist
- Conflict detection: Unique (namespace_id, name) and (namespace_id, slug)
- Related data: Fetches namespace and project_type names for responses
Group Management Features:
- CRUD operations on groups
- Manage permissions per group
- Add/remove users from groups
- List group members
- Cascade delete (removes members when group deleted)
Permission Model:
- Admin operations: ProjectType, Environment, Group CRUD, Project deletion
- Authenticated operations: Project create/update
- Public operations: List/get operations (no auth required)
Total API Surface:
- Endpoints migrated: 24 (across 4 routers)
- Models created: 3 new (ProjectType, Environment, Project)
- Total endpoints live: 33 (health + auth + admin + projects)
- Total models: 8 (User, Group, GroupMember, AuthToken, OAuth2Token, Namespace, ProjectType, Environment, Project)
Architecture Improvements:
- Type-safe models with Piccolo ORM
- Automatic validation with Pydantic
- Dependency injection for authentication
- RFC 7807 error responses throughout
- Auto-generated OpenAPI docs
Next Steps:
- Add project relationship endpoints (dependencies, links, URLs, facts)
- Add operations log endpoints
- Add report endpoints
- Implement automation triggers for project creation
- Add OpenSearch indexing for projects
- Write comprehensive tests for new endpoints
🤖 Generated with Claude Code1 parent 80d493f commit c15b2b0
14 files changed
Lines changed: 1906 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
275 | 275 | | |
276 | 276 | | |
277 | 277 | | |
278 | | - | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
279 | 286 | | |
280 | 287 | | |
281 | 288 | | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
282 | 293 | | |
283 | 294 | | |
284 | | - | |
285 | | - | |
| 295 | + | |
286 | 296 | | |
287 | 297 | | |
288 | 298 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
| 9 | + | |
| 10 | + | |
8 | 11 | | |
9 | 12 | | |
10 | 13 | | |
| |||
25 | 28 | | |
26 | 29 | | |
27 | 30 | | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
28 | 34 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
0 commit comments