Bug 31798 - Add POST endpoint for Items
Summary: Add POST endpoint for Items
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: Marcel de Rooy
URL:
Keywords:
Depends on: 31797
Blocks: 32896 31789 31799
  Show dependency treegraph
 
Reported: 2022-10-14 14:38 UTC by Nick Clemens
Modified: 2023-07-26 12:57 UTC (History)
5 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


Attachments
Bug 31798: Add REST endpoint to add a biblio's item (6.85 KB, patch)
2022-12-30 15:42 UTC, Agustín Moyano
Details | Diff | Splinter Review
Bug 31798: Add REST endpoint to add a biblio's item (6.92 KB, patch)
2022-12-30 16:14 UTC, Lucas Gass
Details | Diff | Splinter Review
Bug 31798: (follow-up) Tidy up camel cased variables and unnecessary checks (1.19 KB, patch)
2023-01-03 17:44 UTC, Agustín Moyano
Details | Diff | Splinter Review
Bug 31798: (follow-up) Add duplicate barcode test (1.07 KB, patch)
2023-01-03 17:55 UTC, Agustín Moyano
Details | Diff | Splinter Review
Bug 31798: (follow-up) Tidy up and add duplicate barcode test (2.81 KB, patch)
2023-01-03 18:32 UTC, Agustín Moyano
Details | Diff | Splinter Review
Bug 31798: (follow-up) Handle all values of autoBarcode (3.09 KB, patch)
2023-02-27 17:58 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 31798: (follow-up) Handle all values of autoBarcode (3.59 KB, patch)
2023-02-27 18:11 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 31798: Add REST endpoint to add a biblio's item (6.97 KB, patch)
2023-03-02 16:28 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 31798: (follow-up) Tidy up and add duplicate barcode test (2.87 KB, patch)
2023-03-02 16:28 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 31798: (follow-up) Handle all values of autoBarcode (4.22 KB, patch)
2023-03-02 16:28 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 31798: Add REST endpoint to add a biblio's item (7.09 KB, patch)
2023-05-03 15:14 UTC, Agustín Moyano
Details | Diff | Splinter Review
Bug 31798: (follow-up) Tidy up and add duplicate barcode test (2.87 KB, patch)
2023-05-03 15:14 UTC, Agustín Moyano
Details | Diff | Splinter Review
Bug 31798: (follow-up) Handle all values of autoBarcode (4.24 KB, patch)
2023-05-03 15:14 UTC, Agustín Moyano
Details | Diff | Splinter Review
Bug 31798: Add REST endpoint to add a biblio's item (7.14 KB, patch)
2023-05-05 15:27 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 31798: Add REST endpoint to add a biblio's item (7.14 KB, patch)
2023-05-05 15:38 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 31798: (follow-up) Tidy up and add duplicate barcode test (2.92 KB, patch)
2023-05-05 15:38 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 31798: (follow-up) Handle all values of autoBarcode (4.29 KB, patch)
2023-05-05 15:38 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 31798: (QA follow-up) Remove use Koha::Item, we already use Koha::Items (703 bytes, patch)
2023-05-05 15:38 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:38:53 UTC

    
Comment 1 Agustín Moyano 2022-12-30 15:42:38 UTC
Created attachment 144893 [details] [review]
Bug 31798: Add REST endpoint to add a biblio's item

To test:
1. Apply patch
2. Set RESTBasicAuth preference to true
3. Get a biblio
4. Make a POST request to /api/v1/biblios/:biblio_id/items with a json body that represents the new item
5. Check that the item is created
6. Sign off
Comment 2 Lucas Gass 2022-12-30 16:14:37 UTC
Created attachment 144894 [details] [review]
Bug 31798: Add REST endpoint to add a biblio's item

To test:
1. Apply patch
2. Set RESTBasicAuth preference to true
3. Get a biblio
4. Make a POST request to /api/v1/biblios/:biblio_id/items with a json body that represents the new item
5. Check that the item is created
6. Sign off

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Comment 3 Agustín Moyano 2023-01-03 17:44:27 UTC
Created attachment 144952 [details] [review]
Bug 31798: (follow-up) Tidy up camel cased variables and unnecessary checks
Comment 4 Tomás Cohen Arazi 2023-01-03 17:47:46 UTC
Agustin, I think this is missing tests for the duplicate barcode use case. And in those tests it should be returning a 409 (conflict?) instead of a 500 because of the unhandled exception.

Thanks.
Comment 5 Agustín Moyano 2023-01-03 17:55:09 UTC
Created attachment 144953 [details] [review]
Bug 31798: (follow-up) Add duplicate barcode test
Comment 6 Agustín Moyano 2023-01-03 17:57:58 UTC
(In reply to Tomás Cohen Arazi from comment #4)
> Agustin, I think this is missing tests for the duplicate barcode use case.
> And in those tests it should be returning a 409 (conflict?) instead of a 500
> because of the unhandled exception.
> 
> Thanks.

Should we return 409 conflict or 400 bad request?

Thanks
Comment 7 Agustín Moyano 2023-01-03 18:32:32 UTC
Created attachment 144956 [details] [review]
Bug 31798: (follow-up) Tidy up and add duplicate barcode test
Comment 8 Martin Renvoize 2023-02-07 14:25:25 UTC
Aren't we being a bit nieve here in terms of autoBarcode?

I'm wondering:
1) Can we move the autoBarcode handling into Koha::Item->store() instead?
2) Even if we don't move the autoBarcode handling, don't we need to account for the other options it supports?
Comment 9 Agustín Moyano 2023-02-08 13:20:07 UTC
(In reply to Martin Renvoize from comment #8)
> Aren't we being a bit nieve here in terms of autoBarcode?
> 
> I'm wondering:
> 1) Can we move the autoBarcode handling into Koha::Item->store() instead?
> 2) Even if we don't move the autoBarcode handling, don't we need to account
> for the other options it supports?

Hi Martin, 

If I remove all about autoBarcode and link this to bug 32896, would it pass QA?

Thanks
Comment 10 Martin Renvoize 2023-02-27 14:23:12 UTC
Hmm, it would help move this bug.. but in my opinion it's moving towards blocked rather than PQA.

It's hard... I don't really want to block this one and asking for the autoBarcode move is a bit out of direct scope of this piece.
Comment 11 Nick Clemens 2023-02-27 17:58:01 UTC
Created attachment 147463 [details] [review]
Bug 31798: (follow-up) Handle all values of autoBarcode
Comment 12 Nick Clemens 2023-02-27 18:11:00 UTC
Created attachment 147464 [details] [review]
Bug 31798: (follow-up) Handle all values of autoBarcode
Comment 13 Nick Clemens 2023-02-27 18:11:49 UTC
(In reply to Martin Renvoize from comment #10)
> Hmm, it would help move this bug.. but in my opinion it's moving towards
> blocked rather than PQA.
> 
> It's hard... I don't really want to block this one and asking for the
> autoBarcode move is a bit out of direct scope of this piece.

Follow-up attached, crude, but lets us handle the move more elegantly on 32896
Comment 14 Martin Renvoize 2023-03-02 16:28:43 UTC
Created attachment 147655 [details] [review]
Bug 31798: Add REST endpoint to add a biblio's item

To test:
1. Apply patch
2. Set RESTBasicAuth preference to true
3. Get a biblio
4. Make a POST request to /api/v1/biblios/:biblio_id/items with a json body that represents the new item
5. Check that the item is created
6. Sign off

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 15 Martin Renvoize 2023-03-02 16:28:46 UTC
Created attachment 147656 [details] [review]
Bug 31798: (follow-up) Tidy up and add duplicate barcode test

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 16 Martin Renvoize 2023-03-02 16:28:49 UTC
Created attachment 147657 [details] [review]
Bug 31798: (follow-up) Handle all values of autoBarcode

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 17 Marcel de Rooy 2023-04-14 07:53:44 UTC
Applying: Bug 31798: (follow-up) Handle all values of autoBarcode
error: sha1 information is lacking or useless (Koha/REST/V1/Biblios.pm).
error: could not build fake ancestor
Patch failed at 0001 Bug 31798: (follow-up) Handle all values of autoBarcode
Comment 18 Agustín Moyano 2023-05-03 15:14:36 UTC
Created attachment 150598 [details] [review]
Bug 31798: Add REST endpoint to add a biblio's item

To test:
1. Apply patch
2. Set RESTBasicAuth preference to true
3. Get a biblio
4. Make a POST request to /api/v1/biblios/:biblio_id/items with a json body that represents the new item
5. Check that the item is created
6. Sign off

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 19 Agustín Moyano 2023-05-03 15:14:39 UTC
Created attachment 150599 [details] [review]
Bug 31798: (follow-up) Tidy up and add duplicate barcode test

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 20 Agustín Moyano 2023-05-03 15:14:42 UTC
Created attachment 150600 [details] [review]
Bug 31798: (follow-up) Handle all values of autoBarcode

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 21 Kyle M Hall 2023-05-05 15:27:25 UTC
Created attachment 150771 [details] [review]
Bug 31798: Add REST endpoint to add a biblio's item

To test:
1. Apply patch
2. Set RESTBasicAuth preference to true
3. Get a biblio
4. Make a POST request to /api/v1/biblios/:biblio_id/items with a json body that represents the new item
5. Check that the item is created
6. Sign off

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 22 Kyle M Hall 2023-05-05 15:38:41 UTC
Created attachment 150772 [details] [review]
Bug 31798: Add REST endpoint to add a biblio's item

To test:
1. Apply patch
2. Set RESTBasicAuth preference to true
3. Get a biblio
4. Make a POST request to /api/v1/biblios/:biblio_id/items with a json body that represents the new item
5. Check that the item is created
6. Sign off

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 23 Kyle M Hall 2023-05-05 15:38:48 UTC
Created attachment 150773 [details] [review]
Bug 31798: (follow-up) Tidy up and add duplicate barcode test

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 24 Kyle M Hall 2023-05-05 15:38:50 UTC
Created attachment 150774 [details] [review]
Bug 31798: (follow-up) Handle all values of autoBarcode

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 25 Kyle M Hall 2023-05-05 15:38:52 UTC
Created attachment 150775 [details] [review]
Bug 31798: (QA follow-up) Remove use Koha::Item, we already use Koha::Items

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 26 Tomás Cohen Arazi 2023-05-05 18:42:59 UTC
Pushed to master for 23.05.

Nice work everyone, thanks!
Comment 27 Martin Renvoize 2023-05-12 15:33:07 UTC
Another API addition.. for now I'm choosing not to backport, but let me know if this is important to you and I'll look at backporting the whole tree.