Migration to binding V3
[apps/agl-service-unicens.git] / ucs2-afb / ucs_apidef.h
1
2 static const char _afb_description_UNICENS[] =
3         "{\"openapi\":\"3.0.0\",\"$schema\":\"http:iot.bzh/download/openapi/s"
4         "chema-3.0/default-schema.json\",\"info\":{\"description\":\"\",\"tit"
5         "le\":\"ucs2\",\"version\":\"1.0\",\"x-binding-c-generator\":{\"api\""
6         ":\"UNICENS\",\"version\":3,\"prefix\":\"ucs2_\",\"postfix\":\"\",\"s"
7         "tart\":null,\"onevent\":null,\"preinit\":null,\"init\":\"ucs2_initbi"
8         "nding\",\"scope\":\"\",\"private\":false}},\"servers\":[{\"url\":\"w"
9         "s://{host}:{port}/api/monitor\",\"description\":\"Unicens2 API.\",\""
10         "variables\":{\"host\":{\"default\":\"localhost\"},\"port\":{\"defaul"
11         "t\":\"1234\"}},\"x-afb-events\":[{\"$ref\":\"#/components/schemas/af"
12         "b-event\"}]}],\"components\":{\"schemas\":{\"afb-reply\":{\"$ref\":\""
13         "#/components/schemas/afb-reply-v2\"},\"afb-event\":{\"$ref\":\"#/com"
14         "ponents/schemas/afb-event-v2\"},\"afb-reply-v2\":{\"title\":\"Generi"
15         "c response.\",\"type\":\"object\",\"required\":[\"jtype\",\"request\""
16         "],\"properties\":{\"jtype\":{\"type\":\"string\",\"const\":\"afb-rep"
17         "ly\"},\"request\":{\"type\":\"object\",\"required\":[\"status\"],\"p"
18         "roperties\":{\"status\":{\"type\":\"string\"},\"info\":{\"type\":\"s"
19         "tring\"},\"token\":{\"type\":\"string\"},\"uuid\":{\"type\":\"string"
20         "\"},\"reqid\":{\"type\":\"string\"}}},\"response\":{\"type\":\"objec"
21         "t\"}}},\"afb-event-v2\":{\"type\":\"object\",\"required\":[\"jtype\""
22         ",\"event\"],\"properties\":{\"jtype\":{\"type\":\"string\",\"const\""
23         ":\"afb-event\"},\"event\":{\"type\":\"string\"},\"data\":{\"type\":\""
24         "object\"}}}},\"x-permissions\":{\"config\":{\"permission\":\"urn:AGL"
25         ":permission:UNICENS:public:initialise\"},\"monitor\":{\"permission\""
26         ":\"urn:AGL:permission:UNICENS:public:monitor\"},\"controller\":{\"pe"
27         "rmission\":\"urn:AGL:permission:UNICENS:public:controller\"}},\"resp"
28         "onses\":{\"200\":{\"description\":\"A complex object array response\""
29         ",\"content\":{\"application/json\":{\"schema\":{\"$ref\":\"#/compone"
30         "nts/schemas/afb-reply\"}}}}}},\"paths\":{\"/listconfig\":{\"descript"
31         "ion\":\"List Config Files\",\"get\":{\"x-permissions\":{\"$ref\":\"#"
32         "/components/x-permissions/config\"},\"parameters\":[{\"in\":\"query\""
33         ",\"name\":\"cfgpath\",\"required\":false,\"schema\":{\"type\":\"stri"
34         "ng\"}}],\"responses\":{\"200\":{\"$ref\":\"#/components/responses/20"
35         "0\"}}}},\"/initialise\":{\"description\":\"configure Unicens2 lib fr"
36         "om NetworkConfig.XML.\",\"get\":{\"x-permissions\":{\"$ref\":\"#/com"
37         "ponents/x-permissions/config\"},\"parameters\":[{\"in\":\"query\",\""
38         "name\":\"filename\",\"required\":true,\"schema\":{\"type\":\"string\""
39         "}}],\"responses\":{\"200\":{\"$ref\":\"#/components/responses/200\"}"
40         "}}},\"/subscribe\":{\"description\":\"Subscribe to network events.\""
41         ",\"get\":{\"x-permissions\":{\"$ref\":\"#/components/x-permissions/m"
42         "onitor\"},\"responses\":{\"200\":{\"$ref\":\"#/components/responses/"
43         "200\"}}}},\"/subscriberx\":{\"description\":\"Subscribe to Rx contro"
44         "l message events.\",\"get\":{\"x-permissions\":{\"$ref\":\"#/compone"
45         "nts/x-permissions/monitor\"},\"responses\":{\"200\":{\"$ref\":\"#/co"
46         "mponents/responses/200\"}}}},\"/writei2c\":{\"description\":\"Writes"
47         " I2C command to remote node.\",\"get\":{\"x-permissions\":{\"$ref\":"
48         "\"#/components/x-permissions/monitor\"},\"parameters\":[{\"in\":\"qu"
49         "ery\",\"name\":\"node\",\"required\":true,\"schema\":{\"type\":\"int"
50         "eger\",\"format\":\"int32\"}},{\"in\":\"query\",\"name\":\"data\",\""
51         "required\":true,\"schema\":{\"type\":\"array\",\"format\":\"int32\"}"
52         ",\"style\":\"simple\"}],\"responses\":{\"200\":{\"$ref\":\"#/compone"
53         "nts/responses/200\"}}}},\"/sendmessage\":{\"description\":\"Transmit"
54         "s a control message to a node.\",\"get\":{\"x-permissions\":{\"$ref\""
55         ":\"#/components/x-permissions/controller\"},\"parameters\":[{\"in\":"
56         "\"query\",\"name\":\"node\",\"required\":true,\"schema\":{\"type\":\""
57         "integer\",\"format\":\"int32\"}},{\"in\":\"query\",\"name\":\"msgid\""
58         ",\"required\":true,\"schema\":{\"type\":\"integer\",\"format\":\"int"
59         "32\"}},{\"in\":\"query\",\"name\":\"data\",\"required\":false,\"sche"
60         "ma\":{\"type\":\"string\",\"format\":\"byte\"},\"style\":\"simple\"}"
61         "],\"responses\":{\"200\":{\"$ref\":\"#/components/responses/200\"}}}"
62         "}}}"
63 ;
64
65 static const struct afb_auth _afb_auths_UNICENS[] = {
66         { .type = afb_auth_Permission, .text = "urn:AGL:permission:UNICENS:public:initialise" },
67         { .type = afb_auth_Permission, .text = "urn:AGL:permission:UNICENS:public:monitor" },
68         { .type = afb_auth_Permission, .text = "urn:AGL:permission:UNICENS:public:controller" }
69 };
70
71 void ucs2_listconfig(afb_req_t req);
72 void ucs2_initialise(afb_req_t req);
73 void ucs2_subscribe(afb_req_t req);
74 void ucs2_subscriberx(afb_req_t req);
75 void ucs2_writei2c(afb_req_t req);
76 void ucs2_sendmessage(afb_req_t req);
77
78 static const struct afb_verb_v3 _afb_verbs_UNICENS[] = {
79     {
80         .verb = "listconfig",
81         .callback = ucs2_listconfig,
82         .auth = &_afb_auths_UNICENS[0],
83         .info = "List Config Files",
84         .vcbdata = NULL,
85         .session = AFB_SESSION_NONE,
86         .glob = 0
87     },
88     {
89         .verb = "initialise",
90         .callback = ucs2_initialise,
91         .auth = &_afb_auths_UNICENS[0],
92         .info = "configure Unicens2 lib from NetworkConfig.XML.",
93         .vcbdata = NULL,
94         .session = AFB_SESSION_NONE,
95         .glob = 0
96     },
97     {
98         .verb = "subscribe",
99         .callback = ucs2_subscribe,
100         .auth = &_afb_auths_UNICENS[1],
101         .info = "Subscribe to network events.",
102         .vcbdata = NULL,
103         .session = AFB_SESSION_NONE,
104         .glob = 0
105     },
106     {
107         .verb = "subscriberx",
108         .callback = ucs2_subscriberx,
109         .auth = &_afb_auths_UNICENS[1],
110         .info = "Subscribe to Rx control message events.",
111         .vcbdata = NULL,
112         .session = AFB_SESSION_NONE,
113         .glob = 0
114     },
115     {
116         .verb = "writei2c",
117         .callback = ucs2_writei2c,
118         .auth = &_afb_auths_UNICENS[1],
119         .info = "Writes I2C command to remote node.",
120         .vcbdata = NULL,
121         .session = AFB_SESSION_NONE,
122         .glob = 0
123     },
124     {
125         .verb = "sendmessage",
126         .callback = ucs2_sendmessage,
127         .auth = &_afb_auths_UNICENS[2],
128         .info = "Transmits a control message to a node.",
129         .vcbdata = NULL,
130         .session = AFB_SESSION_NONE,
131         .glob = 0
132     },
133     {
134         .verb = NULL,
135         .callback = NULL,
136         .auth = NULL,
137         .info = NULL,
138         .vcbdata = NULL,
139         .session = 0,
140         .glob = 0
141     }
142 };
143
144 int ucs2_initbinding(afb_api_t api);
145
146 const struct afb_binding_v3 afbBindingV3 = {
147     .api = "UNICENS",
148     .specification = _afb_description_UNICENS,
149     .info = "",
150     .verbs = _afb_verbs_UNICENS,
151     .preinit = NULL,
152     .init = ucs2_initbinding,
153     .onevent = NULL,
154     .userdata = NULL,
155     .provide_class = NULL,
156     .require_class = NULL,
157     .require_api = NULL,
158     .noconcurrency = 0
159 };
160