diff options
Diffstat (limited to 'pykolab/wap_client/__init__.py')
-rw-r--r-- | pykolab/wap_client/__init__.py | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/pykolab/wap_client/__init__.py b/pykolab/wap_client/__init__.py index 9274be3..1dd6aab 100644 --- a/pykolab/wap_client/__init__.py +++ b/pykolab/wap_client/__init__.py @@ -292,7 +292,8 @@ def request(method, api_uri, get=None, post=None, headers={}): del response_data['status'] return response_data['result'] else: - return response_data['result'] + print "ERROR: %r" % (response_data['reason']) + return False def request_raw(method, api_uri, get=None, post=None, headers={}): global session_id @@ -383,6 +384,30 @@ def user_edit(user = None, attributes={}): return user_edit +def user_find(attribs=None): + if attribs == None: + post = { + 'search': { + 'params': { + utils.ask_question("Attribute") : { + 'value': utils.ask_question("value"), + 'type': 'exact' + } + } + } + } + else: + post = { 'search': { 'params': {} } } + + for (k,v) in attribs.iteritems(): + post['search']['params'][k] = { 'value': v, 'type': 'exact' } + + post = json.dumps(post) + + user = request('POST', 'user.find', post=post) + + return user + def user_form_value_generate(params=None): if params == None: params = get_user_input() |