Bug 17387: add deleted biblios restore api

Signed-off-by: Michaela <michaela.sieber@kit.edu>
Sponsored-by: ByWater Solutions
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Jacob O'Mara 2025-10-30 09:54:37 +00:00 committed by Lucas Gass
parent d7ce637ed4
commit 6272f438d5
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
2 changed files with 71 additions and 0 deletions

View File

@ -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;

View File

@ -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