Create a new datasource. The datasource will be henceforth identified by account/container which must be unique or this function will return a 400.
(
datasource: DataSource,
datasources: AgnosticCollection = Depends(datasource_repo.collection),
current_user: dict = Depends(get_current_user),
)
| 19 | |
| 20 | @router.post("/api/datasources", status_code=201, response_model=DataSource) |
| 21 | async def create_datasource( |
| 22 | datasource: DataSource, |
| 23 | datasources: AgnosticCollection = Depends(datasource_repo.collection), |
| 24 | current_user: dict = Depends(get_current_user), |
| 25 | ): |
| 26 | """ |
| 27 | Create a new datasource. The datasource will be henceforth identified by account/container which |
| 28 | must be unique or this function will return a 400. |
| 29 | """ |
| 30 | if await datasource_exists(datasource.account, datasource.container): |
| 31 | raise HTTPException(status_code=409, detail="Datasource Already Exists") |
| 32 | |
| 33 | datasource = await create(datasource=datasource, user=current_user) |
| 34 | return datasource |
| 35 | |
| 36 | |
| 37 | @router.get("/api/datasources", response_model=list[DataSource]) |
nothing calls this directly
no test coverage detected