Line data Source code
1 : /*
2 : This file is part of TALER
3 : (C) 2025 Taler Systems SA
4 :
5 : TALER is free software; you can redistribute it and/or modify it under the
6 : terms of the GNU Affero General Public License as published by the Free Software
7 : Foundation; either version 3, or (at your option) any later version.
8 :
9 : TALER is distributed in the hope that it will be useful, but WITHOUT ANY
10 : WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 : A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12 :
13 : You should have received a copy of the GNU General Public License along with
14 : TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
15 : */
16 : /**
17 : * @file taler-merchant-httpd_private-delete-units-ID.c
18 : * @brief implement DELETE /private/units/$UNIT
19 : * @author Bohdan Potuzhnyi
20 : */
21 : #include "platform.h"
22 : #include "taler-merchant-httpd_private-delete-units-ID.h"
23 :
24 :
25 : MHD_RESULT
26 6 : TMH_private_delete_units_ID (const struct TMH_RequestHandler *rh,
27 : struct MHD_Connection *connection,
28 : struct TMH_HandlerContext *hc)
29 : {
30 : enum GNUNET_DB_QueryStatus qs;
31 6 : bool no_instance = false;
32 6 : bool no_unit = false;
33 6 : bool builtin_conflict = false;
34 :
35 6 : GNUNET_assert (NULL != hc->infix);
36 6 : qs = TMH_db->delete_unit (TMH_db->cls,
37 6 : hc->instance->settings.id,
38 6 : hc->infix,
39 : &no_instance,
40 : &no_unit,
41 : &builtin_conflict);
42 6 : switch (qs)
43 : {
44 6 : case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
45 6 : break;
46 0 : case GNUNET_DB_STATUS_SOFT_ERROR:
47 0 : GNUNET_break (0);
48 0 : return TALER_MHD_reply_with_error (connection,
49 : MHD_HTTP_INTERNAL_SERVER_ERROR,
50 : TALER_EC_GENERIC_DB_SOFT_FAILURE,
51 : "delete_unit");
52 0 : case GNUNET_DB_STATUS_HARD_ERROR:
53 : default:
54 0 : GNUNET_break (0);
55 0 : return TALER_MHD_reply_with_error (connection,
56 : MHD_HTTP_INTERNAL_SERVER_ERROR,
57 : TALER_EC_GENERIC_DB_STORE_FAILED,
58 : "delete_unit");
59 : }
60 6 : if (no_instance)
61 0 : return TALER_MHD_reply_with_error (connection,
62 : MHD_HTTP_NOT_FOUND,
63 : TALER_EC_MERCHANT_GENERIC_INSTANCE_UNKNOWN,
64 0 : hc->instance->settings.id);
65 6 : if (no_unit)
66 0 : return TALER_MHD_reply_with_error (connection,
67 : MHD_HTTP_NOT_FOUND,
68 : TALER_EC_MERCHANT_GENERIC_UNIT_UNKNOWN,
69 0 : hc->infix);
70 6 : if (builtin_conflict)
71 2 : return TALER_MHD_reply_with_error (connection,
72 : MHD_HTTP_CONFLICT,
73 : TALER_EC_MERCHANT_GENERIC_UNIT_BUILTIN,
74 2 : hc->infix);
75 4 : return TALER_MHD_reply_static (connection,
76 : MHD_HTTP_NO_CONTENT,
77 : NULL,
78 : NULL,
79 : 0);
80 : }
81 :
82 :
83 : /* end of taler-merchant-httpd_private-delete-units-ID.c */
|