how to create your own exchange compatible backend
TRANSCRIPT
HOW TO CREATE YOUR OWN EXCHANGE COMPATIBLE BACKENDDIVE INTO THE OPENCHANGE REST API
Julien Kerihuel@jkerihuel
2 of 2615/07/2013 OpenChange The World www.openchange.org
What is OpenChange?http://www.openchange.org
3 of 2615/05/14 OpenChange The World www.openchange.org
Interoperable Exchange framework
● From client to server:
● Client libraries working with every Exchange
● Server interoperable with every Outlook
● Exchange RPC Protocols (MAPI) / on top of Samba4
● Mainly written in C
● License: GPLv3 or later
● Hosted on github: https://github.com/openchange/openchange
4 of 2615/05/14 OpenChange The World www.openchange.org
OpenChange server architecture
OpenChange Server
MAPISTORE
Stackable backends - Dynamic Shared Object
[...]
5 of 2615/05/14 OpenChange The World www.openchange.org
Zero to One Paradigm
1.Language is a blocker
(C, C++, Objective-C)
2.Learning curve is too steep
3.Take too long to develop backend
6 of 2615/07/2013 OpenChange The World www.openchange.org
How to make this easier?MORE 1 AND LESS 0
7 of 2615/05/14 OpenChange The World www.openchange.org
Python-C mapistore gateway
● Python script as a backend
● Backend implements REST API (rest.py)
● Embed MAPI logic / abstract complexity● Make backends language agnostic● Speed up PoC development● Dogfooding
8 of 2615/05/14 OpenChange The World www.openchange.org
Python-REST architecture
PYTHON MOCK Server
OpenChange Server
MAPISTORE
rest.py script - PYTHON backend
REST API
KISSDB
Python-C gateway
9 of 2615/07/2013 OpenChange The World www.openchange.org
REST API Overview WHAT DOES IT LOOK LIKE?
10 of 2615/05/14 OpenChange The World www.openchange.org
REST Resource and syntax transfer
● It is all about get/set MAPI properties
● HTTP commands + JSON payload
● 1 resource for each Exchange item:● /folders, /mails, /calendars, /contacts, /attachments
● GET http://localhost:5001/folders/2
http://www.openchange.org/documentation/api/mapistore-http/index.html
11 of 2615/05/14 OpenChange The World www.openchange.org
JSON Payload
● Dictionaries of MAPI properties
● Include custom properties (id, collection, parent_id, type)
{ "PidTagChangeNumber": 12249790986447749121, "PidTagComment": "", "PidTagContainerClass": "IPF.Contact", "PidTagDisplayName": "Contacts", "PidTagExtendedFolderFlags": "AQQAABAA", "PidTagFolderType": 1, "PidTagParentFolderId": 17582897370184548353, "id": 101, "parent_id": 1, "type": "folder"}
12 of 2615/05/14 OpenChange The World www.openchange.org
REST Operations
HEAD /resource/<id> Does the resource exist?
HEAD /resource/<id>/{messages, folders} Returns number of items
GET /resource/<id> Return the item
GET /resource/<id>/{messages, folders} Return list of items
POST /resource/ Create a resource
PUT /resource/<id> Update a resource
DELETE /resource/<id> Delete a resource
13 of 2615/05/14 OpenChange The World www.openchange.org
REST Operations
HEAD /resource/<id> Does the resource exist?
HEAD /resource/<id>/{messages, folders} Returns number of items
GET /resource/<id> Return the item
GET /resource/<id>/{messages, folders} Return list of items
POST /resource/ Create a resource
PUT /resource/<id> Update a resource
DELETE /resource/<id> Delete a resource
14 of 2615/05/14 OpenChange The World www.openchange.org
REST Operations
HEAD /resource/<id> Does the resource exist?
HEAD /resource/<id>/{messages, folders} Returns number of items
GET /resource/<id> Return the item
GET /resource/<id>/{messages, folders} Return list of items
POST /resource/ Create a resource
PUT /resource/<id> Update a resource
DELETE /resource/<id> Delete a resource
15 of 2615/05/14 OpenChange The World www.openchange.org
REST Operations
HEAD /resource/<id> Does the resource exist?
HEAD /resource/<id>/{messages, folders} Returns number of items
GET /resource/<id> Return the item
GET /resource/<id>/{messages, folders} Return list of items
POST /resource/ Create a resource
PUT /resource/<id> Update a resource
DELETE /resource/<id> Delete a resource
16 of 2615/05/14 OpenChange The World www.openchange.org
REST Operations
HEAD /resource/<id> Does the resource exist?
HEAD /resource/<id>/{messages, folders} Returns number of items
GET /resource/<id> Return the item
GET /resource/<id>/{messages, folders} Return list of items
POST /resource/ Create a resource
PUT /resource/<id> Update a resource
DELETE /resource/<id> Delete a resource
17 of 2615/05/14 OpenChange The World www.openchange.org
REST Operations
HEAD /resource/<id> Does the resource exist?
HEAD /resource/<id>/{messages, folders} Returns number of items
GET /resource/<id> Return the item
GET /resource/<id>/{messages, folders} Return list of items
POST /resource/ Create a resource
PUT /resource/<id> Update a resource
DELETE /resource/<id> Delete a resource
18 of 2615/05/14 OpenChange The World www.openchange.org
REST Operations
HEAD /resource/<id> Does the resource exist?
HEAD /resource/<id>/{messages, folders} Returns number of items
GET /resource/<id> Return the item
GET /resource/<id>/{messages, folders} Return list of items
POST /resource/ Create a resource
PUT /resource/<id> Update a resource
DELETE /resource/<id> Delete a resource
19 of 2615/07/2013 OpenChange The World www.openchange.org
THE DEV ENVIRONMENT 3 STEPS SETUP
20 of 2615/05/14 OpenChange The World www.openchange.org
Step 1. Prepare environment
1. Clone docker repository:
$ git clone https://github.com/openchange/docker
2. Clone openchange repository with REST API support
$ git clone https://github.com/openchange/openchange
$ cd openchange
$ git fetch && git checkout jkerihuel/mapistore-python
3. Install docker 1.4.1
$ lsdocker openchange
docker and openchange repositories MUSTMUST be at the same level
21 of 2615/05/14 OpenChange The World www.openchange.org
Step 2. Run the containers
● 2 consoles required at minimum
● run sequence in the order below
Console 1:
$ make mysql
$ make restserver
Console 2:
$ make openchange
3openchange
1mysql
2restserver
22 of 2615/05/14 OpenChange The World www.openchange.org
Step 3. DNS configuration options
2 options available:
● Point DNS to openchange container
● Edit /etc/hosts and map openchange.zentyal.lan to openchange container IP address
23 of 2615/05/14 OpenChange The World www.openchange.org
Outlook options requirements
ALWAYS UNTICK THE BOX – RUN OUTLOOK IN ONLINE MODE
24 of 2615/07/2013 OpenChange The World www.openchange.org
ROADMAP AND DELIVERABLESCONTINUOUS WORK IN PROGRESS
25 of 2615/05/14 OpenChange The World www.openchange.org
Agenda
Mid-February 2015 Single-UserOutlook in online modeCRUD operationsCommon filtering/sort/restrictions support
April 2015 NotificationsPermissionsAuthentication System
May 2015 Cached modeOptimization Pass
26 of 2615/05/14 OpenChange The World www.openchange.org
Julien Kerihuel,
OpenChange Founder
www.openchange.org
Questions?