Bug 29016 [25.11.x]: Add REST API for action logs
Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk> Signed-off-by: Lucas Gass <lucas@bywatersolutions.com> Signed-off-by: Jacob O'Mara <Jacob.omara@openfifth.co.uk>
This commit is contained in:
parent
4c119b95fa
commit
637139d782
|
|
@ -0,0 +1,45 @@
|
|||
package Koha::REST::V1::ActionLogs;
|
||||
|
||||
# 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 <https://www.gnu.org/licenses>.
|
||||
|
||||
use Modern::Perl;
|
||||
|
||||
use Mojo::Base 'Mojolicious::Controller';
|
||||
|
||||
use Koha::ActionLogs;
|
||||
|
||||
use Try::Tiny qw( catch try );
|
||||
|
||||
=head1 API
|
||||
|
||||
=head2 Methods
|
||||
|
||||
=head3 list
|
||||
|
||||
=cut
|
||||
|
||||
sub list {
|
||||
my $c = shift->openapi->valid_input or return;
|
||||
|
||||
return try {
|
||||
my $logs = $c->objects->search( Koha::ActionLogs->new );
|
||||
return $c->render( status => 200, openapi => $logs );
|
||||
} catch {
|
||||
$c->unhandled_exception($_);
|
||||
};
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
---
|
||||
type: object
|
||||
properties:
|
||||
action_id:
|
||||
type: integer
|
||||
description: Internal action log identifier
|
||||
readOnly: true
|
||||
timestamp:
|
||||
type: string
|
||||
format: date-time
|
||||
description: The date and time the action took place
|
||||
user:
|
||||
type: integer
|
||||
description: The staff member who performed the action (borrowernumber)
|
||||
module:
|
||||
type:
|
||||
- string
|
||||
- "null"
|
||||
description: The module this action was taken against
|
||||
action:
|
||||
type:
|
||||
- string
|
||||
- "null"
|
||||
description: The action performed (e.g. ADD, DELETE, MODIFY)
|
||||
object:
|
||||
type:
|
||||
- integer
|
||||
- "null"
|
||||
description: The object that the action was taken against
|
||||
info:
|
||||
type:
|
||||
- string
|
||||
- "null"
|
||||
description: Information about the action
|
||||
interface:
|
||||
type:
|
||||
- string
|
||||
- "null"
|
||||
description: The context this action was taken in (INTRANET, OPAC, SIP, etc.)
|
||||
script:
|
||||
type:
|
||||
- string
|
||||
- "null"
|
||||
description: The name of the cron script that caused this change
|
||||
trace:
|
||||
type:
|
||||
- string
|
||||
- "null"
|
||||
description: An optional stack trace
|
||||
diff:
|
||||
type:
|
||||
- string
|
||||
- "null"
|
||||
description: A diff of the changed object
|
||||
additionalProperties: false
|
||||
|
|
@ -0,0 +1,91 @@
|
|||
---
|
||||
/action_logs:
|
||||
get:
|
||||
x-mojo-to: ActionLogs#list
|
||||
operationId: listActionLogs
|
||||
tags:
|
||||
- action_logs
|
||||
summary: List action logs
|
||||
produces:
|
||||
- application/json
|
||||
parameters:
|
||||
- name: action_id
|
||||
in: query
|
||||
description: Search on action log id
|
||||
required: false
|
||||
type: integer
|
||||
- name: timestamp
|
||||
in: query
|
||||
description: Search on timestamp
|
||||
required: false
|
||||
type: string
|
||||
format: date-time
|
||||
- name: user
|
||||
in: query
|
||||
description: Search on user (borrowernumber)
|
||||
required: false
|
||||
type: integer
|
||||
- name: module
|
||||
in: query
|
||||
description: Search on module
|
||||
required: false
|
||||
type: string
|
||||
- name: action
|
||||
in: query
|
||||
description: Search on action
|
||||
required: false
|
||||
type: string
|
||||
- name: object
|
||||
in: query
|
||||
description: Search on object
|
||||
required: false
|
||||
type: integer
|
||||
- name: info
|
||||
in: query
|
||||
description: Search on info
|
||||
required: false
|
||||
type: string
|
||||
- name: interface
|
||||
in: query
|
||||
description: Search on interface
|
||||
required: false
|
||||
type: string
|
||||
- $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/request_id_header"
|
||||
responses:
|
||||
"200":
|
||||
description: A list of action logs
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: "../swagger.yaml#/definitions/action_log"
|
||||
"400":
|
||||
description: |
|
||||
Bad request. Possible `error_code` attribute values:
|
||||
|
||||
* `invalid_query`
|
||||
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:
|
||||
tools: view_system_logs
|
||||
|
|
@ -4,6 +4,8 @@ basePath: /api/v1
|
|||
definitions:
|
||||
account_line:
|
||||
$ref: ./definitions/account_line.yaml
|
||||
action_log:
|
||||
$ref: ./definitions/action_log.yaml
|
||||
additional_content:
|
||||
$ref: ./definitions/additional_content.yaml
|
||||
advancededitormacro:
|
||||
|
|
@ -209,6 +211,8 @@ definitions:
|
|||
vendors_config:
|
||||
$ref: ./definitions/vendors_config.yaml
|
||||
paths:
|
||||
/action_logs:
|
||||
$ref: ./paths/action_logs.yaml#/~1action_logs
|
||||
/acquisitions/baskets:
|
||||
$ref: ./paths/acquisitions_baskets.yaml#/~1acquisitions~1baskets
|
||||
/acquisitions/baskets/managers:
|
||||
|
|
|
|||
Loading…
Reference in New Issue