NAME
WebService::BitbucketServer::Response - A response object for Bitbucket Server REST APIs
VERSION
version 0.600
SYNOPSIS
# Normal response with blocking user agent:
my $response = $core->get_application_properties;
my $app_info = $response->data;
print "Making API calls to: $app_info->{displayName} $app_info->{version}\n";
# Normal reponse with non-blocking user agent:
my $future = $core->get_application_properties;
$future->on_done(sub {
my $response = shift;
my $app_info = $response->data;
print "Making API calls to: $app_info->{displayName} $app_info->{version}\n";
});
# Paged response with blocking user agent:
my $response = $core->get_projects;
do {
last if $response->error;
for my $project_info (@{ $response->values }) {
print "$project_info->{key}\t$project_info->{name}\n"
}
} while ($response = $response->next);
# Paged response with non-blocking user agent:
my $future;
my $print_projects;
$print_projects = sub {
my $response = shift;
for my $project_info (@{ $response->values }) {
print "$project_info->{key}\t$project_info->{name}\n"
}
$future = $response->next; # get more projects
$future->on_done($print_projects) if $future;
};
$future = $core->get_projects; # get first page of projects
$future->on_done($print_projects);
DESCRIPTION
This module represents a response from a Bitbucket Server API call. It has various convenient accessors and provides a mechanism to handle paging.
ATTRIBUTES
context
A WebService::BitbucketServer object.
request_args
A hashref of the request arguments originally provided to "call" in WebService::BitbucketServer.
raw
The raw response from the server in a hashref structure similar to an HTTP::Tiny response (regardless of which user agent was used to get the response).
decoded_content
Get the decoded response content which may include page info if this is a paged response. Consider using "data", "page_data", etc. before this.
json
Get the JSON (or compatible) object used for encoding and decoding documents.
is_success
Get whether or not the response is a success.
status
Get the HTTP status code.
error
Get the error message or structure if this response represents an error (i.e. "is_success" is false), or undef if this response is not an error.
is_paged
Get whether or not the response is a page of values.
METHODS
new
$response = WebService::BitbucketServer::Response->new(
context => $webservice_bitbucketserver_obj,
request_args => $data,
raw => $response,
);
Create a new response.
data
info
value
values
Get the decoded response content. If this is a paged response (see "is_paged"), this will be an arrayref of values.
page_info
Get a hashref of page info or undef if this is not a paged response.
filter
is_last_page
limit
next_page_start
size
start
next
$next_response = $response->next;
Get the next page of results or undef if no more results. As with "call" in WebService::BitbucketServer, the returned response may be a hashref or a Future.
wrap
$subresponse = $response->wrap($field);
Sometimes the response doesn't include the page information in the root object, typically when the response has an envelope with other non-repeated information. In such cases, "is_paged" is false and "page_info" is undef. You can use this method to easily create a paged response by specifying the field name of the object that contains the page info.
BUGS
Please report any bugs or feature requests on the bugtracker website https://github.com/chazmcgarvey/WebService-BitbucketServer/issues
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.
AUTHOR
Charles McGarvey <ccm@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2017 by Charles McGarvey.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.