From b74815dc6478a64770efb995caab73ab731f229e Mon Sep 17 00:00:00 2001 From: Matt Blenkinsop Date: Thu, 3 Aug 2023 13:24:08 +0000 Subject: [PATCH] Bug 34587: Add list endpoints for usage_databases/items/platforms Needed to display lists in the provider tabs in the UI Signed-off-by: Jessica Zairo Signed-off-by: Michaela Sieber Signed-off-by: Nick Clemens Signed-off-by: Tomas Cohen Arazi --- Koha/REST/V1/ERM/UsageDatabases.pm | 51 +++++++++++ Koha/REST/V1/ERM/UsageItems.pm | 51 +++++++++++ Koha/REST/V1/ERM/UsagePlatforms.pm | 51 +++++++++++ .../definitions/erm_usage_database.yaml | 45 ++++++++++ .../swagger/definitions/erm_usage_item.yaml | 40 +++++++++ .../definitions/erm_usage_platform.yaml | 30 +++++++ api/v1/swagger/paths/erm_usage_databases.yaml | 88 +++++++++++++++++++ api/v1/swagger/paths/erm_usage_items.yaml | 83 +++++++++++++++++ api/v1/swagger/paths/erm_usage_platforms.yaml | 73 +++++++++++++++ api/v1/swagger/swagger.yaml | 12 +++ 10 files changed, 524 insertions(+) create mode 100644 Koha/REST/V1/ERM/UsageDatabases.pm create mode 100644 Koha/REST/V1/ERM/UsageItems.pm create mode 100644 Koha/REST/V1/ERM/UsagePlatforms.pm create mode 100644 api/v1/swagger/definitions/erm_usage_database.yaml create mode 100644 api/v1/swagger/definitions/erm_usage_item.yaml create mode 100644 api/v1/swagger/definitions/erm_usage_platform.yaml create mode 100644 api/v1/swagger/paths/erm_usage_databases.yaml create mode 100644 api/v1/swagger/paths/erm_usage_items.yaml create mode 100644 api/v1/swagger/paths/erm_usage_platforms.yaml diff --git a/Koha/REST/V1/ERM/UsageDatabases.pm b/Koha/REST/V1/ERM/UsageDatabases.pm new file mode 100644 index 0000000000..a1754d7393 --- /dev/null +++ b/Koha/REST/V1/ERM/UsageDatabases.pm @@ -0,0 +1,51 @@ +package Koha::REST::V1::ERM::UsageDatabases; + +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +use Modern::Perl; + +use Mojo::Base 'Mojolicious::Controller'; +use Module::Load qw( load ); + +use Koha::ERM::UsageDatabases; + +use Clone qw( clone ); +use Scalar::Util qw( blessed ); +use Try::Tiny qw( catch try ); +use JSON; + +=head1 API + +=head2 Methods + +=head3 list + +=cut + +sub list { + my $c = shift->openapi->valid_input or return; + + return try { + my $usage_databases_set = Koha::ERM::UsageDatabases->new; + my $usage_databases = $c->objects->search($usage_databases_set); + return $c->render( status => 200, openapi => $usage_databases ); + } + catch { + $c->unhandled_exception($_); + }; +} + +1; diff --git a/Koha/REST/V1/ERM/UsageItems.pm b/Koha/REST/V1/ERM/UsageItems.pm new file mode 100644 index 0000000000..3807d4c320 --- /dev/null +++ b/Koha/REST/V1/ERM/UsageItems.pm @@ -0,0 +1,51 @@ +package Koha::REST::V1::ERM::UsageItems; + +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +use Modern::Perl; + +use Mojo::Base 'Mojolicious::Controller'; +use Module::Load qw( load ); + +use Koha::ERM::UsageItems; + +use Clone qw( clone ); +use Scalar::Util qw( blessed ); +use Try::Tiny qw( catch try ); +use JSON; + +=head1 API + +=head2 Methods + +=head3 list + +=cut + +sub list { + my $c = shift->openapi->valid_input or return; + + return try { + my $usage_items_set = Koha::ERM::UsageItems->new; + my $usage_items = $c->objects->search($usage_items_set); + return $c->render( status => 200, openapi => $usage_items ); + } + catch { + $c->unhandled_exception($_); + }; +} + +1; diff --git a/Koha/REST/V1/ERM/UsagePlatforms.pm b/Koha/REST/V1/ERM/UsagePlatforms.pm new file mode 100644 index 0000000000..00ab253e09 --- /dev/null +++ b/Koha/REST/V1/ERM/UsagePlatforms.pm @@ -0,0 +1,51 @@ +package Koha::REST::V1::ERM::UsagePlatforms; + +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +use Modern::Perl; + +use Mojo::Base 'Mojolicious::Controller'; +use Module::Load qw( load ); + +use Koha::ERM::UsagePlatforms; + +use Clone qw( clone ); +use Scalar::Util qw( blessed ); +use Try::Tiny qw( catch try ); +use JSON; + +=head1 API + +=head2 Methods + +=head3 list + +=cut + +sub list { + my $c = shift->openapi->valid_input or return; + + return try { + my $usage_platforms_set = Koha::ERM::UsagePlatforms->new; + my $usage_platforms = $c->objects->search($usage_platforms_set); + return $c->render( status => 200, openapi => $usage_platforms ); + } + catch { + $c->unhandled_exception($_); + }; +} + +1; diff --git a/api/v1/swagger/definitions/erm_usage_database.yaml b/api/v1/swagger/definitions/erm_usage_database.yaml new file mode 100644 index 0000000000..9525eacf5e --- /dev/null +++ b/api/v1/swagger/definitions/erm_usage_database.yaml @@ -0,0 +1,45 @@ +--- +type: object +properties: + database_id: + type: integer + description: internally assigned database identifier + readOnly: true + database: + description: name of the database + type: + - string + - "null" + usage_data_provider_id: + description: usage_data_provider the database is harvested by + type: integer + platform: + description: name of the platform + type: + - string + - "null" + publisher: + description: publisher of the database data + type: + - string + - "null" + publisher_id: + description: publisher_id of the database data + type: + - string + - "null" + erm_usage_muses: + type: array + description: usage mus + items: + $ref: erm_usage_mus.yaml + erm_usage_yuses: + type: array + description: usage yus + items: + $ref: erm_usage_yus.yaml + +additionalProperties: false +required: + - database + - usage_data_provider_id diff --git a/api/v1/swagger/definitions/erm_usage_item.yaml b/api/v1/swagger/definitions/erm_usage_item.yaml new file mode 100644 index 0000000000..bbb4017224 --- /dev/null +++ b/api/v1/swagger/definitions/erm_usage_item.yaml @@ -0,0 +1,40 @@ +--- +type: object +properties: + item_id: + type: integer + description: internally assigned item identifier + readOnly: true + item: + description: item of the item + type: + - string + - "null" + usage_data_provider_id: + description: usage_data_provider the item is harvested by + type: integer + platform: + description: name of the platform + type: + - string + - "null" + publisher: + description: publisher of the item data + type: + - string + - "null" + erm_usage_muses: + type: array + description: usage mus + items: + $ref: erm_usage_mus.yaml + erm_usage_yuses: + type: array + description: usage yus + items: + $ref: erm_usage_yus.yaml + +additionalProperties: false +required: + - item + - usage_data_provider_id diff --git a/api/v1/swagger/definitions/erm_usage_platform.yaml b/api/v1/swagger/definitions/erm_usage_platform.yaml new file mode 100644 index 0000000000..aa7b8e8426 --- /dev/null +++ b/api/v1/swagger/definitions/erm_usage_platform.yaml @@ -0,0 +1,30 @@ +--- +type: object +properties: + platform_id: + type: integer + description: internally assigned platform identifier + readOnly: true + platform: + description: title of the platform + type: + - string + - "null" + usage_data_provider_id: + description: usage_data_provider the platform is harvested by + type: integer + erm_usage_muses: + type: array + description: usage mus + items: + $ref: erm_usage_mus.yaml + erm_usage_yuses: + type: array + description: usage yus + items: + $ref: erm_usage_yus.yaml + +additionalProperties: false +required: + - platform + - usage_data_provider_id diff --git a/api/v1/swagger/paths/erm_usage_databases.yaml b/api/v1/swagger/paths/erm_usage_databases.yaml new file mode 100644 index 0000000000..33326d5468 --- /dev/null +++ b/api/v1/swagger/paths/erm_usage_databases.yaml @@ -0,0 +1,88 @@ +--- +/erm/usage_databases: + get: + x-mojo-to: ERM::UsageDatabases#list + operationId: listErmUsageDatabases + tags: + - usage_database + summary: List usage_databases + produces: + - application/json + parameters: + - description: Case insensitive search on usage_database database_id + in: query + name: database_id + required: false + type: integer + - description: Case insensitive search on usage_database database + in: query + name: database + required: false + type: string + - description: Case insensitive search on usage_database usage_data_provider_id + in: query + name: usage_data_provider_id + required: false + type: string + - description: Case insensitive search on usage_database platform + in: query + name: platform + required: false + type: string + - description: Case insensitive search on usage_database publisher + in: query + name: publisher + required: false + type: string + - description: Case insensitive search on usage_title publisher_id + in: query + name: publisher_id + required: false + type: string + - name: x-koha-embed + in: header + required: false + description: Embed list sent as a request header + type: array + items: + type: string + enum: + - erm_usage_muses + - erm_usage_yuses + collectionFormat: csv + - $ref: "../swagger.yaml#/parameters/match" + - $ref: "../swagger.yaml#/parameters/order_by" + - $ref: "../swagger.yaml#/parameters/page" + - $ref: "../swagger.yaml#/parameters/per_page" + - $ref: "../swagger.yaml#/parameters/q_param" + - $ref: "../swagger.yaml#/parameters/q_body" + - $ref: "../swagger.yaml#/parameters/q_header" + - $ref: "../swagger.yaml#/parameters/request_id_header" + responses: + 200: + description: A list of usage_databases + schema: + items: + $ref: "../swagger.yaml#/definitions/erm_usage_database" + type: array + 400: + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" + 403: + description: Access forbidden + schema: + $ref: "../swagger.yaml#/definitions/error" + 500: + description: |- + Internal server error. Possible `error_code` attribute values: + * `internal_server_error` + schema: + $ref: "../swagger.yaml#/definitions/error" + 503: + description: Under maintenance + schema: + $ref: "../swagger.yaml#/definitions/error" + x-koha-authorization: + permissions: + erm: 1 \ No newline at end of file diff --git a/api/v1/swagger/paths/erm_usage_items.yaml b/api/v1/swagger/paths/erm_usage_items.yaml new file mode 100644 index 0000000000..7e326dd3c2 --- /dev/null +++ b/api/v1/swagger/paths/erm_usage_items.yaml @@ -0,0 +1,83 @@ +--- +/erm/usage_items: + get: + x-mojo-to: ERM::UsageItems#list + operationId: listErmUsageItems + tags: + - usage_item + summary: List usage_items + produces: + - application/json + parameters: + - description: Case insensitive search on usage_item item_id + in: query + name: item_id + required: false + type: integer + - description: Case insensitive search on usage_item item + in: query + name: item + required: false + type: string + - description: Case insensitive search on usage_item usage_data_provider_id + in: query + name: usage_data_provider_id + required: false + type: string + - description: Case insensitive search on usage_item platform + in: query + name: platform + required: false + type: string + - description: Case insensitive search on usage_item publisher + in: query + name: publisher + required: false + type: string + - name: x-koha-embed + in: header + required: false + description: Embed list sent as a request header + type: array + items: + type: string + enum: + - erm_usage_muses + - erm_usage_yuses + collectionFormat: csv + - $ref: "../swagger.yaml#/parameters/match" + - $ref: "../swagger.yaml#/parameters/order_by" + - $ref: "../swagger.yaml#/parameters/page" + - $ref: "../swagger.yaml#/parameters/per_page" + - $ref: "../swagger.yaml#/parameters/q_param" + - $ref: "../swagger.yaml#/parameters/q_body" + - $ref: "../swagger.yaml#/parameters/q_header" + - $ref: "../swagger.yaml#/parameters/request_id_header" + responses: + 200: + description: A list of usage_items + schema: + items: + $ref: "../swagger.yaml#/definitions/erm_usage_item" + type: array + 400: + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" + 403: + description: Access forbidden + schema: + $ref: "../swagger.yaml#/definitions/error" + 500: + description: |- + Internal server error. Possible `error_code` attribute values: + * `internal_server_error` + schema: + $ref: "../swagger.yaml#/definitions/error" + 503: + description: Under maintenance + schema: + $ref: "../swagger.yaml#/definitions/error" + x-koha-authorization: + permissions: + erm: 1 \ No newline at end of file diff --git a/api/v1/swagger/paths/erm_usage_platforms.yaml b/api/v1/swagger/paths/erm_usage_platforms.yaml new file mode 100644 index 0000000000..13d72e26ce --- /dev/null +++ b/api/v1/swagger/paths/erm_usage_platforms.yaml @@ -0,0 +1,73 @@ +--- +/erm/usage_platforms: + get: + x-mojo-to: ERM::UsagePlatforms#list + operationId: listErmUsagePlatforms + tags: + - usage_platform + summary: List usage_platforms + produces: + - application/json + parameters: + - description: Case insensitive search on usage_platform platform_id + in: query + name: platform_id + required: false + type: integer + - description: Case insensitive search on usage_platform platform + in: query + name: platform + required: false + type: string + - description: Case insensitive search on usage_platform usage_data_provider_id + in: query + name: usage_data_provider_id + required: false + type: string + - name: x-koha-embed + in: header + required: false + description: Embed list sent as a request header + type: array + items: + type: string + enum: + - erm_usage_muses + - erm_usage_yuses + collectionFormat: csv + - $ref: "../swagger.yaml#/parameters/match" + - $ref: "../swagger.yaml#/parameters/order_by" + - $ref: "../swagger.yaml#/parameters/page" + - $ref: "../swagger.yaml#/parameters/per_page" + - $ref: "../swagger.yaml#/parameters/q_param" + - $ref: "../swagger.yaml#/parameters/q_body" + - $ref: "../swagger.yaml#/parameters/q_header" + - $ref: "../swagger.yaml#/parameters/request_id_header" + responses: + 200: + description: A list of usage_platforms + schema: + items: + $ref: "../swagger.yaml#/definitions/erm_usage_platform" + type: array + 400: + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" + 403: + description: Access forbidden + schema: + $ref: "../swagger.yaml#/definitions/error" + 500: + description: |- + Internal server error. Possible `error_code` attribute values: + * `internal_server_error` + schema: + $ref: "../swagger.yaml#/definitions/error" + 503: + description: Under maintenance + schema: + $ref: "../swagger.yaml#/definitions/error" + x-koha-authorization: + permissions: + erm: 1 \ No newline at end of file diff --git a/api/v1/swagger/swagger.yaml b/api/v1/swagger/swagger.yaml index db68b9030a..2d9003dfd0 100644 --- a/api/v1/swagger/swagger.yaml +++ b/api/v1/swagger/swagger.yaml @@ -58,8 +58,14 @@ definitions: $ref: ./definitions/erm_license.yaml erm_usage_data_provider: $ref: ./definitions/erm_usage_data_provider.yaml + erm_usage_database: + $ref: ./definitions/erm_usage_database.yaml + erm_usage_item: + $ref: ./definitions/erm_usage_item.yaml erm_usage_mus: $ref: ./definitions/erm_usage_mus.yaml + erm_usage_platform: + $ref: ./definitions/erm_usage_platform.yaml erm_usage_title: $ref: ./definitions/erm_usage_title.yaml erm_usage_yus: @@ -307,6 +313,12 @@ paths: $ref: "./paths/erm_usage_data_providers.yaml#/~1erm~1usage_data_providers~1{erm_usage_data_provider_id}~1run" "/erm/usage_data_providers/{erm_usage_data_provider_id}/test_connection": $ref: "./paths/erm_usage_data_providers.yaml#/~1erm~1usage_data_providers~1{erm_usage_data_provider_id}~1test_connection" + /erm/usage_databases: + $ref: ./paths/erm_usage_databases.yaml#/~1erm~1usage_databases + /erm/usage_items: + $ref: ./paths/erm_usage_items.yaml#/~1erm~1usage_items + /erm/usage_platforms: + $ref: ./paths/erm_usage_platforms.yaml#/~1erm~1usage_platforms /erm/usage_titles: $ref: ./paths/erm_usage_titles.yaml#/~1erm~1usage_titles /erm/users: -- 2.39.5