Project

General

Profile

Xcapclient » History » Version 9

Adrian Georgescu, 10/26/2008 02:11 PM

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