9
9
10
10
from stac_fastapi .elasticsearch import serializers
11
11
from stac_fastapi .elasticsearch .config import ElasticsearchSettings
12
- from stac_fastapi .types import stac as stac_types
13
12
from stac_fastapi .types .errors import ConflictError , ForeignKeyError , NotFoundError
14
13
from stac_fastapi .types .stac import Collection , Collections , Item , ItemCollection
15
14
@@ -65,11 +64,6 @@ def get_all_collections(self, base_url: str) -> Collections:
65
64
66
65
return serialized_collections
67
66
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
-
73
67
def get_item_collection (
74
68
self , collection_id : str , limit : int , base_url : str
75
69
) -> ItemCollection :
@@ -235,7 +229,7 @@ def check_collection_exists(self, collection_id: str):
235
229
if not self .client .exists (index = COLLECTIONS_INDEX , id = collection_id ):
236
230
raise ForeignKeyError (f"Collection { collection_id } does not exist" )
237
231
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 :
239
233
"""Database logic for prepping an item for insertion."""
240
234
self .check_collection_exists (collection_id = item ["collection" ])
241
235
@@ -248,7 +242,7 @@ def prep_create_item(self, item: stac_types.Item, base_url: str) -> stac_types.I
248
242
249
243
return self .item_serializer .stac_to_db (item , base_url )
250
244
251
- def create_item (self , item : stac_types . Item , base_url : str ):
245
+ def create_item (self , item : Item , base_url : str ):
252
246
"""Database logic for creating one item."""
253
247
# todo: check if collection exists, but cache
254
248
es_resp = self .client .index (
@@ -262,10 +256,6 @@ def create_item(self, item: stac_types.Item, base_url: str):
262
256
f"Item { item ['id' ]} in collection { item ['collection' ]} already exists"
263
257
)
264
258
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
-
269
259
def delete_item (self , item_id : str , collection_id : str ):
270
260
"""Database logic for deleting one item."""
271
261
try :
@@ -275,7 +265,7 @@ def delete_item(self, item_id: str, collection_id: str):
275
265
f"Item { item_id } in collection { collection_id } not found"
276
266
)
277
267
278
- def create_collection (self , collection : stac_types . Collection ):
268
+ def create_collection (self , collection : Collection ):
279
269
"""Database logic for creating one collection."""
280
270
if self .client .exists (index = COLLECTIONS_INDEX , id = collection ["id" ]):
281
271
raise ConflictError (f"Collection { collection ['id' ]} already exists" )
@@ -286,7 +276,7 @@ def create_collection(self, collection: stac_types.Collection):
286
276
document = collection ,
287
277
)
288
278
289
- def find_collection (self , collection_id : str ) -> stac_types . Collection :
279
+ def find_collection (self , collection_id : str ) -> Collection :
290
280
"""Database logic to find and return a collection."""
291
281
try :
292
282
collection = self .client .get (index = COLLECTIONS_INDEX , id = collection_id )
@@ -295,10 +285,6 @@ def find_collection(self, collection_id: str) -> stac_types.Collection:
295
285
296
286
return collection
297
287
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
-
302
288
def delete_collection (self , collection_id : str ):
303
289
"""Database logic for deleting one collection."""
304
290
_ = self .find_collection (collection_id = collection_id )
0 commit comments