From ca57c618fee732fa18e8eb2aa6201715f98995e4 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 --- 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 009f61e2eb..d9d2ba30c2 100644 --- a/api/v1/swagger/definitions.json +++ b/api/v1/swagger/definitions.json @@ -32,6 +32,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 6b75af3873..35f33ececc 100644 --- a/api/v1/swagger/paths.json +++ b/api/v1/swagger/paths.json @@ -83,6 +83,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.11.0