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 <http://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 (+70 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
  ft_acquisitions:
48
    type: boolean
49
    description: ft_acquisitions
50
  created_on:
51
    description: date of creation
52
    type:
53
      - string
54
      - "null"
55
  updated_on:
56
    description: date of update
57
    type:
58
      - string
59
      - "null"
60
additionalProperties: false
61
required:
62
  - id
63
  - title
64
  - ft_limit_item_editing
65
  - ft_search_groups_opac
66
  - ft_search_groups_staff
67
  - ft_local_hold_group
68
  - ft_local_float_group
69
  - ft_acquisitions
70
(-)a/api/v1/swagger/paths/library_groups.yaml (+101 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
      - name: ft_acquisitions
61
        in: query
62
        description: search on ft_acquisitions
63
        required: false
64
        type: integer
65
      - $ref: "../swagger.yaml#/parameters/match"
66
      - $ref: "../swagger.yaml#/parameters/order_by"
67
      - $ref: "../swagger.yaml#/parameters/page"
68
      - $ref: "../swagger.yaml#/parameters/per_page"
69
      - $ref: "../swagger.yaml#/parameters/q_param"
70
      - $ref: "../swagger.yaml#/parameters/q_body"
71
      - $ref: "../swagger.yaml#/parameters/request_id_header"
72
    produces:
73
      - application/json
74
    responses:
75
      "200":
76
        description: A list of library groups
77
        schema:
78
          type: array
79
          items:
80
            $ref: "../swagger.yaml#/definitions/library_group"
81
      "400":
82
        description: |
83
          Bad request. Possible `error_code` attribute values:
84
85
            * `invalid_query`
86
        schema:
87
          $ref: "../swagger.yaml#/definitions/error"
88
      "500":
89
        description: |
90
          Internal server error. Possible `error_code` attribute values:
91
92
          * `internal_server_error`
93
        schema:
94
          $ref: "../swagger.yaml#/definitions/error"
95
      "503":
96
        description: Under maintenance
97
        schema:
98
          $ref: "../swagger.yaml#/definitions/error"
99
    x-koha-authorization:
100
      permissions:
101
        catalogue: "1"
(-)a/api/v1/swagger/swagger.yaml (-1 / +4 lines)
Lines 132-137 definitions: Link Here
132
    $ref: ./definitions/job.yaml
132
    $ref: ./definitions/job.yaml
133
  library:
133
  library:
134
    $ref: ./definitions/library.yaml
134
    $ref: ./definitions/library.yaml
135
  library_group:
136
    $ref: ./definitions/library_group.yaml
135
  list:
137
  list:
136
    $ref: ./definitions/list.yaml
138
    $ref: ./definitions/list.yaml
137
  merge_biblios:
139
  merge_biblios:
Lines 445-450 paths: Link Here
445
    $ref: "./paths/libraries.yaml#/~1libraries~1{library_id}~1cash_registers"
447
    $ref: "./paths/libraries.yaml#/~1libraries~1{library_id}~1cash_registers"
446
  "/libraries/{library_id}/desks":
448
  "/libraries/{library_id}/desks":
447
    $ref: "./paths/libraries.yaml#/~1libraries~1{library_id}~1desks"
449
    $ref: "./paths/libraries.yaml#/~1libraries~1{library_id}~1desks"
450
  /library_groups:
451
    $ref: ./paths/library_groups.yaml#/~1library_groups
448
  "/oauth/login/{provider_code}/{interface}":
452
  "/oauth/login/{provider_code}/{interface}":
449
    $ref: ./paths/oauth.yaml#/~1oauth~1login~1{provider_code}~1{interface}
453
    $ref: ./paths/oauth.yaml#/~1oauth~1login~1{provider_code}~1{interface}
450
  /oauth/token:
454
  /oauth/token:
451
- 

Return to bug 38291