2222from gcloud .exceptions import NotFound
2323from gcloud .storage .bucket import Bucket
2424from gcloud .storage .iterator import Iterator
25- import six
2625
2726
2827class Connection (_Base ):
@@ -296,7 +295,7 @@ def get_bucket(self, bucket_name):
296295 :returns: The bucket matching the name provided.
297296 :raises: :class:`gcloud.exceptions.NotFound`
298297 """
299- bucket = self . new_bucket ( bucket_name )
298+ bucket = Bucket ( connection = self , name = bucket_name )
300299 response = self .api_request (method = 'GET' , path = bucket .path )
301300 return Bucket (properties = response , connection = self )
302301
@@ -326,7 +325,7 @@ def lookup(self, bucket_name):
326325 except NotFound :
327326 return None
328327
329- def create_bucket (self , bucket ):
328+ def create_bucket (self , bucket_name ):
330329 """Create a new bucket.
331330
332331 For example::
@@ -337,34 +336,27 @@ def create_bucket(self, bucket):
337336 >>> print bucket
338337 <Bucket: my-bucket>
339338
340- :type bucket : string or :class:`gcloud.storage.bucket.Bucket`
341- :param bucket : The bucket name (or bucket object) to create.
339+ :type bucket_name : string
340+ :param bucket_name : The bucket name to create.
342341
343342 :rtype: :class:`gcloud.storage.bucket.Bucket`
344343 :returns: The newly created bucket.
345344 :raises: :class:`gcloud.exceptions.Conflict` if
346345 there is a confict (bucket already exists, invalid name, etc.)
347346 """
348- bucket = self .new_bucket (bucket )
349347 response = self .api_request (method = 'POST' , path = '/b' ,
350- data = {'name' : bucket . name })
348+ data = {'name' : bucket_name })
351349 return Bucket (properties = response , connection = self )
352350
353- def delete_bucket (self , bucket ):
351+ def delete_bucket (self , bucket_name ):
354352 """Delete a bucket.
355353
356- You can use this method to delete a bucket by name, or to delete
357- a bucket object::
354+ You can use this method to delete a bucket by name.
358355
359356 >>> from gcloud import storage
360357 >>> connection = storage.get_connection(project)
361358 >>> connection.delete_bucket('my-bucket')
362359
363- You can also delete pass in the bucket object::
364-
365- >>> bucket = connection.get_bucket('other-bucket')
366- >>> connection.delete_bucket(bucket)
367-
368360 If the bucket doesn't exist, this will raise a
369361 :class:`gcloud.exceptions.NotFound`::
370362
@@ -383,36 +375,11 @@ def delete_bucket(self, bucket):
383375 >>> except Conflict:
384376 >>> print 'That bucket is not empty!'
385377
386- :type bucket: string or :class:`gcloud.storage.bucket.Bucket`
387- :param bucket: The bucket name (or bucket object) to delete.
388- """
389- bucket = self .new_bucket (bucket )
390- self .api_request (method = 'DELETE' , path = bucket .path )
391-
392- def new_bucket (self , bucket ):
393- """Factory method for creating a new (unsaved) bucket object.
394-
395- This method is really useful when you're not sure whether you
396- have an actual :class:`gcloud.storage.bucket.Bucket` object or
397- just a name of a bucket. It always returns the object::
398-
399- >>> bucket = connection.new_bucket('bucket')
400- >>> print bucket
401- <Bucket: bucket>
402- >>> bucket = connection.new_bucket(bucket)
403- >>> print bucket
404- <Bucket: bucket>
405-
406- :type bucket: string or :class:`gcloud.storage.bucket.Bucket`
407- :param bucket: A name of a bucket or an existing Bucket object.
378+ :type bucket_name: string
379+ :param bucket_name: The bucket name to delete.
408380 """
409- if isinstance (bucket , Bucket ):
410- return bucket
411-
412- if isinstance (bucket , six .string_types ):
413- return Bucket (connection = self , name = bucket )
414-
415- raise TypeError ('Invalid bucket: %s' % bucket )
381+ bucket_path = Bucket .path_helper (bucket_name )
382+ self .api_request (method = 'DELETE' , path = bucket_path )
416383
417384
418385class _BucketIterator (Iterator ):
0 commit comments