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;
31 struct afb_stored_req;
34 * Describes an argument (or parameter) of a request
38 const char *name; /* name of the argument or NULL if invalid */
39 const char *value; /* string representation of the value of the argument */
40 /* original filename of the argument if path != NULL */
41 const char *path; /* if not NULL, path of the received file for the argument */
42 /* when the request is finalized this file is removed */
47 const struct afb_request_itf *itf;
51 * Interface for handling requests.
52 * It records the functions to be called for the request.
53 * Don't use this structure directly.
54 * Use the helper functions
56 struct afb_request_itf
58 /* CAUTION: respect the order, add at the end */
60 struct json_object *(*json)(
61 struct afb_request *request);
63 struct afb_arg (*get)(
64 struct afb_request *request,
68 struct afb_request *request,
69 struct json_object *obj,
73 struct afb_request *request,
78 struct afb_request *request,
79 struct json_object *obj,
84 struct afb_request *request,
90 struct afb_request *request);
93 struct afb_request *request,
95 void (*free_value)(void*));
97 struct afb_request *(*addref)(
98 struct afb_request *request);
101 struct afb_request *request);
103 void (*session_close)(
104 struct afb_request *request);
106 int (*session_set_LOA)(
107 struct afb_request *request,
111 struct afb_request *request,
112 struct afb_event event);
115 struct afb_request *request,
116 struct afb_event event);
119 struct afb_request *request,
122 struct json_object *args,
123 void (*callback)(void*, int, struct json_object*),
127 struct afb_request *request,
130 struct json_object *args,
131 struct json_object **result);
134 struct afb_request *request,
142 struct afb_stored_req *(*store)(
143 struct afb_request *request);
146 struct afb_request *request,
149 struct json_object *args,
150 void (*callback)(void*, int, struct json_object*, struct afb_req),
153 int (*has_permission)(
154 struct afb_request *request,
155 const char *permission);
157 char *(*get_application_id)(
158 struct afb_request *request);
160 void *(*context_make)(
161 struct afb_request *request,
163 void *(*create_value)(void *creation_closure),
164 void (*free_value)(void*),
165 void *creation_closure);
167 int (*subscribe_eventid)(
168 struct afb_request *request,
169 struct afb_eventid *eventid);
171 int (*unsubscribe_eventid)(
172 struct afb_request *request,
173 struct afb_eventid *eventid);