@@ -67,11 +67,7 @@ def get_all_collections(self, base_url: str) -> Collections:
67
67
68
68
def get_one_collection (self , collection_id : str ) -> Collection :
69
69
"""Database logic to retrieve a single collection."""
70
- try :
71
- collection = self .client .get (index = COLLECTIONS_INDEX , id = collection_id )
72
- except elasticsearch .exceptions .NotFoundError :
73
- raise NotFoundError (f"Collection { collection_id } not found" )
74
-
70
+ collection = self .find_collection (collection_id = collection_id )
75
71
return collection ["_source" ]
76
72
77
73
def get_item_collection (
@@ -287,19 +283,22 @@ def create_collection(self, collection: stac_types.Collection):
287
283
document = collection ,
288
284
)
289
285
290
- def prep_update_collection (self , collection_id : str ):
291
- """Database logic for prepping a collection for updating ."""
286
+ def find_collection (self , collection_id : str ) -> stac_types . Collection :
287
+ """Database logic to find and return a collection ."""
292
288
try :
293
- _ = self .client .get (index = COLLECTIONS_INDEX , id = collection_id )
289
+ collection = self .client .get (index = COLLECTIONS_INDEX , id = collection_id )
294
290
except elasticsearch .exceptions .NotFoundError :
295
291
raise NotFoundError (f"Collection { collection_id } not found" )
296
292
293
+ return collection
294
+
295
+ def prep_update_collection (self , collection_id : str ):
296
+ """Database logic for prepping a collection for updating."""
297
+ _ = self .find_collection (collection_id = collection_id )
298
+
297
299
def delete_collection (self , collection_id : str ):
298
300
"""Database logic for deleting one collection."""
299
- try :
300
- _ = self .client .get (index = COLLECTIONS_INDEX , id = collection_id )
301
- except elasticsearch .exceptions .NotFoundError :
302
- raise NotFoundError (f"Collection { collection_id } not found" )
301
+ _ = self .find_collection (collection_id = collection_id )
303
302
self .client .delete (index = COLLECTIONS_INDEX , id = collection_id )
304
303
305
304
def bulk_sync (self , processed_items ):
0 commit comments