🔧 fix(store.py): remove duplicate list_components endpoint to avoid conflicts and improve code organization
✨ feat(store.py): add new list_components endpoint to retrieve a paginated list of components from the store
This commit is contained in:
parent
4c8550579d
commit
09d4ee43cf
1 changed files with 19 additions and 16 deletions
|
|
@ -45,6 +45,25 @@ def create_component(
|
||||||
raise HTTPException(status_code=400, detail=str(exc))
|
raise HTTPException(status_code=400, detail=str(exc))
|
||||||
|
|
||||||
|
|
||||||
|
@router.get("/components/", response_model=List[ComponentResponse])
|
||||||
|
def list_components(
|
||||||
|
page: int = 1,
|
||||||
|
limit: int = 10,
|
||||||
|
store_service: StoreService = Depends(get_store_service),
|
||||||
|
store_api_Key: str = Depends(get_optional_user_store_api_key),
|
||||||
|
settings_service=Depends(get_settings_service),
|
||||||
|
):
|
||||||
|
try:
|
||||||
|
if store_api_Key:
|
||||||
|
decrypted = auth_utils.decrypt_api_key(store_api_Key, settings_service)
|
||||||
|
else:
|
||||||
|
decrypted = None
|
||||||
|
result = store_service.list_components(decrypted, page, limit)
|
||||||
|
return result
|
||||||
|
except Exception as exc:
|
||||||
|
raise HTTPException(status_code=400, detail=str(exc))
|
||||||
|
|
||||||
|
|
||||||
@router.get("/components/{component_id}", response_model=ComponentResponse)
|
@router.get("/components/{component_id}", response_model=ComponentResponse)
|
||||||
def read_component(
|
def read_component(
|
||||||
component_id: UUID,
|
component_id: UUID,
|
||||||
|
|
@ -64,22 +83,6 @@ def read_component(
|
||||||
return component
|
return component
|
||||||
|
|
||||||
|
|
||||||
@router.get("/components/", response_model=List[ComponentResponse])
|
|
||||||
def list_components(
|
|
||||||
page: int = 1,
|
|
||||||
limit: int = 10,
|
|
||||||
store_service: StoreService = Depends(get_store_service),
|
|
||||||
store_api_Key: str = Depends(get_user_store_api_key),
|
|
||||||
settings_service=Depends(get_settings_service),
|
|
||||||
):
|
|
||||||
try:
|
|
||||||
decrypted = auth_utils.decrypt_api_key(store_api_Key, settings_service)
|
|
||||||
result = store_service.list_components(decrypted, page, limit)
|
|
||||||
return result
|
|
||||||
except Exception as exc:
|
|
||||||
raise HTTPException(status_code=400, detail=str(exc))
|
|
||||||
|
|
||||||
|
|
||||||
@router.get("/search", response_model=List[ComponentResponse])
|
@router.get("/search", response_model=List[ComponentResponse])
|
||||||
async def search_endpoint(
|
async def search_endpoint(
|
||||||
query: str = Query(...),
|
query: str = Query(...),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue