2 * Copyright (C) 2016, 2017, 2018 "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 any) */
55 struct afb_dynapi *dynapi;
57 /* closure associated with the callback processing the verb of the request
58 * as given at its declaration */
61 /* the name of the called verb */
64 /* the name of the called verb */
69 * Interface for handling requests.
70 * It records the functions to be called for the request.
71 * Don't use this structure directly.
72 * Use the helper functions
74 struct afb_request_itf
76 /* CAUTION: respect the order, add at the end */
78 struct json_object *(*json)(
79 struct afb_request *request);
81 struct afb_arg (*get)(
82 struct afb_request *request,
86 struct afb_request *request,
87 struct json_object *obj,
91 struct afb_request *request,
96 struct afb_request *request,
97 struct json_object *obj,
102 struct afb_request *request,
107 void *(*context_get)(
108 struct afb_request *request);
111 struct afb_request *request,
113 void (*free_value)(void*));
115 struct afb_request *(*addref)(
116 struct afb_request *request);
119 struct afb_request *request);
121 void (*session_close)(
122 struct afb_request *request);
124 int (*session_set_LOA)(
125 struct afb_request *request,
129 struct afb_request *request,
130 struct afb_event event);
133 struct afb_request *request,
134 struct afb_event event);
137 struct afb_request *request,
140 struct json_object *args,
141 void (*callback)(void*, int, struct json_object*),
145 struct afb_request *request,
148 struct json_object *args,
149 struct json_object **result);
152 struct afb_request *request,
160 struct afb_stored_req *(*store)(
161 struct afb_request *request);
164 struct afb_request *request,
167 struct json_object *args,
168 void (*callback)(void*, int, struct json_object*, struct afb_req),
171 int (*has_permission)(
172 struct afb_request *request,
173 const char *permission);
175 char *(*get_application_id)(
176 struct afb_request *request);
178 void *(*context_make)(
179 struct afb_request *request,
181 void *(*create_value)(void *creation_closure),
182 void (*free_value)(void*),
183 void *creation_closure);
185 int (*subscribe_eventid)(
186 struct afb_request *request,
187 struct afb_eventid *eventid);
189 int (*unsubscribe_eventid)(
190 struct afb_request *request,
191 struct afb_eventid *eventid);
193 void (*subcall_request)(
194 struct afb_request *request,
197 struct json_object *args,
198 void (*callback)(void*, int, struct json_object*, struct afb_request *request),
202 struct afb_request *request);