@@ -46,14 +46,11 @@ def lookup_bucket(bucket_name, connection=None):
4646 :type connection: :class:`gcloud.storage.connection.Connection` or
4747 ``NoneType``
4848 :param connection: Optional. The connection to use when sending requests.
49- If not provided, falls back to default.
49+ If not provided, Bucket() will fall back to default.
5050
5151 :rtype: :class:`gcloud.storage.bucket.Bucket`
5252 :returns: The bucket matching the name provided or None if not found.
5353 """
54- if connection is None :
55- connection = get_default_connection ()
56-
5754 try :
5855 return get_bucket (bucket_name , connection = connection )
5956 except NotFound :
@@ -116,15 +113,11 @@ def get_bucket(bucket_name, connection=None):
116113 :type connection: :class:`gcloud.storage.connection.Connection` or
117114 ``NoneType``
118115 :param connection: Optional. The connection to use when sending requests.
119- If not provided, falls back to default.
116+ If not provided, Bucket() will fall back to default.
120117
121118 :rtype: :class:`gcloud.storage.bucket.Bucket`
122119 :returns: The bucket matching the name provided.
123- :raises: :class:`gcloud.exceptions.NotFound`
124120 """
125- if connection is None :
126- connection = get_default_connection ()
127-
128121 bucket = Bucket (bucket_name , connection = connection )
129122 bucket ._reload_properties ()
130123 return bucket
@@ -143,6 +136,9 @@ def create_bucket(bucket_name, project=None, connection=None):
143136
144137 This implements "storage.buckets.insert".
145138
139+ If the bucket already exists, will raise
140+ :class:`gcloud.exceptions.Conflict`.
141+
146142 :type project: string
147143 :param project: Optional. The project to use when creating bucket.
148144 If not provided, falls back to default.
@@ -153,25 +149,13 @@ def create_bucket(bucket_name, project=None, connection=None):
153149 :type connection: :class:`gcloud.storage.connection.Connection` or
154150 ``NoneType``
155151 :param connection: Optional. The connection to use when sending requests.
156- If not provided, falls back to default.
152+ If not provided, Bucket() will fall back to default.
157153
158154 :rtype: :class:`gcloud.storage.bucket.Bucket`
159155 :returns: The newly created bucket.
160- :raises: :class:`gcloud.exceptions.Conflict` if
161- there is a confict (bucket already exists, invalid name, etc.)
162156 """
163- if connection is None :
164- connection = get_default_connection ()
165- if project is None :
166- project = get_default_project ()
167-
168- query_params = {'project' : project }
169- response = connection .api_request (method = 'POST' , path = '/b' ,
170- query_params = query_params ,
171- data = {'name' : bucket_name })
172- name = response .get ('name' )
173- bucket = Bucket (name , connection = connection )
174- bucket ._properties = response
157+ bucket = Bucket (bucket_name , connection = connection )
158+ bucket .create (project )
175159 return bucket
176160
177161
0 commit comments