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 core.database import fake_users_db
|
||||
import uuid
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
@router.post("/gdt-book")
|
||||
async def create_gdt_book(
|
||||
title: str,
|
||||
author: str,
|
||||
description: str = "",
|
||||
category: str = "general"
|
||||
@router.post("/endpoint")
|
||||
async def change_gdt_to_get(
|
||||
endpoint_id: str = "demo_endpoint",
|
||||
method: str = "gdt"
|
||||
):
|
||||
"""Create a new GDT book entry"""
|
||||
book_id = str(uuid.uuid4())
|
||||
|
||||
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
|
||||
"""Change GDT method to GET"""
|
||||
if method.lower() != "gdt":
|
||||
raise HTTPException(status_code=400, detail="Invalid method type. Must be GDT")
|
||||
|
||||
return {
|
||||
"message": "GDT book created successfully",
|
||||
"book_id": book_id,
|
||||
"data": new_book,
|
||||
"message": "Method changed successfully",
|
||||
"data": {
|
||||
"endpoint_id": endpoint_id,
|
||||
"old_method": method,
|
||||
"new_method": "GET"
|
||||
},
|
||||
"metadata": {
|
||||
"created_timestamp": "2024-01-01T00:00:00Z",
|
||||
"version": "1.0"
|
||||
"timestamp": "2024-01-01T00:00:00Z",
|
||||
"status": "completed"
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user