Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: boto/gs/connection.py

Issue 8386013: Merging in latest boto. (Closed) Base URL: svn://svn.chromium.org/boto
Patch Set: Redoing vendor drop by deleting and then merging. Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « boto/gs/bucket.py ('k') | boto/gs/key.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2010 Google Inc. 1 # Copyright 2010 Google Inc.
2 # 2 #
3 # Permission is hereby granted, free of charge, to any person obtaining a 3 # Permission is hereby granted, free of charge, to any person obtaining a
4 # copy of this software and associated documentation files (the 4 # copy of this software and associated documentation files (the
5 # "Software"), to deal in the Software without restriction, including 5 # "Software"), to deal in the Software without restriction, including
6 # without limitation the rights to use, copy, modify, merge, publish, dis- 6 # without limitation the rights to use, copy, modify, merge, publish, dis-
7 # tribute, sublicense, and/or sell copies of the Software, and to permit 7 # tribute, sublicense, and/or sell copies of the Software, and to permit
8 # persons to whom the Software is furnished to do so, subject to the fol- 8 # persons to whom the Software is furnished to do so, subject to the fol-
9 # lowing conditions: 9 # lowing conditions:
10 # 10 #
11 # The above copyright notice and this permission notice shall be included 11 # The above copyright notice and this permission notice shall be included
12 # in all copies or substantial portions of the Software. 12 # in all copies or substantial portions of the Software.
13 # 13 #
14 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 15 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
16 # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 16 # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
17 # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 17 # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18 # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 19 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 # IN THE SOFTWARE. 20 # IN THE SOFTWARE.
21 21
22 from boto.gs.bucket import Bucket
22 from boto.s3.connection import S3Connection 23 from boto.s3.connection import S3Connection
23 from boto.s3.connection import SubdomainCallingFormat 24 from boto.s3.connection import SubdomainCallingFormat
24 from boto.gs.bucket import Bucket 25 from boto.s3.connection import check_lowercase_bucketname
26
27 class Location:
28 DEFAULT = '' # US
29 EU = 'EU'
25 30
26 class GSConnection(S3Connection): 31 class GSConnection(S3Connection):
27 32
28 DefaultHost = 'commondatastorage.googleapis.com' 33 DefaultHost = 'commondatastorage.googleapis.com'
29 QueryString = 'Signature=%s&Expires=%d&AWSAccessKeyId=%s' 34 QueryString = 'Signature=%s&Expires=%d&AWSAccessKeyId=%s'
30 35
31 def __init__(self, gs_access_key_id=None, gs_secret_access_key=None, 36 def __init__(self, gs_access_key_id=None, gs_secret_access_key=None,
32 is_secure=True, port=None, proxy=None, proxy_port=None, 37 is_secure=True, port=None, proxy=None, proxy_port=None,
33 proxy_user=None, proxy_pass=None, 38 proxy_user=None, proxy_pass=None,
34 host=DefaultHost, debug=0, https_connection_factory=None, 39 host=DefaultHost, debug=0, https_connection_factory=None,
35 calling_format=SubdomainCallingFormat(), path='/'): 40 calling_format=SubdomainCallingFormat(), path='/'):
36 S3Connection.__init__(self, gs_access_key_id, gs_secret_access_key, 41 S3Connection.__init__(self, gs_access_key_id, gs_secret_access_key,
37 is_secure, port, proxy, proxy_port, proxy_user, proxy_pass, 42 is_secure, port, proxy, proxy_port, proxy_user, proxy_pass,
38 host, debug, https_connection_factory, calling_format, path, 43 host, debug, https_connection_factory, calling_format, path,
39 "google", Bucket) 44 "google", Bucket)
45
46 def create_bucket(self, bucket_name, headers=None,
47 location=Location.DEFAULT, policy=None):
48 """
49 Creates a new bucket. By default it's located in the USA. You can
50 pass Location.EU to create an European bucket. You can also pass
51 a LocationConstraint, which (in addition to locating the bucket
52 in the specified location) informs Google that Google services
53 must not copy data out of that location.
54
55 :type bucket_name: string
56 :param bucket_name: The name of the new bucket
57
58 :type headers: dict
59 :param headers: Additional headers to pass along with the request to AWS .
60
61 :type location: :class:`boto.gs.connection.Location`
62 :param location: The location of the new bucket
63
64 :type policy: :class:`boto.s3.acl.CannedACLStrings`
65 :param policy: A canned ACL policy that will be applied to the new key i n S3.
66
67 """
68 check_lowercase_bucketname(bucket_name)
69
70 if policy:
71 if headers:
72 headers[self.provider.acl_header] = policy
73 else:
74 headers = {self.provider.acl_header : policy}
75 if not location:
76 data = ''
77 else:
78 data = ('<CreateBucketConfiguration>'
79 '<LocationConstraint>%s</LocationConstraint>'
80 '</CreateBucketConfiguration>' % location)
81 response = self.make_request('PUT', bucket_name, headers=headers,
82 data=data)
83 body = response.read()
84 if response.status == 409:
85 raise self.provider.storage_create_error(
86 response.status, response.reason, body)
87 if response.status == 200:
88 return self.bucket_class(self, bucket_name)
89 else:
90 raise self.provider.storage_response_error(
91 response.status, response.reason, body)
92
OLDNEW
« no previous file with comments | « boto/gs/bucket.py ('k') | boto/gs/key.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698