1Net::DAVTalk(3)       User Contributed Perl Documentation      Net::DAVTalk(3)
2
3
4

NAME

6       Net::DAVTalk - Interface to talk to DAV servers
7

VERSION

9       Version 0.22
10

SYNOPSIS

12       Net::DAVTalk is was originally designed as a service module for
13       Net::CalDAVTalk and Net::DAVTalk, abstracting the process of connecting
14       to a DAV server and parsing the XML responses.
15
16       Example:
17
18           use Net::DAVTalk;
19           use XML::Spice;
20
21           my $davtalk = Net::DAVTalk->new(
22               url => "https://dav.example.com/",
23               user => "foo\@example.com",
24               password => "letmein",
25               headers => { Cookie => "123", Referer => "456" },
26           );
27
28           $davtalk->Request(
29               'MKCALENDAR',
30               "$calendarId/",
31               x('C:mkcalendar', $Self->NS(),
32                   x('D:set',
33                        x('D:prop', @Properties),
34                   ),
35               ),
36           );
37
38           $davtalk->Request(
39               'DELETE',
40               "$calendarId/",
41           );
42

SUBROUTINES/METHODS

44   $class->new(%Options)
45       Options:
46
47           url: either full https?:// url, or relative base path on the
48           server to the DAV endpoint
49
50           host, scheme and port: alternative to using full URL.
51           If URL doesn't start with https?:// then these will be used to
52           construct the endpoint URI.
53
54           expandurl and wellknown: if these are set, then the wellknown
55           name (caldav and carddav are both defined) will be used to
56           resolve /.well-known/$wellknown to find the current-user-principal
57           URI, and then THAT will be resovlved to find the $wellknown-home-set
58           URI, which will be used as the URL for all further actions on
59           this object.
60
61           user and password: if these are set, perform basic authentication.
62           user and access_token: if these are set, perform Bearer (OAUTH2)
63           authentication.
64
65           headers: a hashref of additional headers to add to every request
66
67   my $ua = $Self->ua(); =head2 $Self->ua($setua);
68       Get or set the useragent (HTTP::Tiny or compatible) that will be used
69       to make the requests:
70
71       e.g.
72
73           my $ua = $Self->ua();
74
75           $Self->ua(HTTP::Tiny->new(agent => "MyAgent/1.0", timeout => 5));
76
77   $Self->SetURL($url)
78       Change the endpoint URL for an existing connection.
79
80   $Self->SetPrincipalURL($url)
81       Set the URL to the DAV Principal
82
83   $Self->fullpath($shortpath)
84       Convert from a relative path to a full path:
85
86       e.g
87           my $path = $Dav->fullpath('Default');
88           ## /dav/calendars/user/foo/Default
89
90       NOTE: a you can pass a non-relative full path (leading /) to this
91       function and it will be returned unchanged.
92
93   $Self->shortpath($fullpath)
94       Convert from a full path to a relative path
95
96       e.g
97           my $path = $Dav->fullpath('/dav/calendars/user/foo/Default');
98           ## Default
99
100       NOTE: if the full path is outside the basepath of the object, it will
101       be unchanged.
102
103           my $path = $Dav->fullpath('/dav/calendars/user/bar/Default');
104           ## /dav/calendars/user/bar/Default
105
106   $Self->Request($method, $path, $content, %headers)
107       The whole point of the module!  Perform a DAV request against the
108       endpoint, returning the response as a parsed hash.
109
110          method: http method, i.e. GET, PROPFIND, MKCOL, DELETE, etc
111
112          path: relative to base url.  With a leading slash, relative to
113                server root, i.e. "Default/", "/dav/calendars/user/foo/Default".
114
115          content: if the method takes a body, raw bytes to send
116
117          headers: additional headers to add to request, i.e (Depth => 1)
118
119   $Self->GetProps($Path, @Props)
120       perform a propfind on a particular path and get the properties back
121
122   $Self->GetPropsArray($Path, @Props)
123       perform a propfind on a particular path and get the properties back as
124       an array of one or more items
125
126   $Self->GetCurrentUserPrincipal() =head2
127       $class->GetCurrentUserPrincipal(%Args)
128       Can be called with the same args as new() as a class method, or on an
129       existing object.  Either way it will use the .well-known URI to find
130       the path to the current-user-principal.
131
132       Returns a string with the path.
133
134   $Self->GetHomeSet =head2 $class->GetHomeSet(%Args)
135       Can be called with the same args as new() as a class method, or on an
136       existing object.  Either way it assumes that the created object has a
137       'url' parameter pointing at the current user principal URL (see
138       GetCurrentUserPrincipal above)
139
140       Returns a string with the path to the home set.
141
142   $Self->genuuid()
143       Helper to generate a uuid string.  Returns a UUID, e.g.
144
145           my $uuid = $DAVTalk->genuuid(); # 9b9d68af-ad13-46b8-b7ab-30ab70da14ac
146
147   $Self->auth_header()
148       Generate the authentication header to use on requests:
149
150       e.g:
151
152           $Headers{'Authorization'} = $Self->auth_header();
153
154   $Self->request_url()
155       Generate the authentication header to use on requests:
156
157       e.g:
158
159           $Headers{'Authorization'} = $Self->auth_header();
160
161   $Self->NS()
162       Returns a hashref of the 'xmlns:shortname' => 'full namespace' items
163       for use in XML::Spice body generation, e.g.
164
165           $DAVTalk->Request(
166               'MKCALENDAR',
167               "$calendarId/",
168               x('C:mkcalendar', $Self->NS(),
169                   x('D:set',
170                        x('D:prop', @Properties),
171                   ),
172               ),
173           );
174
175           # { 'xmlns:C' => 'urn:ietf:params:xml:ns:caldav', 'xmlns:D' => 'DAV:' }
176
177   $Self->ns($key, $value)
178       Get or set namespace aliases, e.g
179
180         $Self->ns(C => 'urn:ietf:params:xml:ns:caldav');
181         my $NS_C = $Self->ns('C'); # urn:ietf:params:xml:ns:caldav
182
183   function2

AUTHOR

185       Bron Gondwana, "<brong at cpan.org>"
186

BUGS

188       Please report any bugs or feature requests to "bug-net-davtalk at
189       rt.cpan.org", or through the web interface at
190       <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Net-DAVTalk>.  I will
191       be notified, and then you'll automatically be notified of progress on
192       your bug as I make changes.
193

SUPPORT

195       You can find documentation for this module with the perldoc command.
196
197           perldoc Net::DAVTalk
198
199       You can also look for information at:
200
201       •   RT: CPAN's request tracker (report bugs here)
202
203           <http://rt.cpan.org/NoAuth/Bugs.html?Dist=Net-DAVTalk>
204
205       •   AnnoCPAN: Annotated CPAN documentation
206
207           <http://annocpan.org/dist/Net-DAVTalk>
208
209       •   CPAN Ratings
210
211           <http://cpanratings.perl.org/d/Net-DAVTalk>
212
213       •   Search CPAN
214
215           <http://search.cpan.org/dist/Net-DAVTalk/>
216

ACKNOWLEDGEMENTS

219       Copyright 2015 FastMail Pty. Ltd.
220
221       This program is free software; you can redistribute it and/or modify it
222       under the terms of the the Artistic License (2.0). You may obtain a
223       copy of the full license at:
224
225       <http://www.perlfoundation.org/artistic_license_2_0>
226
227       Any use, modification, and distribution of the Standard or Modified
228       Versions is governed by this Artistic License. By using, modifying or
229       distributing the Package, you accept this license. Do not use, modify,
230       or distribute the Package, if you do not accept this license.
231
232       If your Modified Version has been derived from a Modified Version made
233       by someone other than you, you are nevertheless required to ensure that
234       your Modified Version complies with the requirements of this license.
235
236       This license does not grant you the right to use any trademark, service
237       mark, tradename, or logo of the Copyright Holder.
238
239       This license includes the non-exclusive, worldwide, free-of-charge
240       patent license to make, have made, use, offer to sell, sell, import and
241       otherwise transfer the Package with respect to any patent claims
242       licensable by the Copyright Holder that are necessarily infringed by
243       the Package. If you institute patent litigation (including a cross-
244       claim or counterclaim) against any party alleging that the Package
245       constitutes direct or contributory patent infringement, then this
246       Artistic License to you shall terminate on the date that such
247       litigation is filed.
248
249       Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER
250       AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
251       THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
252       PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY
253       YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR
254       CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR
255       CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE,
256       EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
257
258
259
260perl v5.38.0                      2023-07-21                   Net::DAVTalk(3)
Impressum