web_api.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // SPDX-License-Identifier: GPL-3.0-or-later
  2. #ifndef NETDATA_WEB_API_H
  3. #define NETDATA_WEB_API_H 1
  4. #include "daemon/common.h"
  5. #include "web/api/badges/web_buffer_svg.h"
  6. #include "web/api/formatters/rrd2json.h"
  7. #include "web/api/health/health_cmdapi.h"
  8. #include "web/api/queries/weights.h"
  9. extern bool netdata_is_protected_by_bearer;
  10. extern DICTIONARY *netdata_authorized_bearers;
  11. typedef enum __attribute__((packed)) {
  12. BEARER_STATUS_NO_BEARER_IN_HEADERS,
  13. BEARER_STATUS_BEARER_DOES_NOT_FIT,
  14. BEARER_STATUS_NOT_PARSABLE,
  15. BEARER_STATUS_EXTRACTED_FROM_HEADER,
  16. BEARER_STATUS_NO_BEARERS_DICTIONARY,
  17. BEARER_STATUS_NOT_FOUND_IN_DICTIONARY,
  18. BEARER_STATUS_EXPIRED,
  19. BEARER_STATUS_AVAILABLE_AND_VALIDATED,
  20. } BEARER_STATUS;
  21. BEARER_STATUS api_check_bearer_token(struct web_client *w);
  22. BEARER_STATUS extract_bearer_token_from_request(struct web_client *w, char *dst, size_t dst_len);
  23. struct web_api_command {
  24. const char *command;
  25. uint32_t hash;
  26. WEB_CLIENT_ACL acl;
  27. int (*callback)(RRDHOST *host, struct web_client *w, char *url);
  28. unsigned int allow_subpaths;
  29. };
  30. struct web_client;
  31. int web_client_api_request_vX(RRDHOST *host, struct web_client *w, char *url_path_endpoint, struct web_api_command *api_commands);
  32. static inline void fix_google_param(char *s) {
  33. if(unlikely(!s || !*s)) return;
  34. for( ; *s ;s++) {
  35. if(!isalnum(*s) && *s != '.' && *s != '_' && *s != '-')
  36. *s = '_';
  37. }
  38. }
  39. int web_client_api_request_weights(RRDHOST *host, struct web_client *w, char *url, WEIGHTS_METHOD method, WEIGHTS_FORMAT format, size_t api_version);
  40. bool web_client_interrupt_callback(void *data);
  41. #include "web_api_v1.h"
  42. #include "web_api_v2.h"
  43. #endif //NETDATA_WEB_API_H