(
account: Optional[List[str]] = Query([]),
container: Optional[List[str]] = Query([]),
database_id: Optional[List[str]] = Query([]),
min_frequency: Optional[float] = Query(None),
max_frequency: Optional[float] = Query(None),
author: Optional[str] = Query(None),
label: Optional[str] = Query(None),
comment: Optional[str] = Query(None),
description: Optional[str] = Query(None), # global description
min_datetime: Optional[datetime] = Query(None),
max_datetime: Optional[datetime] = Query(None),
text: Optional[str] = Query(None),
captures_geo: Optional[str] = Query(None),
annotations_geo: Optional[str] = Query(None),
current_user: Optional[dict] = Depends(get_current_user),
)
| 171 | response_model=list[DataSourceReference], |
| 172 | ) |
| 173 | async def query_meta( |
| 174 | account: Optional[List[str]] = Query([]), |
| 175 | container: Optional[List[str]] = Query([]), |
| 176 | database_id: Optional[List[str]] = Query([]), |
| 177 | min_frequency: Optional[float] = Query(None), |
| 178 | max_frequency: Optional[float] = Query(None), |
| 179 | author: Optional[str] = Query(None), |
| 180 | label: Optional[str] = Query(None), |
| 181 | comment: Optional[str] = Query(None), |
| 182 | description: Optional[str] = Query(None), # global description |
| 183 | min_datetime: Optional[datetime] = Query(None), |
| 184 | max_datetime: Optional[datetime] = Query(None), |
| 185 | text: Optional[str] = Query(None), |
| 186 | captures_geo: Optional[str] = Query(None), |
| 187 | annotations_geo: Optional[str] = Query(None), |
| 188 | current_user: Optional[dict] = Depends(get_current_user), |
| 189 | ): |
| 190 | try: |
| 191 | result = await query_metadata( |
| 192 | account=account, |
| 193 | container=container, |
| 194 | database_id=database_id, |
| 195 | min_frequency=min_frequency, |
| 196 | max_frequency=max_frequency, |
| 197 | author=author, |
| 198 | description=description, |
| 199 | label=label, |
| 200 | comment=comment, |
| 201 | captures_geo=captures_geo, |
| 202 | annotations_geo=annotations_geo, |
| 203 | min_datetime=min_datetime, |
| 204 | max_datetime=max_datetime, |
| 205 | text=text, |
| 206 | ) |
| 207 | |
| 208 | if not result: |
| 209 | return [] |
| 210 | |
| 211 | # Process result to remove metadata from unauthorized datasources |
| 212 | access_cache = {} |
| 213 | filtered_result = [] |
| 214 | |
| 215 | for item in result: |
| 216 | key = (item.account, item.container) |
| 217 | if key not in access_cache: |
| 218 | access_cache[key] = await check_access( |
| 219 | item.account, item.container, current_user |
| 220 | ) |
| 221 | |
| 222 | if access_cache[key] is not None: |
| 223 | filtered_result.append(item) |
| 224 | |
| 225 | return filtered_result |
| 226 | |
| 227 | except InvalidGeolocationFormat as e: |
| 228 | raise HTTPException(status_code=400, detail=str(e)) |
| 229 | |
| 230 | except Exception as e: |
nothing calls this directly
no test coverage detected