delete-management-instances-INSTANCE.h (5867B)
1 /* 2 This file is part of TALER 3 Copyright (C) 2014-2026 Taler Systems SA 4 5 TALER is free software; you can redistribute it and/or modify it under the 6 terms of the GNU Lesser General Public License as published by the Free Software 7 Foundation; either version 2.1, 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 Lesser General Public License for more details. 12 13 You should have received a copy of the GNU Lesser General Public License along with 14 TALER; see the file COPYING.LGPL. If not, see 15 <http://www.gnu.org/licenses/> 16 */ 17 /** 18 * @file src/include/taler/merchant/delete-management-instances-INSTANCE.h 19 * @brief C interface for DELETE /management/instances/$INSTANCE 20 * @author Christian Grothoff 21 */ 22 #ifndef _TALER_MERCHANT__DELETE_MANAGEMENT_INSTANCES_INSTANCE_H 23 #define _TALER_MERCHANT__DELETE_MANAGEMENT_INSTANCES_INSTANCE_H 24 25 #include <taler/merchant/common.h> 26 27 28 /** 29 * Handle for a DELETE /management/instances/$INSTANCE operation. 30 */ 31 struct TALER_MERCHANT_DeleteManagementInstanceHandle; 32 33 34 /** 35 * Set up DELETE /management/instances/$INSTANCE operation. 36 * Note that you must explicitly start the operation after setup. 37 * 38 * @param ctx curl context 39 * @param url merchant backend base URL 40 * @param instance_id identifier of the instance to delete 41 * @return handle to operation, NULL on error 42 */ 43 struct TALER_MERCHANT_DeleteManagementInstanceHandle * 44 TALER_MERCHANT_delete_management_instance_create ( 45 struct GNUNET_CURL_Context *ctx, 46 const char *url, 47 const char *instance_id); 48 49 50 /** 51 * Options for DELETE /management/instances/$INSTANCE. 52 */ 53 enum TALER_MERCHANT_DeleteManagementInstanceOption 54 { 55 /** 56 * Sentinel value, end of options. 57 */ 58 TALER_MERCHANT_DELETE_MANAGEMENT_INSTANCE_OPTION_END = 0, 59 60 /** 61 * If set, purge (hard delete) the instance, removing all data. 62 * Without this option, a soft delete is performed (preserves data). 63 * Value type: none (presence of option means purge=yes). 64 */ 65 TALER_MERCHANT_DELETE_MANAGEMENT_INSTANCE_OPTION_PURGE 66 }; 67 68 69 /** 70 * Value for a DELETE /management/instances/$INSTANCE option. 71 */ 72 struct TALER_MERCHANT_DeleteManagementInstanceOptionValue 73 { 74 /** 75 * Which option is being set. 76 */ 77 enum TALER_MERCHANT_DeleteManagementInstanceOption option; 78 }; 79 80 81 /** 82 * Set options for DELETE /management/instances/$INSTANCE operation. 83 * 84 * @param[in,out] handle the handle to set options for 85 * @param num_options length of the @a options array 86 * @param options array of option values (terminated with _END) 87 */ 88 void 89 TALER_MERCHANT_delete_management_instance_set_options_ ( 90 struct TALER_MERCHANT_DeleteManagementInstanceHandle *handle, 91 unsigned int num_options, 92 const struct TALER_MERCHANT_DeleteManagementInstanceOptionValue options[]); 93 94 95 /** 96 * Maximum number of options for set_options macro. 97 */ 98 #define TALER_MERCHANT_DELETE_MANAGEMENT_INSTANCE_OPTIONS_ARRAY_MAX_SIZE 4 99 100 /** 101 * Set options for DELETE /management/instances/$INSTANCE operation. 102 * Variadic macro wrapper around 103 * #TALER_MERCHANT_delete_management_instance_set_options_(). 104 * 105 * @param handle the handle to set options for 106 * @param ... option values (automatically terminated with _END) 107 */ 108 #define TALER_MERCHANT_delete_management_instance_set_options(handle, ...) \ 109 do { \ 110 struct TALER_MERCHANT_DeleteManagementInstanceOptionValue __opts[] = { \ 111 __VA_ARGS__, \ 112 { .option = TALER_MERCHANT_DELETE_MANAGEMENT_INSTANCE_OPTION_END } \ 113 }; \ 114 TALER_MERCHANT_delete_management_instance_set_options_ ( \ 115 handle, \ 116 sizeof (__opts) / sizeof (__opts[0]) - 1, \ 117 __opts); \ 118 } while (0) 119 120 121 /** 122 * Response details for a DELETE /management/instances/$INSTANCE request. 123 */ 124 struct TALER_MERCHANT_DeleteManagementInstanceResponse 125 { 126 /** 127 * HTTP response details. 128 */ 129 struct TALER_MERCHANT_HttpResponse hr; 130 131 /** 132 * Details depending on HTTP status code. 133 */ 134 union 135 { 136 /** 137 * Details in case HTTP status code is #MHD_HTTP_ACCEPTED. 138 */ 139 struct TALER_MERCHANT_MfaChallengeResponse accepted; 140 } details; 141 }; 142 143 144 #ifndef TALER_MERCHANT_DELETE_MANAGEMENT_INSTANCE_RESULT_CLOSURE 145 /** 146 * Type of the closure used by 147 * the #TALER_MERCHANT_DeleteManagementInstanceCallback. 148 */ 149 #define TALER_MERCHANT_DELETE_MANAGEMENT_INSTANCE_RESULT_CLOSURE void 150 #endif /* TALER_MERCHANT_DELETE_MANAGEMENT_INSTANCE_RESULT_CLOSURE */ 151 152 /** 153 * Type of the function that receives the result of a 154 * DELETE /management/instances/$INSTANCE request. 155 * 156 * @param cls closure 157 * @param result result returned by the HTTP server 158 */ 159 typedef void 160 (*TALER_MERCHANT_DeleteManagementInstanceCallback)( 161 TALER_MERCHANT_DELETE_MANAGEMENT_INSTANCE_RESULT_CLOSURE *cls, 162 const struct TALER_MERCHANT_DeleteManagementInstanceResponse *result); 163 164 165 /** 166 * Start DELETE /management/instances/$INSTANCE operation. 167 * 168 * @param[in,out] handle operation to start 169 * @param cb function to call with the result 170 * @param cb_cls closure for @a cb 171 * @return status code, #TALER_EC_NONE on success 172 */ 173 enum TALER_ErrorCode 174 TALER_MERCHANT_delete_management_instance_start ( 175 struct TALER_MERCHANT_DeleteManagementInstanceHandle *handle, 176 TALER_MERCHANT_DeleteManagementInstanceCallback cb, 177 TALER_MERCHANT_DELETE_MANAGEMENT_INSTANCE_RESULT_CLOSURE *cb_cls); 178 179 180 /** 181 * Cancel DELETE /management/instances/$INSTANCE operation. 182 * This function must not be called by clients after the 183 * callback has been invoked. 184 * 185 * @param[in] handle operation to cancel 186 */ 187 void 188 TALER_MERCHANT_delete_management_instance_cancel ( 189 struct TALER_MERCHANT_DeleteManagementInstanceHandle *handle); 190 191 192 #endif /* _TALER_MERCHANT__DELETE_MANAGEMENT_INSTANCES_INSTANCE_H */