File Coverage

blib/lib/Net/Amazon/S3/Vendor.pm
Criterion Covered Total %
statement 5 5 100.0
branch n/a
condition n/a
subroutine 2 2 100.0
pod 1 1 100.0
total 8 8 100.0


line stmt bran cond sub pod time code
1             $Net::Amazon::S3::Vendor::VERSION = '0.991';
2             use Moose 0.85;
3 99     99   655  
  99         1743  
  99         620  
4             # ABSTRACT: Base class for vendor specific behaviour
5              
6             has host => (
7             is => 'ro',
8             isa => 'Str',
9             required => 1,
10             );
11              
12             has authorization_method => (
13             is => 'ro',
14             isa => 'Str',
15             lazy => 1,
16             default => sub {
17             require Net::Amazon::S3::Signature::V2;
18             'Net::Amazon::S3::Signature::V2',
19             },
20             );
21              
22             has use_https => (
23             is => 'ro',
24             isa => 'Bool',
25             lazy => 1,
26             default => sub { 1 },
27             );
28              
29             has use_virtual_host => (
30             is => 'ro',
31             isa => 'Bool',
32             lazy => 1,
33             default => sub { $_[0]->authorization_method->enforce_use_virtual_host },
34             );
35              
36             has default_region => (
37             is => 'ro',
38             required => 0,
39             default => sub { 'us-east-1' },
40             );
41              
42             has enforce_empty_content_length => (
43             is => 'ro',
44             default => sub { 1 },
45             );
46              
47             my ($self, $bucket) = @_;
48              
49 1     1 1 4 return $self->default_region;
50             }
51 1         40  
52             1;
53              
54              
55             =pod
56              
57             =encoding UTF-8
58              
59             =head1 NAME
60              
61             Net::Amazon::S3::Vendor - Base class for vendor specific behaviour
62              
63             =head1 VERSION
64              
65             version 0.991
66              
67             =head1 SYNOPSIS
68              
69             # use it with Amazon AWS
70             my $s3 = Net::Amazon::S3->new (
71             vendor => Net::Amazon::S3::Vendor::Amazon->new,
72             ...,
73             );
74              
75             # or build your own vendor description
76             my $vendor = Net::Amazon::S3::Vendor::Generic->new (
77             host => 'my.s3.service',
78             use_https => 1,
79             use_virtual_host => 1,
80             authorization_method => 'Net::Amazon::S3::Signature::V2',
81             );
82              
83             # or
84             my $vendor = Net::Amazon::S3::Vendor::Generic->new (
85             host => 'my.s3.service',
86             use_https => 1,
87             use_virtual_host => 1,
88             authorization_method => 'Net::Amazon::S3::Signature::V4',
89             default_region => '...',
90             );
91              
92             # and construct your s3 connection
93             my $s3 = Net::Amazon::S3->new (
94             vendor => $vendor,
95             ...
96             );
97              
98             =head1 DESCRIPTION
99              
100             S3 protocol is used not only by Amazon AWS but by many other object-storage services.
101             They provide same API, but it's just there's a little difference.
102              
103             Examples?
104              
105             Allright, you can upload file but other provider does not support multipart uploads.
106              
107             Or although some providers support Signature V4 they may not support HEAD bucket request
108             to fetch it automatically.
109              
110             =head2 Properties
111              
112             =head3 host
113              
114             Required, where service is located.
115              
116             Available here so one can move its parameters into its own vendor class.
117              
118             =head3 authorization_method
119              
120             Default: L<< Net::Amazon::S3::Signature::V2 >>
121              
122             Signature class used to authorize requests.
123              
124             =head3 use_https
125              
126             Default: true.
127              
128             Whether to use HTTPS or not.
129              
130             =head3 use_virtual_host
131              
132             Default: whatever C<authorization_method> enforces
133              
134             Whether to use path or virtual host access style.
135             Path style uses single host with bucket contained in uri path whereas virtual host style
136             use bucket specific virtual hosts.
137              
138             =head3 default_region
139              
140             Default: undef
141              
142             Value that C<guess_bucket_region> will return.
143              
144             Use when your provider doesn't support HEAD region request but uses Signature V4 authorization
145             method.
146              
147             =head2 Methods
148              
149             =head3 guess_bucket_region ($bucket)
150              
151             Returns bucket's region
152              
153             =head1 AUTHOR
154              
155             Branislav Zahradník <barney@cpan.org>
156              
157             =head1 COPYRIGHT AND LICENSE
158              
159             This software is copyright (c) 2022 by Amazon Digital Services, Leon Brocard, Brad Fitzpatrick, Pedro Figueiredo, Rusty Conover, Branislav Zahradník.
160              
161             This is free software; you can redistribute it and/or modify it under
162             the same terms as the Perl 5 programming language system itself.
163              
164             =cut