Mercurial > repos > guerler > springsuite
comparison planemo/lib/python3.7/site-packages/boto/s3/__init__.py @ 0:d30785e31577 draft
"planemo upload commit 6eee67778febed82ddd413c3ca40b3183a3898f1"
author | guerler |
---|---|
date | Fri, 31 Jul 2020 00:18:57 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:d30785e31577 |
---|---|
1 # Copyright (c) 2006-2012 Mitch Garnaat http://garnaat.org/ | |
2 # Copyright (c) 2010, Eucalyptus Systems, Inc. | |
3 # Copyright (c) 2014, Steven Richards <sbrichards@mit.edu> | |
4 # All rights reserved. | |
5 # | |
6 # Permission is hereby granted, free of charge, to any person obtaining a | |
7 # copy of this software and associated documentation files (the | |
8 # "Software"), to deal in the Software without restriction, including | |
9 # without limitation the rights to use, copy, modify, merge, publish, dis- | |
10 # tribute, sublicense, and/or sell copies of the Software, and to permit | |
11 # persons to whom the Software is furnished to do so, subject to the fol- | |
12 # lowing conditions: | |
13 # | |
14 # The above copyright notice and this permission notice shall be included | |
15 # in all copies or substantial portions of the Software. | |
16 # | |
17 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | |
18 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- | |
19 # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT | |
20 # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | |
21 # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
22 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | |
23 # IN THE SOFTWARE. | |
24 # | |
25 | |
26 from boto.regioninfo import RegionInfo, get_regions | |
27 from boto.regioninfo import connect | |
28 | |
29 | |
30 class S3RegionInfo(RegionInfo): | |
31 | |
32 def connect(self, **kw_params): | |
33 """ | |
34 Connect to this Region's endpoint. Returns an connection | |
35 object pointing to the endpoint associated with this region. | |
36 You may pass any of the arguments accepted by the connection | |
37 class's constructor as keyword arguments and they will be | |
38 passed along to the connection object. | |
39 | |
40 :rtype: Connection object | |
41 :return: The connection to this regions endpoint | |
42 """ | |
43 if self.connection_cls: | |
44 return self.connection_cls(host=self.endpoint, **kw_params) | |
45 | |
46 | |
47 def regions(): | |
48 """ | |
49 Get all available regions for the Amazon S3 service. | |
50 | |
51 :rtype: list | |
52 :return: A list of :class:`boto.regioninfo.RegionInfo` | |
53 """ | |
54 from boto.s3.connection import S3Connection | |
55 return get_regions( | |
56 's3', | |
57 region_cls=S3RegionInfo, | |
58 connection_cls=S3Connection | |
59 ) | |
60 | |
61 | |
62 def connect_to_region(region_name, **kw_params): | |
63 from boto.s3.connection import S3Connection | |
64 if 'host' in kw_params: | |
65 host = kw_params.pop('host') | |
66 if host not in ['', None]: | |
67 region = S3RegionInfo( | |
68 name='custom', | |
69 endpoint=host, | |
70 connection_cls=S3Connection | |
71 ) | |
72 return region.connect(**kw_params) | |
73 | |
74 return connect('s3', region_name, region_cls=S3RegionInfo, | |
75 connection_cls=S3Connection, **kw_params) |