-
Notifications
You must be signed in to change notification settings - Fork 0
/
legacy.py
71 lines (64 loc) · 2.5 KB
/
legacy.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# Some examples of early tests that I tried.
def getallaccounts():
request = RequestXml()
params = { 'server': { 'by': 'name', '_content': 'collaboration.devnet.imsa.edu' } }
request.add_request('GetAllAccountsRequest', params,'urn:zimbraAdmin')
request.set_auth_token(token)
log.debug("request = %s", request.get_request())
response = ResponseXml()
comm.send_request(request, response)
if response.is_fault():
raise Exception("response is fault")
info = response.get_response()
accounts = info['GetAllAccountsResponse']['account']
pprint.pprint([account['name'] for account in accounts])
for account in accounts:
if account['name'].startswith('fcy@'):
pprint.pprint(account)
break
def getallcalendarresources():
request = RequestXml()
request.add_request('GetAllCalendarResourcesRequest', {'attrs':'sn'}, 'urn:zimbraAdmin')
request.set_auth_token(token)
log.debug("request = %s", request.get_request())
response = ResponseXml()
comm.send_request(request, response)
if response.is_fault():
raise Exception("response is fault")
info = response.get_response()
cals = info['GetAllCalendarResourcesResponse']['calresource']
pprint.pprint([cal['name'] for cal in cals])
for cal in cals:
pprint.pprint(cal['a'])
break
def getmailbox(accountid):
request = RequestXml()
params = {'mbox': {'id': accountid}}
request.add_request('GetMailboxRequest', params, 'urn:zimbraAdmin')
request.set_auth_token(token)
log.debug("request = %s", request.get_request())
response = ResponseXml()
comm.send_request(request, response)
if response.is_fault():
raise Exception("response is fault")
info = response.get_response()
mbox = info['GetMailboxResponse']['mbox']
return mbox
def getcalendarresource():
request = RequestXml()
params = { 'calresource': { '_content': 'itsconfroom@devnet.imsa.edu', 'by': 'name' },
'attrs': 'sn,zimbraId',
}
request.add_request('GetCalendarResourceRequest', params, 'urn:zimbraAdmin')
request.set_auth_token(token)
log.debug("request = %s", request.get_request())
response = ResponseXml()
try:
comm.send_request(request, response)
except:
log.exception("send_request failed: request=%s", request.get_request())
return none
if response.is_fault():
raise Exception("response is fault")
info = response.get_response()
pprint.pprint(info)