3434)
3535from stac_fastapi .types .links import CollectionLinks
3636from stac_fastapi .types .stac import Collection , Collections , Item , ItemCollection
37+ from stac_fastapi .types .search import BaseSearchPostRequest
3738
3839logger = logging .getLogger (__name__ )
3940
@@ -91,7 +92,13 @@ async def get_collection(self, collection_id: str, **kwargs) -> Collection:
9192
9293 @overrides
9394 async def item_collection (
94- self , collection_id : str , limit : int = 10 , token : str = None , ** kwargs
95+ self ,
96+ collection_id : str ,
97+ bbox : Optional [List [NumType ]] = None ,
98+ datetime : Union [str , datetime_type , None ] = None ,
99+ limit : int = 10 ,
100+ token : str = None ,
101+ ** kwargs
95102 ) -> ItemCollection :
96103 """Read an item collection from the database."""
97104 request : Request = kwargs ["request" ]
@@ -236,7 +243,7 @@ async def get_search(
236243
237244 @overrides
238245 async def post_search (
239- self , search_request : stac_pydantic . api . Search , ** kwargs
246+ self , search_request : BaseSearchPostRequest , ** kwargs
240247 ) -> ItemCollection :
241248 """POST search catalog."""
242249 request : Request = kwargs ["request" ]
@@ -286,8 +293,8 @@ async def post_search(
286293 cql2_filter = getattr (search_request , "filter" , None )
287294 if filter_lang in [None , FilterLang .cql2_json ]:
288295 search = self .database .apply_cql2_filter (search , cql2_filter )
289- else :
290- raise Exception ("CQL2-Text is not supported with POST" )
296+ # else:
297+ # raise Exception("CQL2-Text is not supported with POST")
291298
292299 sort = None
293300 if search_request .sortby :
@@ -358,7 +365,7 @@ class TransactionsClient(AsyncBaseTransactionsClient):
358365 database = DatabaseLogic ()
359366
360367 @overrides
361- async def create_item (self , item : stac_types .Item , ** kwargs ) -> stac_types .Item :
368+ async def create_item (self , collection_id : str , item : stac_types .Item , ** kwargs ) -> stac_types .Item :
362369 """Create item."""
363370 base_url = str (kwargs ["request" ].base_url )
364371
@@ -368,9 +375,7 @@ async def create_item(self, item: stac_types.Item, **kwargs) -> stac_types.Item:
368375 processed_items = [
369376 bulk_client .preprocess_item (item , base_url ) for item in item ["features" ] # type: ignore
370377 ]
371-
372- # not a great way to get the collection_id-- should be part of the method signature
373- collection_id = processed_items [0 ]["collection" ]
378+
374379 await self .database .bulk_async (
375380 collection_id , processed_items , refresh = kwargs .get ("refresh" , False )
376381 )
@@ -382,18 +387,17 @@ async def create_item(self, item: stac_types.Item, **kwargs) -> stac_types.Item:
382387 return item
383388
384389 @overrides
385- async def update_item (self , item : stac_types .Item , ** kwargs ) -> stac_types .Item :
390+ async def update_item (self , collection_id : str , item_id : str , item : stac_types .Item , ** kwargs ) -> stac_types .Item :
386391 """Update item."""
387392 base_url = str (kwargs ["request" ].base_url )
388- collection_id = item ["collection" ]
389393
390394 now = datetime_type .now (timezone .utc ).isoformat ().replace ("+00:00" , "Z" )
391395 item ["properties" ]["updated" ] = str (now )
392396
393397 await self .database .check_collection_exists (collection_id )
394398 # todo: index instead of delete and create
395- await self .delete_item (item_id = item [ "id" ] , collection_id = collection_id )
396- await self .create_item (item = item , ** kwargs )
399+ await self .delete_item (item_id = item_id , collection_id = collection_id )
400+ await self .create_item (collection_id = collection_id , item = item , ** kwargs )
397401
398402 return ItemSerializer .db_to_stac (item , base_url )
399403
0 commit comments