Project

General

Profile

Xcapclient » History » Version 20

Adrian Georgescu, 04/13/2009 10:56 AM

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