Xcapclient

Version 11 (Adrian Georgescu, 10/26/2008 04:26 pm)

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