afb-apiset: Fix start of apis
[src/app-framework-binder.git] / src / monitor-api.inc
1
2 static const char _afb_description_monitor[] =
3     "{\"openapi\":\"3.0.0\",\"info\":{\"description\":\"monitoring of binding"
4     "s and internals\",\"title\":\"monitor\",\"version\":\"1.0\",\"x-binding-"
5     "c-generator\":{\"api\":\"monitor\",\"version\":2,\"prefix\":\"f_\",\"pos"
6     "tfix\":\"\",\"preinit\":null,\"init\":null,\"onevent\":null,\"scope\":\""
7     "static\",\"private\":true}},\"servers\":[{\"url\":\"ws://{host}:{port}/a"
8     "pi/monitor\",\"description\":\"The API server.\",\"variables\":{\"host\""
9     ":{\"default\":\"localhost\"},\"port\":{\"default\":\"1234\"}},\"x-afb-ev"
10     "ents\":[{\"$ref\":\"#/components/schemas/afb-event\"}]}],\"components\":"
11     "{\"schemas\":{\"afb-reply\":{\"$ref\":\"#/components/schemas/afb-reply-v"
12     "1\"},\"afb-event\":{\"$ref\":\"#/components/schemas/afb-event-v1\"},\"af"
13     "b-reply-v1\":{\"title\":\"Generic response.\",\"type\":\"object\",\"requ"
14     "ired\":[\"jtype\",\"request\"],\"properties\":{\"jtype\":{\"type\":\"str"
15     "ing\",\"const\":\"afb-reply\"},\"request\":{\"type\":\"object\",\"requir"
16     "ed\":[\"status\"],\"properties\":{\"status\":{\"type\":\"string\"},\"inf"
17     "o\":{\"type\":\"string\"},\"token\":{\"type\":\"string\"},\"uuid\":{\"ty"
18     "pe\":\"string\"},\"reqid\":{\"type\":\"string\"}}},\"response\":{\"type\""
19     ":\"object\"}}},\"afb-event-v1\":{\"type\":\"object\",\"required\":[\"jty"
20     "pe\",\"event\"],\"properties\":{\"jtype\":{\"type\":\"string\",\"const\""
21     ":\"afb-event\"},\"event\":{\"type\":\"string\"},\"data\":{\"type\":\"obj"
22     "ect\"}}},\"set-verbosity\":{\"anyOf\":[{\"$ref\":\"#/components/schemas/"
23     "verbosity-map\"},{\"$ref\":\"#/components/schemas/verbosity-level\"}]},\""
24     "get-request\":{\"type\":\"object\",\"properties\":{\"verbosity\":{\"$ref"
25     "\":\"#/components/schemas/get-verbosity\"},\"apis\":{\"$ref\":\"#/compon"
26     "ents/schemas/get-apis\"}}},\"get-response\":{\"type\":\"object\",\"prope"
27     "rties\":{\"verbosity\":{\"$ref\":\"#/components/schemas/verbosity-map\"}"
28     ",\"apis\":{\"type\":\"object\"}}},\"get-verbosity\":{\"anyOf\":[{\"type\""
29     ":\"boolean\"},{\"type\":\"array\",\"items\":{\"type\":\"string\"}},{\"ty"
30     "pe\":\"object\"}]},\"get-apis\":{\"anyOf\":[{\"type\":\"boolean\"},{\"ty"
31     "pe\":\"array\",\"items\":{\"type\":\"string\"}},{\"type\":\"object\"}]},"
32     "\"verbosity-map\":{\"type\":\"object\",\"patternProperties\":{\"^.*$\":{"
33     "\"$ref\":\"#/components/schemas/verbosity-level\"}}},\"verbosity-level\""
34     ":{\"enum\":[\"debug\",3,\"info\",2,\"notice\",\"warning\",1,\"error\",0]"
35     "},\"trace-add\":{\"anyOf\":[{\"type\":\"array\",\"items\":{\"$ref\":\"#/"
36     "components/schemas/trace-add-object\"}},{\"$ref\":\"#/components/schemas"
37     "/trace-add-any\"}]},\"trace-add-any\":{\"anyOf\":[{\"$ref\":\"#/componen"
38     "ts/schemas/trace-add-request\"},{\"$ref\":\"#/components/schemas/trace-a"
39     "dd-object\"}]},\"trace-add-object\":{\"type\":\"object\",\"properties\":"
40     "{\"name\":{\"type\":\"string\",\"description\":\"name of the generated e"
41     "vent\",\"default\":\"trace\"},\"tag\":{\"type\":\"string\",\"description"
42     "\":\"tag for grouping traces\",\"default\":\"trace\"},\"api\":{\"type\":"
43     "\"string\",\"description\":\"api for requests, daemons and services\"},\""
44     "verb\":{\"type\":\"string\",\"description\":\"verb for requests\"},\"uui"
45     "d\":{\"type\":\"string\",\"description\":\"uuid of session for requests\""
46     "},\"pattern\":{\"type\":\"string\",\"description\":\"pattern for events\""
47     "},\"request\":{\"$ref\":\"#/components/schemas/trace-add-request\"},\"da"
48     "emon\":{\"$ref\":\"#/components/schemas/trace-add-daemon\"},\"service\":"
49     "{\"$ref\":\"#/components/schemas/trace-add-service\"},\"event\":{\"$ref\""
50     ":\"#/components/schemas/trace-add-event\"},\"session\":{\"$ref\":\"#/com"
51     "ponents/schemas/trace-add-session\"},\"for\":{\"$ref\":\"#/components/sc"
52     "hemas/trace-add\"}},\"examples\":[{\"tag\":\"1\",\"for\":[\"common\",{\""
53     "api\":\"xxx\",\"request\":\"*\",\"daemon\":\"*\",\"service\":\"*\"}]}]},"
54     "\"trace-add-request\":{\"anyOf\":[{\"type\":\"array\",\"items\":{\"$ref\""
55     ":\"#/components/schemas/trace-request-names\"}},{\"$ref\":\"#/components"
56     "/schemas/trace-request-names\"}]},\"trace-request-names\":{\"title\":\"n"
57     "ame of traceable items of requests\",\"enum\":[\"*\",\"addref\",\"all\","
58     "\"args\",\"begin\",\"common\",\"context\",\"context_get\",\"context_set\""
59     ",\"end\",\"event\",\"extra\",\"fail\",\"get\",\"json\",\"life\",\"ref\","
60     "\"result\",\"session\",\"session_close\",\"session_set_LOA\",\"simple\","
61     "\"store\",\"stores\",\"subcall\",\"subcall_result\",\"subcalls\",\"subca"
62     "llsync\",\"subcallsync_result\",\"subscribe\",\"success\",\"unref\",\"un"
63     "store\",\"unsubscribe\",\"vverbose\"]},\"trace-add-daemon\":{\"anyOf\":["
64     "{\"type\":\"array\",\"items\":{\"$ref\":\"#/components/schemas/trace-dae"
65     "mon-names\"}},{\"$ref\":\"#/components/schemas/trace-daemon-names\"}]},\""
66     "trace-daemon-names\":{\"title\":\"name of traceable items of daemons\",\""
67     "enum\":[\"*\",\"all\",\"common\",\"event_broadcast_after\",\"event_broad"
68     "cast_before\",\"event_make\",\"extra\",\"get_event_loop\",\"get_system_b"
69     "us\",\"get_user_bus\",\"queue_job\",\"require_api\",\"require_api_result"
70     "\",\"rootdir_get_fd\",\"rootdir_open_locale\",\"unstore_req\",\"vverbose"
71     "\"]},\"trace-add-service\":{\"anyOf\":[{\"type\":\"array\",\"items\":{\""
72     "$ref\":\"#/components/schemas/trace-service-names\"}},{\"$ref\":\"#/comp"
73     "onents/schemas/trace-service-names\"}]},\"trace-service-names\":{\"title"
74     "\":\"name of traceable items of services\",\"enum\":[\"*\",\"all\",\"cal"
75     "l\",\"call_result\",\"callsync\",\"callsync_result\",\"on_event_after\","
76     "\"on_event_before\",\"start_after\",\"start_before\"]},\"trace-add-event"
77     "\":{\"anyOf\":[{\"type\":\"array\",\"items\":{\"$ref\":\"#/components/sc"
78     "hemas/trace-event-names\"}},{\"$ref\":\"#/components/schemas/trace-event"
79     "-names\"}]},\"trace-event-names\":{\"title\":\"name of traceable items o"
80     "f events\",\"enum\":[\"*\",\"all\",\"broadcast_after\",\"broadcast_befor"
81     "e\",\"common\",\"create\",\"drop\",\"extra\",\"name\",\"push_after\",\"p"
82     "ush_before\"]},\"trace-add-session\":{\"anyOf\":[{\"type\":\"array\",\"i"
83     "tems\":{\"$ref\":\"#/components/schemas/trace-session-names\"}},{\"$ref\""
84     ":\"#/components/schemas/trace-session-names\"}]},\"trace-session-names\""
85     ":{\"title\":\"name of traceable items for sessions\",\"enum\":[\"*\",\"a"
86     "ddref\",\"all\",\"close\",\"common\",\"create\",\"destroy\",\"renew\",\""
87     "unref\"]},\"trace-drop\":{\"anyOf\":[{\"type\":\"boolean\"},{\"type\":\""
88     "object\",\"properties\":{\"event\":{\"anyOf\":[{\"type\":\"string\"},{\""
89     "type\":\"array\",\"items\":\"string\"}]},\"tag\":{\"anyOf\":[{\"type\":\""
90     "string\"},{\"type\":\"array\",\"items\":\"string\"}]},\"uuid\":{\"anyOf\""
91     ":[{\"type\":\"string\"},{\"type\":\"array\",\"items\":\"string\"}]}}}]}}"
92     "},\"paths\":{\"/get\":{\"description\":\"Get monitoring data.\",\"get\":"
93     "{\"x-permissions\":{\"session\":\"check\"},\"parameters\":[{\"in\":\"que"
94     "ry\",\"name\":\"verbosity\",\"required\":false,\"schema\":{\"$ref\":\"#/"
95     "components/schemas/get-verbosity\"}},{\"in\":\"query\",\"name\":\"apis\""
96     ",\"required\":false,\"schema\":{\"$ref\":\"#/components/schemas/get-apis"
97     "\"}}],\"responses\":{\"200\":{\"description\":\"A complex object array r"
98     "esponse\",\"content\":{\"application/json\":{\"schema\":{\"$ref\":\"#/co"
99     "mponents/schemas/afb-reply\"}}}}}}},\"/set\":{\"description\":\"Set moni"
100     "toring actions.\",\"get\":{\"x-permissions\":{\"session\":\"check\"},\"p"
101     "arameters\":[{\"in\":\"query\",\"name\":\"verbosity\",\"required\":false"
102     ",\"schema\":{\"$ref\":\"#/components/schemas/set-verbosity\"}}],\"respon"
103     "ses\":{\"200\":{\"description\":\"A complex object array response\",\"co"
104     "ntent\":{\"application/json\":{\"schema\":{\"$ref\":\"#/components/schem"
105     "as/afb-reply\"}}}}}}},\"/trace\":{\"description\":\"Set monitoring actio"
106     "ns.\",\"get\":{\"x-permissions\":{\"session\":\"check\"},\"parameters\":"
107     "[{\"in\":\"query\",\"name\":\"add\",\"required\":false,\"schema\":{\"$re"
108     "f\":\"#/components/schemas/trace-add\"}},{\"in\":\"query\",\"name\":\"dr"
109     "op\",\"required\":false,\"schema\":{\"$ref\":\"#/components/schemas/trac"
110     "e-drop\"}}],\"responses\":{\"200\":{\"description\":\"A complex object a"
111     "rray response\",\"content\":{\"application/json\":{\"schema\":{\"$ref\":"
112     "\"#/components/schemas/afb-reply\"}}}}}}},\"/session\":{\"description\":"
113     "\"describes the session.\",\"get\":{\"x-permissions\":{\"session\":\"che"
114     "ck\"},\"parameters\":[{\"in\":\"query\",\"name\":\"refresh-token\",\"req"
115     "uired\":false,\"schema\":{\"type\":\"boolean\"}}],\"responses\":{\"200\""
116     ":{\"description\":\"A complex object array response\",\"content\":{\"app"
117     "lication/json\":{\"schema\":{\"$ref\":\"#/components/schemas/afb-reply\""
118     "}}}}}}}}}"
119 ;
120
121 static void f_get(afb_req_t req);
122 static void f_set(afb_req_t req);
123 static void f_trace(afb_req_t req);
124 static void f_session(afb_req_t req);
125
126 static const struct afb_verb_v3 _afb_verbs_monitor[] = {
127     {
128         .verb = "get",
129         .callback = f_get,
130         .auth = NULL,
131         .info = "Get monitoring data.",
132         .session = AFB_SESSION_CHECK,
133         .vcbdata = NULL,
134         .glob = 0
135     },
136     {
137         .verb = "set",
138         .callback = f_set,
139         .auth = NULL,
140         .info = "Set monitoring actions.",
141         .session = AFB_SESSION_CHECK,
142         .vcbdata = NULL,
143         .glob = 0
144     },
145     {
146         .verb = "trace",
147         .callback = f_trace,
148         .auth = NULL,
149         .info = "Set monitoring actions.",
150         .session = AFB_SESSION_CHECK,
151         .vcbdata = NULL,
152         .glob = 0
153     },
154     {
155         .verb = "session",
156         .callback = f_session,
157         .auth = NULL,
158         .info = "describes the session.",
159         .session = AFB_SESSION_CHECK,
160         .vcbdata = NULL,
161         .glob = 0
162     },
163     {
164         .verb = NULL,
165         .callback = NULL,
166         .auth = NULL,
167         .info = NULL,
168         .session = 0,
169         .vcbdata = NULL,
170         .glob = 0
171         }
172 };
173
174 static const struct afb_binding_v3 _afb_binding_monitor = {
175     .api = "monitor",
176     .specification = _afb_description_monitor,
177     .info = "monitoring of bindings and internals",
178     .verbs = _afb_verbs_monitor,
179     .preinit = NULL,
180     .init = NULL,
181     .onevent = NULL,
182     .userdata = NULL,
183     .noconcurrency = 0
184 };
185