| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | |
| 3 | #ifndef NETDATA_WEB_API_H |
| 4 | #define NETDATA_WEB_API_H 1 |
| 5 | |
| 6 | #define ENABLE_API_V1 1 |
| 7 | #define ENABLE_API_v2 1 |
| 8 | |
| 9 | struct web_client; |
| 10 | |
| 11 | #include "database/rrd.h" |
| 12 | #include "maps/maps.h" |
| 13 | #include "functions/functions.h" |
| 14 | |
| 15 | #include "web/api/http_header.h" |
| 16 | #include "web/api/http_auth.h" |
| 17 | #include "web/api/formatters/rrd2json.h" |
| 18 | #include "web/api/queries/weights.h" |
| 19 | #include "libnetdata/user-auth/user-auth.h" |
| 20 | |
| 21 | void nd_web_api_init(void); |
| 22 | |
| 23 | void web_client_progress_functions_update(nd_uuid_t *transaction, void *data, size_t done, size_t all); |
| 24 | |
| 25 | void host_labels2json(RRDHOST *host, BUFFER *wb, const char *key); |
| 26 | |
| 27 | struct web_api_command { |
| 28 | const char *api; |
| 29 | uint32_t hash; |
| 30 | HTTP_ACL acl; |
| 31 | HTTP_ACCESS access; |
| 32 | int (*callback)(RRDHOST *host, struct web_client *w, char *url); |
| 33 | unsigned int allow_subpaths; |
| 34 | }; |
| 35 | |
| 36 | struct web_client; |
| 37 | |
| 38 | int web_client_api_request_vX(RRDHOST *host, struct web_client *w, char *url_path_endpoint, struct web_api_command *api_commands); |
| 39 | |
| 40 | static inline void fix_google_param(char *s) { |
| 41 | if(unlikely(!s || !*s)) return; |
| 42 | |
| 43 | for( ; *s ;s++) { |
| 44 | if(!isalnum((uint8_t)*s) && *s != '.' && *s != '_' && *s != '-') |
| 45 | *s = '_'; |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | int web_client_api_request_weights(RRDHOST *host, struct web_client *w, char *url, WEIGHTS_METHOD method, WEIGHTS_FORMAT format, size_t api_version); |
| 50 | |
| 51 | bool web_client_interrupt_callback(void *data); |
| 52 | |
| 53 | char *format_value_and_unit(char *value_string, size_t value_string_len, |
| 54 | NETDATA_DOUBLE value, const char *units, int precision); |
| 55 | |
| 56 | void web_client_ensure_proper_authorization(struct web_client *w); |
| 57 | |
| 58 | #include "web_api_v1.h" |
| 59 | #include "web_api_v2.h" |
| 60 | #include "web_api_v3.h" |
| 61 | |
| 62 | #endif //NETDATA_WEB_API_H |