]> git.ipfire.org Git - thirdparty/strongswan.git/blob - src/libcharon/plugins/vici/python/vici/command_wrappers.py
vici: Add missing command wrappers for Python bindings
[thirdparty/strongswan.git] / src / libcharon / plugins / vici / python / vici / command_wrappers.py
1 class CommandWrappers(object):
2 def version(self):
3 """Retrieve daemon and system specific version information.
4
5 :return: daemon and system specific version information
6 :rtype: dict
7 """
8 return self.request("version")
9
10 def stats(self):
11 """Retrieve IKE daemon statistics and load information.
12
13 :return: IKE daemon statistics and load information
14 :rtype: dict
15 """
16 return self.request("stats")
17
18 def reload_settings(self):
19 """Reload strongswan.conf settings and any plugins supporting reload.
20 """
21 self.request("reload-settings")
22
23 def initiate(self, sa):
24 """Initiate an SA.
25
26 :param sa: the SA to initiate
27 :type sa: dict
28 :return: generator for logs emitted as dict
29 :rtype: generator
30 """
31 return self.streamed_request("initiate", "control-log", sa)
32
33 def terminate(self, sa):
34 """Terminate an SA.
35
36 :param sa: the SA to terminate
37 :type sa: dict
38 :return: generator for logs emitted as dict
39 :rtype: generator
40 """
41 return self.streamed_request("terminate", "control-log", sa)
42
43 def rekey(self, sa):
44 """Initiate the rekeying of an SA.
45
46 .. versionadded:: 5.5.2
47
48 :param sa: the SA to rekey
49 :type sa: dict
50 :return: number of matched SAs
51 :rtype: dict
52 """
53 return self.request("rekey", sa)
54
55 def redirect(self, sa):
56 """Redirect an IKE_SA.
57
58 .. versionchanged:: 5.5.2
59 The number of matched SAs is returned.
60
61 :param sa: the SA to redirect
62 :type sa: dict
63 :return: number of matched SAs
64 :rtype: dict
65 """
66 return self.request("redirect", sa)
67
68 def install(self, policy):
69 """Install a trap, drop or bypass policy defined by a CHILD_SA config.
70
71 :param policy: policy to install
72 :type policy: dict
73 """
74 self.request("install", policy)
75
76 def uninstall(self, policy):
77 """Uninstall a trap, drop or bypass policy defined by a CHILD_SA config.
78
79 :param policy: policy to uninstall
80 :type policy: dict
81 """
82 self.request("uninstall", policy)
83
84 def list_sas(self, filters=None):
85 """Retrieve active IKE_SAs and associated CHILD_SAs.
86
87 :param filters: retrieve only matching IKE_SAs (optional)
88 :type filters: dict
89 :return: generator for active IKE_SAs and associated CHILD_SAs as dict
90 :rtype: generator
91 """
92 return self.streamed_request("list-sas", "list-sa", filters)
93
94 def list_policies(self, filters=None):
95 """Retrieve installed trap, drop and bypass policies.
96
97 :param filters: retrieve only matching policies (optional)
98 :type filters: dict
99 :return: generator for installed trap, drop and bypass policies as dict
100 :rtype: generator
101 """
102 return self.streamed_request("list-policies", "list-policy",
103 filters)
104
105 def list_conns(self, filters=None):
106 """Retrieve loaded connections.
107
108 :param filters: retrieve only matching configuration names (optional)
109 :type filters: dict
110 :return: generator for loaded connections as dict
111 :rtype: generator
112 """
113 return self.streamed_request("list-conns", "list-conn",
114 filters)
115
116 def get_conns(self):
117 """Retrieve connection names loaded exclusively over vici.
118
119 :return: connection names
120 :rtype: dict
121 """
122 return self.request("get-conns")
123
124 def list_certs(self, filters=None):
125 """Retrieve loaded certificates.
126
127 :param filters: retrieve only matching certificates (optional)
128 :type filters: dict
129 :return: generator for loaded certificates as dict
130 :rtype: generator
131 """
132 return self.streamed_request("list-certs", "list-cert", filters)
133
134 def list_authorities(self, filters=None):
135 """Retrieve loaded certification authority information.
136
137 .. versionadded:: 5.3.3
138
139 :param filters: retrieve only matching CAs (optional)
140 :type filters: dict
141 :return: generator for loaded CAs as dict
142 :rtype: generator
143 """
144 return self.streamed_request("list-authorities", "list-authority",
145 filters)
146
147 def get_authorities(self):
148 """Retrieve certification authority names loaded exclusively over vici.
149
150 :return: CA names
151 :rtype: dict
152 """
153 return self.request("get-authorities")
154
155 def load_conn(self, connection):
156 """Load a connection definition into the daemon.
157
158 :param connection: connection definition
159 :type connection: dict
160 """
161 self.request("load-conn", connection)
162
163 def unload_conn(self, name):
164 """Unload a connection definition.
165
166 :param name: connection definition name
167 :type name: dict
168 """
169 self.request("unload-conn", name)
170
171 def load_cert(self, certificate):
172 """Load a certificate into the daemon.
173
174 :param certificate: PEM or DER encoded certificate
175 :type certificate: dict
176 """
177 self.request("load-cert", certificate)
178
179 def load_key(self, private_key):
180 """Load a private key into the daemon.
181
182 .. versionchanged:: 5.5.3
183 The key identifier of the loaded key is returned.
184
185 :param private_key: PEM or DER encoded key
186 :type private_key: dict
187 :return: key identifier
188 :rtype: dict
189 """
190 return self.request("load-key", private_key)
191
192 def unload_key(self, key_id):
193 """Unload the private key with the given key identifier.
194
195 .. versionadded:: 5.5.2
196
197 :param key_id: key identifier
198 :type key_id: dict
199 """
200 self.request("unload-key", key_id)
201
202 def get_keys(self):
203 """Retrieve identifiers of private keys loaded exclusively over vici.
204
205 .. versionadded:: 5.5.2
206
207 :return: key identifiers
208 :rtype: dict
209 """
210 return self.request("get-keys")
211
212 def load_token(self, token):
213 """Load a private key located on a token into the daemon.
214
215 .. versionadded:: 5.5.2
216
217 :param token: token details
218 :type token: dict
219 :return: key identifier
220 :rtype: dict
221 """
222 return self.request("load-token", token)
223
224 def load_shared(self, secret):
225 """Load a shared IKE PSK, EAP or XAuth secret into the daemon.
226
227 .. versionchanged:: 5.5.2
228 A unique identifier may be associated with the secret.
229
230 :param secret: shared IKE PSK, EAP or XAuth secret
231 :type secret: dict
232 """
233 self.request("load-shared", secret)
234
235
236 def unload_shared(self, identifier):
237 """Unload a previously loaded shared secret by its unique identifier.
238
239 .. versionadded:: 5.5.2
240
241 :param identifier: unique identifier
242 :type secret: dict
243 """
244 self.request("unload-shared", identifier)
245
246 def get_shared(self):
247 """Retrieve identifiers of shared keys loaded exclusively over vici.
248
249 .. versionadded:: 5.5.2
250
251 :return: identifiers
252 :rtype: dict
253 """
254 return self.request("get-shared")
255
256 def flush_certs(self, filter=None):
257 """Flush the volatile certificate cache.
258
259 Flush the certificate stored temporarily in the cache. The filter
260 allows to flush only a certain type of certificates, e.g. CRLs.
261
262 :param filter: flush only certificates of a given type (optional)
263 :type filter: dict
264 """
265 self.request("flush-certs", filter)
266
267 def clear_creds(self):
268 """Clear credentials loaded over vici.
269
270 Clear all loaded certificate, private key and shared key credentials.
271 This affects only credentials loaded over vici, but additionally
272 flushes the credential cache.
273 """
274 self.request("clear-creds")
275
276 def load_authority(self, ca):
277 """Load a certification authority definition into the daemon.
278
279 :param ca: certification authority definition
280 :type ca: dict
281 """
282 self.request("load-authority", ca)
283
284 def unload_authority(self, ca):
285 """Unload a previously loaded certification authority by name.
286
287 :param ca: certification authority name
288 :type ca: dict
289 """
290 self.request("unload-authority", ca)
291
292 def load_pool(self, pool):
293 """Load a virtual IP pool.
294
295 Load an in-memory virtual IP and configuration attribute pool.
296 Existing pools with the same name get updated, if possible.
297
298 :param pool: virtual IP and configuration attribute pool
299 :type pool: dict
300 """
301 return self.request("load-pool", pool)
302
303 def unload_pool(self, pool_name):
304 """Unload a virtual IP pool.
305
306 Unload a previously loaded virtual IP and configuration attribute pool.
307 Unloading fails for pools with leases currently online.
308
309 :param pool_name: pool by name
310 :type pool_name: dict
311 """
312 self.request("unload-pool", pool_name)
313
314 def get_pools(self, options):
315 """Retrieve loaded pools.
316
317 :param options: filter by name and/or retrieve leases (optional)
318 :type options: dict
319 :return: loaded pools
320 :rtype: dict
321 """
322 return self.request("get-pools", options)
323
324 def get_algorithms(self):
325 """List of currently loaded algorithms and their implementation.
326
327 .. versionadded:: 5.4.0
328
329 :return: algorithms
330 :rtype: dict
331 """
332 return self.request("get-algorithms")
333
334 def get_counters(self, options=None):
335 """List global or connection-specific counters for several IKE events.
336
337 .. versionadded:: 5.6.1
338
339 :param options: get global counters or those of all or one connection
340 :type options: dict
341 :return: counters
342 :rtype: dict
343 """
344 return self.request("get-counters", options)
345
346 def reset_counters(self, options=None):
347 """Reset global or connection-specific IKE event counters.
348
349 .. versionadded:: 5.6.1
350
351 :param options: reset global counters or those of all or one connection
352 :type options: dict
353 """
354 self.request("reset-counters", options)