99
1010from stac_fastapi .elasticsearch import serializers
1111from stac_fastapi .elasticsearch .config import ElasticsearchSettings
12- from stac_fastapi .types import stac as stac_types
1312from stac_fastapi .types .errors import ConflictError , ForeignKeyError , NotFoundError
1413from stac_fastapi .types .stac import Collection , Collections , Item , ItemCollection
1514
@@ -65,11 +64,6 @@ def get_all_collections(self, base_url: str) -> Collections:
6564
6665 return serialized_collections
6766
68- def get_one_collection (self , collection_id : str ) -> Collection :
69- """Database logic to retrieve a single collection."""
70- collection = self .find_collection (collection_id = collection_id )
71- return collection ["_source" ]
72-
7367 def get_item_collection (
7468 self , collection_id : str , limit : int , base_url : str
7569 ) -> ItemCollection :
@@ -235,7 +229,7 @@ def check_collection_exists(self, collection_id: str):
235229 if not self .client .exists (index = COLLECTIONS_INDEX , id = collection_id ):
236230 raise ForeignKeyError (f"Collection { collection_id } does not exist" )
237231
238- def prep_create_item (self , item : stac_types . Item , base_url : str ) -> stac_types . Item :
232+ def prep_create_item (self , item : Item , base_url : str ) -> Item :
239233 """Database logic for prepping an item for insertion."""
240234 self .check_collection_exists (collection_id = item ["collection" ])
241235
@@ -248,7 +242,7 @@ def prep_create_item(self, item: stac_types.Item, base_url: str) -> stac_types.I
248242
249243 return self .item_serializer .stac_to_db (item , base_url )
250244
251- def create_item (self , item : stac_types . Item , base_url : str ):
245+ def create_item (self , item : Item , base_url : str ):
252246 """Database logic for creating one item."""
253247 # todo: check if collection exists, but cache
254248 es_resp = self .client .index (
@@ -262,10 +256,6 @@ def create_item(self, item: stac_types.Item, base_url: str):
262256 f"Item { item ['id' ]} in collection { item ['collection' ]} already exists"
263257 )
264258
265- def prep_update_item (self , item : stac_types .Item ):
266- """Database logic for prepping an item for updating."""
267- self .check_collection_exists (collection_id = item ["collection" ])
268-
269259 def delete_item (self , item_id : str , collection_id : str ):
270260 """Database logic for deleting one item."""
271261 try :
@@ -275,7 +265,7 @@ def delete_item(self, item_id: str, collection_id: str):
275265 f"Item { item_id } in collection { collection_id } not found"
276266 )
277267
278- def create_collection (self , collection : stac_types . Collection ):
268+ def create_collection (self , collection : Collection ):
279269 """Database logic for creating one collection."""
280270 if self .client .exists (index = COLLECTIONS_INDEX , id = collection ["id" ]):
281271 raise ConflictError (f"Collection { collection ['id' ]} already exists" )
@@ -286,7 +276,7 @@ def create_collection(self, collection: stac_types.Collection):
286276 document = collection ,
287277 )
288278
289- def find_collection (self , collection_id : str ) -> stac_types . Collection :
279+ def find_collection (self , collection_id : str ) -> Collection :
290280 """Database logic to find and return a collection."""
291281 try :
292282 collection = self .client .get (index = COLLECTIONS_INDEX , id = collection_id )
@@ -295,10 +285,6 @@ def find_collection(self, collection_id: str) -> stac_types.Collection:
295285
296286 return collection
297287
298- def prep_update_collection (self , collection_id : str ):
299- """Database logic for prepping a collection for updating."""
300- _ = self .find_collection (collection_id = collection_id )
301-
302288 def delete_collection (self , collection_id : str ):
303289 """Database logic for deleting one collection."""
304290 _ = self .find_collection (collection_id = collection_id )
0 commit comments