File Coverage

blib/lib/Net/Amazon/S3/Operation/Object/Upload/Complete/Request.pm
Criterion Covered Total %
statement 13 13 100.0
branch 2 2 100.0
condition n/a
subroutine 4 4 100.0
pod 0 1 0.0
total 19 20 95.0


line stmt bran cond sub pod time code
1             package Net::Amazon::S3::Operation::Object::Upload::Complete::Request;
2             # ABSTRACT: An internal class to complete a multipart upload
3             $Net::Amazon::S3::Operation::Object::Upload::Complete::Request::VERSION = '0.98';
4 96     96   892 use Moose 0.85;
  96         2823  
  96         771  
5 96     96   662857 use Carp qw/croak/;
  96         299  
  96         31692  
6              
7             extends 'Net::Amazon::S3::Request::Object';
8              
9             with 'Net::Amazon::S3::Request::Role::HTTP::Method::POST';
10             with 'Net::Amazon::S3::Request::Role::Query::Param::Upload_id';
11             with 'Net::Amazon::S3::Request::Role::XML::Content';
12              
13             has 'etags' => ( is => 'ro', isa => 'ArrayRef', required => 1 );
14             has 'part_numbers' => ( is => 'ro', isa => 'ArrayRef', required => 1 );
15              
16             __PACKAGE__->meta->make_immutable;
17              
18             sub _request_content {
19 2     2   6 my ($self) = @_;
20              
21             return $self->_build_xml (CompleteMultipartUpload => [
22             map +{ Part => [
23             { PartNumber => $self->part_numbers->[$_] },
24             { ETag => $self->etags->[$_] },
25 2         8 ]}, 0 .. (@{$self->part_numbers} - 1)
  2         85  
26             ]);
27             }
28              
29             sub BUILD {
30 3     3 0 11790 my ($self) = @_;
31              
32             croak "must have an equally sized list of etags and part numbers"
33 3 100       7 unless scalar(@{$self->part_numbers}) == scalar(@{$self->etags});
  3         167  
  3         131  
34             }
35              
36             1;
37              
38             __END__
39              
40             =pod
41              
42             =encoding UTF-8
43              
44             =head1 NAME
45              
46             Net::Amazon::S3::Operation::Object::Upload::Complete::Request - An internal class to complete a multipart upload
47              
48             =head1 VERSION
49              
50             version 0.98
51              
52             =head1 SYNOPSIS
53              
54             my $request = Net::Amazon::S3::Operation::Object::Upload::Complete::Request->new (
55             s3 => $s3,
56             bucket => $bucket,
57             etags => \@etags,
58             part_numbers => \@part_numbers,
59             );
60              
61             =head1 DESCRIPTION
62              
63             This module completes a multipart upload.
64              
65             Implements operation L<< CompleteMultipartUpload|https://docs.aws.amazon.com/AmazonS3/latest/API/API_CompleteMultipartUpload.html >>
66              
67             =for test_synopsis no strict 'vars'
68              
69             =head1 METHODS
70              
71             =head2 http_request
72              
73             This method returns a HTTP::Request object.
74              
75             =head1 AUTHOR
76              
77             Branislav Zahradník <barney@cpan.org>
78              
79             =head1 COPYRIGHT AND LICENSE
80              
81             This software is copyright (c) 2021 by Amazon Digital Services, Leon Brocard, Brad Fitzpatrick, Pedro Figueiredo, Rusty Conover, Branislav Zahradník.
82              
83             This is free software; you can redistribute it and/or modify it under
84             the same terms as the Perl 5 programming language system itself.
85              
86             =cut