zimbraSync device selfcare management
-------------------------------------

Non-admin in the 'zimbraSync' Namespace:
----------------------------------------
<GetDeviceStatusRequest>
<GetDeviceStatusResponse>
<RemoveDeviceRequest>
<RemoveDeviceResponse>
<SuspendDeviceRequest>
<SuspendDeviceResponse> 
<ResumeDeviceRequest>
<ResumeDeviceResponse>
<RemoteWipeRequest>
<RemoteWipeResponse>
<CancelPendingRemoteWipeRequest>
<CancelPendingRemoteWipeResponse>



------------------------
<GetDeviceStatusRequest>
------------------------

List all registered devices and their status

<GetDeviceStatusRequest xmlns="urn:zimbraSync"/>
 
<GetDeviceStatusResponse xmlns="urn:zimbraSync">
  [<device id="{device_id}" type="{device_type}" protocol="{protocol_version}" [ua="{user_agent}"] [model="{model}"] [imei="{imei}"] [friendly_name="{friendly_name}"] [os="{os}"] [os_language="{os_language}"] [phone_number="{phone_number}"]>
    <provisionable>{provisionable}</provisionable>
    <status>{status}</status>
    <firstReqReceived>{first_req_recv}</firstReqReceived>
    [<lastPolicyUpdate>{last_policy_update}</lastPolicyUpdate>]
    [<remoteWipeReqTime>{remote_wipe_req}</remoteWipeReqTime>
    [<removeWipeAckTime>{remote_wipe_ack}</remoteWipeAckTime>]]
    [<recoveryPassword>{recover_password}</recoveryPassword>]
    [<lastUsedDate>{last_used_date}</lastUsedDate>]
  </device>]*
</GetDeviceStatusResponse>

device_id - DeviceID
device_type - DeviceType
protocol_version - Protocol Version
user_agent - User Agent
model - Device model
imei - International Mobile Equipment Identity
friendly_name - Friendly name of the device
os - Device running OS (Operating System; e.g. android, ios etc.)
os_language - OS language
phone_number - Phone Number
provisionable - 0: no; 1: yes
status - 0: need provision (same as 1 if provisionable=0) 1: ok; 2: suspended; 3: remote wipe requested; 4: remote wipe complete
first_req_recv - when this device first registered with the server
last_policy_update - when policy was last updated on this device
remote_wipe_req - time (seconds since epoch) when remote wipe was initiated
remote_wipe_ack - time (seconds since epoch) when device confirmed the remote wipe
last_used_date - date when the device was last used (the date is stored in server's time zone)

---------------------
<RemoveDeviceRequest>
---------------------

Remove a device from registered list.  This will not cause a reset of sync data, but will cause a reset of policies on the next sync.

<RemoveDeviceRequest xmlns="urn:zimbraSync">
  <device id="{device_id}" />
</RemoveDeviceRequest>
         
<RemoveDeviceResponse />


----------------------
<SuspendDeviceRequest>
----------------------

Suspend a device from further sync actions.

<SuspendDeviceRequest xmlns="urn:zimbraSync">
  <device id="{device_id}" />
</SuspendDeviceRequest>
         
<SuspendDeviceResponse>
  [<device id="{device_id}" type="{device_type}" protocol="{protocol_version}" [ua="{user_agent}"] [model="{model}"] [imei="{imei}"] [friendly_name="{friendly_name}"] [os="{os}"] [os_language="{os_language}"] [phone_number="{phone_number}"]>
    <provisionable>{provisionable}</provisionable>
    <status>{status}</status>
    <firstReqReceived>{first_req_recv}</firstReqReceived>
    [<lastPolicyUpdate>{last_policy_update}</lastPolicyUpdate>]
    [<remoteWipeReqTime>{remote_wipe_req}</remoteWipeReqTime>
    [<removeWipeAckTime>{remote_wipe_ack}</remoteWipeAckTime>]]
    [<recoveryPassword>{recover_password}</recoveryPassword>]
    [<lastUsedDate>{last_used_date}</lastUsedDate>]
  </device>]*
</SuspendDeviceResponse>

---------------------
<ResumeDeviceRequest>
---------------------

Resume sync with a device if currently suspended.  This will cause a policy reset, but will not reset sync data.

<ResumeDeviceRequest xmlns="urn:zimbraSync">
  <device id="{device_id}" />
</ResumeDeviceRequest>
         
<ResumeDeviceResponse>
  [<device id="{device_id}" type="{device_type}" protocol="{protocol_version}" [ua="{user_agent}"] [model="{model}"] [imei="{imei}"] [friendly_name="{friendly_name}"] [os="{os}"] [os_language="{os_language}"] [phone_number="{phone_number}"]>
    <provisionable>{provisionable}</provisionable>
    <status>{status}</status>
    <firstReqReceived>{first_req_recv}</firstReqReceived>
    [<lastPolicyUpdate>{last_policy_update}</lastPolicyUpdate>]
    [<remoteWipeReqTime>{remote_wipe_req}</remoteWipeReqTime>
    [<removeWipeAckTime>{remote_wipe_ack}</remoteWipeAckTime>]]
    [<recoveryPassword>{recover_password}</recoveryPassword>]
    [<lastUsedDate>{last_used_date}</lastUsedDate>]
  </device>]*
</ResumeDeviceResponse>


-------------------
<RemoteWipeRequest>
-------------------

Request a device (e.g. a lost device) be wiped of all its data on the next sync.

<RemoteWipeRequest xmlns="urn:zimbraSync">
  <device id="{device_id}" />
</RemoteWipeRequest>
         
<RemoteWipeResponse />


--------------------------------
<CancelPendingRemoteWipeRequest>
--------------------------------

Cancel a pending Remote Wipe request.  Remote Wipe can't be canceled once the device confirms the wipe.

<CancelPendingRemoteWipeRequest xmlns="urn:zimbraSync">
  <device id="{device_id}" />
</CancelPendingRemoteWipeRequest>

<CancelPendingRemoteWipeResponse />



zimbra sync specific admin SOAP messages:
-----------------------------------------
<GetDevicesCountRequest>
<GetDevicesCountResponse>
<GetDevicesCountSinceLastUsedRequest>
<GetDevicesCountSinceLastUsedResponse>
<GetDevicesCountUsedTodayRequest>
<GetDevicesCountUsedTodayResponse>
<RemoteWipeRequest>
<RemoteWipeResponse>
<CancelPendingRemoteWipeRequest>
<CancelPendingRemoteWipeResponse>
<GetDeviceStatusRequest>
<GetDeviceStatusResponse>
<RemoveDeviceRequest>
<RemoveDeviceResponse>
<SuspendDeviceRequest>
<SuspendDeviceResponse>
<ResumeDeviceRequest>
<ResumeDeviceResponse>
------------------------
<GetDevicesCountRequest>
------------------------

Get the registered devices count on the server.

<GetDevicesCountRequest xmlns="urn:zimbraAdmin"/>
         
<GetDevicesCountResponse>
  <count>1023</count>
</GetDevicesCountResponse>


-------------------------------------
<GetDevicesCountSinceLastUsedRequest>
-------------------------------------

Get the mobile devices count on the server since last used date.

<GetDevicesCountSinceLastUsedRequest xmlns="urn:zimbraAdmin">
  <lastUsedDate date="{yyyy-MM-dd}" />
</GetDevicesCountSinceLastUsedRequest>

<GetDevicesCountSinceLastUsedResponse>
  <count>1023</count>
</GetDevicesCountSinceLastUsedResponse>


---------------------------------
<GetDevicesCountUsedTodayRequest>
---------------------------------

Get the mobile devices count on the server used today.

<GetDevicesCountUsedTodayRequest xmlns="urn:zimbraAdmin"/>

<GetDevicesCountUsedTodayResponse>
  <count>1023</count>
</GetDevicesCountUsedTodayResponse>


-------------------
<RemoteWipeRequest>
-------------------

Request a device (e.g. a lost device) be wiped of all its data on the next sync.

<RemoteWipeRequest xmlns="urn:zimbraAdmin">
  <account by="id|name">...</account>
  [<device id="{device_id}" />]
</RemoteWipeRequest>
         
<RemoteWipeResponse xmlns="urn:zimbraAdmin">
  [<device id="{device_id}" type="{device_type}" protocol="{protocol_version}" [ua="{user_agent}"] [model="{model}"] [imei="{imei}"] [friendly_name="{friendly_name}"] [os="{os}"] [os_language="{os_language}"] [phone_number="{phone_number}"]>
    <provisionable>{provisionable}</provisionable>
    <status>{status}</status>
    <firstReqReceived>{first_req_recv}</firstReqReceived>
    [<lastPolicyUpdate>{last_policy_update}</lastPolicyUpdate>]
    [<remoteWipeReqTime>{remote_wipe_req}</remoteWipeReqTime>
    [<removeWipeAckTime>{remote_wipe_ack}</remoteWipeAckTime>]]
    [<recoveryPassword>{recover_password}</recoveryPassword>]
    [<lastUsedDate>{last_used_date}</lastUsedDate>]
  </device>]*
</RemoteWipeResponse>

--------------------------------
<CancelPendingRemoteWipeRequest>
--------------------------------

Cancel a pending Remote Wipe request.  Remote Wipe can't be canceled once the device confirms the wipe.

<CancelPendingRemoteWipeRequest xmlns="urn:zimbraAdmin">
  <account by="id|name">...</account>
  [<device id="{device_id}" />]
</CancelPendingRemoteWipeRequest>

<CancelPendingRemoteWipeResponse>
  [<device id="{device_id}" type="{device_type}" protocol="{protocol_version}" [ua="{user_agent}"] [model="{model}"] [imei="{imei}"] [friendly_name="{friendly_name}"] [os="{os}"] [os_language="{os_language}"] [phone_number="{phone_number}"]>
    <provisionable>{provisionable}</provisionable>
    <status>{status}</status>
    <firstReqReceived>{first_req_recv}</firstReqReceived>
    [<lastPolicyUpdate>{last_policy_update}</lastPolicyUpdate>]
    [<remoteWipeReqTime>{remote_wipe_req}</remoteWipeReqTime>
    [<removeWipeAckTime>{remote_wipe_ack}</remoteWipeAckTime>]]
    [<recoveryPassword>{recover_password}</recoveryPassword>]
    [<lastUsedDate>{last_used_date}</lastUsedDate>]
  </device>]*
</CancelPendingRemoteWipeResponse>
------------------------
<GetDeviceStatusRequest>
------------------------

get the requested device's status

<GetDeviceStatusRequest xmlns="urn:zimbraAdmin"/>
  <account by="id|name">...</account>
  [<device id="{device_id}" />]
</GetDeviceStatusRequest>

<GetDeviceStatusResponse xmlns="urn:zimbraAdmin">
  [<device id="{device_id}" type="{device_type}" protocol="{protocol_version}" [ua="{user_agent}"] [model="{model}"] [imei="{imei}"] [friendly_name="{friendly_name}"] [os="{os}"] [os_language="{os_language}"] [phone_number="{phone_number}"]>
    <provisionable>{provisionable}</provisionable>
    <status>{status}</status>
    <firstReqReceived>{first_req_recv}</firstReqReceived>
    [<lastPolicyUpdate>{last_policy_update}</lastPolicyUpdate>]
    [<remoteWipeReqTime>{remote_wipe_req}</remoteWipeReqTime>
    [<removeWipeAckTime>{remote_wipe_ack}</remoteWipeAckTime>]]
    [<recoveryPassword>{recover_password}</recoveryPassword>]
    [<lastUsedDate>{last_used_date}</lastUsedDate>]
  </device>]*
</GetDeviceStatusResponse>

device_id - DeviceID
device_type - DeviceType
protocol_version - Protocol Version
user_agent - User Agent
model - Device model
imei - International Mobile Equipment Identity
friendly_name - Friendly name of the device
os - Device running OS (Operating System; e.g. android, ios etc.)
os_language - OS language
phone_number - Phone Number
provisionable - 0: no; 1: yes
status - 0: need provision (same as 1 if provisionable=0) 1: ok; 2: suspended; 3: remote wipe requested; 4: remote wipe complete
first_req_recv - when this device first registered with the server
last_policy_update - when policy was last updated on this device
remote_wipe_req - time (seconds since epoch) when remote wipe was initiated
remote_wipe_ack - time (seconds since epoch) when device confirmed the remote wipe
last_used_date - date when the device was last used (the date is stored in server's time zone)

---------------------
<RemoveDeviceRequest>
---------------------

Remove a device or remove all devices attached to an account. This will not cause a reset of sync data, but will cause a reset of policies on the next sync.

<RemoveDeviceRequest xmlns="urn:zimbraAdmin">
  <account by="id|name">...</account>
  [<device id="{device_id}" />]
</RemoveDeviceRequest>

<RemoveDeviceResponse />

----------------------
<SuspendDeviceRequest>
----------------------

Suspend a device or all devices attached to an account from further sync actions.

<SuspendDeviceRequest xmlns="urn:zimbraAdmin">
  <account by="id|name">...</account>
  [<device id="{device_id}" />]
</SuspendDeviceRequest>

<SuspendDeviceResponse>
  [<device id="{device_id}" type="{device_type}" protocol="{protocol_version}" [ua="{user_agent}"] [model="{model}"] [imei="{imei}"] [friendly_name="{friendly_name}"] [os="{os}"] [os_language="{os_language}"] [phone_number="{phone_number}"]>
    <provisionable>{provisionable}</provisionable>
    <status>{status}</status>
    <firstReqReceived>{first_req_recv}</firstReqReceived>
    [<lastPolicyUpdate>{last_policy_update}</lastPolicyUpdate>]
    [<remoteWipeReqTime>{remote_wipe_req}</remoteWipeReqTime>
    [<removeWipeAckTime>{remote_wipe_ack}</remoteWipeAckTime>]]
    [<recoveryPassword>{recover_password}</recoveryPassword>]
    [<lastUsedDate>{last_used_date}</lastUsedDate>]
  </device>]*
</SuspendDeviceResponse>

---------------------
<ResumeDeviceRequest>
---------------------

Resume sync with a device or all devices attached to an account if currently suspended.  This will cause a policy reset, but will not reset sync data.

<ResumeDeviceRequest xmlns="urn:zimbraAdmin">
  <account by="id|name">...</account>
  [<device id="{device_id}" />]
</ResumeDeviceRequest>

<ResumeDeviceResponse>
  [<device id="{device_id}" type="{device_type}" protocol="{protocol_version}" [ua="{user_agent}"] [model="{model}"] [imei="{imei}"] [friendly_name="{friendly_name}"] [os="{os}"] [os_language="{os_language}"] [phone_number="{phone_number}"]>
    <provisionable>{provisionable}</provisionable>
    <status>{status}</status>
    <firstReqReceived>{first_req_recv}</firstReqReceived>
    [<lastPolicyUpdate>{last_policy_update}</lastPolicyUpdate>]
    [<remoteWipeReqTime>{remote_wipe_req}</remoteWipeReqTime>
    [<removeWipeAckTime>{remote_wipe_ack}</remoteWipeAckTime>]]
    [<recoveryPassword>{recover_password}</recoveryPassword>]
    [<lastUsedDate>{last_used_date}</lastUsedDate>]
  </device>]*
</ResumeDeviceResponse>

---------------------
<GetSyncStateRequest>
---------------------

Get SyncState of a given folder from a given device, this can be used to trouble shooting items that are supposed to be on device

<GetSyncStateRequest xmlns="urn:zimbraAdmin">
  <account by="id|name">...</account>
  <device id="{device_id}" />
  <folder id="{folder_id}" class="{Email|Calendar|Contacts}" showItems="true|false" />
  <item id="itemId" />
</GetSyncStateRequest>

<GetSyncStateResponse>
  <syncstate>
     Description of SyncState
  </syncstate>
</GetSyncStateResponse>

---------------------
<RemoveStaleDeviceMetadata>
---------------------

Remove stale data from mailbox_metadata. Stale data are metadata from devices whose last_used_date is at least 90 days before now.

<RemoveStaleDeviceMetadataRequest @lastUsedDateOlderThan="{days}"/>

<RemoveStaleDeviceMetadataResponse />