]> git.ipfire.org Git - thirdparty/strongswan.git/blob - src/libimcv/rest/rest.h
Update copyright headers after acquisition by secunet
[thirdparty/strongswan.git] / src / libimcv / rest / rest.h
1 /*
2 * Copyright (C) 2017 Andreas Steffen
3 *
4 * Copyright (C) secunet Security Networks AG
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * for more details.
15 */
16
17 /**
18 * @defgroup imv_swima imv_swima
19 * @ingroup libimcv_plugins
20 *
21 * @defgroup rest_t rest
22 * @{ @ingroup imv_swima
23 */
24
25 #ifndef REST_H_
26 #define REST_H_
27
28 #ifdef USE_JSON
29
30 #include <library.h>
31 #include <json.h>
32
33 typedef struct rest_t rest_t;
34
35 /**
36 * Public REST interface
37 */
38 struct rest_t {
39
40 /**
41 * Send an HTTP GET request returning a JSON object
42 *
43 * @param jresp JSON object in HTTP
44 * @return Status (SUCCESS or FAILED)
45 */
46 status_t (*get)(rest_t *this, char *command, json_object **jresp);
47
48 /**
49 * Send an HTTP POST request including a JSON object
50 *
51 * @param jreq JSON object in HTTP request
52 * @param jresp JSON object in HTTP response if NEED_MORE
53 * @return Status (SUCCESS, NEED_MORE or FAILED)
54 */
55 status_t (*post)(rest_t *this, char *command, json_object *jreq,
56 json_object **jresp);
57
58 /**
59 * Destroy rest_t object
60 */
61 void (*destroy)(rest_t *this);
62
63 };
64
65 /**
66 * Create an rest_t instance
67 *
68 * @param uri REST URI (http://username:password@hostname[:port]/api/)
69 * @param timeout Timeout of the REST connection
70 */
71 rest_t* rest_create(char *uri, u_int timeout);
72
73 #endif /* USE_JSON */
74
75 #endif /** REST_H_ @}*/