876ac89bf0b37bcef7d6405f0d6f089218394ca6
[apps/agl-service-unicens.git] / ucs2-afb / ucs_apidef.h
1
2 static const char _afb_description_v2_UNICENS[] =
3     "{\"openapi\":\"3.0.0\",\"$schema\":\"http:iot.bzh/download/openapi/schem"
4     "a-3.0/default-schema.json\",\"info\":{\"description\":\"\",\"title\":\"u"
5     "cs2\",\"version\":\"1.0\",\"x-binding-c-generator\":{\"api\":\"UNICENS\""
6     ",\"version\":2,\"prefix\":\"ucs2_\",\"postfix\":\"\",\"start\":null,\"on"
7     "event\":null,\"init\":null,\"scope\":\"\",\"private\":false}},\"servers\""
8     ":[{\"url\":\"ws://{host}:{port}/api/monitor\",\"description\":\"Unicens2"
9     " API.\",\"variables\":{\"host\":{\"default\":\"localhost\"},\"port\":{\""
10     "default\":\"1234\"}},\"x-afb-events\":[{\"$ref\":\"#/components/schemas/"
11     "afb-event\"}]}],\"components\":{\"schemas\":{\"afb-reply\":{\"$ref\":\"#"
12     "/components/schemas/afb-reply-v2\"},\"afb-event\":{\"$ref\":\"#/componen"
13     "ts/schemas/afb-event-v2\"},\"afb-reply-v2\":{\"title\":\"Generic respons"
14     "e.\",\"type\":\"object\",\"required\":[\"jtype\",\"request\"],\"properti"
15     "es\":{\"jtype\":{\"type\":\"string\",\"const\":\"afb-reply\"},\"request\""
16     ":{\"type\":\"object\",\"required\":[\"status\"],\"properties\":{\"status"
17     "\":{\"type\":\"string\"},\"info\":{\"type\":\"string\"},\"token\":{\"typ"
18     "e\":\"string\"},\"uuid\":{\"type\":\"string\"},\"reqid\":{\"type\":\"str"
19     "ing\"}}},\"response\":{\"type\":\"object\"}}},\"afb-event-v2\":{\"type\""
20     ":\"object\",\"required\":[\"jtype\",\"event\"],\"properties\":{\"jtype\""
21     ":{\"type\":\"string\",\"const\":\"afb-event\"},\"event\":{\"type\":\"str"
22     "ing\"},\"data\":{\"type\":\"object\"}}}},\"x-permissions\":{\"config\":{"
23     "\"permission\":\"urn:AGL:permission:UNICENS:public:initialise\"},\"monit"
24     "or\":{\"permission\":\"urn:AGL:permission:UNICENS:public:monitor\"}},\"r"
25     "esponses\":{\"200\":{\"description\":\"A complex object array response\""
26     ",\"content\":{\"application/json\":{\"schema\":{\"$ref\":\"#/components/"
27     "schemas/afb-reply\"}}}}}},\"paths\":{\"/listconfig\":{\"description\":\""
28     "List Config Files\",\"get\":{\"x-permissions\":{\"$ref\":\"#/components/"
29     "x-permissions/config\"},\"parameters\":[{\"in\":\"query\",\"name\":\"cfg"
30     "path\",\"required\":false,\"schema\":{\"type\":\"string\"}}],\"responses"
31     "\":{\"200\":{\"$ref\":\"#/components/responses/200\"}}}},\"/initialise\""
32     ":{\"description\":\"configure Unicens2 lib from NetworkConfig.XML.\",\"g"
33     "et\":{\"x-permissions\":{\"$ref\":\"#/components/x-permissions/config\"}"
34     ",\"parameters\":[{\"in\":\"query\",\"name\":\"filename\",\"required\":tr"
35     "ue,\"schema\":{\"type\":\"string\"}}],\"responses\":{\"200\":{\"$ref\":\""
36     "#/components/responses/200\"}}}},\"/subscribe\":{\"description\":\"Subsc"
37     "ribe to UNICENS Events.\",\"get\":{\"x-permissions\":{\"$ref\":\"#/compo"
38     "nents/x-permissions/monitor\"},\"responses\":{\"200\":{\"$ref\":\"#/comp"
39     "onents/responses/200\"}}}},\"/writei2c\":{\"description\":\"Writes I2C c"
40     "ommand to remote node.\",\"get\":{\"x-permissions\":{\"$ref\":\"#/compon"
41     "ents/x-permissions/monitor\"},\"parameters\":[{\"in\":\"query\",\"name\""
42     ":\"node\",\"required\":true,\"schema\":{\"type\":\"integer\",\"format\":"
43     "\"int32\"}},{\"in\":\"query\",\"name\":\"data\",\"required\":true,\"sche"
44     "ma\":{\"type\":\"array\",\"format\":\"int32\"},\"style\":\"simple\"}],\""
45     "responses\":{\"200\":{\"$ref\":\"#/components/responses/200\"}}}}}}"
46 ;
47
48 static const struct afb_auth _afb_auths_v2_UNICENS[] = {
49         { .type = afb_auth_Permission, .text = "urn:AGL:permission:UNICENS:public:initialise" },
50         { .type = afb_auth_Permission, .text = "urn:AGL:permission:UNICENS:public:monitor" }
51 };
52
53  void ucs2_listconfig(struct afb_req req);
54  void ucs2_initialise(struct afb_req req);
55  void ucs2_subscribe(struct afb_req req);
56  void ucs2_writei2c(struct afb_req req);
57
58 static const struct afb_verb_v2 _afb_verbs_v2_UNICENS[] = {
59     {
60         .verb = "listconfig",
61         .callback = ucs2_listconfig,
62         .auth = &_afb_auths_v2_UNICENS[0],
63         .info = NULL,
64         .session = AFB_SESSION_NONE_V2
65     },
66     {
67         .verb = "initialise",
68         .callback = ucs2_initialise,
69         .auth = &_afb_auths_v2_UNICENS[0],
70         .info = NULL,
71         .session = AFB_SESSION_NONE_V2
72     },
73     {
74         .verb = "subscribe",
75         .callback = ucs2_subscribe,
76         .auth = &_afb_auths_v2_UNICENS[1],
77         .info = NULL,
78         .session = AFB_SESSION_NONE_V2
79     },
80     {
81         .verb = "writei2c",
82         .callback = ucs2_writei2c,
83         .auth = &_afb_auths_v2_UNICENS[1],
84         .info = NULL,
85         .session = AFB_SESSION_NONE_V2
86     },
87     { .verb = NULL }
88 };
89
90 const struct afb_binding_v2 afbBindingV2 = {
91     .api = "UNICENS",
92     .specification = _afb_description_v2_UNICENS,
93     .info = NULL,
94     .verbs = _afb_verbs_v2_UNICENS,
95     .preinit = NULL,
96     .init = NULL,
97     .onevent = NULL,
98     .noconcurrency = 0
99 };
100