Bugzilla – Attachment 174808 Details for
Bug 38050
Add REST endpoints for working with "lists"/"virtual shelves"
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 38050: create methods for admin CRUD list endpoints
Bug-38050-create-methods-for-admin-CRUD-list-endpo.patch (text/plain), 3.83 KB, created by
Jacob O'Mara
on 2024-11-19 19:17:53 UTC
(
hide
)
Description:
Bug 38050: create methods for admin CRUD list endpoints
Filename:
MIME Type:
Creator:
Jacob O'Mara
Created:
2024-11-19 19:17:53 UTC
Size:
3.83 KB
patch
obsolete
>From a75fee0ae5aadb7565d8d6ef23ded43121c5aa7e Mon Sep 17 00:00:00 2001 >From: Jacob O'Mara <jacobomara901@gmail.com> >Date: Tue, 29 Oct 2024 10:59:03 +0000 >Subject: [PATCH] Bug 38050: create methods for admin CRUD list endpoints > >This patch implements the methods for the admin CRUD endpoints for lists/virtualshelves >--- > Koha/REST/V1/Lists.pm | 112 ++++++++++++++++++++++++++++++++++-- > api/v1/swagger/swagger.yaml | 4 +- > 2 files changed, 110 insertions(+), 6 deletions(-) > >diff --git a/Koha/REST/V1/Lists.pm b/Koha/REST/V1/Lists.pm >index a557627e7e..2fef438abc 100644 >--- a/Koha/REST/V1/Lists.pm >+++ b/Koha/REST/V1/Lists.pm >@@ -16,17 +16,122 @@ package Koha::REST::V1::Lists; > # along with Koha; if not, see <http://www.gnu.org/licenses>. > > use Modern::Perl; >- > use Mojo::Base 'Mojolicious::Controller'; >- > use Koha::Virtualshelves; >- > use Try::Tiny qw( catch try ); > >+use Data::Dumper; >+ > =head1 API > > =head2 Methods > >+=head3 list >+ >+List all virtual shelves >+ >+=cut >+ >+sub list { >+ my $c = shift->openapi->valid_input or return; >+ >+ return try { >+ my $lists = $c->objects->search( Koha::Virtualshelves->new ); >+ return $c->render( status => 200, openapi => $lists ); >+ } catch { >+ $c->unhandled_exception($_); >+ }; >+ >+} >+ >+=head3 read >+ >+List the contents of a virtual shelf >+ >+=cut >+ >+sub read { >+ my $c = shift->openapi->valid_input or return; >+ >+ return try { >+ my $list_id = Koha::Virtualshelves->find( $c->param('list_id') ); >+ return $c->render_resource_not_found("list_id") >+ unless $list_id; >+ >+ return $c->render( status => 200, openapi => $c->objects->to_api($list_id), ); >+ } catch { >+ $c->unhandled_exception($_); >+ }; >+} >+ >+=head3 create >+ >+Create a virtual shelf >+ >+=cut >+ >+sub create { >+ my $c = shift->openapi->valid_input or return; >+ >+ return try { >+ >+ my $list = Koha::Virtualshelf->new_from_api( $c->req->json ); >+ $list->store->discard_changes; >+ $c->res->headers->location( $c->req->url->to_string . '/' . $list->id ); >+ return $c->render( >+ status => 201, >+ openapi => $c->objects->to_api($list), >+ ); >+ } catch { >+ $c->unhandled_exception($_); >+ }; >+} >+ >+=head3 update >+ >+Update a virtual shelf >+ >+=cut >+ >+sub update { >+ my $c = shift->openapi->valid_input or return; >+ >+ my $list = Koha::Virtualshelves->find( $c->param('list_id') ); >+ >+ return $c->render_resource_not_found("List") >+ unless $list; >+ >+ return try { >+ $list->set_from_api( $c->req->json ); >+ $list->store(); >+ return $c->render( status => 200, openapi => $c->objects->to_api($list), ); >+ } catch { >+ $c->unhandled_exception($_); >+ }; >+} >+ >+=head3 delete >+ >+Delete a virtual shelf if it exists >+ >+=cut >+ >+sub delete { >+ my $c = shift->openapi->valid_input or return; >+ >+ my $list = Koha::Virtualshelves->find( $c->param('list_id') ); >+ >+ return $c->render_resource_not_found("List") >+ unless $list; >+ >+ return try { >+ $list->delete; >+ return $c->render_resource_deleted; >+ } catch { >+ $c->unhandled_exception($_); >+ }; >+} >+ > =head3 list_public > > =cut >@@ -73,5 +178,4 @@ sub list_public { > $c->unhandled_exception($_); > }; > } >- > 1; >diff --git a/api/v1/swagger/swagger.yaml b/api/v1/swagger/swagger.yaml >index 51ed2bb3e9..307a0059e2 100644 >--- a/api/v1/swagger/swagger.yaml >+++ b/api/v1/swagger/swagger.yaml >@@ -447,8 +447,8 @@ paths: > $ref: "./paths/libraries.yaml#/~1libraries~1{library_id}~1desks" > /lists: > $ref: ./paths/lists.yaml#/~1lists >- "/lists/{id}": >- $ref: "./paths/lists.yaml#/~1lists~1{id}" >+ "/lists/{list_id}": >+ $ref: "./paths/lists.yaml#/~1lists~1{list_id}" > "/oauth/login/{provider_code}/{interface}": > $ref: ./paths/oauth.yaml#/~1oauth~1login~1{provider_code}~1{interface} > /oauth/token: >-- >2.39.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 38050
:
174807
|
174808
|
174809
|
174810
|
176462
|
176463
|
176464
|
176465
|
176466
|
176467
|
176769
|
176770
|
176771
|
176772
|
176773
|
176774
|
180788
|
180789
|
180790
|
180791
|
180792
|
180793
|
180838
|
180839
|
180840
|
180841
|
180842
|
180843
|
180879
|
180880
|
180881
|
180882
|
180883
|
180884