diff --git a/kowalski/api.py b/kowalski/api.py index 8a49f3ed..8ee07241 100644 --- a/kowalski/api.py +++ b/kowalski/api.py @@ -679,6 +679,7 @@ async def users_put(request: web.Request) -> web.Response: "aggregate", "info", "near", + "drop", ) INFO_COMMANDS = ( "catalog_names", @@ -1153,6 +1154,13 @@ async def post(self, request: web.Request) -> web.Response: "filter": {"objectId": "ZTF20aakyoez"} } + drop: + value: + "query_type": "drop" + "query": { + "catalog": "ZTF_alerts", + } + estimated_document_count: value: "query_type": "estimated_document_count" @@ -1265,6 +1273,12 @@ async def post(self, request: web.Request) -> web.Response: "message": "Successfully executed query" "data": 1 + drop: + value: + "status": "success" + "message": "Successfully dropped collection" + "data": 1 + estimated_document_count: value: "status": "success" @@ -1332,6 +1346,12 @@ async def post(self, request: web.Request) -> web.Response: # execute query, depending on query.query_type data = dict() + if query.query_type == "drop": + catalog = query.query["catalog"] + cursor = request.app["mongo"][catalog].drop() + data = await cursor + return self.success(message="Successfully dropped collection", data=data) + if query.query_type in ("cone_search", "near"): # iterate over catalogs for catalog in query.query: