summaryrefslogtreecommitdiffstats
path: root/pykolab/wap_client/__init__.py
diff options
context:
space:
mode:
authorTimotheus Pokorra <tp@tbits.net>2015-06-12 12:15:07 +0200
committerTimotheus Pokorra <tp@tbits.net>2015-06-12 12:15:07 +0200
commit94d58ba529201de81f956fa8e868a9438bdd18c8 (patch)
tree48f0d9921940e99e85027d638387b1bbbed47d2e /pykolab/wap_client/__init__.py
parentac1ab08b8611b7f5b8b6e0f0834f801f75e73918 (diff)
downloadpykolab-94d58ba529201de81f956fa8e868a9438bdd18c8.tar.gz
cli: kolab delete-domain improved. (#5098)
it now displays if the command succeeded, or shows the error message from the Kolab API. new parameter --force to delete a domain even if user accounts exist.
Diffstat (limited to 'pykolab/wap_client/__init__.py')
-rw-r--r--pykolab/wap_client/__init__.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/pykolab/wap_client/__init__.py b/pykolab/wap_client/__init__.py
index ed96292..f625bd6 100644
--- a/pykolab/wap_client/__init__.py
+++ b/pykolab/wap_client/__init__.py
@@ -123,12 +123,15 @@ def domain_add(domain, aliases=[]):
return request('POST', 'domain.add', post=post)
-def domain_delete(domain):
+def domain_delete(domain, force=False):
domain_id, domain_attrs = domain_find(domain).popitem()
- post = json.dumps({
- 'id': domain_id
- })
+ param = {}
+ param['id'] = domain_id
+
+ if force:
+ param['force'] = force
+ post = json.dumps(param)
return request('POST', 'domain.delete', post=post)
@@ -390,6 +393,7 @@ def request(method, api_uri, get=None, post=None, headers={}):
del response_data['status']
return response_data['result']
else:
+ print("%s: %s (code %s)" % (response_data['status'], response_data['reason'], response_data['code']))
return False
def request_raw(method, api_uri, get=None, post=None, headers={}, isretry=False):