aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorMartin Schanzenbach <mschanzenbach@posteo.de>2015-03-26 14:57:05 +0000
committerMartin Schanzenbach <mschanzenbach@posteo.de>2015-03-26 14:57:05 +0000
commitb68a1cacd29fb91dee84f736085c48db4ea5acaf (patch)
tree16b343e23754b0eec27f927e877e0f457955c105 /src/include
parent496e08d0b3e7719b4bf63eb9e0a3e0f8f19d6569 (diff)
downloadgnunet-b68a1cacd29fb91dee84f736085c48db4ea5acaf.tar.gz
gnunet-b68a1cacd29fb91dee84f736085c48db4ea5acaf.zip
-more REST
Diffstat (limited to 'src/include')
-rw-r--r--src/include/gnunet_rest_lib.h79
1 files changed, 72 insertions, 7 deletions
diff --git a/src/include/gnunet_rest_lib.h b/src/include/gnunet_rest_lib.h
index cc02f01d0..398cbfdbe 100644
--- a/src/include/gnunet_rest_lib.h
+++ b/src/include/gnunet_rest_lib.h
@@ -90,7 +90,7 @@ struct JsonApiResource;
90/** 90/**
91 * Responses for JSON API 91 * Responses for JSON API
92 */ 92 */
93struct JsonApiResponse; 93struct JsonApiObject;
94 94
95/** 95/**
96 * Create a JSON API resource 96 * Create a JSON API resource
@@ -124,18 +124,64 @@ int
124GNUNET_REST_jsonapi_resource_add_attr (const struct JsonApiResource *resource, 124GNUNET_REST_jsonapi_resource_add_attr (const struct JsonApiResource *resource,
125 const char* key, 125 const char* key,
126 json_t *json); 126 json_t *json);
127/**
128 * Read a JSON API attribute
129 *
130 * @param res the JSON resource
131 * @param key the key for the attribute
132 * @return the json attr
133 */
134json_t*
135GNUNET_REST_jsonapi_resource_read_attr (const struct JsonApiResource *resource,
136 const char* key);
137
138
139/**
140 * Check a JSON API resource id
141 *
142 * @param res the JSON resource
143 * @param id the expected id
144 * @return GNUNET_YES if id matches
145 */
146int
147GNUNET_REST_jsonapi_resource_check_id (const struct JsonApiResource *resource,
148 const char* id);
149
127 150
128/** 151/**
152 * Check a JSON API resource type
153 *
154 * @param res the JSON resource
155 * @param type the expected type
156 * @return GNUNET_YES if id matches
157 */
158int
159GNUNET_REST_jsonapi_resource_check_type (const struct JsonApiResource *resource,
160 const char* type);
161
162
163/**
129 * Create a JSON API primary data 164 * Create a JSON API primary data
130 * 165 *
131 * @param type the JSON API resource type 166 * @param type the JSON API resource type
132 * @param id the JSON API resource id 167 * @param id the JSON API resource id
133 * @return a new JSON API resource or NULL on error. 168 * @return a new JSON API resource or NULL on error.
134 */ 169 */
135struct JsonApiResponse* 170struct JsonApiObject*
136GNUNET_REST_jsonapi_response_new (); 171GNUNET_REST_jsonapi_object_new ();
172
137 173
138/** 174/**
175 * Create a JSON API primary data from a string
176 *
177 * @param data the string of the JSON API data
178 * @return a new JSON API resource or NULL on error.
179 */
180struct JsonApiObject*
181GNUNET_REST_jsonapi_object_parse (const char* data);
182
183
184/**
139 * Delete a JSON API primary data 185 * Delete a JSON API primary data
140 * 186 *
141 * @param type the JSON API resource type 187 * @param type the JSON API resource type
@@ -143,7 +189,7 @@ GNUNET_REST_jsonapi_response_new ();
143 * @return a new JSON API resource or NULL on error. 189 * @return a new JSON API resource or NULL on error.
144 */ 190 */
145void 191void
146GNUNET_REST_jsonapi_response_delete (struct JsonApiResponse *resp); 192GNUNET_REST_jsonapi_object_delete (struct JsonApiObject *resp);
147 193
148/** 194/**
149 * Add a JSON API resource to primary data 195 * Add a JSON API resource to primary data
@@ -153,8 +199,27 @@ GNUNET_REST_jsonapi_response_delete (struct JsonApiResponse *resp);
153 * @return the new number of resources 199 * @return the new number of resources
154 */ 200 */
155void 201void
156GNUNET_REST_jsonapi_response_resource_add (struct JsonApiResponse *resp, 202GNUNET_REST_jsonapi_object_resource_add (struct JsonApiObject *resp,
157 struct JsonApiResource *res); 203 struct JsonApiResource *res);
204/**
205 * Get a JSON API object resource count
206 *
207 * @param resp the JSON API object
208 * @return the number of resources
209 */
210int
211GNUNET_REST_jsonapi_object_resource_count (struct JsonApiObject *resp);
212
213/**
214 * Get a JSON API object resource #num
215 *
216 * @param resp the JSON API object
217 * @param num the number of the resource
218 * @return the resource
219 */
220struct JsonApiResource*
221GNUNET_REST_jsonapi_object_get_resource (struct JsonApiObject *resp, int num);
222
158 223
159/** 224/**
160 * Add a JSON API resource to primary data 225 * Add a JSON API resource to primary data
@@ -164,7 +229,7 @@ GNUNET_REST_jsonapi_response_resource_add (struct JsonApiResponse *resp,
164 * @return the new number of resources 229 * @return the new number of resources
165 */ 230 */
166void 231void
167GNUNET_REST_jsonapi_data_resource_remove (struct JsonApiResponse *resp, 232GNUNET_REST_jsonapi_data_resource_remove (struct JsonApiObject *resp,
168 struct JsonApiResource *res); 233 struct JsonApiResource *res);
169 234
170/** 235/**
@@ -175,7 +240,7 @@ GNUNET_REST_jsonapi_data_resource_remove (struct JsonApiResponse *resp,
175 * @return GNUNET_SYSERR on error else GNUNET_OK 240 * @return GNUNET_SYSERR on error else GNUNET_OK
176 */ 241 */
177int 242int
178GNUNET_REST_jsonapi_data_serialize (const struct JsonApiResponse *resp, 243GNUNET_REST_jsonapi_data_serialize (const struct JsonApiObject *resp,
179 char **result); 244 char **result);
180 245
181/** 246/**