File Coverage

blib/lib/AWS/S3/Request/ListBucket.pm
Criterion Covered Total %
statement 18 18 100.0
branch 6 8 75.0
condition n/a
subroutine 4 4 100.0
pod 0 1 0.0
total 28 31 90.3


line stmt bran cond sub pod time code
1              
2             package AWS::S3::Request::ListBucket;
3              
4 1     1   1347 use Moose;
  1         3  
  1         11  
5 1     1   11922 use AWS::S3::Signer;
  1         5  
  1         85  
6 1     1   10 use URI::Escape qw/ uri_escape /;
  1         3  
  1         405  
7              
8             with 'AWS::S3::Roles::Request';
9             with 'AWS::S3::Roles::Bucket';
10              
11             has 'bucket' => (
12             is => 'ro',
13             isa => 'Str',
14             required => 1,
15             );
16              
17             has 'max_keys' => (
18             is => 'ro',
19             isa => 'Int',
20             required => 1,
21             );
22              
23             has 'marker' => (
24             is => 'ro',
25             isa => 'Str',
26             required => 0,
27             );
28              
29             has 'prefix' => (
30             is => 'ro',
31             isa => 'Str',
32             required => 0,
33             );
34              
35             has 'delimiter' => (
36             is => 'ro',
37             isa => 'Str',
38             required => 0,
39             );
40              
41             has '+_expect_nothing' => ( default => 0 );
42              
43             sub request {
44 5     5 0 10 my $s = shift;
45              
46 5         10 my @params = ();
47 5         140 push @params, 'max-keys=' . $s->max_keys;
48 5 100       110 push @params, 'marker=' . uri_escape( $s->marker ) if $s->marker;
49 5 100       215 push @params, 'prefix=' . $s->prefix if $s->prefix;
50 5 50       133 push @params, 'delimiter=' . $s->delimiter if $s->delimiter;
51              
52 5         33 my $uri = $s->bucket_uri;
53              
54 5 50       109 my $signer = AWS::S3::Signer->new(
55             s3 => $s->s3,
56             method => 'GET',
57             uri => $uri . '/' . ( @params ? '?' . join( '&', @params ) : '' ),
58             );
59 5         9934 $s->_send_request(
60             $signer->method => $signer->uri => {
61             Authorization => $signer->auth_header,
62             Date => $signer->date,
63             }
64             );
65             } # end request()
66              
67             __PACKAGE__->meta->make_immutable;