SipXCAPApi » History » Revision 7
Revision 6 (Adrian Georgescu, 04/13/2010 10:14 AM) → Revision 7/8 (Adrian Georgescu, 04/13/2010 10:14 AM)
h1. = XCAP API = [[TOC(WikiStart, Sip*, depth=3)]] 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. XCAP client is implemented by "python-xcaplib":http://devel.ag-projects.com/cgi-bin/darcsweb.cgi?r=python-xcaplib;a=summary. [http://devel.ag-projects.com/cgi-bin/darcsweb.cgi?r=python-xcaplib;a=summary python-xcaplib]. The library provides @xcaplib.client.XCAPClient@ {{{xcaplib.client.XCAPClient}}} class which is an HTTP client with an interface better suited for XCAP servers. The library also provides a version of XCAPClient (@xcaplib.green.XCAPClient@) ({{{xcaplib.green.XCAPClient}}}) built on top of eventlet, which may be used in twisted reactor. h2. == Components *get*(_self_, _application_, _node_=@None@, _etag_=@None@, _headers_=@None@) == '''get'''(''self'', ''application'', ''node''={{{None}}}, ''etag''={{{None}}}, ''headers''={{{None}}}):: Make an HTTP GET request to the resource identified by _application_ ''application'' and _node_. ''node''. Return a Resource instance on success. Raise HTTPError if the operation was unsuccessful. *put*(_self_, _application_, _resource_, _node_=@None@, _etag_=@None@, _headers_=@None@) '''put'''(''self'', ''application'', ''resource'', ''node''={{{None}}}, ''etag''={{{None}}}, ''headers''={{{None}}}):: Make an HTTP PUT request to the resource identified by _application_ ''application'' and _node_. ''node''. Use _resource_ ''resource'' as a request body. Raise HTTPError is the operation was unsuccessful. *delete*(_self_, _application_, _node_=@None@, _etag_=@None@, _headers_=@None@) '''delete'''(''self'', ''application'', ''node''={{{None}}}, ''etag''={{{None}}}, ''headers''={{{None}}}):: Make an HTTP DELETE request to the resource identified by _application_ ''application'' and _node_. ''node''. Raise HTTPError if the operation was unsuccessful. h2. == Usage <pre> == {{{ client = XCAPClient(xcap_root, xcap_user_id, password=password) document = file('examples/resource-lists.xml').read() # put the document on the server client.put('resource-lists', document) # read the document from the server got = client.get('resource-lists') # get a specific element within a document element = client.get('resource-lists', '/resource-lists/list/entry/display-name') # get an attribute: res = client.get('resource-lists', '/resource-lists/list/entry/@uri') # replace an element conditionally, based on the etag client.put('resource-lists', '<entry uri="sip:bob@example.com"><display-name>The Bob</display-name></entry>', '/resource-lists/list/entry[@uri="sip:bob@example.com"]', etag=stored_etag) # delete an element client.delete('resource-lists', node_selector, etag=res.etag) </pre> }}}