typo
[src/app-framework-binder.git] / include / afb / afb-binding-v2.h
1 /*
2  * Copyright (C) 2016, 2017 "IoT.bzh"
3  * Author: José Bollo <jose.bollo@iot.bzh>
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *   http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 #pragma once
19
20 struct afb_binding_interface;
21 struct afb_service;
22 struct json_object;
23
24 /*
25  * A binding V2 MUST have an exported symbol of name
26  *
27  *              afbBindingV2
28  *
29  */
30 extern const struct afb_binding_v2 afbBindingV2;
31
32 /*
33  * Description of one verb of the API provided by the binding
34  * This enumeration is valid for bindings of type version 2
35  */
36 struct afb_verb_v2
37 {
38         const char *verb;                       /* name of the verb */
39         void (*callback)(struct afb_req req);   /* callback function implementing the verb */
40         const char * const *permissions;        /* required permissions */
41         enum afb_session_v1 session;            /* authorisation and session requirements of the verb */
42 };
43
44 /*
45  * Description of the bindings of type version 2
46  */
47 struct afb_binding_v2
48 {
49         const char *api;                        /* api name for the binding */
50         const char *specification;              /* textual specification of the binding */
51         const struct afb_verb_v2 *verbs;        /* array of descriptions of verbs terminated by a NULL name */
52         int (*init)(const struct afb_binding_interface *interface);
53         int (*start)(const struct afb_binding_interface *interface, struct afb_service service);
54         void (*onevent)(const char *event, struct json_object *object);
55 };
56