ucs_binding.c: Add control message transmission
[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 UNICENS Events.\",\"get\":{\"x-"
38     "permissions\":{\"$ref\":\"#/components/x-permissions/monitor\"},\"respon"
39     "ses\":{\"200\":{\"$ref\":\"#/components/responses/200\"}}}},\"/writei2c\""
40     ":{\"description\":\"Writes I2C command to remote node.\",\"get\":{\"x-pe"
41     "rmissions\":{\"$ref\":\"#/components/x-permissions/monitor\"},\"paramete"
42     "rs\":[{\"in\":\"query\",\"name\":\"node\",\"required\":true,\"schema\":{"
43     "\"type\":\"integer\",\"format\":\"int32\"}},{\"in\":\"query\",\"name\":\""
44     "data\",\"required\":true,\"schema\":{\"type\":\"array\",\"format\":\"int"
45     "32\"},\"style\":\"simple\"}],\"responses\":{\"200\":{\"$ref\":\"#/compon"
46     "ents/responses/200\"}}}},\"/sendmessage\":{\"description\":\"Transmits a"
47     " control message to a node.\",\"get\":{\"x-permissions\":{\"$ref\":\"#/c"
48     "omponents/x-permissions/monitor\"},\"parameters\":[{\"in\":\"query\",\"n"
49     "ame\":\"node\",\"required\":true,\"schema\":{\"type\":\"integer\",\"form"
50     "at\":\"int32\"}},{\"in\":\"query\",\"name\":\"msgid\",\"required\":true,"
51     "\"schema\":{\"type\":\"integer\",\"format\":\"int32\"}},{\"in\":\"query\""
52     ",\"name\":\"data\",\"required\":true,\"schema\":{\"type\":\"array\",\"fo"
53     "rmat\":\"int32\"},\"style\":\"simple\"}],\"responses\":{\"200\":{\"$ref\""
54     ":\"#/components/responses/200\"}}}}}}"
55 ;
56
57 static const struct afb_auth _afb_auths_v2_UNICENS[] = {
58         { .type = afb_auth_Permission, .text = "urn:AGL:permission:UNICENS:public:initialise" },
59         { .type = afb_auth_Permission, .text = "urn:AGL:permission:UNICENS:public:monitor" }
60 };
61
62  void ucs2_listconfig(struct afb_req req);
63  void ucs2_initialise(struct afb_req req);
64  void ucs2_subscribe(struct afb_req req);
65  void ucs2_writei2c(struct afb_req req);
66  void ucs2_sendmessage(struct afb_req req);
67
68 static const struct afb_verb_v2 _afb_verbs_v2_UNICENS[] = {
69     {
70         .verb = "listconfig",
71         .callback = ucs2_listconfig,
72         .auth = &_afb_auths_v2_UNICENS[0],
73         .info = "List Config Files",
74         .session = AFB_SESSION_NONE_V2
75     },
76     {
77         .verb = "initialise",
78         .callback = ucs2_initialise,
79         .auth = &_afb_auths_v2_UNICENS[0],
80         .info = "configure Unicens2 lib from NetworkConfig.XML.",
81         .session = AFB_SESSION_NONE_V2
82     },
83     {
84         .verb = "subscribe",
85         .callback = ucs2_subscribe,
86         .auth = &_afb_auths_v2_UNICENS[1],
87         .info = "Subscribe to UNICENS Events.",
88         .session = AFB_SESSION_NONE_V2
89     },
90     {
91         .verb = "writei2c",
92         .callback = ucs2_writei2c,
93         .auth = &_afb_auths_v2_UNICENS[1],
94         .info = "Writes I2C command to remote node.",
95         .session = AFB_SESSION_NONE_V2
96     },
97     {
98         .verb = "sendmessage",
99         .callback = ucs2_sendmessage,
100         .auth = &_afb_auths_v2_UNICENS[1],
101         .info = "Transmits a control message to a node.",
102         .session = AFB_SESSION_NONE_V2
103     },
104     {
105         .verb = NULL,
106         .callback = NULL,
107         .auth = NULL,
108         .info = NULL,
109         .session = 0
110         }
111 };
112
113 const struct afb_binding_v2 afbBindingV2 = {
114     .api = "UNICENS",
115     .specification = _afb_description_v2_UNICENS,
116     .info = "",
117     .verbs = _afb_verbs_v2_UNICENS,
118     .preinit = NULL,
119     .init = ucs2_initbinding,
120     .onevent = NULL,
121     .noconcurrency = 0
122 };
123