Skip to content

Commit ad6f393

Browse files
committed
create collection
1 parent 2225e76 commit ad6f393

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/database_logic.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,3 +273,13 @@ def delete_item(self, item_id: str, collection_id: str):
273273
f"Item {item_id} in collection {collection_id} not found"
274274
)
275275

276+
def create_collection(self, collection: stac_types.Collection):
277+
if self.client.exists(index=COLLECTIONS_INDEX, id=collection["id"]):
278+
raise ConflictError(f"Collection {collection['id']} already exists")
279+
280+
self.client.index(
281+
index=COLLECTIONS_INDEX,
282+
id=collection["id"],
283+
document=collection,
284+
)
285+

stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/transactions.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,8 @@ def create_collection(
9191
collection_id=collection["id"], base_url=base_url
9292
).create_links()
9393
collection["links"] = collection_links
94+
self.database.create_collection(collection=collection)
9495

95-
if self.client.exists(index=COLLECTIONS_INDEX, id=collection["id"]):
96-
raise ConflictError(f"Collection {collection['id']} already exists")
97-
98-
self.client.index(
99-
index=COLLECTIONS_INDEX,
100-
id=collection["id"],
101-
document=collection,
102-
)
10396
return CollectionSerializer.db_to_stac(collection, base_url)
10497

10598
@overrides

0 commit comments

Comments
 (0)