73d6fba3e33c40df82105317e1f0d6c95b07c255
[src/app-framework-binder.git] / src / afb-api-v3.h
1 /*
2  * Copyright (C) 2016-2019 "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
19 #pragma once
20
21 struct afb_apiset;
22 struct afb_api_v3;
23 struct afb_api_x3;
24 struct afb_auth;
25 struct afb_req_x2;
26 struct afb_verb_v3;
27 struct afb_binding_v3;
28 struct afb_xreq;
29 struct json_object;
30 struct afb_export;
31
32 extern struct afb_api_v3 *afb_api_v3_create(struct afb_apiset *declare_set,
33                 struct afb_apiset *call_set,
34                 const char *apiname,
35                 const char *info,
36                 int noconcurrency,
37                 int (*preinit)(void*, struct afb_api_x3 *),
38                 void *closure,
39                 int copy_info,
40                 struct afb_export* creator,
41                 const char* path);
42
43 extern struct afb_api_v3 *afb_api_v3_from_binding(
44                 const struct afb_binding_v3 *desc,
45                 struct afb_apiset *declare_set,
46                 struct afb_apiset * call_set);
47
48 extern int afb_api_v3_safe_preinit(
49                 struct afb_api_x3 *api,
50                 int (*preinit)(struct afb_api_x3 *));
51
52 extern int afb_api_v3_set_binding_fields(const struct afb_binding_v3 *desc, struct afb_api_x3 *api);
53
54 extern struct afb_api_v3 *afb_api_v3_addref(struct afb_api_v3 *api);
55 extern void afb_api_v3_unref(struct afb_api_v3 *api);
56
57 extern struct afb_export *afb_api_v3_export(struct afb_api_v3 *api);
58
59 extern void afb_api_v3_set_verbs_v3(
60                 struct afb_api_v3 *api,
61                 const struct afb_verb_v3 *verbs);
62
63 extern int afb_api_v3_add_verb(
64                 struct afb_api_v3 *api,
65                 const char *verb,
66                 const char *info,
67                 void (*callback)(struct afb_req_x2 *req),
68                 void *vcbdata,
69                 const struct afb_auth *auth,
70                 uint16_t session,
71                 int glob);
72
73 extern int afb_api_v3_del_verb(
74                 struct afb_api_v3 *api,
75                 const char *verb,
76                 void **vcbdata);
77
78 extern void afb_api_v3_process_call(struct afb_api_v3 *api, struct afb_xreq *xreq);
79 extern struct json_object *afb_api_v3_make_description_openAPIv3(struct afb_api_v3 *api, const char *apiname);
80
81 #if WITH_LEGACY_BINDING_V2
82
83 struct afb_verb_v2;
84
85 extern void afb_api_v3_set_verbs_v2(
86                 struct afb_api_v3 *api,
87                 const struct afb_verb_v2 *verbs);
88
89 #endif