Bug 28020: (follow-up) Add docs about error_code on the API
[koha.git] / api / v1 / swagger / paths / transfer_limits.yaml
1 /transfer_limits:
2   get:
3     x-mojo-to: TransferLimits#list
4     operationId: listTransferLimits
5     description: This resource returns a list of existing transfer limits.
6     summary: List transfer limits
7     tags:
8       - transfer
9     parameters:
10       - name: to_library_id
11         in: query
12         description: Search on to_library_id
13         required: false
14         type: string
15       - name: from_library_id
16         in: query
17         description: Search on from_library_id
18         required: false
19         type: string
20       - name: item_type
21         in: query
22         description: Search on item_type
23         required: false
24         type: string
25       - name: collection_code
26         in: query
27         description: Search on collection_code
28         required: false
29         type: string
30       - $ref: ../parameters.yaml#/match
31       - $ref: ../parameters.yaml#/order_by
32       - $ref: ../parameters.yaml#/page
33       - $ref: ../parameters.yaml#/per_page
34       - $ref: ../parameters.yaml#/q_param
35       - $ref: ../parameters.yaml#/q_body
36       - $ref: ../parameters.yaml#/q_header
37     produces:
38       - application/json
39     responses:
40       "200":
41         description: A list of transfer limits
42         schema:
43           type: array
44           items:
45             $ref: ../definitions.yaml#/transfer_limit
46       "500":
47         description: |
48           Internal server error. Possible `error_code` attribute values:
49
50           * `internal_server_error`
51         schema:
52           $ref: ../definitions.yaml#/error
53       "503":
54         description: Under maintenance
55         schema:
56           $ref: ../definitions.yaml#/error
57     x-koha-authorization:
58       permissions:
59         parameters: manage_transfers
60   post:
61     x-mojo-to: TransferLimits#add
62     operationId: addTransferLimit
63     description: This resource accepts a new transfer limit and creates it if it does not
64       already exist.
65     tags:
66       - transfer
67     summary: Add a transfer limit
68     parameters:
69       - name: body
70         in: body
71         description: A JSON object containing information about a new transfer limit
72         required: true
73         schema:
74           $ref: ../definitions.yaml#/transfer_limit
75     produces:
76       - application/json
77     responses:
78       "201":
79         description: Transfer limit added
80         schema:
81           $ref: ../definitions.yaml#/transfer_limit
82       "400":
83         description: Bad request
84         schema:
85           $ref: ../definitions.yaml#/error
86       "401":
87         description: Authentication required
88         schema:
89           $ref: ../definitions.yaml#/error
90       "403":
91         description: Access forbidden
92         schema:
93           $ref: ../definitions.yaml#/error
94       "409":
95         description: Conflict in creating resource
96         schema:
97           $ref: ../definitions.yaml#/error
98       "500":
99         description: |
100           Internal server error. Possible `error_code` attribute values:
101
102           * `internal_server_error`
103         schema:
104           $ref: ../definitions.yaml#/error
105       "503":
106         description: Under maintenance
107         schema:
108           $ref: ../definitions.yaml#/error
109     x-koha-authorization:
110       permissions:
111         parameters: manage_transfers
112 "/transfer_limits/{limit_id}":
113   delete:
114     x-mojo-to: TransferLimits#delete
115     operationId: deleteTransferLimit
116     description: This resource deletes a transfer limit for the given limit id
117     tags:
118       - transfer
119     summary: Delete transfer limit
120     parameters:
121       - $ref: ../parameters.yaml#/transfer_limit_id_pp
122     produces:
123       - application/json
124     responses:
125       "204":
126         description: Transfer limit deleted
127         schema:
128           type: string
129       "401":
130         description: Authentication required
131         schema:
132           $ref: ../definitions.yaml#/error
133       "403":
134         description: Access forbidden
135         schema:
136           $ref: ../definitions.yaml#/error
137       "404":
138         description: Library not found
139         schema:
140           $ref: ../definitions.yaml#/error
141       "500":
142         description: |
143           Internal server error. Possible `error_code` attribute values:
144
145           * `internal_server_error`
146         schema:
147           $ref: ../definitions.yaml#/error
148       "503":
149         description: Under maintenance
150         schema:
151           $ref: ../definitions.yaml#/error
152     x-koha-authorization:
153       permissions:
154         parameters: manage_transfers
155 /transfer_limits/batch:
156   post:
157     x-mojo-to: TransferLimits#batch_add
158     operationId: batchAddTransferLimits
159     description: >
160
161       This resource batch creates new transfer limits based on the given data.
162
163       For example, if the paramters `to_library_id: 'BranchA'` and `item_type: 'BOOK'` are passed in
164       new transfer limits for `BOOK`s will be created, with one transfer limit each for all the
165       branches defined in Koha. Given 4 branches, 3 limits would be created:
166
167       * to_library_id: 'BranchA', from_library_id: 'BranchB', item_type: 'BOOK'
168       * to_library_id: 'BranchA', from_library_id: 'BranchC', item_type: 'BOOK'
169       * to_library_id: 'BranchA', from_library_id: 'BranchD', item_type: 'BOOK'
170
171
172       The body of the query would look like
173
174       ```
175
176       {
177           'to_library_id': 'BranchA',
178           'item_type': 'BOOK'
179
180       }
181
182       ```
183
184       As another example, imagine we have an itemtype that is never supposed to be transferred to another library.
185       If we call that itemtype `LOCAL_ONLY` we would need to just pass `item_type: 'LOCAL_ONLY'`, which would create transfer
186       limits for all libraries, meaning those items would never be allowed to transfer to another
187       library. The body of the query would look like
188
189       ```
190
191       {
192           'item_type': 'LOCAL_ONLY'
193       }
194
195       ```
196     tags:
197       - transfer
198     summary: Batch add transfer limits
199     parameters:
200       - name: body
201         in: body
202         description: A JSON object containing information about new transfer limits.
203         required: true
204         schema:
205           type: object
206           properties:
207             to_library_id:
208               type: string
209               description: Internal library id for which library the item is going to
210             from_library_id:
211               type: string
212               description: Internal library id for which library the item is coming from
213             item_type:
214               type:
215                 - string
216                 - "null"
217               description: Itemtype defining the type for this limi
218             collection_code:
219               type:
220                 - string
221                 - "null"
222               description: Authorized value for the collection code associated with this
223                 limit
224           additionalProperties: false
225     produces:
226       - application/json
227     responses:
228       "201":
229         description: A list of transfer limits
230         schema:
231           type: array
232           items:
233             $ref: ../definitions.yaml#/transfer_limit
234       "500":
235         description: |
236           Internal server error. Possible `error_code` attribute values:
237
238           * `internal_server_error`
239         schema:
240           $ref: ../definitions.yaml#/error
241       "503":
242         description: Under maintenance
243         schema:
244           $ref: ../definitions.yaml#/error
245     x-koha-authorization:
246       permissions:
247         parameters: manage_transfers
248   delete:
249     x-mojo-to: TransferLimits#batch_delete
250     operationId: batchDeleteTransferLimits
251     description: This endpoint works just like [the POST
252       version](#op-post-transfer_limits-batch), except it deletes transfer in
253       batch rather than creating them.
254     tags:
255       - transfer
256     summary: Batch delete transfer limits
257     parameters:
258       - name: body
259         in: body
260         description: A JSON object containing information about new transfer limits.
261         required: true
262         schema:
263           type: object
264           properties:
265             to_library_id:
266               type: string
267               description: Internal library id for which library the item is going to
268             from_library_id:
269               type: string
270               description: Internal library id for which library the item is coming from
271             item_type:
272               type:
273                 - string
274                 - "null"
275               description: Itemtype defining the type for this limi
276             collection_code:
277               type:
278                 - string
279                 - "null"
280               description: Authorized value for the collection code associated with this
281                 limit
282           additionalProperties: false
283     produces:
284       - application/json
285     responses:
286       "204":
287         description: Transfer limits deleted
288         schema:
289           type: string
290       "401":
291         description: Authentication required
292         schema:
293           $ref: ../definitions.yaml#/error
294       "403":
295         description: Access forbidden
296         schema:
297           $ref: ../definitions.yaml#/error
298       "404":
299         description: Library not found
300         schema:
301           $ref: ../definitions.yaml#/error
302       "500":
303         description: |
304           Internal server error. Possible `error_code` attribute values:
305
306           * `internal_server_error`
307         schema:
308           $ref: ../definitions.yaml#/error
309       "503":
310         description: Under maintenance
311         schema:
312           $ref: ../definitions.yaml#/error
313     x-koha-authorization:
314       permissions:
315         parameters: manage_transfers