Provided by: libatompub-perl_0.3.7-2_all bug

NAME

       Atompub::Client - A client for the Atom Publishing Protocol

SYNOPSIS

           use Atompub::Client;

           my $client = Atompub::Client->new;
           $client->username('Melody');
           $client->password('Nelson');
           #$client->proxy( $proxy_uri );

           # Get a Service Document
           my $service = $client->getService($service_uri);

           my @workspaces = $service->workspaces;
           my @collections = $workspaces[0]->collections;

           # CRUD an Entry Resource; assuming that the 0-th collection supports
           # Entry Resources
           my $collection_uri = $collections[0]->href;

           my $name = 'New Post';

           my $entry = XML::Atom::Entry->new;
           $entry->title($name);
           $entry->content('Content of my post.');

           my $edit_uri = $client->createEntry($collection_uri, $entry, $name);

           my $feed = $client->getFeed($collection_uri);
           my @entries = $feed->entries;

           $entry = $client->getEntry($edit_uri);

           $client->updateEntry($edit_uri, $entry);

           $client->deleteEntry($edit_uri);

           # CRUD a Media Resource; assuming that the 1-st collection supports
           # Media Resources
           my $collection_uri = $collections[1]->href;

           my $name = 'My Photo';

           my $edit_uri = $client->createMedia($collection_uri, 'sample1.png',
                                               'image/png', $name);

           # Get a href attribute of an "edit-media" link
           my $edit_media_uri = $client->resource->edit_media_link;

           my $binary = $client->getMedia($edit_media_uri);

           $client->updateMedia($edit_media_uri, 'sample2.png', 'image/png');

           $client->deleteEntry($edit_media_uri);

           # Access to the requested HTTP::Request object
           my $request  = $client->request;

           # Access to the received HTTP::Response object
           my $response = $client->response;

           # Access to the received resource (XML::Atom object or binary data)
           my $resource = $client->resource;

DESCRIPTION

       Atompub::Client implements a client for the Atom Publishing Protocol described at
       <http://www.ietf.org/rfc/rfc5023.txt>.

       The client supports the following features:

       ·   Authentication

           Atompub::Client supports the Basic and WSSE Authentication described in
           <http://www.intertwingly.net/wiki/pie/DifferentlyAbledClients>.

       ·   Service Document

           Atompub::Client understands Service Documents, in which information of collections are
           described, such as URIs, acceptable media types, and allowable categories.

       ·   Media Resource support

           Media Resources (binary data) as well as Entry Resources are supported.  You can
           create and edit Media Resources such as image and video by using Atompub::Client.

       ·   Media type check

           Atompub::Client checks media types of resources before creating and editing them to
           the collection.  Acceptable media types are shown in app:accept elements in the
           Service Document.

       ·   Category check

           Atompub::Client checks categories in Entry Resources before creating and editing them
           to the collection.  Allowable categories are shown in app:categories elements in the
           Service Document.

       ·   Cache controll and versioning

           On-memory cache and versioning, which are controlled by ETag and Last-Modified header,
           are implemented in Atompub::Client.

       ·   Naming resources by Slug header

           The client can specify Slug header when creating a resource, which may be used as part
           of the resource URI.

METHODS

   Atompub::Client->new([ %options ])
       Creates a new Atompub client object.  The options are same as LWP::UserAgent.

   $client->getService($service_uri)
       Retrieves a Service Document at URI $service_uri.

       Returns an XML::Atom::Service object on success, false otherwise.

   $client->getCategories($category_uri)
       Retrieves a Category Document at URI $category_uri.

       Returns an XML::Atom::Categories object on success, false otherwise.

   $client->getFeed($collection_uri)
       Retrieves a Feed Document from the collection at URI $collection_uri.

       Returns an XML::Atom::Feed object, false otherwise.

   $client->createEntry($collection_uri, $entry, [ $slug ])
       Creates a new entry in the collection at URI $collection_uri.

       $entry must be an XML::Atom::Entry object.

       If $slug is provided, it is set in Slug header and may be used as part of the resource
       URI.

       Returns a Location header, which contains a URI of the newly created resource, or false on
       error.

   $client->createMedia($collection_uri, $media, $media_type, [ $slug ])
       Creates a new Media Resource and a Media Link Entry in the collection at URI
       $collection_uri.

       If $media is a reference to a scalar, it is treated as the binary.  If a scalar, treated
       as a file containing the Media Resource.

       $media_type is the media type of the Media Resource, such as 'image/png'.

       $slug is set in the Slug header, and may be used as part of the resource URI.

       Returns a Location header, which contains a URI of the newly created resource, or false on
       error.

   $client->getEntry($edit_uri)
       Retrieves an Entry Document with the given URI $edit_uri.

       Returns an XML::Atom::Entry object on success, false otherwise.  If the server returns 304
       (Not Modified), returns a cache of the Media Resource.

   $client->getMedia($edit_uri)
       Retrieves a Media Resource with the given URI $edit_uri.

       Returns binary data of the Media Resource on success, false otherwise.  If the server
       returns 304 (Not Modified), returns a cache of the Media Resource.

   $client->updateEntry($edit_uri, $entry)
       Updates the Entry Document at URI $edit_uri with the new Entry Document $entry, which must
       be an XML::Atom::Entry object.

       Returns true on success, false otherwise.

   $client->updateMedia($edit_uri, $media, $media_type)
       Updates the Media Resource at URI $edit_uri with the $media.

       If $media is a reference to a scalar, it is treated as the binary.  If a scalar, treated
       as a file containing the Media Resource.

       $media_type is the media type of the Media Resource, such as 'image/png'.

       Returns true on success, false otherwise.

   $client->deleteEntry($edit_uri)
       Deletes the Entry Document at URI $edit_uri.

       Returns true on success, false otherwise.

   $client->deleteMedia($edit_uri)
       Deletes the Media Resource at URI $edit_uri and related Media Link Entry.

       Returns true on success, false otherwise.

Accessors

   $client->username([ $username ])
       If called with an argument, sets the username for login to $username.

       Returns the current username that will be used when logging in to the Atompub server.

   $client->password([ $password ])
       If called with an argument, sets the password for login to $password.

       Returns the current password that will be used when logging in to the Atompub server.

   $client->proxy([ $proxy_uri ])
       If called with an argument, sets URI of proxy server like 'http://proxy.example.com:8080'.

       Returns the current URI of the proxy server.

   $client->resource
   $client->rc
       An accessor for Entry or Media Resource, which was retrieved in the previous action.

   $client->request
   $client->req
       An accessor for an HTTP::Request object, which was used in the previous action.

   $client->response
   $client->res
       An accessor for an HTTP::Response object, which was used in the previous action.

INTERNAL INTERFACES

   $client->init
   $client->ua
       Accessor to the UserAgent.

   $client->info
       An accessor to information of Collections described in a Service Document.

   $client->cache
       An accessor to the resource cache.

   $client->munge_request($req)
   $client->_clear
   $client->_get_service(\%args)
   $client->_get_categories(\%args)
   $client->_get_feed(\%args)
   $client->_create_resource(\%args)
   $client->_get_resource(\%args)
   $client->_update_resource(\%args)
   $client->_delete_resource(\%args)

ERROR HANDLING

       Methods return "undef" on error, and the error message can be retrieved using the errstr
       method.

SEE ALSO

       XML::Atom XML::Atom::Service Atompub

AUTHOR

       Takeru INOUE, <takeru.inoue _ gmail.com>

LICENCE AND COPYRIGHT

       Copyright (c) 2007, Takeru INOUE "<takeru.inoue _ gmail.com>". All rights reserved.

       This module is free software; you can redistribute it and/or modify it under the same
       terms as Perl itself. See perlartistic.

DISCLAIMER OF WARRANTY

       BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE,
       TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE
       COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF
       ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
       WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO
       THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE
       DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.

       IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT
       HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY
       THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL,
       INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
       SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR
       LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY
       OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
       SUCH DAMAGES.