agl-service-unicens: Rx message event
[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,\"preinit\":null,\"init\":\"ucs2_initbinding\",\"scope\":\""
8     "\",\"private\":false}},\"servers\":[{\"url\":\"ws://{host}:{port}/api/mo"
9     "nitor\",\"description\":\"Unicens2 API.\",\"variables\":{\"host\":{\"def"
10     "ault\":\"localhost\"},\"port\":{\"default\":\"1234\"}},\"x-afb-events\":"
11     "[{\"$ref\":\"#/components/schemas/afb-event\"}]}],\"components\":{\"sche"
12     "mas\":{\"afb-reply\":{\"$ref\":\"#/components/schemas/afb-reply-v2\"},\""
13     "afb-event\":{\"$ref\":\"#/components/schemas/afb-event-v2\"},\"afb-reply"
14     "-v2\":{\"title\":\"Generic response.\",\"type\":\"object\",\"required\":"
15     "[\"jtype\",\"request\"],\"properties\":{\"jtype\":{\"type\":\"string\",\""
16     "const\":\"afb-reply\"},\"request\":{\"type\":\"object\",\"required\":[\""
17     "status\"],\"properties\":{\"status\":{\"type\":\"string\"},\"info\":{\"t"
18     "ype\":\"string\"},\"token\":{\"type\":\"string\"},\"uuid\":{\"type\":\"s"
19     "tring\"},\"reqid\":{\"type\":\"string\"}}},\"response\":{\"type\":\"obje"
20     "ct\"}}},\"afb-event-v2\":{\"type\":\"object\",\"required\":[\"jtype\",\""
21     "event\"],\"properties\":{\"jtype\":{\"type\":\"string\",\"const\":\"afb-"
22     "event\"},\"event\":{\"type\":\"string\"},\"data\":{\"type\":\"object\"}}"
23     "}},\"x-permissions\":{\"config\":{\"permission\":\"urn:AGL:permission:UN"
24     "ICENS:public:initialise\"},\"monitor\":{\"permission\":\"urn:AGL:permiss"
25     "ion:UNICENS:public:monitor\"}},\"responses\":{\"200\":{\"description\":\""
26     "A complex object array response\",\"content\":{\"application/json\":{\"s"
27     "chema\":{\"$ref\":\"#/components/schemas/afb-reply\"}}}}}},\"paths\":{\""
28     "/listconfig\":{\"description\":\"List Config Files\",\"get\":{\"x-permis"
29     "sions\":{\"$ref\":\"#/components/x-permissions/config\"},\"parameters\":"
30     "[{\"in\":\"query\",\"name\":\"cfgpath\",\"required\":false,\"schema\":{\""
31     "type\":\"string\"}}],\"responses\":{\"200\":{\"$ref\":\"#/components/res"
32     "ponses/200\"}}}},\"/initialise\":{\"description\":\"configure Unicens2 l"
33     "ib from NetworkConfig.XML.\",\"get\":{\"x-permissions\":{\"$ref\":\"#/co"
34     "mponents/x-permissions/config\"},\"parameters\":[{\"in\":\"query\",\"nam"
35     "e\":\"filename\",\"required\":true,\"schema\":{\"type\":\"string\"}}],\""
36     "responses\":{\"200\":{\"$ref\":\"#/components/responses/200\"}}}},\"/sub"
37     "scribe\":{\"description\":\"Subscribe to network events.\",\"get\":{\"x-"
38     "permissions\":{\"$ref\":\"#/components/x-permissions/monitor\"},\"respon"
39     "ses\":{\"200\":{\"$ref\":\"#/components/responses/200\"}}}},\"/subscribe"
40     "rx\":{\"description\":\"Subscribe to Rx control message events.\",\"get\""
41     ":{\"x-permissions\":{\"$ref\":\"#/components/x-permissions/monitor\"},\""
42     "responses\":{\"200\":{\"$ref\":\"#/components/responses/200\"}}}},\"/wri"
43     "tei2c\":{\"description\":\"Writes I2C command to remote node.\",\"get\":"
44     "{\"x-permissions\":{\"$ref\":\"#/components/x-permissions/monitor\"},\"p"
45     "arameters\":[{\"in\":\"query\",\"name\":\"node\",\"required\":true,\"sch"
46     "ema\":{\"type\":\"integer\",\"format\":\"int32\"}},{\"in\":\"query\",\"n"
47     "ame\":\"data\",\"required\":true,\"schema\":{\"type\":\"array\",\"format"
48     "\":\"int32\"},\"style\":\"simple\"}],\"responses\":{\"200\":{\"$ref\":\""
49     "#/components/responses/200\"}}}},\"/sendmessage\":{\"description\":\"Tra"
50     "nsmits a control message to a node.\",\"get\":{\"x-permissions\":{\"$ref"
51     "\":\"#/components/x-permissions/monitor\"},\"parameters\":[{\"in\":\"que"
52     "ry\",\"name\":\"node\",\"required\":true,\"schema\":{\"type\":\"integer\""
53     ",\"format\":\"int32\"}},{\"in\":\"query\",\"name\":\"msgid\",\"required\""
54     ":true,\"schema\":{\"type\":\"integer\",\"format\":\"int32\"}},{\"in\":\""
55     "query\",\"name\":\"data\",\"required\":true,\"schema\":{\"type\":\"array"
56     "\",\"format\":\"int32\"},\"style\":\"simple\"}],\"responses\":{\"200\":{"
57     "\"$ref\":\"#/components/responses/200\"}}}}}}"
58 ;
59
60 static const struct afb_auth _afb_auths_v2_UNICENS[] = {
61         { .type = afb_auth_Permission, .text = "urn:AGL:permission:UNICENS:public:initialise" },
62         { .type = afb_auth_Permission, .text = "urn:AGL:permission:UNICENS:public:monitor" }
63 };
64
65  void ucs2_listconfig(struct afb_req req);
66  void ucs2_initialise(struct afb_req req);
67  void ucs2_subscribe(struct afb_req req);
68  void ucs2_subscriberx(struct afb_req req);
69  void ucs2_writei2c(struct afb_req req);
70  void ucs2_sendmessage(struct afb_req req);
71
72 static const struct afb_verb_v2 _afb_verbs_v2_UNICENS[] = {
73     {
74         .verb = "listconfig",
75         .callback = ucs2_listconfig,
76         .auth = &_afb_auths_v2_UNICENS[0],
77         .info = "List Config Files",
78         .session = AFB_SESSION_NONE_V2
79     },
80     {
81         .verb = "initialise",
82         .callback = ucs2_initialise,
83         .auth = &_afb_auths_v2_UNICENS[0],
84         .info = "configure Unicens2 lib from NetworkConfig.XML.",
85         .session = AFB_SESSION_NONE_V2
86     },
87     {
88         .verb = "subscribe",
89         .callback = ucs2_subscribe,
90         .auth = &_afb_auths_v2_UNICENS[1],
91         .info = "Subscribe to network events.",
92         .session = AFB_SESSION_NONE_V2
93     },
94     {
95         .verb = "subscriberx",
96         .callback = ucs2_subscriberx,
97         .auth = &_afb_auths_v2_UNICENS[1],
98         .info = "Subscribe to Rx control message events.",
99         .session = AFB_SESSION_NONE_V2
100     },
101     {
102         .verb = "writei2c",
103         .callback = ucs2_writei2c,
104         .auth = &_afb_auths_v2_UNICENS[1],
105         .info = "Writes I2C command to remote node.",
106         .session = AFB_SESSION_NONE_V2
107     },
108     {
109         .verb = "sendmessage",
110         .callback = ucs2_sendmessage,
111         .auth = &_afb_auths_v2_UNICENS[1],
112         .info = "Transmits a control message to a node.",
113         .session = AFB_SESSION_NONE_V2
114     },
115     {
116         .verb = NULL,
117         .callback = NULL,
118         .auth = NULL,
119         .info = NULL,
120         .session = 0
121         }
122 };
123
124 const struct afb_binding_v2 afbBindingV2 = {
125     .api = "UNICENS",
126     .specification = _afb_description_v2_UNICENS,
127     .info = "",
128     .verbs = _afb_verbs_v2_UNICENS,
129     .preinit = NULL,
130     .init = ucs2_initbinding,
131     .onevent = NULL,
132     .noconcurrency = 0
133 };
134