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 <jzairo@bywatersolutions.com>
Signed-off-by: Michaela Sieber <michaela.sieber@kit.edu>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Matt Blenkinsop 2023-08-03 13:24:08 +00:00 committed by Tomas Cohen Arazi
parent 8987ff1591
commit b74815dc64
No known key found for this signature in database
GPG Key ID: 0A272EA1B2F3C15F
10 changed files with 524 additions and 0 deletions

View File

@ -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 <http://www.gnu.org/licenses>.
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;

View File

@ -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 <http://www.gnu.org/licenses>.
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;

View File

@ -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 <http://www.gnu.org/licenses>.
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;

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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: