Bug 31801 - Add PUT endpoint for Biblios
Summary: Add PUT endpoint for Biblios
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: REST API (show other bugs)
Version: Main
Hardware: All All
: P5 - low new feature (vote)
Assignee: Agustín Moyano
QA Contact: Kyle M Hall
URL:
Keywords:
: 30799 (view as bug list)
Depends on: 31800
Blocks: 35380 31788 32734
  Show dependency treegraph
 
Reported: 2022-10-14 14:41 UTC by Nick Clemens
Modified: 2023-11-21 22:04 UTC (History)
12 users (show)

See Also:
Change sponsored?: Sponsored
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
23.05.00,22.11.04


Attachments
Bug 31801: Add REST endpoint to modify a biblio (21.84 KB, patch)
2022-12-23 21:42 UTC, Agustín Moyano
Details | Diff | Splinter Review
Bug 31801: Add REST endpoint to modify a biblio (17.46 KB, patch)
2022-12-26 13:38 UTC, Agustín Moyano
Details | Diff | Splinter Review
Bug 31801: Add REST endpoint to modify a biblio (17.52 KB, patch)
2022-12-26 15:09 UTC, Agustín Moyano
Details | Diff | Splinter Review
Bug 31801: Add REST endpoint to modify a biblio (17.57 KB, patch)
2023-02-22 13:36 UTC, Hammat wele
Details | Diff | Splinter Review
Bug 31801: Add REST endpoint to modify a biblio (17.62 KB, patch)
2023-03-03 16:55 UTC, Kyle M Hall
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Nick Clemens 2022-10-14 14:41:59 UTC

    
Comment 1 Agustín Moyano 2022-12-23 21:42:52 UTC Comment hidden (obsolete)
Comment 2 Agustín Moyano 2022-12-26 13:38:38 UTC Comment hidden (obsolete)
Comment 3 Agustín Moyano 2022-12-26 15:09:15 UTC
Created attachment 144838 [details] [review]
Bug 31801: Add REST endpoint to modify a biblio

To test:
1. Apply patch
2. Set RESTBasicAuth preference to true
3. Pick a biblio to modify, and modify it's marc record
4. Make a PUT request to /api/v1/biblios/:biblionumber with one of the following content type header
  - application/marcxml+xml
  - application/marc-in-json
  - application/marc
5. Add the following header in the request 'x-framework-id: <framework id>'
5. Check that the biblio was modified
6. Sign off
Comment 4 Jan Kissig 2023-01-04 14:08:47 UTC
Great that this route is going to be implemented in core. 
There is plugin available at https://github.com/NatLibFi/koha-plugin-rest-biblios.

I found that if  MARCOverlayRules are used, f.e. protect field 100 from being overwritten, the field is overwritten if api is used.

Can you verify this?

A modified test plan would be
1. Apply patch
2. Set RESTBasicAuth preference to true
3. Add Marc overlay rule in administration / MARC overlay rules 
  module = source
  filter = *
  tag = 001
  preset = protect
4. Set MARCOverlayRules to Use in system prefs
5. Pick a biblio to modify, and modify it's marc record especially field 001
6. Make a PUT request to /api/v1/biblios/:biblionumber with one of the following content type header
  - application/marcxml+xml
  - application/marc-in-json
  - application/marc
7. Add the following header in the request 'x-framework-id: <framework id>'
8. Check that the biblio was modified but not field 001
Comment 5 Jan Kissig 2023-01-13 12:46:10 UTC
To respect MARCOverlayRules the call of ModBiblio could be extended like this:

ModBiblio( $record, $biblionumber, $frameworkcode, { overlay_context => { source => 'API biblios' } } );

Shall i write another patch or can you change the line?
Comment 6 Hammat wele 2023-02-22 13:36:44 UTC
Created attachment 147146 [details] [review]
Bug 31801: Add REST endpoint to modify a biblio

To test:
1. Apply patch
2. Set RESTBasicAuth preference to true
3. Pick a biblio to modify, and modify it's marc record
4. Make a PUT request to /api/v1/biblios/:biblionumber with one of the following content type header
  - application/marcxml+xml
  - application/marc-in-json
  - application/marc
5. Add the following header in the request 'x-framework-id: <framework id>'
5. Check that the biblio was modified
6. Sign off

Signed-off-by: Hammat Wele <hammat.wele@inlibro.com>
Comment 7 Kyle M Hall 2023-03-03 16:55:27 UTC
Created attachment 147718 [details] [review]
Bug 31801: Add REST endpoint to modify a biblio

To test:
1. Apply patch
2. Set RESTBasicAuth preference to true
3. Pick a biblio to modify, and modify it's marc record
4. Make a PUT request to /api/v1/biblios/:biblionumber with one of the following content type header
  - application/marcxml+xml
  - application/marc-in-json
  - application/marc
5. Add the following header in the request 'x-framework-id: <framework id>'
5. Check that the biblio was modified
6. Sign off

Signed-off-by: Hammat Wele <hammat.wele@inlibro.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 8 Jan Kissig 2023-03-08 10:33:26 UTC
I am sorry to ask again (see comment #4 & #5). Shouldn't this route respect MARCOverlayRules, if set in Administration?
Comment 9 Katrin Fischer 2023-03-08 10:38:53 UTC
(In reply to Jan Kissig from comment #5)
> To respect MARCOverlayRules the call of ModBiblio could be extended like
> this:
> 
> ModBiblio( $record, $biblionumber, $frameworkcode, { overlay_context => {
> source => 'API biblios' } } );
> 
> Shall i write another patch or can you change the line?

Since Jan already provided the solution - how can we best move forward here? I agree that the rules should be respected.

Maybe we could move the change to a separate bug and also extend the 'filters' pull-down list on the overly rules administration page with an API entry. Not sure if a new source needs to be defined in other spots as well.
Comment 10 Tomás Cohen Arazi 2023-03-08 11:19:03 UTC
(In reply to Katrin Fischer from comment #9)
> (In reply to Jan Kissig from comment #5)
> > To respect MARCOverlayRules the call of ModBiblio could be extended like
> > this:
> > 
> > ModBiblio( $record, $biblionumber, $frameworkcode, { overlay_context => {
> > source => 'API biblios' } } );
> > 
> > Shall i write another patch or can you change the line?
> 
> Since Jan already provided the solution - how can we best move forward here?
> I agree that the rules should be respected.
> 
> Maybe we could move the change to a separate bug and also extend the
> 'filters' pull-down list on the overly rules administration page with an API
> entry. Not sure if a new source needs to be defined in other spots as well.

I agree, but this is gonna be more complex :-D

We are adding a new table for record sources on bug 32607
Comment 11 Tomás Cohen Arazi 2023-03-08 13:14:23 UTC
(In reply to Jan Kissig from comment #5)
> To respect MARCOverlayRules the call of ModBiblio could be extended like
> this:
> 
> ModBiblio( $record, $biblionumber, $frameworkcode, { overlay_context => {
> source => 'API biblios' } } );

This is an interesting point. If we think we will eventually replace our current code with an API-driven UI, having an 'API biblios' record source doesn't feel useful.

That's why we are introducing the concept of configurable record sources on bug 32607. With that in mind, the record source will be undefined in case of regular cataloguing, or a specific one based on a header with an allow list of users that can impersonate the record source.

Once we have that, we can move the cataloguing sources in the MARC overlay rules pages into the record sources tables, and adapt the code so it is used from there.
Comment 12 Jan Kissig 2023-03-08 18:46:29 UTC
(In reply to Tomás Cohen Arazi from comment #11)
> (In reply to Jan Kissig from comment #5)
> > To respect MARCOverlayRules the call of ModBiblio could be extended like
> > this:
> > 
> > ModBiblio( $record, $biblionumber, $frameworkcode, { overlay_context => {
> > source => 'API biblios' } } );
> 
> This is an interesting point. If we think we will eventually replace our
> current code with an API-driven UI, having an 'API biblios' record source
> doesn't feel useful.
> 
> That's why we are introducing the concept of configurable record sources on
> bug 32607. With that in mind, the record source will be undefined in case of
> regular cataloguing, or a specific one based on a header with an allow list
> of users that can impersonate the record source.
> 
> Once we have that, we can move the cataloguing sources in the MARC overlay
> rules pages into the record sources tables, and adapt the code so it is used
> from there.

source => 'API biblios' in my comment #5 was just something like a placeholder for me and I didn't find anything that suited for the API routes. But without overlay_context any MARC overlay rules will be checked.
Comment 13 Tomás Cohen Arazi 2023-03-13 18:13:36 UTC
Pushed to master for 22.11.

Nice work everyone, thanks!
Comment 14 Jacob O'Mara 2023-03-16 19:49:03 UTC
Nice work, thanks everyone!

Pushed to 22.11.x for the next release.
Comment 15 Julian Maurice 2023-03-23 15:05:58 UTC
*** Bug 30799 has been marked as a duplicate of this bug. ***
Comment 16 Lucas Gass 2023-04-14 18:20:55 UTC
Enhancement will no be backported to 22.05.x