View | Details | Raw Unified | Return to bug 38291
Collapse All | Expand All

(-)a/Koha/REST/V1/LibraryGroups.pm (+54 lines)
Line 0 Link Here
1
package Koha::REST::V1::LibraryGroups;
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <https://www.gnu.org/licenses>.
17
18
use Modern::Perl;
19
20
use Mojo::Base 'Mojolicious::Controller';
21
use Koha::Library::Groups;
22
23
use Scalar::Util qw( blessed );
24
25
use Try::Tiny qw( catch try );
26
27
=head1 NAME
28
29
Koha::REST::V1::LibraryGroups - Koha REST API for handling library groups (V1)
30
31
=head1 API
32
33
=head2 Methods
34
35
=cut
36
37
=head3 list
38
39
Controller function that handles listing Koha::Library::Group objects
40
41
=cut
42
43
sub list {
44
    my $c = shift->openapi->valid_input or return;
45
46
    return try {
47
        my $library_groups = $c->objects->search( Koha::Library::Groups->new );
48
        return $c->render( status => 200, openapi => $library_groups );
49
    } catch {
50
        $c->unhandled_exception($_);
51
    };
52
}
53
54
1;
(-)a/api/v1/swagger/definitions/library_group.yaml (+65 lines)
Line 0 Link Here
1
---
2
type: object
3
properties:
4
  id:
5
    type: string
6
    description: internally assigned library group identifier
7
    maxLength: 10
8
    minLength: 1
9
  title:
10
    type:
11
      - string
12
      - "null"
13
    description: Title of the library group
14
  branchcode:
15
    type:
16
      - string
17
      - "null"
18
    description: Branchcode in the library group
19
  description:
20
    type:
21
      - string
22
      - "null"
23
    description: the description of the library
24
  parent_id:
25
    type:
26
      - integer
27
      - "null"
28
    description: identifier for the parent group
29
  ft_hide_patron_info:
30
    type: boolean
31
    description: ft_hide_patron_info
32
  ft_limit_item_editing:
33
    type: boolean
34
    description: ft_limit_item_editing
35
  ft_search_groups_opac:
36
    type: boolean
37
    description: ft_search_groups_opac
38
  ft_search_groups_staff:
39
    type: boolean
40
    description: ft_search_groups_staff
41
  ft_local_hold_group:
42
    type: boolean
43
    description: ft_local_hold_group
44
  ft_local_float_group:
45
    type: boolean
46
    description: ft_local_float_group
47
  created_on:
48
    description: date of creation
49
    type:
50
      - string
51
      - "null"
52
  updated_on:
53
    description: date of update
54
    type:
55
      - string
56
      - "null"
57
additionalProperties: false
58
required:
59
  - id
60
  - title
61
  - ft_limit_item_editing
62
  - ft_search_groups_opac
63
  - ft_search_groups_staff
64
  - ft_local_hold_group
65
  - ft_local_float_group
(-)a/api/v1/swagger/paths/library_groups.yaml (+96 lines)
Line 0 Link Here
1
---
2
/library_groups:
3
  get:
4
    x-mojo-to: LibraryGroups#list
5
    operationId: listLibraryGroups
6
    tags:
7
      - library_groups
8
    summary: List library groups
9
    parameters:
10
      - name: parent_id
11
        in: query
12
        description: Identifier for the parent group
13
        required: false
14
        type: integer
15
      - name: branchcode
16
        in: query
17
        description: Branchcode included in the group
18
        required: false
19
        type: string
20
      - name: title
21
        in: query
22
        description: title of the library group
23
        required: false
24
        type: string
25
      - name: description
26
        in: query
27
        description: description of the library group
28
        required: false
29
        type: string
30
      - name: ft_hide_patron_info
31
        in: query
32
        description: search on ft_hide_patron_info
33
        required: false
34
        type: integer
35
      - name: ft_limit_item_editing
36
        in: query
37
        description: search on ft_limit_item_editing
38
        required: false
39
        type: integer
40
      - name: ft_search_groups_opac
41
        in: query
42
        description: search on ft_search_groups_opac
43
        required: false
44
        type: integer
45
      - name: ft_search_groups_staff
46
        in: query
47
        description: search on ft_search_groups_staff
48
        required: false
49
        type: integer
50
      - name: ft_local_hold_group
51
        in: query
52
        description: search on ft_local_hold_group
53
        required: false
54
        type: integer
55
      - name: ft_local_float_group
56
        in: query
57
        description: search on ft_local_float_group
58
        required: false
59
        type: integer
60
      - $ref: "../swagger.yaml#/parameters/match"
61
      - $ref: "../swagger.yaml#/parameters/order_by"
62
      - $ref: "../swagger.yaml#/parameters/page"
63
      - $ref: "../swagger.yaml#/parameters/per_page"
64
      - $ref: "../swagger.yaml#/parameters/q_param"
65
      - $ref: "../swagger.yaml#/parameters/q_body"
66
      - $ref: "../swagger.yaml#/parameters/request_id_header"
67
    produces:
68
      - application/json
69
    responses:
70
      "200":
71
        description: A list of library groups
72
        schema:
73
          type: array
74
          items:
75
            $ref: "../swagger.yaml#/definitions/library_group"
76
      "400":
77
        description: |
78
          Bad request. Possible `error_code` attribute values:
79
80
            * `invalid_query`
81
        schema:
82
          $ref: "../swagger.yaml#/definitions/error"
83
      "500":
84
        description: |
85
          Internal server error. Possible `error_code` attribute values:
86
87
          * `internal_server_error`
88
        schema:
89
          $ref: "../swagger.yaml#/definitions/error"
90
      "503":
91
        description: Under maintenance
92
        schema:
93
          $ref: "../swagger.yaml#/definitions/error"
94
    x-koha-authorization:
95
      permissions:
96
        catalogue: "1"
(-)a/api/v1/swagger/swagger.yaml (-1 / +4 lines)
Lines 136-141 definitions: Link Here
136
    $ref: ./definitions/job.yaml
136
    $ref: ./definitions/job.yaml
137
  library:
137
  library:
138
    $ref: ./definitions/library.yaml
138
    $ref: ./definitions/library.yaml
139
  library_group:
140
    $ref: ./definitions/library_group.yaml
139
  list:
141
  list:
140
    $ref: ./definitions/list.yaml
142
    $ref: ./definitions/list.yaml
141
  merge_biblios:
143
  merge_biblios:
Lines 471-476 paths: Link Here
471
    $ref: "./paths/libraries.yaml#/~1libraries~1{library_id}~1cash_registers"
473
    $ref: "./paths/libraries.yaml#/~1libraries~1{library_id}~1cash_registers"
472
  "/libraries/{library_id}/desks":
474
  "/libraries/{library_id}/desks":
473
    $ref: "./paths/libraries.yaml#/~1libraries~1{library_id}~1desks"
475
    $ref: "./paths/libraries.yaml#/~1libraries~1{library_id}~1desks"
476
  /library_groups:
477
    $ref: ./paths/library_groups.yaml#/~1library_groups
474
  "/oauth/login/{provider_code}/{interface}":
478
  "/oauth/login/{provider_code}/{interface}":
475
    $ref: ./paths/oauth.yaml#/~1oauth~1login~1{provider_code}~1{interface}
479
    $ref: ./paths/oauth.yaml#/~1oauth~1login~1{provider_code}~1{interface}
476
  /oauth/token:
480
  /oauth/token:
477
- 

Return to bug 38291