Net/Amazon/S3/Vendor.pm

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