1
0
mirror of https://github.com/bitwarden/server synced 2025-12-16 08:13:33 +00:00

Add support for destroying seeded data

This commit is contained in:
Hinton
2025-10-07 14:59:17 -07:00
parent 2b340b72da
commit 79f5d8f147
4 changed files with 83 additions and 13 deletions

View File

@@ -64,9 +64,43 @@ public class SeedController : Controller
}
}
[HttpGet("/delete")]
public string Delete()
[HttpDelete("/delete")]
public IActionResult Delete([FromBody] SeedRequestModel request)
{
return "hello delete";
_logger.LogInformation("Deleting with template: {Template}", request.Template);
try
{
var result = _recipeService.DestroyRecipe(request.Template, request.Arguments);
return Ok(new
{
Message = "Delete completed successfully",
request.Template,
Result = result
});
}
catch (RecipeNotFoundException ex)
{
return NotFound(new { Error = ex.Message });
}
catch (RecipeExecutionException ex)
{
_logger.LogError(ex, "Error executing recipe delete: {Template}", request.Template);
return BadRequest(new
{
Error = ex.Message,
Details = ex.InnerException?.Message
});
}
catch (Exception ex)
{
_logger.LogError(ex, "Unexpected error deleting with template: {Template}", request.Template);
return StatusCode(500, new
{
Error = "An unexpected error occurred while deleting",
Details = ex.Message
});
}
}
}