Python library for interfacing with Zimbra's SOAP API. It's based on PySimpleSOAP and provides a framework to make and respond to any given Zimbra SOAP API request.
import zimbrasoap
zimbra = zimbrasoap.admin(server = 'zimbra.example.com')
# Calls AuthRequest, and stores auth token in zimbrasoap object
zimbra.Auth(name = '[email protected]', password = 'password')
# Calls GetAccountRequest
response = zimbra.GetAccount(account = {'by':'name', 'value':'[email protected]'})
# Reponse looks similar to:
# <GetAccountResponse xmlns="urn:zimbraAdmin">
# <account id="abcde1234-1234-abcd-1234-abcdef123456" name="[email protected]">
# <a n="zimbraMailStatus">closed</a>
# <a n="givenName">John</a>
# [...]
# <a n="displayName">John Doe</a>
# </account>
# </GetAccountResponse>
# Print tag attribute (could also use just response.account['id'])
print response.GetAccountResponse.account['id']
# Use ParseAttributes to print a dict of all Zimbra attributes
# (ie zimbraMailStatus / enabled)
print zimbra.ParseAttributes(response.account.a)
# Call ModifyAccountRequest to set "zimbraMailStatus" to "active"
#
# Sends request similar to:
#
# <ModifyAccountRequest xmlns="urn:zimbraAdmin">
# <a n="zimbraAccountStatus">active</a>
# <id>e78b0780-3802-411c-8151-a5a7943cdb41</id>
# </ModifyAccountRequest>
zimbra.ModifyAccount(id = response.account['id'], a = {'n':'zimbraAccountStatus', 'value':'active'})
# Call ModifyAccountRequest again to set multiple attributes
# Sends request similar to:
#
# <ModifyAccountRequest xmlns="urn:zimbraAdmin">
# <a n="givenName">Jane</a>
# <a n="initials">J</a>
# <a n="sn">Doe</a>
# <id>e78b0780-3802-411c-8151-a5a7943cdb41</id>
# </ModifyAccountRequest>
zimbra.ModifyAccount(id = response.account['id'], a = [{'n':'givenName', 'value':'Jane'},
{'n':'initials', 'value':'J'},
{'n':'sn', 'value':'Doe'}])
- Could support XPath-like syntax of zmsoap