From 81655e7dbf6d769219260828b6f4781435efca1c Mon Sep 17 00:00:00 2001 From: Josef Moravec Date: Wed, 22 Jan 2020 14:21:33 +0000 Subject: [PATCH] Bug 22615: Add endpoint for getting one ill backend Signed-off-by: Andrew Isherwood Signed-off-by: Kyle M Hall Signed-off-by: Martin Renvoize --- Koha/REST/V1/Illbackends.pm | 28 ++++++++++++ api/v1/swagger/definitions.json | 3 ++ api/v1/swagger/paths.json | 3 ++ api/v1/swagger/paths/ill_backends.json | 62 ++++++++++++++++++++++++++ 4 files changed, 96 insertions(+) diff --git a/Koha/REST/V1/Illbackends.pm b/Koha/REST/V1/Illbackends.pm index 01cdd9e5e0..15807e9dd9 100644 --- a/Koha/REST/V1/Illbackends.pm +++ b/Koha/REST/V1/Illbackends.pm @@ -51,4 +51,32 @@ sub list { return $c->render( status => 200, openapi => \@data ); } +=head3 get + +Get one backend + +=cut + +sub get { + my $c = shift->openapi->valid_input; + + my $backend_id = $c->validation->param('ill_backend_id'); + + return try { + my $backend = Koha::Illrequest->new->load_backend( $backend_id ); + return $c->render( + status => 200, + openapi => { + ill_backend_id => $backend_id, + capabilities => $backend->capabilities + } + ); + } catch { + return $c->render( + status => 404, + openapi => { error => "ILL backend does not exist" } + ); + }; +} + 1; diff --git a/api/v1/swagger/definitions.json b/api/v1/swagger/definitions.json index 26765383e7..4b21d32f32 100644 --- a/api/v1/swagger/definitions.json +++ b/api/v1/swagger/definitions.json @@ -35,6 +35,9 @@ "ill_backends": { "$ref": "definitions/ill_backends.json" }, + "ill_backend": { + "$ref": "definitions/ill_backend.json" + }, "library": { "$ref": "definitions/library.json" }, diff --git a/api/v1/swagger/paths.json b/api/v1/swagger/paths.json index c4a16f8a6f..0631ecb53b 100644 --- a/api/v1/swagger/paths.json +++ b/api/v1/swagger/paths.json @@ -86,6 +86,9 @@ "/ill_backends": { "$ref": "paths/ill_backends.json#/~1ill_backends" }, + "/ill_backends/{ill_backend_id}": { + "$ref": "paths/ill_backends.json#/~1ill_backends~1{ill_backend_id}" + }, "/illrequests": { "$ref": "paths/illrequests.json#/~1illrequests" }, diff --git a/api/v1/swagger/paths/ill_backends.json b/api/v1/swagger/paths/ill_backends.json index a14c3d651e..ca895ddd0c 100644 --- a/api/v1/swagger/paths/ill_backends.json +++ b/api/v1/swagger/paths/ill_backends.json @@ -52,5 +52,67 @@ } } } + }, + "/ill_backends/{ill_backend_id}": { + "get": { + "x-mojo-to": "Illbackends#get", + "operationId": "getIllbackends", + "tags": ["illbackends"], + "parameters": [ + { + "name": "ill_backend_id", + "in": "path", + "description": "ILL backend id/name", + "required": true, + "type": "string" + } + ], + "produces": [ + "application/json" + ], + "responses": { + "200": { + "description": "An ILL backends", + "schema": { + "$ref": "../definitions.json#/ill_backend" + } + }, + "401": { + "description": "Authentication required", + "schema": { + "$ref": "../definitions.json#/error" + } + }, + "403": { + "description": "Access forbidden", + "schema": { + "$ref": "../definitions.json#/error" + } + }, + "404": { + "description": "ILL backends not found", + "schema": { + "$ref": "../definitions.json#/error" + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "../definitions.json#/error" + } + }, + "503": { + "description": "Under maintenance", + "schema": { + "$ref": "../definitions.json#/error" + } + } + }, + "x-koha-authorization": { + "permissions": { + "ill": "1" + } + } + } } } -- 2.39.5