taler-merchant-httpd_delete-private-donau-DONAU_SERIAL.c (3570B)
1 /* 2 This file is part of TALER 3 (C) 2024 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 src/backend/taler-merchant-httpd_delete-private-donau-DONAU_SERIAL.c 18 * @brief implement DELETE /private/donau/$donau_serial_id 19 * @author Bohdan Potuzhnyi 20 * @author Vlada Svirsh 21 */ 22 23 #include "platform.h" 24 #include "taler-merchant-httpd_delete-private-donau-DONAU_SERIAL.h" 25 #include <taler/taler_json_lib.h> 26 #include <taler/taler_error_codes.h> 27 #include <taler/taler_dbevents.h> 28 #include "merchant-database/delete_donau_instance.h" 29 30 /** 31 * Handle a DELETE "/donau/$donau_serial_id/" request. 32 * 33 * @param rh context of the handler 34 * @param connection the MHD connection to handle 35 * @param[in,out] hc context with further information about the request 36 * @return MHD result code 37 */ 38 enum MHD_Result 39 TMH_private_delete_donau_instance_ID (const struct TMH_RequestHandler *rh, 40 struct MHD_Connection *connection, 41 struct TMH_HandlerContext *hc) 42 { 43 struct TMH_MerchantInstance *mi = hc->instance; 44 enum GNUNET_DB_QueryStatus qs; 45 uint64_t donau_serial_id; 46 char dummy; 47 48 GNUNET_assert (NULL != mi); 49 if (1 != sscanf (hc->infix, 50 "%lu%c", 51 &donau_serial_id, 52 &dummy)) 53 { 54 return TALER_MHD_reply_with_error (connection, 55 MHD_HTTP_BAD_REQUEST, 56 TALER_EC_GENERIC_PARAMETER_MALFORMED, 57 hc->infix); 58 } 59 60 qs = TALER_MERCHANTDB_delete_donau_instance (TMH_db, 61 hc->instance->settings.id, 62 donau_serial_id); 63 switch (qs) 64 { 65 case GNUNET_DB_STATUS_HARD_ERROR: 66 return TALER_MHD_reply_with_error (connection, 67 MHD_HTTP_INTERNAL_SERVER_ERROR, 68 TALER_EC_GENERIC_DB_STORE_FAILED, 69 "delete_donau_instance"); 70 case GNUNET_DB_STATUS_SOFT_ERROR: 71 GNUNET_break (0); 72 return TALER_MHD_reply_with_error (connection, 73 MHD_HTTP_INTERNAL_SERVER_ERROR, 74 TALER_EC_GENERIC_DB_SOFT_FAILURE, 75 "delete_donau_instance (soft)"); 76 case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: 77 return TALER_MHD_reply_with_error (connection, 78 MHD_HTTP_NOT_FOUND, 79 TALER_EC_MERCHANT_GENERIC_DONAU_UNKNOWN, 80 NULL); 81 case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: 82 return TALER_MHD_reply_static (connection, 83 MHD_HTTP_NO_CONTENT, 84 NULL, 85 NULL, 86 0); 87 } 88 GNUNET_assert (0); 89 return MHD_NO; 90 }