Xcapclient

Version 22 (Adrian Georgescu, 04/13/2009 04:14 pm)

1 1 Adrian Georgescu
2 22 Adrian Georgescu
h2. xcapclient
3 1 Adrian Georgescu
4 22 Adrian Georgescu
5 22 Adrian Georgescu
6 22 Adrian Georgescu
7 19 Adrian Georgescu
To use this script you must to have a valid ~/xcapclient.ini configuration file. For more information consult the documentation that comes with python-xcaplib package.
8 1 Adrian Georgescu
9 1 Adrian Georgescu
10 22 Adrian Georgescu
h3. Description
11 14 Adrian Georgescu
12 22 Adrian Georgescu
13 22 Adrian Georgescu
!{}http://www.openxcap.org/chrome/site/SIMPLE-XCAP-client.png!
14 22 Adrian Georgescu
15 9 Adrian Georgescu
XCAP protocol, defined in RFC 4825, allows a client to read, write, and
16 9 Adrian Georgescu
modify application configuration data stored in XML format on a server. XCAP
17 9 Adrian Georgescu
maps XML document sub-trees and element attributes to HTTP URIs, so that
18 1 Adrian Georgescu
these components can be directly accessed by HTTP. An XCAP server used by
19 1 Adrian Georgescu
XCAP clients to store data like presence policy in combination with a SIP
20 9 Adrian Georgescu
Presence server that supports PUBLISH/SUBSCRIBE/NOTIFY SIP methods can
21 9 Adrian Georgescu
provide a complete SIP SIMPLE solution.
22 9 Adrian Georgescu
23 22 Adrian Georgescu
This XCAP  client is part of python-xcaplib package provided by "OpenXCAP":http://openxcap.org server. If you have installed bash_completion.d/xcapclient  you can use TAB completion to browse through the content of the XCAP server documents/nodes/atributes. For more information read the documentation that comes with the package.
24 1 Adrian Georgescu
25 22 Adrian Georgescu
<pre>
26 1 Adrian Georgescu
adigeo@ag-imac3:~$xcapclient -h
27 1 Adrian Georgescu
28 1 Adrian Georgescu
  xcapclient: Client for managing full or partial XML documents on XCAP servers (RFC 4825)
29 1 Adrian Georgescu
  xcapclient [OPTIONS] --app AUID ACTION [NODE-SELECTOR]
30 1 Adrian Georgescu
31 1 Adrian Georgescu
  ACTION is an operation to perform: get, replace, insert, put or delete.
32 1 Adrian Georgescu
  Presence of NODE-SELECTOR indicates that action is to be performed on an
33 1 Adrian Georgescu
  element or an attribute.
34 1 Adrian Georgescu
35 1 Adrian Georgescu
Options:
36 1 Adrian Georgescu
  -h, --help             show this help message and exit
37 1 Adrian Georgescu
  -a NAME, --account-name=NAME
38 1 Adrian Georgescu
                         the account name from which to read account settings.
39 1 Adrian Georgescu
                         Corresponds to section Account_NAME in the
40 1 Adrian Georgescu
                         configuration file. If not supplied, the section
41 1 Adrian Georgescu
                         [Account] will be read.
42 1 Adrian Georgescu
  --show-config          show options from the configuration file; use
43 1 Adrian Georgescu
                         together with --account-name
44 1 Adrian Georgescu
  --xcap-root=XCAP_ROOT  XCAP root, e.g. https://xcap.example.com/xcap-root
45 1 Adrian Georgescu
  --sip-address=SIP_ADDRESS
46 1 Adrian Georgescu
                         SIP address of the user in the form username@domain
47 1 Adrian Georgescu
  -p PASSWORD, --password=PASSWORD
48 1 Adrian Georgescu
                         password to use if authentication is required. If not
49 1 Adrian Georgescu
                         supplied will be asked interactively
50 1 Adrian Georgescu
  --app=AUID             Application Unique ID. There's no default value;
51 1 Adrian Georgescu
                         however, it may be guessed from NODE-SELECTOR or from
52 1 Adrian Georgescu
                         the input file. Known apps: watchers, pidf-
53 1 Adrian Georgescu
                         manipulation, rls-services, resource-lists, xcap-
54 1 Adrian Georgescu
                         caps, pres-rules, test-app
55 1 Adrian Georgescu
  --filename=FILENAME    
56 1 Adrian Georgescu
  -c CONTEXT, --context=CONTEXT
57 1 Adrian Georgescu
                         document context, users or global; default is users
58 1 Adrian Georgescu
                         for everything except xcap-caps
59 1 Adrian Georgescu
  --etag=ETAG            perform a conditional operation
60 1 Adrian Georgescu
  -i INPUT_FILENAME      source file for the PUT request; default is <stdin>
61 1 Adrian Georgescu
  -o OUTPUT_FILENAME     output file for the body of the server response
62 1 Adrian Georgescu
                         (successful or not); default is <stdout>
63 1 Adrian Georgescu
  -d, --dump             print HTTP traffic to stderr
64 22 Adrian Georgescu
</pre>
65 1 Adrian Georgescu
66 2 Adrian Georgescu
67 22 Adrian Georgescu
68 22 Adrian Georgescu
h3. Example for XCAP server capabilities (xcap-caps) 
69 22 Adrian Georgescu
 
70 22 Adrian Georgescu
<pre>
71 6 Adrian Georgescu
adigeo@ag-imac3:~$xcapclient -a alice --app xcap-caps GET
72 6 Adrian Georgescu
get https://xcap.sipthor.net/xcap-root/xcap-caps/global/index
73 6 Adrian Georgescu
etag: "ab12efdd1aff88296deee1aa195b823e"
74 6 Adrian Georgescu
content-type: application/xcap-caps+xml
75 6 Adrian Georgescu
content-length: 826
76 6 Adrian Georgescu
<?xml version='1.0' encoding='UTF-8'?>
77 6 Adrian Georgescu
<xcap-caps xmlns='urn:ietf:params:xml:ns:xcap-caps'>
78 6 Adrian Georgescu
<auids>
79 6 Adrian Georgescu
<auid>watchers</auid>
80 6 Adrian Georgescu
<auid>org.openmobilealliance.pres-rules</auid>
81 6 Adrian Georgescu
<auid>rls-services</auid>
82 6 Adrian Georgescu
<auid>pidf-manipulation</auid>
83 6 Adrian Georgescu
<auid>xcap-caps</auid>
84 6 Adrian Georgescu
<auid>test-app</auid>
85 6 Adrian Georgescu
<auid>resource-lists</auid>
86 6 Adrian Georgescu
<auid>pres-rules</auid>
87 6 Adrian Georgescu
</auids>
88 6 Adrian Georgescu
<extensions>
89 6 Adrian Georgescu
</extensions>
90 6 Adrian Georgescu
<namespaces>
91 1 Adrian Georgescu
<namespace>http://openxcap.org/ns/watchers</namespace>
92 1 Adrian Georgescu
<namespace>urn:ietf:params:xml:ns:pres-rules</namespace>
93 1 Adrian Georgescu
<namespace>urn:ietf:params:xml:ns:rls-services</namespace>
94 1 Adrian Georgescu
<namespace>urn:ietf:params:xml:ns:pidf</namespace>
95 1 Adrian Georgescu
<namespace>urn:ietf:params:xml:ns:xcap-caps</namespace>
96 1 Adrian Georgescu
<namespace>test-app</namespace>
97 1 Adrian Georgescu
<namespace>urn:ietf:params:xml:ns:resource-lists</namespace>
98 1 Adrian Georgescu
<namespace>urn:ietf:params:xml:ns:pres-rules</namespace>
99 6 Adrian Georgescu
</namespaces>
100 6 Adrian Georgescu
</xcap-caps>
101 22 Adrian Georgescu
</pre>
102 6 Adrian Georgescu
103 1 Adrian Georgescu
104 22 Adrian Georgescu
h3. Example for pres-rules XCAP document
105 1 Adrian Georgescu
106 22 Adrian Georgescu
107 22 Adrian Georgescu
108 22 Adrian Georgescu
h4. PUT
109 22 Adrian Georgescu
110 22 Adrian Georgescu
111 22 Adrian Georgescu
<pre>
112 3 Adrian Georgescu
adigeo@ag-imac3:~$xcapclient -a alice PUT -i work/python-xcaplib/examples/pres-rules.xml 
113 2 Adrian Georgescu
put https://xcap.sipthor.net/xcap-root/pres-rules/users/sip:alice@example.com/index
114 2 Adrian Georgescu
201 Created
115 2 Adrian Georgescu
etag: "345ba7c1ce125b2ff2438c19b25b4077"
116 2 Adrian Georgescu
content-type: application/auth-policy+xml
117 22 Adrian Georgescu
</pre>
118 2 Adrian Georgescu
119 2 Adrian Georgescu
120 1 Adrian Georgescu
121 22 Adrian Georgescu
h4. GET
122 22 Adrian Georgescu
123 22 Adrian Georgescu
124 22 Adrian Georgescu
<pre>
125 2 Adrian Georgescu
adigeo@ag-imac3:~$xcapclient -a alice --app pres-rules get 
126 2 Adrian Georgescu
get https://xcap.sipthor.net/xcap-root/pres-rules/users/sip:alice@example.com/index
127 2 Adrian Georgescu
etag: "345ba7c1ce125b2ff2438c19b25b4077"
128 2 Adrian Georgescu
content-type: application/auth-policy+xml
129 2 Adrian Georgescu
content-length: 939
130 2 Adrian Georgescu
<?xml version="1.0" encoding="UTF-8"?>
131 2 Adrian Georgescu
<ruleset xmlns="urn:ietf:params:xml:ns:common-policy" xmlns:pr="urn:ietf:params:xml:ns:pres-rules" xmlns:cp="www.counterpath.com/privacy-lists">
132 2 Adrian Georgescu
<rule id="pres_whitelist">
133 2 Adrian Georgescu
<conditions>
134 2 Adrian Georgescu
<identity>
135 2 Adrian Georgescu
<one id="sip:bob@example.com"/>
136 2 Adrian Georgescu
<one id="sip:alice@example.com"/>
137 2 Adrian Georgescu
<many domain="ag-projects.com">
138 2 Adrian Georgescu
</many>
139 2 Adrian Georgescu
</identity>
140 2 Adrian Georgescu
</conditions>
141 2 Adrian Georgescu
<actions>
142 2 Adrian Georgescu
<pr:sub-handling>allow</pr:sub-handling>
143 2 Adrian Georgescu
</actions>
144 2 Adrian Georgescu
<transformations>
145 2 Adrian Georgescu
<pr:provide-services>
146 2 Adrian Georgescu
<pr:all-services/>
147 2 Adrian Georgescu
</pr:provide-services>
148 2 Adrian Georgescu
<pr:provide-persons>
149 2 Adrian Georgescu
<pr:all-persons/>
150 2 Adrian Georgescu
</pr:provide-persons>
151 2 Adrian Georgescu
<pr:provide-devices>
152 1 Adrian Georgescu
<pr:all-devices/>
153 1 Adrian Georgescu
</pr:provide-devices>
154 1 Adrian Georgescu
<pr:provide-all-attributes/>
155 1 Adrian Georgescu
</transformations>
156 1 Adrian Georgescu
</rule>
157 2 Adrian Georgescu
<rule id="pres_blacklist">
158 2 Adrian Georgescu
<conditions>
159 2 Adrian Georgescu
<identity>
160 1 Adrian Georgescu
<one id="sip:40316600024@abc.com"/>
161 2 Adrian Georgescu
</identity>
162 1 Adrian Georgescu
</conditions>
163 1 Adrian Georgescu
<actions>
164 1 Adrian Georgescu
<pr:sub-handling>block</pr:sub-handling>
165 1 Adrian Georgescu
</actions>
166 1 Adrian Georgescu
<transformations/>
167 1 Adrian Georgescu
</rule>
168 1 Adrian Georgescu
</ruleset>
169 22 Adrian Georgescu
</pre>
170 2 Adrian Georgescu
171 1 Adrian Georgescu
172 22 Adrian Georgescu
h4. DELETE
173 22 Adrian Georgescu
174 22 Adrian Georgescu
175 22 Adrian Georgescu
<pre>
176 1 Adrian Georgescu
adigeo@ag-imac3:~$xcapclient -a alice --app pres-rules DELETE
177 1 Adrian Georgescu
delete https://xcap.sipthor.net/xcap-root/pres-rules/users/sip:alice@example.com/index
178 2 Adrian Georgescu
200 OK
179 14 Adrian Georgescu
content-type: application/auth-policy+xml
180 22 Adrian Georgescu
</pre>
181 2 Adrian Georgescu
182 2 Adrian Georgescu
183 1 Adrian Georgescu
184 22 Adrian Georgescu
h3. Example for resource-lists XCAP document
185 3 Adrian Georgescu
186 22 Adrian Georgescu
187 22 Adrian Georgescu
188 22 Adrian Georgescu
h4. PUT
189 22 Adrian Georgescu
190 22 Adrian Georgescu
191 22 Adrian Georgescu
<pre>
192 3 Adrian Georgescu
adigeo@ag-imac3:~$xcapclient -a alice PUT -i work/python-xcaplib/examples/resource-lists.xml 
193 3 Adrian Georgescu
put https://xcap.sipthor.net/xcap-root/resource-lists/users/sip:alice@example.com/index
194 3 Adrian Georgescu
201 Created
195 3 Adrian Georgescu
etag: "f8c47352d61b5b256ee80d964e03efd6"
196 3 Adrian Georgescu
content-type: application/resource-lists+xml
197 22 Adrian Georgescu
</pre>
198 3 Adrian Georgescu
199 3 Adrian Georgescu
200 22 Adrian Georgescu
h4. GET
201 22 Adrian Georgescu
202 22 Adrian Georgescu
203 22 Adrian Georgescu
<pre>
204 1 Adrian Georgescu
adigeo@ag-imac3:~$xcapclient -a alice --app resource-lists GET
205 1 Adrian Georgescu
get https://xcap.sipthor.net/xcap-root/resource-lists/users/sip:alice@example.com/index
206 1 Adrian Georgescu
etag: "f8c47352d61b5b256ee80d964e03efd6"
207 1 Adrian Georgescu
content-type: application/resource-lists+xml
208 1 Adrian Georgescu
content-length: 991
209 3 Adrian Georgescu
<?xml version="1.0" encoding="UTF-8"?>
210 3 Adrian Georgescu
   <resource-lists xmlns="urn:ietf:params:xml:ns:resource-lists"
211 3 Adrian Georgescu
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
212 3 Adrian Georgescu
    <list name="friends">
213 1 Adrian Georgescu
     <entry uri="sip:bill@example.com">
214 1 Adrian Georgescu
      <display-name>Bill Doe</display-name>
215 1 Adrian Georgescu
     </entry>
216 1 Adrian Georgescu
     <entry-ref ref="resource-lists/users/sip:bill@example.com/index/~~/resource-lists/list%5b@name=%22list1%22%5d/entry%5b@uri=%22sip:petri@example.com%22%5d"/>
217 1 Adrian Georgescu
     <list name="close-friends">
218 1 Adrian Georgescu
      <display-name>Close Friends</display-name>
219 1 Adrian Georgescu
      <entry uri="sip:joe@example.com">
220 1 Adrian Georgescu
       <display-name>Joe Smith</display-name>
221 3 Adrian Georgescu
      </entry>
222 3 Adrian Georgescu
      <entry uri="sip:nancy@example.com">
223 3 Adrian Georgescu
       <display-name>Nancy Gross</display-name>
224 3 Adrian Georgescu
      </entry>
225 1 Adrian Georgescu
      <external anchor="http://xcap.example.org/resource-lists/users/sip:a@example.org/index/~~/resource-lists/list%5b@name=%22mkting%22%5d">
226 1 Adrian Georgescu
        <display-name>Marketing</display-name>
227 1 Adrian Georgescu
       </external>
228 1 Adrian Georgescu
     </list>
229 1 Adrian Georgescu
    </list>
230 3 Adrian Georgescu
   </resource-lists>
231 22 Adrian Georgescu
</pre>
232 3 Adrian Georgescu
233 3 Adrian Georgescu
234 22 Adrian Georgescu
h4. DELETE
235 22 Adrian Georgescu
236 22 Adrian Georgescu
237 22 Adrian Georgescu
<pre>
238 3 Adrian Georgescu
adigeo@ag-imac3:~$xcapclient -a alice --app resource-lists DELETE
239 3 Adrian Georgescu
delete https://xcap.sipthor.net/xcap-root/resource-lists/users/sip:alice@example.com/index
240 3 Adrian Georgescu
200 OK
241 3 Adrian Georgescu
content-type: application/resource-lists+xml
242 3 Adrian Georgescu
adigeo@ag-imac3:~$
243 22 Adrian Georgescu
</pre>
244 3 Adrian Georgescu
245 1 Adrian Georgescu
246 22 Adrian Georgescu
h3. Example for rls-services XCAP document
247 14 Adrian Georgescu
248 22 Adrian Georgescu
249 22 Adrian Georgescu
250 22 Adrian Georgescu
h4. PUT
251 22 Adrian Georgescu
252 22 Adrian Georgescu
253 22 Adrian Georgescu
<pre>
254 1 Adrian Georgescu
adigeo@ag-imac3:~$xcapclient -a alice PUT -i work/python-xcaplib/examples/rls-services.xml 
255 1 Adrian Georgescu
put https://xcap.sipthor.net/xcap-root/rls-services/users/sip:alice@example.com/index
256 1 Adrian Georgescu
201 Created
257 1 Adrian Georgescu
etag: "44f5fca1b08352815ee12f1a0c32d812"
258 1 Adrian Georgescu
content-type: application/rls-services+xml
259 22 Adrian Georgescu
</pre>
260 4 Adrian Georgescu
261 4 Adrian Georgescu
262 22 Adrian Georgescu
h4. GET
263 22 Adrian Georgescu
264 22 Adrian Georgescu
265 22 Adrian Georgescu
<pre>
266 4 Adrian Georgescu
adigeo@ag-imac3:~$xcapclient -a alice --app rls-services GET
267 4 Adrian Georgescu
get https://xcap.sipthor.net/xcap-root/rls-services/users/sip:alice@example.com/index
268 4 Adrian Georgescu
etag: "44f5fca1b08352815ee12f1a0c32d812"
269 4 Adrian Georgescu
content-type: application/rls-services+xml
270 4 Adrian Georgescu
content-length: 797
271 4 Adrian Georgescu
<?xml version="1.0" encoding="UTF-8"?>
272 4 Adrian Georgescu
   <rls-services xmlns="urn:ietf:params:xml:ns:rls-services"
273 4 Adrian Georgescu
      xmlns:rl="urn:ietf:params:xml:ns:resource-lists"
274 4 Adrian Georgescu
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
275 4 Adrian Georgescu
    <service uri="sip:mybuddies@example.com">
276 4 Adrian Georgescu
     <resource-list>https://xcap.example.com/xcap-root/resource-lists/users/sip:alice@example.com/index/~~/resource-lists/list%5b@name=%22l1%22%5d</resource-list>
277 4 Adrian Georgescu
     <packages>
278 4 Adrian Georgescu
      <package>presence</package>
279 4 Adrian Georgescu
     </packages>
280 4 Adrian Georgescu
    </service>
281 4 Adrian Georgescu
    <service uri="sip:marketing@example.com">
282 4 Adrian Georgescu
      <list name="marketing">
283 4 Adrian Georgescu
        <rl:entry uri="sip:joe@example.com"/>
284 4 Adrian Georgescu
        <rl:entry uri="sip:sudhir@example.com"/>
285 4 Adrian Georgescu
      </list>
286 4 Adrian Georgescu
      <packages>
287 4 Adrian Georgescu
        <package>presence</package>
288 4 Adrian Georgescu
      </packages>
289 4 Adrian Georgescu
    </service>
290 4 Adrian Georgescu
   </rls-services>
291 22 Adrian Georgescu
</pre>
292 4 Adrian Georgescu
293 4 Adrian Georgescu
294 22 Adrian Georgescu
h4. DELETE
295 22 Adrian Georgescu
296 22 Adrian Georgescu
297 22 Adrian Georgescu
<pre>
298 4 Adrian Georgescu
adigeo@ag-imac3:~$xcapclient -a alice --app rls-services DELETE
299 4 Adrian Georgescu
delete https://xcap.sipthor.net/xcap-root/rls-services/users/sip:alice@example.com/index
300 4 Adrian Georgescu
200 OK
301 4 Adrian Georgescu
content-type: application/rls-services+xml
302 22 Adrian Georgescu
</pre>