|
20 | 20 |
|
21 | 21 | from gcloud import connection as base_connection |
22 | 22 | from gcloud.exceptions import make_exception |
23 | | -from gcloud.storage.bucket import Bucket |
24 | 23 |
|
25 | 24 |
|
26 | 25 | class Connection(base_connection.Connection): |
27 | 26 | """A connection to Google Cloud Storage via the JSON REST API. |
28 | 27 |
|
29 | 28 | This defines :meth:`Connection.api_request` for making a generic JSON |
30 | | - API request and most API requests are created elsewhere (e.g. in |
| 29 | + API request and API requests are created elsewhere (e.g. in |
| 30 | + :mod:`gcloud.storage.api` and |
31 | 31 | :class:`gcloud.storage.bucket.Bucket` and |
32 | 32 | :class:`gcloud.storage.blob.Blob`). |
33 | 33 |
|
34 | 34 | See :class:`gcloud.connection.Connection` for a full list of |
35 | 35 | parameters. This subclass differs only in needing a project |
36 | 36 | name (which you specify when creating a project in the Cloud |
37 | 37 | Console). |
38 | | -
|
39 | | - A typical use of this is to operate on |
40 | | - :class:`gcloud.storage.bucket.Bucket` objects:: |
41 | | -
|
42 | | - >>> from gcloud import storage |
43 | | - >>> connection = storage.get_connection(project) |
44 | | - >>> bucket = connection.create_bucket('my-bucket-name') |
45 | 38 | """ |
46 | 39 |
|
47 | 40 | API_BASE_URL = base_connection.API_BASE_URL |
@@ -245,28 +238,3 @@ def api_request(self, method, path, query_params=None, |
245 | 238 | return json.loads(content) |
246 | 239 |
|
247 | 240 | return content |
248 | | - |
249 | | - def create_bucket(self, bucket_name): |
250 | | - """Create a new bucket. |
251 | | -
|
252 | | - For example:: |
253 | | -
|
254 | | - >>> from gcloud import storage |
255 | | - >>> connection = storage.get_connection(project) |
256 | | - >>> bucket = connection.create_bucket('my-bucket') |
257 | | - >>> print bucket |
258 | | - <Bucket: my-bucket> |
259 | | -
|
260 | | - This implements "storage.buckets.insert". |
261 | | -
|
262 | | - :type bucket_name: string |
263 | | - :param bucket_name: The bucket name to create. |
264 | | -
|
265 | | - :rtype: :class:`gcloud.storage.bucket.Bucket` |
266 | | - :returns: The newly created bucket. |
267 | | - :raises: :class:`gcloud.exceptions.Conflict` if |
268 | | - there is a confict (bucket already exists, invalid name, etc.) |
269 | | - """ |
270 | | - response = self.api_request(method='POST', path='/b', |
271 | | - data={'name': bucket_name}) |
272 | | - return Bucket(properties=response, connection=self) |
0 commit comments