bot
commited on
Commit
·
ee969cd
1
Parent(s):
df44ba9
完善API
Browse files
main.py
CHANGED
|
@@ -13,7 +13,9 @@ from fastapi import (
|
|
| 13 |
APIRouter,
|
| 14 |
Depends,
|
| 15 |
Request,
|
|
|
|
| 16 |
Body,
|
|
|
|
| 17 |
Response,
|
| 18 |
HTTPException,
|
| 19 |
status,
|
|
@@ -162,20 +164,146 @@ async def get_files(item: FileRequest):
|
|
| 162 |
)
|
| 163 |
|
| 164 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 165 |
@api_router.get(
|
| 166 |
"/files/{file_id}", summary="文件信息", description="获取文件信息", tags=["文件"]
|
| 167 |
)
|
| 168 |
-
async def get_file_info(file_id: str):
|
| 169 |
return await THUNDERX_CLIENT.get_download_url(file_id)
|
| 170 |
|
| 171 |
|
| 172 |
@api_router.delete(
|
| 173 |
"/files/{file_id}", summary="删除文件", description="删除文件", tags=["文件"]
|
| 174 |
)
|
| 175 |
-
async def delete_file_info(
|
|
|
|
|
|
|
| 176 |
return await THUNDERX_CLIENT.delete_forever([file_id])
|
| 177 |
|
| 178 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 179 |
@api_router.post(
|
| 180 |
"/emptytrash", summary="清空回收站", description="清空回收站【慎用】", tags=["文件"]
|
| 181 |
)
|
|
@@ -190,7 +318,11 @@ async def emptytrash():
|
|
| 190 |
description="获取账号分享列表",
|
| 191 |
tags=["分享"],
|
| 192 |
)
|
| 193 |
-
async def get_share_list(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 194 |
return await THUNDERX_CLIENT.get_share_list(page_token)
|
| 195 |
|
| 196 |
|
|
@@ -198,9 +330,13 @@ async def get_share_list(page_token: str | None = None):
|
|
| 198 |
"/file_batch_share", summary="创建分享", description="创建分享", tags=["分享"]
|
| 199 |
)
|
| 200 |
async def file_batch_share(
|
| 201 |
-
ids: List[str] = None,
|
| 202 |
-
need_password: bool | None =
|
| 203 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 204 |
):
|
| 205 |
return await THUNDERX_CLIENT.file_batch_share(ids, need_password, expiration_days)
|
| 206 |
|
|
@@ -208,7 +344,9 @@ async def file_batch_share(
|
|
| 208 |
@api_router.post(
|
| 209 |
"/share_batch_delete", summary="取消分享", description="取消分享", tags=["分享"]
|
| 210 |
)
|
| 211 |
-
async def share_batch_delete(
|
|
|
|
|
|
|
| 212 |
return await THUNDERX_CLIENT.share_batch_delete(ids)
|
| 213 |
|
| 214 |
|
|
@@ -219,7 +357,9 @@ async def share_batch_delete(ids: List[str]):
|
|
| 219 |
tags=["分享"],
|
| 220 |
)
|
| 221 |
async def get_share_folder(
|
| 222 |
-
share_id: str
|
|
|
|
|
|
|
| 223 |
):
|
| 224 |
return await THUNDERX_CLIENT.get_share_folder(share_id, pass_code_token, parent_id)
|
| 225 |
|
|
|
|
| 13 |
APIRouter,
|
| 14 |
Depends,
|
| 15 |
Request,
|
| 16 |
+
Query,
|
| 17 |
Body,
|
| 18 |
+
Path,
|
| 19 |
Response,
|
| 20 |
HTTPException,
|
| 21 |
status,
|
|
|
|
| 164 |
)
|
| 165 |
|
| 166 |
|
| 167 |
+
@api_router.post(
|
| 168 |
+
"/file_star_list", summary="加星文件列表", description="加星文件列表", tags=["文件"]
|
| 169 |
+
)
|
| 170 |
+
async def file_star_list(
|
| 171 |
+
size: int = Query(default=100, title="显示数量", description="显示数量"),
|
| 172 |
+
next_page_token: str | None = Query(
|
| 173 |
+
default=None, title="分页Token", description="分页Token"
|
| 174 |
+
),
|
| 175 |
+
):
|
| 176 |
+
return await THUNDERX_CLIENT.file_star_list(size, next_page_token)
|
| 177 |
+
|
| 178 |
+
|
| 179 |
@api_router.get(
|
| 180 |
"/files/{file_id}", summary="文件信息", description="获取文件信息", tags=["文件"]
|
| 181 |
)
|
| 182 |
+
async def get_file_info(file_id: str = Path(..., title="文件ID", description="文件ID")):
|
| 183 |
return await THUNDERX_CLIENT.get_download_url(file_id)
|
| 184 |
|
| 185 |
|
| 186 |
@api_router.delete(
|
| 187 |
"/files/{file_id}", summary="删除文件", description="删除文件", tags=["文件"]
|
| 188 |
)
|
| 189 |
+
async def delete_file_info(
|
| 190 |
+
file_id: str = Path(..., title="文件ID", description="文件ID")
|
| 191 |
+
):
|
| 192 |
return await THUNDERX_CLIENT.delete_forever([file_id])
|
| 193 |
|
| 194 |
|
| 195 |
+
@api_router.post(
|
| 196 |
+
"/file_rename", summary="重命名文件", description="重命名文件", tags=["文件"]
|
| 197 |
+
)
|
| 198 |
+
async def file_rename(
|
| 199 |
+
file_id: str = Query(title="文件ID", description="文件ID"),
|
| 200 |
+
new_file_name: str = Query(title="新文件名", description="新文件名"),
|
| 201 |
+
):
|
| 202 |
+
return await THUNDERX_CLIENT.file_rename(file_id, new_file_name)
|
| 203 |
+
|
| 204 |
+
|
| 205 |
+
@api_router.post(
|
| 206 |
+
"/file_batch_copy",
|
| 207 |
+
summary="批量复制文件",
|
| 208 |
+
description="批量复制文件",
|
| 209 |
+
tags=["文件"],
|
| 210 |
+
)
|
| 211 |
+
async def file_batch_copy(
|
| 212 |
+
ids: List[str] = Body(title="文件ID列表", description="文件ID列表"),
|
| 213 |
+
to_parent_id: str = Query(
|
| 214 |
+
title="复制到的文件夹id, 默认为根目录",
|
| 215 |
+
description="复制到的文件夹id, 默认为根目录",
|
| 216 |
+
),
|
| 217 |
+
):
|
| 218 |
+
return await THUNDERX_CLIENT.file_batch_copy(ids, to_parent_id)
|
| 219 |
+
|
| 220 |
+
|
| 221 |
+
@api_router.post(
|
| 222 |
+
"/file_batch_move",
|
| 223 |
+
summary="批量移动文件",
|
| 224 |
+
description="批量移动文件",
|
| 225 |
+
tags=["文件"],
|
| 226 |
+
)
|
| 227 |
+
async def file_batch_move(
|
| 228 |
+
ids: List[str] = Body(title="文件ID列表", description="文件ID列表"),
|
| 229 |
+
to_parent_id: str = Query(
|
| 230 |
+
title="移动到的文件夹id, 默认为根目录",
|
| 231 |
+
description="移动到的文件夹id, 默认为根目录",
|
| 232 |
+
),
|
| 233 |
+
):
|
| 234 |
+
return await THUNDERX_CLIENT.file_batch_move(ids, to_parent_id)
|
| 235 |
+
|
| 236 |
+
|
| 237 |
+
@api_router.post(
|
| 238 |
+
"/create_folder", summary="新建文件夹", description="新建文件夹", tags=["文件"]
|
| 239 |
+
)
|
| 240 |
+
async def create_folder(
|
| 241 |
+
name: str = Query(title="文件夹名称", description="文件夹名称"),
|
| 242 |
+
parent_id: str = Query(
|
| 243 |
+
title="父文件夹id, 默认创建到根目录", description="父文件夹id, 默认创建到根目录"
|
| 244 |
+
),
|
| 245 |
+
):
|
| 246 |
+
return await THUNDERX_CLIENT.create_folder(name, parent_id)
|
| 247 |
+
|
| 248 |
+
|
| 249 |
+
@api_router.post(
|
| 250 |
+
"/delete_to_trash",
|
| 251 |
+
summary="将文件夹、文件移动到回收站",
|
| 252 |
+
description="将文件夹、文件移动到回收站",
|
| 253 |
+
tags=["文件"],
|
| 254 |
+
)
|
| 255 |
+
async def delete_to_trash(
|
| 256 |
+
ids: List[str] = Body(title="文件ID列表", description="文件ID列表")
|
| 257 |
+
):
|
| 258 |
+
return await THUNDERX_CLIENT.delete_to_trash(ids)
|
| 259 |
+
|
| 260 |
+
|
| 261 |
+
@api_router.post(
|
| 262 |
+
"/delete_forever",
|
| 263 |
+
summary="将文件夹、文件彻底删除",
|
| 264 |
+
description="将文件夹、文件彻底删除",
|
| 265 |
+
tags=["文件"],
|
| 266 |
+
)
|
| 267 |
+
async def delete_forever(
|
| 268 |
+
ids: List[str] = Body(title="文件ID列表", description="文件ID列表")
|
| 269 |
+
):
|
| 270 |
+
return await THUNDERX_CLIENT.delete_forever(ids)
|
| 271 |
+
|
| 272 |
+
|
| 273 |
+
@api_router.post(
|
| 274 |
+
"/untrash",
|
| 275 |
+
summary="将文件夹、文件移出回收站",
|
| 276 |
+
description="将文件夹、文件移出回收站",
|
| 277 |
+
tags=["文件"],
|
| 278 |
+
)
|
| 279 |
+
async def untrash(ids: List[str] = Body(title="文件ID列表", description="文件ID列表")):
|
| 280 |
+
return await THUNDERX_CLIENT.untrash(ids)
|
| 281 |
+
|
| 282 |
+
|
| 283 |
+
@api_router.post(
|
| 284 |
+
"/file_batch_star",
|
| 285 |
+
summary="批量给文件加星标",
|
| 286 |
+
description="批量给文件加星标",
|
| 287 |
+
tags=["文件"],
|
| 288 |
+
)
|
| 289 |
+
async def file_batch_star(
|
| 290 |
+
ids: List[str] = Body(title="文件ID列表", description="文件ID列表")
|
| 291 |
+
):
|
| 292 |
+
return await THUNDERX_CLIENT.file_batch_star(ids)
|
| 293 |
+
|
| 294 |
+
|
| 295 |
+
@api_router.post(
|
| 296 |
+
"/file_batch_unstar",
|
| 297 |
+
summary="批量给文件加星标",
|
| 298 |
+
description="批量给文件加星标",
|
| 299 |
+
tags=["文件"],
|
| 300 |
+
)
|
| 301 |
+
async def file_batch_unstar(
|
| 302 |
+
ids: List[str] = Body(title="文件ID列表", description="文件ID列表")
|
| 303 |
+
):
|
| 304 |
+
return await THUNDERX_CLIENT.file_batch_unstar(ids)
|
| 305 |
+
|
| 306 |
+
|
| 307 |
@api_router.post(
|
| 308 |
"/emptytrash", summary="清空回收站", description="清空回收站【慎用】", tags=["文件"]
|
| 309 |
)
|
|
|
|
| 318 |
description="获取账号分享列表",
|
| 319 |
tags=["分享"],
|
| 320 |
)
|
| 321 |
+
async def get_share_list(
|
| 322 |
+
page_token: str | None = Query(
|
| 323 |
+
default=None, title="分页Token", description="分页Token"
|
| 324 |
+
)
|
| 325 |
+
):
|
| 326 |
return await THUNDERX_CLIENT.get_share_list(page_token)
|
| 327 |
|
| 328 |
|
|
|
|
| 330 |
"/file_batch_share", summary="创建分享", description="创建分享", tags=["分享"]
|
| 331 |
)
|
| 332 |
async def file_batch_share(
|
| 333 |
+
ids: List[str] = Body(default=None, title="文件ID列表", description="文件ID列表"),
|
| 334 |
+
need_password: bool | None = Query(
|
| 335 |
+
default=False, title="是否需要密码", description="是否需要密码"
|
| 336 |
+
),
|
| 337 |
+
expiration_days: int | None = Query(
|
| 338 |
+
default=-1, title="过期时间", description="过期时间【天数,默认永远】"
|
| 339 |
+
),
|
| 340 |
):
|
| 341 |
return await THUNDERX_CLIENT.file_batch_share(ids, need_password, expiration_days)
|
| 342 |
|
|
|
|
| 344 |
@api_router.post(
|
| 345 |
"/share_batch_delete", summary="取消分享", description="取消分享", tags=["分享"]
|
| 346 |
)
|
| 347 |
+
async def share_batch_delete(
|
| 348 |
+
ids: List[str] = Body(title="文件ID列表", description="文件ID列表")
|
| 349 |
+
):
|
| 350 |
return await THUNDERX_CLIENT.share_batch_delete(ids)
|
| 351 |
|
| 352 |
|
|
|
|
| 357 |
tags=["分享"],
|
| 358 |
)
|
| 359 |
async def get_share_folder(
|
| 360 |
+
share_id: str = Query(title="分享ID", description="分享ID"),
|
| 361 |
+
pass_code_token: str | None = Query(default=None, title="密码", description="密码"),
|
| 362 |
+
parent_id: str | None = Query(default=None, title="父ID", description="父ID"),
|
| 363 |
):
|
| 364 |
return await THUNDERX_CLIENT.get_share_folder(share_id, pass_code_token, parent_id)
|
| 365 |
|