summaryrefslogtreecommitdiffstats
path: root/src/web/api/web_api.h
blob: cb694a33d7369e5dd98cc7452b985202dd442514 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// SPDX-License-Identifier: GPL-3.0-or-later

#ifndef NETDATA_WEB_API_H
#define NETDATA_WEB_API_H 1

#define ENABLE_API_V1 1
#define ENABLE_API_v2 1

struct web_client;

#include "daemon/common.h"
#include "maps/maps.h"
#include "functions/functions.h"

#include "web/api/http_header.h"
#include "web/api/http_auth.h"
#include "web/api/formatters/rrd2json.h"
#include "web/api/queries/weights.h"

void nd_web_api_init(void);

bool request_source_is_cloud(const char *source);
void web_client_api_request_vX_source_to_buffer(struct web_client *w, BUFFER *source);
void web_client_progress_functions_update(void *data, size_t done, size_t all);

void host_labels2json(RRDHOST *host, BUFFER *wb, const char *key);

struct web_api_command {
    const char *api;
    uint32_t hash;
    HTTP_ACL acl;
    HTTP_ACCESS access;
    int (*callback)(RRDHOST *host, struct web_client *w, char *url);
    unsigned int allow_subpaths;
};

struct web_client;

int web_client_api_request_vX(RRDHOST *host, struct web_client *w, char *url_path_endpoint, struct web_api_command *api_commands);

static inline void fix_google_param(char *s) {
    if(unlikely(!s || !*s)) return;

    for( ; *s ;s++) {
        if(!isalnum((uint8_t)*s) && *s != '.' && *s != '_' && *s != '-')
            *s = '_';
    }
}

int web_client_api_request_weights(RRDHOST *host, struct web_client *w, char *url, WEIGHTS_METHOD method, WEIGHTS_FORMAT format, size_t api_version);

bool web_client_interrupt_callback(void *data);

char *format_value_and_unit(char *value_string, size_t value_string_len,
                            NETDATA_DOUBLE value, const char *units, int precision);

#include "web_api_v1.h"
#include "web_api_v2.h"
#include "web_api_v3.h"

#endif //NETDATA_WEB_API_H