Backend (Phase 1-6): - Pydantic schemas for request/response validation - Service layer (SSH Key, Server, Repo, Sync) - API routes with authentication - FastAPI main application with lifespan management - ORM models (SshKey, Server, Repo, SyncLog) Frontend (Phase 7): - Vue 3 + Element Plus + Pinia + Vue Router - API client with Axios and interceptors - State management stores - All page components (Dashboard, Servers, Repos, SyncLogs, SshKeys, Settings) Deployment (Phase 8): - README with quick start guide - Startup script (start.sh) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
64 lines
1.9 KiB
Python
64 lines
1.9 KiB
Python
"""
|
|
SSH Key Pydantic schemas.
|
|
"""
|
|
from typing import Optional
|
|
from pydantic import BaseModel, Field, field_validator
|
|
|
|
|
|
class SshKeyCreate(BaseModel):
|
|
"""
|
|
Schema for creating a new SSH key.
|
|
"""
|
|
name: str = Field(..., min_length=1, max_length=100, description="SSH key name")
|
|
private_key: str = Field(..., min_length=1, description="SSH private key content")
|
|
|
|
@field_validator("name")
|
|
@classmethod
|
|
def name_must_not_be_empty(cls, v: str) -> str:
|
|
"""Validate that name is not empty or whitespace only."""
|
|
if not v or not v.strip():
|
|
raise ValueError("name must not be empty")
|
|
return v.strip()
|
|
|
|
@field_validator("private_key")
|
|
@classmethod
|
|
def private_key_must_not_be_empty(cls, v: str) -> str:
|
|
"""Validate that private_key is not empty or whitespace only."""
|
|
if not v or not v.strip():
|
|
raise ValueError("private_key must not be empty")
|
|
return v.strip()
|
|
|
|
model_config = {
|
|
"json_schema_extra": {
|
|
"examples": [
|
|
{
|
|
"name": "my-git-key",
|
|
"private_key": "-----BEGIN OPENSSH PRIVATE KEY-----\n...\n-----END OPENSSH PRIVATE KEY-----"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
|
|
|
|
class SshKeyResponse(BaseModel):
|
|
"""
|
|
Schema for SSH key response.
|
|
"""
|
|
id: int = Field(description="SSH key ID")
|
|
name: str = Field(description="SSH key name")
|
|
fingerprint: Optional[str] = Field(default=None, description="SSH key fingerprint")
|
|
created_at: int = Field(description="Creation timestamp (Unix timestamp)")
|
|
|
|
model_config = {
|
|
"json_schema_extra": {
|
|
"examples": [
|
|
{
|
|
"id": 1,
|
|
"name": "my-git-key",
|
|
"fingerprint": "SHA256:abc123...",
|
|
"created_at": 1711804800
|
|
}
|
|
]
|
|
}
|
|
}
|