summaryrefslogtreecommitdiffstats
path: root/pykolab/wap_client/__init__.py
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2013-05-03 17:58:31 +0200
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2013-05-03 18:00:23 +0200
commit030c157841e2b8690938995f5ce6bd6c48a82ea5 (patch)
tree774b624f9809fe6eed84ea1fc406df73d64e92fa /pykolab/wap_client/__init__.py
parent4c89c7a579c9afbd860dacae1087cd1c489da645 (diff)
downloadpykolab-030c157841e2b8690938995f5ce6bd6c48a82ea5.tar.gz
Adjust the WAP client for domain operations
Diffstat (limited to 'pykolab/wap_client/__init__.py')
-rw-r--r--pykolab/wap_client/__init__.py52
1 files changed, 24 insertions, 28 deletions
diff --git a/pykolab/wap_client/__init__.py b/pykolab/wap_client/__init__.py
index 0d61ac3..5daa61c 100644
--- a/pykolab/wap_client/__init__.py
+++ b/pykolab/wap_client/__init__.py
@@ -76,40 +76,36 @@ def connect():
return conn
-def domain_add(domain, parent=None):
- params = {
- 'domain': domain,
- }
-
+def domain_add(domain, aliases=[]):
dna = conf.get('ldap', 'domain_name_attribute')
- if not parent == None:
- domains = domains_list()
- parent_found = False
- if isinstance(domains['list'], dict):
- for _domain in domains['list'].keys():
- if parent_found:
- continue
-
- if isinstance(domains['list'][_domain][dna], basestring):
- if parent == domains['list'][_domain][dna]:
- parent_found = True
- elif isinstance(domains['list'][_domain][dna], list):
- if parent in domains['list'][_domain][dna]:
- parent_found = True
-
- if parent_found:
- params['parent'] = parent
- else:
- log.error(_("Invalid parent domain"))
- return
-
- post = json.dumps(params)
+ post = json.dumps({
+ dna: [ domain ] + aliases
+ })
return request('POST', 'domain.add', post=post)
+def domain_delete(domain):
+ domain_id, domain_attrs = domain_find(domain).popitem()
+
+ post = json.dumps({
+ 'id': domain_id
+ })
+
+ return request('POST', 'domain.delete', post=post)
+
+def domain_find(domain):
+ dna = conf.get('ldap', 'domain_name_attribute')
+
+ get = { dna: domain }
+
+ return request('GET', 'domain.find', get=get)
+
def domain_info(domain):
- get = { 'domain': domain }
+ domain_id, domain_attrs = domain_find(domain)
+
+ get = { 'id': domain_id }
+
return request('GET', 'domain.info', get=get)
def domains_capabilities():