Bug 32734

Summary: Add GET endpoint for listing Biblios
Product: Koha Reporter: Nick Clemens <nick>
Component: REST APIAssignee: Agustín Moyano <agustinmoyano>
Status: CLOSED FIXED QA Contact:
Severity: new feature    
Priority: P5 - low CC: caroline.cyr-la-rose, hammat.wele, jan.kissig, julian.maurice, kyle, lucas, martin.renvoize, maryse.simard, olivier.hubert, philippe.blouin, tomascohen
Version: master   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
23.05.00,22.11.04
Bug Depends on: 31801, 33080, 33083    
Bug Blocks: 25870, 27113, 31788, 33329    
Attachments: Bug 32734: Add REST endpoint to list biblios
Bug 32734: Add REST endpoint to list biblios
Bug 32734: Add REST endpoint to list biblios
Bug 32734: Add REST endpoint to list biblios
Bug 32734: Add REST endpoint to list biblios
Bug 32734: Add REST endpoint to list biblios
Bug 32734: (QA follow-up) Remove stray method
Bug 32734: (QA follow-up) Make use of $c->objects->to_api

Description Nick Clemens 2023-01-26 15:14:21 UTC
In addition to being able to GET a specific biblio, we should be able to search and retrieve subsets of biblios
Comment 1 Agustín Moyano 2023-02-17 02:17:35 UTC
Created attachment 146751 [details] [review]
Bug 32734: Add REST endpoint to list biblios

This patch adds an endpoint to list biblios

To test:
1. apply patch
2. enable basic auth
3. call to GET /api/v1/biblios with the following Accept headers:
 * application/json
 * application/marcxml+xml
 * application/marc-in-json
 * application/marc
 * text/plain
4. notice how data changes with each Accept header
5. prove t/db_dependent/Koha/Biblios.t t/db_dependent/api/v1/biblios.t
6. sign off
Comment 2 Matt Blenkinsop 2023-02-17 10:18:03 UTC
Created attachment 146804 [details] [review]
Bug 32734: Add REST endpoint to list biblios

This patch adds an endpoint to list biblios

To test:
1. apply patch
2. enable basic auth
3. call to GET /api/v1/biblios with the following Accept headers:
 * application/json
 * application/marcxml+xml
 * application/marc-in-json
 * application/marc
 * text/plain
4. notice how data changes with each Accept header
5. prove t/db_dependent/Koha/Biblios.t t/db_dependent/api/v1/biblios.t
6. sign off

Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
Comment 3 Agustín Moyano 2023-02-17 15:49:56 UTC
Created attachment 146855 [details] [review]
Bug 32734: Add REST endpoint to list biblios

This patch adds an endpoint to list biblios

To test:
1. apply patch
2. enable basic auth
3. call to GET /api/v1/biblios with the following Accept headers:
 * application/json
 * application/marcxml+xml
 * application/marc-in-json
 * application/marc
 * text/plain
4. notice how data changes with each Accept header
5. prove t/db_dependent/Koha/Biblios.t t/db_dependent/api/v1/biblios.t
6. sign off

Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
Comment 4 Agustín Moyano 2023-02-17 15:55:47 UTC
RM found that the glue with which I joined 'txt' records was wrong... I thought it was a pretty print and didn't know there was already a standard for it, so he allowed me to do the change, and upload this patch as signed... it almost changes nothing.
Comment 5 Tomás Cohen Arazi 2023-02-21 13:36:54 UTC
Agustin, nice work here. Could you please check this:

- We need tests for the 'return_resultset' parameter.
- Please make sure you have the EditorConfig plugin on your vscode, you seem to be using two spaces for indentation (at least on the tests). Running perltidy on those blocks you add/edit would be even better.
Comment 6 Tomás Cohen Arazi 2023-02-21 13:42:13 UTC
*** Bug 30790 has been marked as a duplicate of this bug. ***
Comment 7 Agustín Moyano 2023-02-27 23:51:51 UTC
Created attachment 147476 [details] [review]
Bug 32734: Add REST endpoint to list biblios

This patch adds an endpoint to list biblios

To test:
1. apply patch
2. enable basic auth
3. call to GET /api/v1/biblios with the following Accept headers:
 * application/json
 * application/marcxml+xml
 * application/marc-in-json
 * application/marc
 * text/plain
4. notice how data changes with each Accept header
5. prove t/db_dependent/Koha/Biblios.t t/db_dependent/api/v1/biblios.t
6. sign off

Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
Comment 8 Kyle M Hall 2023-03-10 14:37:55 UTC
Bug 32734 Depends on bug 31801 (Passed QA)
Follow? [(y)es, (n)o] y

Bug 31801 Depends on bug 31800 (Passed QA)
Follow? [(y)es, (n)o] y

Bug 31800 - REST API: POST endpoint for Biblios

147714 - Bug 31800: Add REST endpoint to add a biblio

Apply? [(y)es, (n)o, (i)nteractive] y
Applying: Bug 31800: Add REST endpoint to add a biblio
Using index info to reconstruct a base tree...
M	api/v1/swagger/swagger.yaml
Falling back to patching base and 3-way merge...
Auto-merging api/v1/swagger/swagger.yaml
CONFLICT (content): Merge conflict in api/v1/swagger/swagger.yaml
error: Failed to merge in the changes.
Patch failed at 0001 Bug 31800: Add REST endpoint to add a biblio
Comment 9 Tomás Cohen Arazi 2023-03-10 14:51:57 UTC
(In reply to Kyle M Hall from comment #8)
> Bug 32734 Depends on bug 31801 (Passed QA)
> Follow? [(y)es, (n)o] y
> 
> Bug 31801 Depends on bug 31800 (Passed QA)
> Follow? [(y)es, (n)o] y
> 
> Bug 31800 - REST API: POST endpoint for Biblios
> 
> 147714 - Bug 31800: Add REST endpoint to add a biblio
> 
> Apply? [(y)es, (n)o, (i)nteractive] y
> Applying: Bug 31800: Add REST endpoint to add a biblio
> Using index info to reconstruct a base tree...
> M	api/v1/swagger/swagger.yaml
> Falling back to patching base and 3-way merge...
> Auto-merging api/v1/swagger/swagger.yaml
> CONFLICT (content): Merge conflict in api/v1/swagger/swagger.yaml
> error: Failed to merge in the changes.
> Patch failed at 0001 Bug 31800: Add REST endpoint to add a biblio

Maybe I just pushed that one?
Comment 10 Hammat wele 2023-03-10 16:07:57 UTC
(In reply to Kyle M Hall from comment #8)
> Bug 32734 Depends on bug 31801 (Passed QA)
> Follow? [(y)es, (n)o] y
> 
> Bug 31801 Depends on bug 31800 (Passed QA)
> Follow? [(y)es, (n)o] y
> 
> Bug 31800 - REST API: POST endpoint for Biblios
> 
> 147714 - Bug 31800: Add REST endpoint to add a biblio
> 
> Apply? [(y)es, (n)o, (i)nteractive] y
> Applying: Bug 31800: Add REST endpoint to add a biblio
> Using index info to reconstruct a base tree...
> M	api/v1/swagger/swagger.yaml
> Falling back to patching base and 3-way merge...
> Auto-merging api/v1/swagger/swagger.yaml
> CONFLICT (content): Merge conflict in api/v1/swagger/swagger.yaml
> error: Failed to merge in the changes.
> Patch failed at 0001 Bug 31800: Add REST endpoint to add a biblio

I had the same problem before update to 22.12.00.011, after update it applies
Comment 11 Hammat wele 2023-03-10 16:16:45 UTC
Created attachment 148086 [details] [review]
Bug 32734: Add REST endpoint to list biblios

This patch adds an endpoint to list biblios

To test:
1. apply patch
2. enable basic auth
3. call to GET /api/v1/biblios with the following Accept headers:
 * application/json
 * application/marcxml+xml
 * application/marc-in-json
 * application/marc
 * text/plain
4. notice how data changes with each Accept header
5. prove t/db_dependent/Koha/Biblios.t t/db_dependent/api/v1/biblios.t
6. sign off

Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
Signed-off-by: Hammat Wele <hammat.wele@inlibro.com>
Comment 12 Nick Clemens 2023-03-13 15:28:38 UTC
Created attachment 148124 [details] [review]
Bug 32734: Add REST endpoint to list biblios

This patch adds an endpoint to list biblios

To test:
1. apply patch
2. enable basic auth
3. call to GET /api/v1/biblios with the following Accept headers:
 * application/json
 * application/marcxml+xml
 * application/marc-in-json
 * application/marc
 * text/plain
4. notice how data changes with each Accept header
5. prove t/db_dependent/Koha/Biblios.t t/db_dependent/api/v1/biblios.t
6. sign off

Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
Signed-off-by: Hammat Wele <hammat.wele@inlibro.com>
Comment 13 Tomás Cohen Arazi 2023-03-13 18:10:01 UTC
Created attachment 148136 [details] [review]
Bug 32734: (QA follow-up) Remove stray method

On bug 33083 we introduce a better way to implement a reusable method
for the same functionality.

This patch just removes the one in `Koha::Biblios` and the result should
be the same as the one inherited from  `Koha::Objects::Record::Collections` will be picked instead.

To test:
1. Run:
   $ prove t/db_dependent/Koha/Biblios.t \
           t/db_dependent/api/v1/biblios.t
=> SUCCESS: Tests pass!
2. Apply this patch
3. Repeat 1
=> SUCCESS: Tests pass!

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 14 Tomás Cohen Arazi 2023-03-13 18:10:05 UTC
Created attachment 148137 [details] [review]
Bug 32734: (QA follow-up) Make use of $c->objects->to_api

This is using plain `$biblios->to_api` but as of bug 33080, the new
helper should be used instead. This patch fixes that.

To test:
1. Run:
   $ ktd --shell
  k$ prove t/db_dependent/api/v1/biblios.t
=> SUCCESS: Tests pass!
2. Apply this patch
3. Repeat 1
=> SUCCESS: Tests pass!

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 15 Tomás Cohen Arazi 2023-03-13 18:13:41 UTC
Pushed to master for 22.11.

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

Pushed to 22.11.x for the next release.
Comment 17 Lucas Gass 2023-04-14 18:21:30 UTC
Enhancement will not be backported to 22.05.x