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