Footprintless-Plugin-Atlassian-Confluence

 view release on metacpan or  search on metacpan

docs/Footprintless-Plugin-Atlassian-Confluence-Client.html  view on Meta::CPAN

  <li class='indexItem indexItem1'><a href='#NAME'>NAME</a>
  <li class='indexItem indexItem1'><a href='#VERSION'>VERSION</a>
  <li class='indexItem indexItem1'><a href='#SYNOPSIS'>SYNOPSIS</a>
  <li class='indexItem indexItem1'><a href='#DESCRIPTION'>DESCRIPTION</a>
  <li class='indexItem indexItem1'><a href='#CONSTRUCTORS'>CONSTRUCTORS</a>
  <ul   class='indexList indexList2'>
    <li class='indexItem indexItem2'><a href='#new(%25options)'>new(%options)</a>
  </ul>
  <li class='indexItem indexItem1'><a href='#METHODS'>METHODS</a>
  <ul   class='indexList indexList2'>
    <li class='indexItem indexItem2'><a href='#request(%24endpoint%2C_%5C%40args%2C_%25response_options)'>request($endpoint, \@args, %response_options)</a>
    <li class='indexItem indexItem2'><a href='#request_all(%24endpoint%2C_%5C%40args%2C_%25response_options)'>request_all($endpoint, \@args, %response_options)</a>
  </ul>
  <li class='indexItem indexItem1'><a href='#AUTHOR'>AUTHOR</a>
  <li class='indexItem indexItem1'><a href='#COPYRIGHT_AND_LICENSE'>COPYRIGHT AND LICENSE</a>
  <li class='indexItem indexItem1'><a href='#SEE_ALSO'>SEE ALSO</a>
</ul>
</div>

<h1><a class='u' href='#___top' title='click to go to top of document'
name="NAME"
>NAME</a></h1>

docs/Footprintless-Plugin-Atlassian-Confluence-Client.html  view on Meta::CPAN

<p>A module that implements response parsing methods. Defaults to <a href="http://search.cpan.org/perldoc?Fooptrintless%3A%3APlugin%3A%3AAtlassian%3A%3AConfluence%3A%3AResponseParser" class="podlinkpod"
>Fooptrintless::Plugin::Atlassian::Confluence::ResponseParser</a>.</p>
</dd>
</dl>

<h1><a class='u' href='#___top' title='click to go to top of document'
name="METHODS"
>METHODS</a></h1>

<h2><a class='u' href='#___top' title='click to go to top of document'
name="request($endpoint,_\@args,_%response_options)"
>request($endpoint, \@args, %response_options)</a></h2>

<p>Generates a request by calling a method named <code>$endpoint</code> on the request builder, supplying it with <code>@args</code>. The request is sent using the agent, and the response is parsed by calling a method named <code>$endpoint</code> on ...

<h2><a class='u' href='#___top' title='click to go to top of document'
name="request_all($endpoint,_\@args,_%response_options)"
>request_all($endpoint, \@args, %response_options)</a></h2>

<p>Same as <a href="http://search.cpan.org/perldoc?request#request(%24endpoint%2C_%5C%40args%2C_%25response_options)" class="podlinkpod"
>&#34;request($endpoint, \@args, %response_options)&#34; in request</a> except that it will loop through <i>all</i> pages until all results have been returned. This method assumes that the last argument to request builder will be an options hash that...

<h1><a class='u' href='#___top' title='click to go to top of document'
name="AUTHOR"
>AUTHOR</a></h1>

<p>Lucas Theisen &#60;lucastheisen@pastdev.com&#62;</p>

<h1><a class='u' href='#___top' title='click to go to top of document'
name="COPYRIGHT_AND_LICENSE"
>COPYRIGHT AND LICENSE</a></h1>

docs/Footprintless-Plugin-Atlassian-Confluence-RequestBuilder.html  view on Meta::CPAN

>Atlassian Confluence REST API</a>.</p>

<h1><a class='u' href='#___top' title='click to go to top of document'
name="CONSTRUCTORS"
>CONSTRUCTORS</a></h1>

<h2><a class='u' href='#___top' title='click to go to top of document'
name="new($base_url)"
>new($base_url)</a></h2>

<p>Constructs a new request builder with the provided <code>base_url</code>. This url will be used to compose the url for each REST endpoint.</p>

<h1><a class='u' href='#___top' title='click to go to top of document'
name="METHODS"
>METHODS</a></h1>

<h2><a class='u' href='#___top' title='click to go to top of document'
name="create_content($content,_%options)"
>create_content($content, %options)</a></h2>

<p>A request to create a new piece of Content or publish a draft if the content id is present. All <code>%options</code> will be transformed into query parameters.</p>

lib/Footprintless/Plugin/Atlassian/Confluence/Client.pm  view on Meta::CPAN

    $self->{response_parser} = dynamic_module_new(
        (   $options{response_parser_module}
                || 'Footprintless::Plugin::Atlassian::Confluence::ResponseParser'
        )
    );

    return $self;
}

sub request {
    my ( $self, $endpoint, $args, %response_options ) = @_;

    my $response;
    eval {
        $logger->debugf( 'requesting %s', $endpoint );
        my $http_request = $self->{request_builder}->$endpoint( ( $args ? @$args : () ) );
        $http_request->authorization_basic( $self->{username}, $self->{password} );

        if ( $logger->is_trace() ) {
            $logger->trace(
                join( '',
                    "----------------------BEGIN REQUEST--------------------\n",
                    $http_request->dump( maxlength => 500 ),
                    "\n---------------------- END REQUEST --------------------\n" )
            );
        }

lib/Footprintless/Plugin/Atlassian/Confluence/Client.pm  view on Meta::CPAN


        if ( $logger->is_trace() ) {
            $logger->trace(
                join( '',
                    "----------------------BEGIN RESPONSE--------------------\n",
                    $http_response->dump( maxlength => 500 ),
                    "\n---------------------- END RESPONSE --------------------\n" )
            );
        }

        $response = $self->{response_parser}->$endpoint( $http_response, %response_options );
    };
    if ($@) {
        if ( ref($@) eq 'HASH' && $@->{code} ) {
            $response = $@;
        }
        else {
            $response = {
                code    => 500,
                content => {},
                message => $@,
                success => 0,
            };
        }
    }
    return $response;
}

sub request_all {
    my ( $self, $endpoint, $args, @response_options ) = @_;

    my $response = $self->request(
        $endpoint,
        [   @$args,
            limit => 100,
            start => 0
        ],
        @response_options
    );

    my $next = $response;
    while ( $next->{success} && $next->{content}{_links}{next} ) {
        my $limit = $response->{content}{limit};
        $next = $self->request(
            $endpoint,
            [   @$args,
                limit => $limit,
                start => $next->{content}{start} + $limit,
            ],
            @response_options
        );
        push( @{ $response->{content}{results} }, @{ $next->{content}{results} } );
    }

    delete( $response->{content}{_links}{next} );

lib/Footprintless/Plugin/Atlassian/Confluence/Client.pm  view on Meta::CPAN


=item response_parser_module

A module that implements response parsing methods.  Defaults to
L<Fooptrintless::Plugin::Atlassian::Confluence::ResponseParser>.

=back

=head1 METHODS

=head2 request($endpoint, \@args, %response_options)

Generates a request by calling a method named C<$endpoint> on the request
builder, supplying it with C<@args>.  The request is sent using the agent,
and the response is parsed by calling a method named C<$endpoint> on the
response parser, supplying it with C<%response_options>.

=head2 request_all($endpoint, \@args, %response_options)

Same as L<request/request($endpoint, \@args, %response_options)> except
that it will loop through I<all> pages until all results have been 
returned.  This method assumes that the last argument to request builder
will be an options hash that will be used as query parameters.

=head1 AUTHOR

Lucas Theisen <lucastheisen@pastdev.com>

=head1 COPYRIGHT AND LICENSE

lib/Footprintless/Plugin/Atlassian/Confluence/RequestBuilder.pm  view on Meta::CPAN


This is the default implementation of a request builder.  It provides a simple
perl interface to the 
L<Atlassian Confluence REST API|https://docs.atlassian.com/atlassian-confluence/REST/latest-server/>.

=head1 CONSTRUCTORS

=head2 new($base_url)

Constructs a new request builder with the provided C<base_url>.  This url
will be used to compose the url for each REST endpoint.

=head1 METHODS

=head2 create_content($content, %options)

A request to create a new piece of Content or publish a draft if the content 
id is present.  All C<%options> will be transformed into query parameters.

=head2 delete_content($id)



( run in 1.140 second using v1.01-cache-2.11-cpan-2b1a40005be )