| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | |
| 3 | #include "api_v2_calls.h" |
| 4 | |
| 5 | int api_v2_alert_config(RRDHOST *host __maybe_unused, struct web_client *w, char *url) { |
| 6 | const char *config = NULL; |
| 7 | |
| 8 | while(url) { |
| 9 | char *value = strsep_skip_consecutive_separators(&url, "&"); |
| 10 | if(!value || !*value) continue; |
| 11 | |
| 12 | char *name = strsep_skip_consecutive_separators(&value, "="); |
| 13 | if(!name || !*name) continue; |
| 14 | if(!value || !*value) continue; |
| 15 | |
| 16 | // name and value are now the parameters |
| 17 | // they are not null and not empty |
| 18 | |
| 19 | if(!strcmp(name, "config")) |
| 20 | config = value; |
| 21 | } |
| 22 | |
| 23 | buffer_flush(w->response.data); |
| 24 | |
| 25 | if(!config) { |
| 26 | w->response.data->content_type = CT_TEXT_PLAIN; |
| 27 | buffer_strcat(w->response.data, "A config hash ID is required. Add ?config=UUID query param"); |
| 28 | return HTTP_RESP_BAD_REQUEST; |
| 29 | } |
| 30 | |
| 31 | return contexts_v2_alert_config_to_json(w, config); |
| 32 | } |