Unify the nested router prefix.
This commit is contained in:
parent
9f26ecf276
commit
ee4e7cf498
@ -21,10 +21,11 @@ from .msgpack import MsgpackResponse
|
|||||||
app = FastAPI()
|
app = FastAPI()
|
||||||
VERSION = "v1"
|
VERSION = "v1"
|
||||||
BASE_PATH = f"/api/{VERSION}"
|
BASE_PATH = f"/api/{VERSION}"
|
||||||
|
COLLECTION_UID_MARKER = "{collection_uid}"
|
||||||
app.include_router(authentication_router, prefix=f"{BASE_PATH}/authentication")
|
app.include_router(authentication_router, prefix=f"{BASE_PATH}/authentication")
|
||||||
app.include_router(collection_router, prefix=f"{BASE_PATH}/collection")
|
app.include_router(collection_router, prefix=f"{BASE_PATH}/collection")
|
||||||
app.include_router(item_router, prefix=f"{BASE_PATH}/collection")
|
app.include_router(item_router, prefix=f"{BASE_PATH}/collection/{COLLECTION_UID_MARKER}")
|
||||||
app.include_router(member_router, prefix=f"{BASE_PATH}/collection")
|
app.include_router(member_router, prefix=f"{BASE_PATH}/collection/{COLLECTION_UID_MARKER}")
|
||||||
app.include_router(invitation_incoming_router, prefix=f"{BASE_PATH}/invitation/incoming")
|
app.include_router(invitation_incoming_router, prefix=f"{BASE_PATH}/invitation/incoming")
|
||||||
app.include_router(invitation_outgoing_router, prefix=f"{BASE_PATH}/invitation/outgoing")
|
app.include_router(invitation_outgoing_router, prefix=f"{BASE_PATH}/invitation/outgoing")
|
||||||
if settings.DEBUG:
|
if settings.DEBUG:
|
||||||
|
@ -379,7 +379,7 @@ def item_create(item_model: CollectionItemIn, collection: models.Collection, val
|
|||||||
return instance
|
return instance
|
||||||
|
|
||||||
|
|
||||||
@item_router.get("/{collection_uid}/item/{item_uid}/")
|
@item_router.get("/item/{item_uid}/")
|
||||||
def item_get(
|
def item_get(
|
||||||
item_uid: str,
|
item_uid: str,
|
||||||
queryset: QuerySet = Depends(get_item_queryset),
|
queryset: QuerySet = Depends(get_item_queryset),
|
||||||
@ -408,7 +408,7 @@ def item_list_common(
|
|||||||
return MsgpackResponse(content=ret)
|
return MsgpackResponse(content=ret)
|
||||||
|
|
||||||
|
|
||||||
@item_router.get("/{collection_uid}/item/")
|
@item_router.get("/item/")
|
||||||
async def item_list(
|
async def item_list(
|
||||||
queryset: QuerySet = Depends(get_item_queryset),
|
queryset: QuerySet = Depends(get_item_queryset),
|
||||||
stoken: t.Optional[str] = None,
|
stoken: t.Optional[str] = None,
|
||||||
@ -440,7 +440,7 @@ def item_bulk_common(data: ItemBatchIn, user: User, stoken: t.Optional[str], uid
|
|||||||
return MsgpackResponse({})
|
return MsgpackResponse({})
|
||||||
|
|
||||||
|
|
||||||
@item_router.get("/{collection_uid}/item/{item_uid}/revision/")
|
@item_router.get("/item/{item_uid}/revision/")
|
||||||
def item_revisions(
|
def item_revisions(
|
||||||
item_uid: str,
|
item_uid: str,
|
||||||
limit: int = 50,
|
limit: int = 50,
|
||||||
@ -476,7 +476,7 @@ def item_revisions(
|
|||||||
return MsgpackResponse(ret)
|
return MsgpackResponse(ret)
|
||||||
|
|
||||||
|
|
||||||
@item_router.post("/{collection_uid}/item/fetch_updates/")
|
@item_router.post("/item/fetch_updates/")
|
||||||
def fetch_updates(
|
def fetch_updates(
|
||||||
data: t.List[CollectionItemBulkGetIn],
|
data: t.List[CollectionItemBulkGetIn],
|
||||||
stoken: t.Optional[str] = None,
|
stoken: t.Optional[str] = None,
|
||||||
@ -510,14 +510,14 @@ def fetch_updates(
|
|||||||
return MsgpackResponse(ret)
|
return MsgpackResponse(ret)
|
||||||
|
|
||||||
|
|
||||||
@item_router.post("/{collection_uid}/item/transaction/", dependencies=[Depends(has_write_access)])
|
@item_router.post("/item/transaction/", dependencies=[Depends(has_write_access)])
|
||||||
def item_transaction(
|
def item_transaction(
|
||||||
collection_uid: str, data: ItemBatchIn, stoken: t.Optional[str] = None, user: User = Depends(get_authenticated_user)
|
collection_uid: str, data: ItemBatchIn, stoken: t.Optional[str] = None, user: User = Depends(get_authenticated_user)
|
||||||
):
|
):
|
||||||
return item_bulk_common(data, user, stoken, collection_uid, validate_etag=True)
|
return item_bulk_common(data, user, stoken, collection_uid, validate_etag=True)
|
||||||
|
|
||||||
|
|
||||||
@item_router.post("/{collection_uid}/item/batch/", dependencies=[Depends(has_write_access)])
|
@item_router.post("/item/batch/", dependencies=[Depends(has_write_access)])
|
||||||
def item_batch(
|
def item_batch(
|
||||||
collection_uid: str, data: ItemBatchIn, stoken: t.Optional[str] = None, user: User = Depends(get_authenticated_user)
|
collection_uid: str, data: ItemBatchIn, stoken: t.Optional[str] = None, user: User = Depends(get_authenticated_user)
|
||||||
):
|
):
|
||||||
|
@ -49,9 +49,7 @@ class MemberListResponse(BaseModel):
|
|||||||
done: bool
|
done: bool
|
||||||
|
|
||||||
|
|
||||||
@member_router.get(
|
@member_router.get("/member/", response_model=MemberListResponse, dependencies=[Depends(verify_collection_admin)])
|
||||||
"/{collection_uid}/member/", response_model=MemberListResponse, dependencies=[Depends(verify_collection_admin)]
|
|
||||||
)
|
|
||||||
def member_list(
|
def member_list(
|
||||||
iterator: t.Optional[str] = None,
|
iterator: t.Optional[str] = None,
|
||||||
limit: int = 50,
|
limit: int = 50,
|
||||||
@ -72,7 +70,7 @@ def member_list(
|
|||||||
|
|
||||||
|
|
||||||
@member_router.delete(
|
@member_router.delete(
|
||||||
"/{collection_uid}/member/{username}/",
|
"/member/{username}/",
|
||||||
status_code=status.HTTP_204_NO_CONTENT,
|
status_code=status.HTTP_204_NO_CONTENT,
|
||||||
dependencies=[Depends(verify_collection_admin)],
|
dependencies=[Depends(verify_collection_admin)],
|
||||||
)
|
)
|
||||||
@ -83,7 +81,7 @@ def member_delete(
|
|||||||
|
|
||||||
|
|
||||||
@member_router.patch(
|
@member_router.patch(
|
||||||
"/{collection_uid}/member/{username}/",
|
"/member/{username}/",
|
||||||
status_code=status.HTTP_204_NO_CONTENT,
|
status_code=status.HTTP_204_NO_CONTENT,
|
||||||
dependencies=[Depends(verify_collection_admin)],
|
dependencies=[Depends(verify_collection_admin)],
|
||||||
)
|
)
|
||||||
@ -100,7 +98,7 @@ def member_patch(
|
|||||||
|
|
||||||
|
|
||||||
@member_router.post(
|
@member_router.post(
|
||||||
"/{collection_uid}/member/leave/",
|
"/member/leave/",
|
||||||
status_code=status.HTTP_204_NO_CONTENT,
|
status_code=status.HTTP_204_NO_CONTENT,
|
||||||
)
|
)
|
||||||
def member_leave(user: User = Depends(get_authenticated_user), collection: models.Collection = Depends(get_collection)):
|
def member_leave(user: User = Depends(get_authenticated_user), collection: models.Collection = Depends(get_collection)):
|
||||||
|
Loading…
Reference in New Issue
Block a user