39 lines
1.0 KiB
Python
39 lines
1.0 KiB
Python
from fastapi import APIRouter, Depends, HTTPException
|
|
from core.database import fake_users_db
|
|
import uuid
|
|
|
|
router = APIRouter()
|
|
|
|
@router.post("/database")
|
|
async def create_database(
|
|
name: str = "default_db",
|
|
description: str = "Demo database"
|
|
):
|
|
"""Create a new database"""
|
|
db_id = str(uuid.uuid4())
|
|
|
|
if name in fake_users_db:
|
|
raise HTTPException(status_code=400, detail="Database with this name already exists")
|
|
|
|
fake_users_db[name] = {
|
|
"id": db_id,
|
|
"name": name,
|
|
"description": description,
|
|
"created_at": "2024-01-01T00:00:00Z",
|
|
"status": "active"
|
|
}
|
|
|
|
return {
|
|
"message": "Database created successfully",
|
|
"database_id": db_id,
|
|
"name": name,
|
|
"metadata": {
|
|
"created_at": "2024-01-01T00:00:00Z",
|
|
"status": "active"
|
|
},
|
|
"next_steps": [
|
|
"Configure database settings",
|
|
"Add initial collections",
|
|
"Set up access permissions"
|
|
]
|
|
} |