From bf78a0dea97a4521c51ae2f82e9824812ef75e67 Mon Sep 17 00:00:00 2001 From: Jacob O'Mara Date: Thu, 30 Oct 2025 09:54:37 +0000 Subject: [PATCH] Bug 17387: add deleted biblios restore api Signed-off-by: Michaela --- Koha/REST/V1/DeletedBiblios.pm | 26 +++++++++++++ api/v1/swagger/paths/deleted_biblios.yaml | 45 +++++++++++++++++++++++ 2 files changed, 71 insertions(+) diff --git a/Koha/REST/V1/DeletedBiblios.pm b/Koha/REST/V1/DeletedBiblios.pm index 30c94eff22..74c62a8d6a 100644 --- a/Koha/REST/V1/DeletedBiblios.pm +++ b/Koha/REST/V1/DeletedBiblios.pm @@ -165,4 +165,30 @@ sub list { }; } +=head3 restore + +Controller function that handles restoring a single deleted biblio object + +=cut + +sub restore { + my $c = shift->openapi->valid_input or return; + + my $deleted_biblio = Koha::Old::Biblios->find( $c->param('biblio_id') ); + + return $c->render_resource_not_found("Bibliographic record") + unless $deleted_biblio; + + return try { + my $biblio = $deleted_biblio->restore; + + return $c->render( + status => 200, + openapi => { biblio_id => $biblio->biblionumber } + ); + } catch { + $c->unhandled_exception($_); + }; +} + 1; diff --git a/api/v1/swagger/paths/deleted_biblios.yaml b/api/v1/swagger/paths/deleted_biblios.yaml index f4fcae318f..dff1890ea9 100644 --- a/api/v1/swagger/paths/deleted_biblios.yaml +++ b/api/v1/swagger/paths/deleted_biblios.yaml @@ -118,3 +118,48 @@ x-koha-authorization: permissions: catalogue: "1" + put: + x-mojo-to: DeletedBiblios#restore + operationId: restoreDeletedBiblio + tags: + - biblios + summary: Restore deleted biblio + parameters: + - $ref: "../swagger.yaml#/parameters/biblio_id_pp" + produces: + - application/json + responses: + "200": + description: Biblio restored successfully + schema: + type: object + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" + "401": + description: Authentication required + schema: + $ref: "../swagger.yaml#/definitions/error" + "403": + description: Access forbidden + schema: + $ref: "../swagger.yaml#/definitions/error" + "404": + description: Deleted bibliographic record not found + schema: + $ref: "../swagger.yaml#/definitions/error" + "500": + description: | + Internal server error. Possible `error_code` attribute values: + + * `internal_server_error` + schema: + $ref: "../swagger.yaml#/definitions/error" + "503": + description: Under maintenance + schema: + $ref: "../swagger.yaml#/definitions/error" + x-koha-authorization: + permissions: + editcatalogue: edit_catalogue -- 2.39.5