Ejemplo n.º 1
0
def get_bucket(bucket_name, connection=None):
    """Get a bucket by name.

    If the bucket isn't found, this will raise a
    :class:`gcloud.storage.exceptions.NotFound`.

    For example::

      >>> from gcloud import storage
      >>> from gcloud.exceptions import NotFound
      >>> try:
      >>>   bucket = storage.get_bucket('my-bucket')
      >>> except NotFound:
      >>>   print 'Sorry, that bucket does not exist!'

    This implements "storage.buckets.get".

    :type bucket_name: string
    :param bucket_name: The name of the bucket to get.

    :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 bucket matching the name provided.
    :raises: :class:`gcloud.exceptions.NotFound`
    """
    connection = _require_connection(connection)
    bucket = Bucket(bucket_name, connection=connection)
    bucket.reload()
    return bucket
Ejemplo n.º 2
0
    def get_bucket(self, bucket_name):
        """Get a bucket by name.

        If the bucket isn't found, this will raise a
        :class:`gcloud.storage.exceptions.NotFound`.

        For example::

          >>> try:
          >>>   bucket = client.get_bucket('my-bucket')
          >>> except gcloud.exceptions.NotFound:
          >>>   print 'Sorry, that bucket does not exist!'

        This implements "storage.buckets.get".

        :type bucket_name: string
        :param bucket_name: The name of the bucket to get.

        :rtype: :class:`gcloud.storage.bucket.Bucket`
        :returns: The bucket matching the name provided.
        :raises: :class:`gcloud.exceptions.NotFound`
        """
        bucket = Bucket(self, name=bucket_name)
        bucket.reload(client=self)
        return bucket
Ejemplo n.º 3
0
    def get_bucket(self, bucket_name):
        """Get a bucket by name.

        If the bucket isn't found, this will raise a
        :class:`gcloud.storage.exceptions.NotFound`.

        For example::

          >>> try:
          >>>   bucket = client.get_bucket('my-bucket')
          >>> except gcloud.exceptions.NotFound:
          >>>   print 'Sorry, that bucket does not exist!'

        This implements "storage.buckets.get".

        :type bucket_name: string
        :param bucket_name: The name of the bucket to get.

        :rtype: :class:`gcloud.storage.bucket.Bucket`
        :returns: The bucket matching the name provided.
        :raises: :class:`gcloud.exceptions.NotFound`
        """
        bucket = Bucket(self, name=bucket_name)
        bucket.reload(client=self)
        return bucket
Ejemplo n.º 4
0
def get_bucket(bucket_name, connection=None):
    """Get a bucket by name.

    If the bucket isn't found, this will raise a
    :class:`gcloud.storage.exceptions.NotFound`.

    For example::

      >>> from gcloud import storage
      >>> from gcloud.exceptions import NotFound
      >>> try:
      >>>   bucket = storage.get_bucket('my-bucket')
      >>> except NotFound:
      >>>   print 'Sorry, that bucket does not exist!'

    This implements "storage.buckets.get".

    :type bucket_name: string
    :param bucket_name: The name of the bucket to get.

    :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 bucket matching the name provided.
    :raises: :class:`gcloud.exceptions.NotFound`
    """
    connection = _require_connection(connection)
    bucket = Bucket(bucket_name, connection=connection)
    bucket.reload(connection=connection)
    return bucket