71c2a029a10a8f7b9291fcb788b53d516f0eb468
[src/app-framework-binder.git] / src / monitor-api.inc
1
2 static const char _afb_description_v2_monitor[] =
3     "{\"openapi\":\"3.0.0\",\"info\":{\"description\":\"\",\"title\":\"monito"
4     "r\",\"version\":\"1.0\",\"x-binding\":{\"version\":2,\"prefix\":\"f_\",\""
5     "postfix\":\"\",\"start\":null,\"onevent\":null,\"init\":null,\"scope\":\""
6     "static\",\"private\":true}},\"servers\":[{\"url\":\"ws://{host}:{port}/a"
7     "pi/monitor\",\"description\":\"The API server.\",\"variables\":{\"host\""
8     ":{\"default\":\"localhost\"},\"port\":{\"default\":\"1234\"}},\"x-afb-ev"
9     "ents\":[{\"$ref\":\"#/components/schemas/afb-event\"}]}],\"components\":"
10     "{\"schemas\":{\"afb-reply\":{\"$ref\":\"#/components/schemas/afb-reply-v"
11     "1\"},\"afb-event\":{\"$ref\":\"#/components/schemas/afb-event-v1\"},\"af"
12     "b-reply-v1\":{\"title\":\"Generic response.\",\"type\":\"object\",\"requ"
13     "ired\":[\"jtype\",\"request\"],\"properties\":{\"jtype\":{\"const\":\"af"
14     "b-reply\"},\"request\":{\"type\":\"object\",\"required\":[\"status\"],\""
15     "properties\":{\"status\":{\"type\":\"string\"},\"info\":{\"type\":\"stri"
16     "ng\"},\"token\":{\"type\":\"string\"},\"uuid\":{\"type\":\"string\"},\"r"
17     "eqid\":{\"type\":\"string\"}}},\"response\":{\"type\":\"object\"}}},\"af"
18     "b-event-v1\":{\"type\":\"object\",\"properties\":{\"jtype\":{\"type\":\""
19     "string\"},\"event\":{\"type\":\"string\"},\"data\":{\"type\":\"object\"}"
20     "}}},\"x-permissions\":{\"set\":{\"permission\":\"urn:AGL:permission:moni"
21     "tor:public:set\"},\"get\":{\"permission\":\"urn:AGL:permission:monitor:p"
22     "ublic:get\"},\"get-or-set\":{\"anyOf\":[{\"$ref\":\"#/components/x-permi"
23     "ssions/get\"},{\"$ref\":\"#/components/x-permissions/set\"}]}}},\"paths\""
24     ":{\"/get\":{\"description\":\"Get monitoring data.\",\"x-permissions\":{"
25     "\"$ref\":\"#/components/x-permissions/get-or-set\"},\"get\":{\"parameter"
26     "s\":[{\"in\":\"query\",\"name\":\"filter\",\"required\":false,\"schema\""
27     ":{\"type\":\"object\",\"properties\":{\"event\":{\"type\":\"string\"}}}}"
28     "],\"responses\":{\"200\":{\"description\":\"A complex object array respo"
29     "nse\",\"content\":{\"application/json\":{\"schema\":{\"$ref\":\"#/compon"
30     "ents/schemas/afb-reply\"}}}}}}},\"/set\":{\"description\":\"Set monitori"
31     "ng actions.\",\"x-permissions\":{\"$ref\":\"#/components/x-permissions/s"
32     "et\"},\"get\":{\"parameters\":[{\"in\":\"query\",\"name\":\"filter\",\"r"
33     "equired\":false,\"schema\":{\"type\":\"object\",\"properties\":{\"event\""
34     ":{\"type\":\"string\"}}}}],\"responses\":{\"200\":{\"description\":\"A c"
35     "omplex object array response\",\"content\":{\"application/json\":{\"sche"
36     "ma\":{\"$ref\":\"#/components/schemas/afb-reply\"}}}}}}}}}"
37 ;
38
39 static const struct afb_auth _afb_auths_v2_monitor[] = {
40         { .type = afb_auth_Permission, .text = "urn:AGL:permission:monitor:public:set" },
41         { .type = afb_auth_Permission, .text = "urn:AGL:permission:monitor:public:get" },
42         { .type = afb_auth_Or, .first = &_afb_auths_v2_monitor[1], .next = &_afb_auths_v2_monitor[0] }
43 };
44
45 static void f_get(struct afb_req req);
46 static void f_set(struct afb_req req);
47
48 static const struct afb_verb_v2 _afb_verbs_v2_monitor[] = {
49     {
50         .verb = "get",
51         .callback = f_get,
52         .auth = &_afb_auths_v2_monitor[2],
53         .session = 0,
54     },
55     {
56         .verb = "set",
57         .callback = f_set,
58         .auth = &_afb_auths_v2_monitor[0],
59         .session = 0,
60     },
61     { .verb = NULL }
62 };
63
64 static const struct afb_binding_v2 _afb_binding_v2_monitor = {
65     .api = "monitor",
66     .specification = _afb_description_v2_monitor,
67     .verbs = _afb_verbs_v2_monitor,
68     .init = NULL,
69     .start = NULL,
70     .onevent = NULL,
71 };
72