Bug 32981 - Add GET endpoint for listing authorised values by a given category
Summary: Add GET endpoint for listing authorised values by a given category
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: REST API (show other bugs)
Version: unspecified
Hardware: All All
: P5 - low new feature (vote)
Assignee: Jonathan Druart
QA Contact: Nick Clemens (kidclamp)
URL:
Keywords:
Depends on:
Blocks: 17390 32997
  Show dependency treegraph
 
Reported: 2023-02-16 13:41 UTC by Jonathan Druart
Modified: 2024-02-12 14:18 UTC (History)
6 users (show)

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


Attachments
Bug 32981: Add endpoint to get AV for given category (12.41 KB, patch)
2023-02-16 13:43 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 32981: Add endpoint to get AV for given category (12.46 KB, patch)
2023-02-17 13:03 UTC, Pedro Amorim
Details | Diff | Splinter Review
Bug 32981: Add endpoint to get AV for given category (12.51 KB, patch)
2023-02-24 14:48 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 32981: (QA follow-up) Fix POD and file permissions (963 bytes, patch)
2023-02-24 14:48 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Druart 2023-02-16 13:41:33 UTC
For, at least, the ERM module we would like to retrieve the authorised values for a given category to build a dropdown list with the different options.

It has been decided on bug 17390 to use
GET /authorised_value_categories/:authorised_value_category_id/values
Comment 1 Jonathan Druart 2023-02-16 13:43:16 UTC
Created attachment 146730 [details] [review]
Bug 32981: Add endpoint to get AV for given category

For, at least, the ERM module we would like to retrieve the authorised
values for a given category to build a dropdown list with the different options.

It has been decided on bug 17390 to use
GET /authorised_value_categories/:authorised_value_category_id/values

Test plan:
curl -v -s -u koha:koha --request GET  http://kohadev-intra.mydnsname.org:8081/api/v1/authorised_value_categories/LOC/values
Should display the list of LOC

curl -v -s -u koha:koha --request GET  http://kohadev-intra.mydnsname.org:8081/api/v1/authorised_value_categories/xLOCx/values
Should return a 404
Comment 2 Pedro Amorim 2023-02-17 13:02:06 UTC
Working as intended, also good to see bug 17390 being broken down so that we can at least get the AV values, we can think about create, update and delete later, as stated by Josef in that bug.

Do we really need a custom to_api_mapping, or should we instead change some of the fields in authorised_values e.g. lib and lib_opac.
Comment 3 Pedro Amorim 2023-02-17 13:03:22 UTC
Created attachment 146842 [details] [review]
Bug 32981: Add endpoint to get AV for given category

For, at least, the ERM module we would like to retrieve the authorised
values for a given category to build a dropdown list with the different options.

It has been decided on bug 17390 to use
GET /authorised_value_categories/:authorised_value_category_id/values

Test plan:
curl -v -s -u koha:koha --request GET  http://kohadev-intra.mydnsname.org:8081/api/v1/authorised_value_categories/LOC/values
Should display the list of LOC

curl -v -s -u koha:koha --request GET  http://kohadev-intra.mydnsname.org:8081/api/v1/authorised_value_categories/xLOCx/values
Should return a 404

Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com>
Comment 4 Jonathan Druart 2023-02-17 13:12:13 UTC
(In reply to Pedro Amorim from comment #2)
> Do we really need a custom to_api_mapping, or should we instead change some
> of the fields in authorised_values e.g. lib and lib_opac.

Yes, we list the names of the attributes we want to modify there.
Comment 5 Pedro Amorim 2023-02-17 13:22:30 UTC
I know! :-D My point is we wouldn't want to modify the names of the attributes if they were already straightforward enough.
Comment 6 Nick Clemens (kidclamp) 2023-02-24 14:48:39 UTC
Created attachment 147335 [details] [review]
Bug 32981: Add endpoint to get AV for given category

For, at least, the ERM module we would like to retrieve the authorised
values for a given category to build a dropdown list with the different options.

It has been decided on bug 17390 to use
GET /authorised_value_categories/:authorised_value_category_id/values

Test plan:
curl -v -s -u koha:koha --request GET  http://kohadev-intra.mydnsname.org:8081/api/v1/authorised_value_categories/LOC/values
Should display the list of LOC

curl -v -s -u koha:koha --request GET  http://kohadev-intra.mydnsname.org:8081/api/v1/authorised_value_categories/xLOCx/values
Should return a 404

Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 7 Nick Clemens (kidclamp) 2023-02-24 14:48:42 UTC
Created attachment 147336 [details] [review]
Bug 32981: (QA follow-up) Fix POD and file permissions
Comment 8 Tomás Cohen Arazi 2023-02-24 20:52:02 UTC
Question: are we sure about the names for things?

I would've expected to see something like:

my $avs_rs = $category->avs;

for querying the avs. Let's suppose we leave that for later, for when we really embed the avs in the /authorised_value_categories endpoint...

Are you sure we will call the accessor $category->values instead? And so the x-koha-embed attribute. I'm not saying it is wrong, just thinking it might get confusing.

I'd go for 'av', like in

/av_categories
/av_categories/:code/avs

I'm not even sure we need this endpoint or just the other one, with an embed :-D

GET /av_categories/:code
x-koha-embed: avs
Comment 9 Jonathan Druart 2023-02-28 07:46:32 UTC
(In reply to Tomás Cohen Arazi from comment #8)
> I'm not even sure we need this endpoint or just the other one, with an embed

It's not used later, feel free to drop it. It felt "more REST" than the other route, that's why I decided to keep it.
Comment 10 Tomás Cohen Arazi 2023-03-02 13:29:11 UTC
I'm still in doubt with comment 8. Please tell me what are your thoughts. It feels like the name for things needs some thought.
Comment 11 Tomás Cohen Arazi 2023-03-02 14:59:41 UTC
Pushed to master for 23.05.

Nice work everyone, thanks!
Comment 12 Matt Blenkinsop 2023-03-03 12:13:42 UTC
Nice work everyone!

Pushed to stable for 22.11.x
Comment 13 Marcel de Rooy 2023-03-06 09:56:27 UTC
This seems to break the complete API. See also bug 32983.
Comment 14 Lucas Gass 2023-03-10 14:53:40 UTC
Enhancement will not be backported to 22.05.x.
Comment 15 Arthur Suzuki 2024-02-12 14:18:31 UTC
*** Bug 17390 has been marked as a duplicate of this bug. ***