|
22 | 22 | LinkType,
|
23 | 23 | )
|
24 | 24 | from models_library.api_schemas_webserver.storage import (
|
| 25 | + BatchDeletePathsBodyParams, |
25 | 26 | DataExportPost,
|
| 27 | + StorageLocationPathParams, |
26 | 28 | StoragePathComputeSizeParams,
|
27 | 29 | )
|
28 | 30 | from models_library.projects_nodes_io import LocationID
|
|
42 | 44 | from servicelib.rabbitmq.rpc_interfaces.storage.paths import (
|
43 | 45 | compute_path_size as remote_compute_path_size,
|
44 | 46 | )
|
| 47 | +from servicelib.rabbitmq.rpc_interfaces.storage.paths import ( |
| 48 | + delete_paths as remote_delete_paths, |
| 49 | +) |
45 | 50 | from servicelib.request_keys import RQT_USERID_KEY
|
46 | 51 | from servicelib.rest_responses import unwrap_envelope
|
47 | 52 | from yarl import URL
|
@@ -206,6 +211,41 @@ async def compute_path_size(request: web.Request) -> web.Response:
|
206 | 211 | )
|
207 | 212 |
|
208 | 213 |
|
| 214 | +@routes.post( |
| 215 | + f"{_storage_locations_prefix}/{{location_id}}/-/paths:batchDelete", |
| 216 | + name="batch_delete_paths", |
| 217 | +) |
| 218 | +@login_required |
| 219 | +@permission_required("storage.files.*") |
| 220 | +async def batch_delete_paths( |
| 221 | + request: web.Request, |
| 222 | +): |
| 223 | + req_ctx = RequestContext.model_validate(request) |
| 224 | + path_params = parse_request_path_parameters_as(StorageLocationPathParams, request) |
| 225 | + body = await parse_request_body_as(BatchDeletePathsBodyParams, request) |
| 226 | + |
| 227 | + rabbitmq_rpc_client = get_rabbitmq_rpc_client(request.app) |
| 228 | + async_job, _ = await remote_delete_paths( |
| 229 | + rabbitmq_rpc_client, |
| 230 | + user_id=req_ctx.user_id, |
| 231 | + product_name=req_ctx.product_name, |
| 232 | + location_id=path_params.location_id, |
| 233 | + paths=body.paths, |
| 234 | + ) |
| 235 | + |
| 236 | + _job_id = f"{async_job.job_id}" |
| 237 | + return create_data_response( |
| 238 | + TaskGet( |
| 239 | + task_id=_job_id, |
| 240 | + task_name=_job_id, |
| 241 | + status_href=f"{request.url.with_path(str(request.app.router['get_async_job_status'].url_for(task_id=_job_id)))}", |
| 242 | + abort_href=f"{request.url.with_path(str(request.app.router['abort_async_job'].url_for(task_id=_job_id)))}", |
| 243 | + result_href=f"{request.url.with_path(str(request.app.router['get_async_job_result'].url_for(task_id=_job_id)))}", |
| 244 | + ), |
| 245 | + status=status.HTTP_202_ACCEPTED, |
| 246 | + ) |
| 247 | + |
| 248 | + |
209 | 249 | @routes.get(
|
210 | 250 | _storage_locations_prefix + "/{location_id}/datasets", name="list_datasets_metadata"
|
211 | 251 | )
|
|
0 commit comments