Spaces:
Building
Building
Update admin_routes.py
Browse files- admin_routes.py +4 -17
admin_routes.py
CHANGED
@@ -114,8 +114,8 @@ class APICreate(BaseModel):
|
|
114 |
name: str
|
115 |
url: str
|
116 |
method: str = "POST"
|
117 |
-
headers: str =
|
118 |
-
body_template: str =
|
119 |
timeout_seconds: int = 10
|
120 |
retry: Dict[str, Any] = Field(default_factory=lambda: {"retry_count": 3, "backoff_seconds": 2, "strategy": "static"})
|
121 |
proxy: Optional[str] = None
|
@@ -126,8 +126,8 @@ class APICreate(BaseModel):
|
|
126 |
class APIUpdate(BaseModel):
|
127 |
url: str
|
128 |
method: str
|
129 |
-
headers: str
|
130 |
-
body_template: str
|
131 |
timeout_seconds: int
|
132 |
retry: Dict[str, Any]
|
133 |
proxy: Optional[str]
|
@@ -963,19 +963,6 @@ async def create_api(api: APICreate, username: str = Depends(verify_token)):
|
|
963 |
"""Create new API"""
|
964 |
config = load_config()
|
965 |
|
966 |
-
# Validate JSON strings
|
967 |
-
try:
|
968 |
-
json.loads(api.headers)
|
969 |
-
json.loads(api.body_template)
|
970 |
-
if api.auth and api.auth.get("token_request_body"):
|
971 |
-
if isinstance(api.auth["token_request_body"], str):
|
972 |
-
json.loads(api.auth["token_request_body"])
|
973 |
-
if api.auth and api.auth.get("token_refresh_body"):
|
974 |
-
if isinstance(api.auth["token_refresh_body"], str):
|
975 |
-
json.loads(api.auth["token_refresh_body"])
|
976 |
-
except json.JSONDecodeError as e:
|
977 |
-
raise HTTPException(status_code=400, detail=f"Invalid JSON format: {str(e)}")
|
978 |
-
|
979 |
# Check duplicate name
|
980 |
existing = [a for a in config.get("apis", []) if a["name"] == api.name]
|
981 |
if existing:
|
|
|
114 |
name: str
|
115 |
url: str
|
116 |
method: str = "POST"
|
117 |
+
headers: Dict[str, str] = {}
|
118 |
+
body_template: Dict[str, Any] = {}
|
119 |
timeout_seconds: int = 10
|
120 |
retry: Dict[str, Any] = Field(default_factory=lambda: {"retry_count": 3, "backoff_seconds": 2, "strategy": "static"})
|
121 |
proxy: Optional[str] = None
|
|
|
126 |
class APIUpdate(BaseModel):
|
127 |
url: str
|
128 |
method: str
|
129 |
+
headers: Dict[str, str]
|
130 |
+
body_template: Dict[str, Any]
|
131 |
timeout_seconds: int
|
132 |
retry: Dict[str, Any]
|
133 |
proxy: Optional[str]
|
|
|
963 |
"""Create new API"""
|
964 |
config = load_config()
|
965 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
966 |
# Check duplicate name
|
967 |
existing = [a for a in config.get("apis", []) if a["name"] == api.name]
|
968 |
if existing:
|