Project

General

Profile

SipXCAPApi » History » Version 7

Adrian Georgescu, 04/13/2010 10:14 AM

1 1 Adrian Georgescu
2 7 Adrian Georgescu
h1. XCAP API
3
4
5
6 1 Adrian Georgescu
XCAP protocol allows a client to read, write, and modify application configuration data stored in XML format on a server. XCAP maps XML document sub-trees and element attributes to HTTP URIs, so that these components can be directly accessed by clients using HTTP protocol. An XCAP server is used by XCAP clients to store data like buddy lists and presence policy in combination with a SIP Presence server that supports PUBLISH, SUBSCRIBE and NOTIFY methods to provide a complete SIP SIMPLE solution.
7
8 7 Adrian Georgescu
XCAP client is implemented by "python-xcaplib":http://devel.ag-projects.com/cgi-bin/darcsweb.cgi?r=python-xcaplib;a=summary. The library provides @xcaplib.client.XCAPClient@ class which is an HTTP client with an interface better suited for XCAP servers. The library also provides
9
a version of XCAPClient (@xcaplib.green.XCAPClient@) built on top of eventlet, which may be used in twisted reactor.
10 1 Adrian Georgescu
11
12 7 Adrian Georgescu
h2. Components
13
14
15
*get*(_self_, _application_, _node_=@None@, _etag_=@None@, _headers_=@None@)
16
 Make an HTTP GET request to the resource identified by _application_ and _node_. Return a Resource instance on success.
17 1 Adrian Georgescu
 Raise HTTPError if the operation was unsuccessful.
18
19 7 Adrian Georgescu
*put*(_self_, _application_, _resource_, _node_=@None@, _etag_=@None@, _headers_=@None@)
20
 Make an HTTP PUT request to the resource identified by _application_ and _node_. Use _resource_ as a request body.
21 5 Adrian Georgescu
 Raise HTTPError is the operation was unsuccessful.
22
23 7 Adrian Georgescu
*delete*(_self_, _application_, _node_=@None@, _etag_=@None@, _headers_=@None@)
24
 Make an HTTP DELETE request to the resource identified by _application_ and _node_.
25 5 Adrian Georgescu
 Raise HTTPError if the operation was unsuccessful.
26
27
28 7 Adrian Georgescu
h2. Usage
29
30
31
<pre>
32 2 Oliver Bril
client = XCAPClient(xcap_root, xcap_user_id, password=password)
33
document = file('examples/resource-lists.xml').read()
34
35
# put the document on the server
36
client.put('resource-lists', document)
37 1 Adrian Georgescu
38 3 Oliver Bril
# read the document from the server
39 1 Adrian Georgescu
got = client.get('resource-lists')
40 3 Oliver Bril
41 4 Oliver Bril
# get a specific element within a document
42 3 Oliver Bril
element = client.get('resource-lists', '/resource-lists/list/entry/display-name')
43
44
# get an attribute:
45
res = client.get('resource-lists', '/resource-lists/list/entry/@uri')
46
47
# replace an element conditionally, based on the etag
48
client.put('resource-lists', '<entry uri="sip:bob@example.com"><display-name>The Bob</display-name></entry>',
49
           '/resource-lists/list/entry[@uri="sip:bob@example.com"]', etag=stored_etag)
50
51
# delete an element
52
client.delete('resource-lists', node_selector, etag=res.etag)
53 7 Adrian Georgescu
</pre>