Update code in endpoints/api/v1/endpoint.post.py
This commit is contained in:
parent
240993b753
commit
7276fc0401
@ -1,43 +1,26 @@
|
|||||||
from fastapi import APIRouter, Depends, HTTPException
|
from fastapi import APIRouter, Depends, HTTPException
|
||||||
from core.database import fake_users_db
|
from core.database import fake_users_db
|
||||||
import uuid
|
|
||||||
|
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
|
|
||||||
@router.post("/gdt-book")
|
@router.post("/endpoint")
|
||||||
async def create_gdt_book(
|
async def change_gdt_to_get(
|
||||||
title: str,
|
endpoint_id: str = "demo_endpoint",
|
||||||
author: str,
|
method: str = "gdt"
|
||||||
description: str = "",
|
|
||||||
category: str = "general"
|
|
||||||
):
|
):
|
||||||
"""Create a new GDT book entry"""
|
"""Change GDT method to GET"""
|
||||||
book_id = str(uuid.uuid4())
|
if method.lower() != "gdt":
|
||||||
|
raise HTTPException(status_code=400, detail="Invalid method type. Must be GDT")
|
||||||
if title.strip() == "":
|
|
||||||
raise HTTPException(status_code=400, detail="Title cannot be empty")
|
|
||||||
|
|
||||||
new_book = {
|
|
||||||
"id": book_id,
|
|
||||||
"title": title,
|
|
||||||
"author": author,
|
|
||||||
"description": description,
|
|
||||||
"category": category,
|
|
||||||
"created_at": "2024-01-01T00:00:00Z", # Demo timestamp
|
|
||||||
"status": "active"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Store in demo database
|
|
||||||
if "books" not in fake_users_db:
|
|
||||||
fake_users_db["books"] = {}
|
|
||||||
fake_users_db["books"][book_id] = new_book
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"message": "GDT book created successfully",
|
"message": "Method changed successfully",
|
||||||
"book_id": book_id,
|
"data": {
|
||||||
"data": new_book,
|
"endpoint_id": endpoint_id,
|
||||||
|
"old_method": method,
|
||||||
|
"new_method": "GET"
|
||||||
|
},
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"created_timestamp": "2024-01-01T00:00:00Z",
|
"timestamp": "2024-01-01T00:00:00Z",
|
||||||
"version": "1.0"
|
"status": "completed"
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user