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;
57 /* closure associated with the callback processing the verb of the request
58 * as given at its declaration */
63 * Interface for handling requests.
64 * It records the functions to be called for the request.
65 * Don't use this structure directly.
66 * Use the helper functions
68 struct afb_request_itf
70 /* CAUTION: respect the order, add at the end */
72 struct json_object *(*json)(
73 struct afb_request *request);
75 struct afb_arg (*get)(
76 struct afb_request *request,
80 struct afb_request *request,
81 struct json_object *obj,
85 struct afb_request *request,
90 struct afb_request *request,
91 struct json_object *obj,
96 struct afb_request *request,
101 void *(*context_get)(
102 struct afb_request *request);
105 struct afb_request *request,
107 void (*free_value)(void*));
109 struct afb_request *(*addref)(
110 struct afb_request *request);
113 struct afb_request *request);
115 void (*session_close)(
116 struct afb_request *request);
118 int (*session_set_LOA)(
119 struct afb_request *request,
123 struct afb_request *request,
124 struct afb_event event);
127 struct afb_request *request,
128 struct afb_event event);
131 struct afb_request *request,
134 struct json_object *args,
135 void (*callback)(void*, int, struct json_object*),
139 struct afb_request *request,
142 struct json_object *args,
143 struct json_object **result);
146 struct afb_request *request,
154 struct afb_stored_req *(*store)(
155 struct afb_request *request);
158 struct afb_request *request,
161 struct json_object *args,
162 void (*callback)(void*, int, struct json_object*, struct afb_req),
165 int (*has_permission)(
166 struct afb_request *request,
167 const char *permission);
169 char *(*get_application_id)(
170 struct afb_request *request);
172 void *(*context_make)(
173 struct afb_request *request,
175 void *(*create_value)(void *creation_closure),
176 void (*free_value)(void*),
177 void *creation_closure);
179 int (*subscribe_eventid)(
180 struct afb_request *request,
181 struct afb_eventid *eventid);
183 int (*unsubscribe_eventid)(
184 struct afb_request *request,
185 struct afb_eventid *eventid);
187 void (*subcall_request)(
188 struct afb_request *request,
191 struct json_object *args,
192 void (*callback)(void*, int, struct json_object*, struct afb_request *request),