本文整理汇总了Python中gcloud.storage.bucket.Bucket.create方法的典型用法代码示例。如果您正苦于以下问题:Python Bucket.create方法的具体用法?Python Bucket.create怎么用?Python Bucket.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gcloud.storage.bucket.Bucket
的用法示例。
在下文中一共展示了Bucket.create方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_bucket
# 需要导入模块: from gcloud.storage.bucket import Bucket [as 别名]
# 或者: from gcloud.storage.bucket.Bucket import create [as 别名]
def create_bucket(bucket_name, project=None, connection=None):
"""Create a new bucket.
For example::
>>> from gcloud import storage
>>> storage.set_defaults()
>>> bucket = storage.create_bucket('my-bucket')
>>> print bucket
<Bucket: my-bucket>
This implements "storage.buckets.insert".
If the bucket already exists, will raise
:class:`gcloud.exceptions.Conflict`.
:type project: string
:param project: Optional. The project to use when creating bucket.
If not provided, falls back to default.
:type bucket_name: string
:param bucket_name: The bucket name to create.
:type connection: :class:`gcloud.storage.connection.Connection` or
``NoneType``
:param connection: Optional. The connection to use when sending requests.
If not provided, falls back to default.
:rtype: :class:`gcloud.storage.bucket.Bucket`
:returns: The newly created bucket.
"""
connection = _require_connection(connection)
bucket = Bucket(bucket_name, connection=connection)
bucket.create(project)
return bucket
示例2: create_bucket
# 需要导入模块: from gcloud.storage.bucket import Bucket [as 别名]
# 或者: from gcloud.storage.bucket.Bucket import create [as 别名]
def create_bucket(self, bucket_name):
"""Create a new bucket.
For example::
>>> bucket = client.create_bucket('my-bucket')
>>> print bucket
<Bucket: my-bucket>
This implements "storage.buckets.insert".
If the bucket already exists, will raise
:class:`gcloud.exceptions.Conflict`.
:type bucket_name: string
:param bucket_name: The bucket name to create.
:rtype: :class:`gcloud.storage.bucket.Bucket`
:returns: The newly created bucket.
"""
bucket = Bucket(self, name=bucket_name)
bucket.create(client=self)
return bucket