2 * Copyright (C) 2016, 2017 "IoT.bzh"
3 * Author: José Bollo <jose.bollo@iot.bzh>
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
23 struct afb_request_itf;
32 struct afb_stored_req;
35 * Describes an argument (or parameter) of a request
39 const char *name; /* name of the argument or NULL if invalid */
40 const char *value; /* string representation of the value of the argument */
41 /* original filename of the argument if path != NULL */
42 const char *path; /* if not NULL, path of the received file for the argument */
43 /* when the request is finalized this file is removed */
47 * structure for the request
51 /* interface for the request */
52 const struct afb_request_itf *itf;
54 /* current dynapi if dynapi (is NULL for bindings v1 and v2) */
55 struct afb_dynapi *dynapi;
59 * Interface for handling requests.
60 * It records the functions to be called for the request.
61 * Don't use this structure directly.
62 * Use the helper functions
64 struct afb_request_itf
66 /* CAUTION: respect the order, add at the end */
68 struct json_object *(*json)(
69 struct afb_request *request);
71 struct afb_arg (*get)(
72 struct afb_request *request,
76 struct afb_request *request,
77 struct json_object *obj,
81 struct afb_request *request,
86 struct afb_request *request,
87 struct json_object *obj,
92 struct afb_request *request,
98 struct afb_request *request);
101 struct afb_request *request,
103 void (*free_value)(void*));
105 struct afb_request *(*addref)(
106 struct afb_request *request);
109 struct afb_request *request);
111 void (*session_close)(
112 struct afb_request *request);
114 int (*session_set_LOA)(
115 struct afb_request *request,
119 struct afb_request *request,
120 struct afb_event event);
123 struct afb_request *request,
124 struct afb_event event);
127 struct afb_request *request,
130 struct json_object *args,
131 void (*callback)(void*, int, struct json_object*),
135 struct afb_request *request,
138 struct json_object *args,
139 struct json_object **result);
142 struct afb_request *request,
150 struct afb_stored_req *(*store)(
151 struct afb_request *request);
154 struct afb_request *request,
157 struct json_object *args,
158 void (*callback)(void*, int, struct json_object*, struct afb_req),
161 int (*has_permission)(
162 struct afb_request *request,
163 const char *permission);
165 char *(*get_application_id)(
166 struct afb_request *request);
168 void *(*context_make)(
169 struct afb_request *request,
171 void *(*create_value)(void *creation_closure),
172 void (*free_value)(void*),
173 void *creation_closure);
175 int (*subscribe_eventid)(
176 struct afb_request *request,
177 struct afb_eventid *eventid);
179 int (*unsubscribe_eventid)(
180 struct afb_request *request,
181 struct afb_eventid *eventid);
183 void (*subcall_request)(
184 struct afb_request *request,
187 struct json_object *args,
188 void (*callback)(void*, int, struct json_object*, struct afb_request *request),