From 2323c881fd276e280ed99a8e24a68b85129788bd Mon Sep 17 00:00:00 2001 From: Danny Hermes Date: Thu, 12 Feb 2015 14:19:07 -0800 Subject: [PATCH] Updating "master" docs with a clean build. This removes some old cruft that never got deleted (e.g. for obsoleted classes) and also adds the "version" marker for the commit hash instead of for the PyPI version. --- master/.buildinfo | 4 + master/_modules/gcloud/connection.html | 8 +- master/_modules/gcloud/credentials.html | 8 +- .../_modules/gcloud/datastore/__init__.html | 8 +- master/_modules/gcloud/datastore/api.html | 8 +- master/_modules/gcloud/datastore/batch.html | 8 +- .../_modules/gcloud/datastore/connection.html | 8 +- master/_modules/gcloud/datastore/dataset.html | 198 ---- master/_modules/gcloud/datastore/entity.html | 8 +- master/_modules/gcloud/datastore/helpers.html | 8 +- master/_modules/gcloud/datastore/key.html | 8 +- master/_modules/gcloud/datastore/query.html | 8 +- .../gcloud/datastore/transaction.html | 8 +- master/_modules/gcloud/exceptions.html | 8 +- master/_modules/gcloud/storage/__init__.html | 8 +- master/_modules/gcloud/storage/acl.html | 8 +- master/_modules/gcloud/storage/blob.html | 8 +- master/_modules/gcloud/storage/bucket.html | 8 +- .../_modules/gcloud/storage/connection.html | 8 +- .../_modules/gcloud/storage/exceptions.html | 321 ------ master/_modules/gcloud/storage/iterator.html | 8 +- master/_modules/gcloud/storage/key.html | 780 -------------- master/_modules/index.html | 8 +- master/_sources/datastore-dataset.txt | 7 - master/_sources/storage-keys.txt | 7 - master/datastore-api.html | 8 +- master/datastore-batches.html | 8 +- master/datastore-dataset.html | 203 ---- master/datastore-entities.html | 8 +- master/datastore-keys.html | 8 +- master/datastore-queries.html | 10 +- master/datastore-transactions.html | 8 +- master/gcloud-api.html | 8 +- master/genindex.html | 8 +- master/index.html | 8 +- master/objects.inv | Bin 2708 -> 2711 bytes master/py-modindex.html | 8 +- master/search.html | 8 +- master/searchindex.js | 2 +- master/storage-acl.html | 8 +- master/storage-api.html | 8 +- master/storage-blobs.html | 10 +- master/storage-buckets.html | 10 +- master/storage-keys.html | 956 ------------------ 44 files changed, 144 insertions(+), 2612 deletions(-) create mode 100644 master/.buildinfo delete mode 100644 master/_modules/gcloud/datastore/dataset.html delete mode 100644 master/_modules/gcloud/storage/exceptions.html delete mode 100644 master/_modules/gcloud/storage/key.html delete mode 100644 master/_sources/datastore-dataset.txt delete mode 100644 master/_sources/storage-keys.txt delete mode 100644 master/datastore-dataset.html delete mode 100644 master/storage-keys.html diff --git a/master/.buildinfo b/master/.buildinfo new file mode 100644 index 000000000000..cc5bbad21ae2 --- /dev/null +++ b/master/.buildinfo @@ -0,0 +1,4 @@ +# Sphinx build info version 1 +# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. +config: beaf141fe69e3afcb871eb5d0861f893 +tags: 645f666f9bcd5a90fca523b33c5a78b7 diff --git a/master/_modules/gcloud/connection.html b/master/_modules/gcloud/connection.html index 2a0d31007407..248390b478f4 100644 --- a/master/_modules/gcloud/connection.html +++ b/master/_modules/gcloud/connection.html @@ -5,7 +5,7 @@ - gcloud.connection — gcloud 0.4.0 documentation + gcloud.connection — gcloud 32e50eb documentation @@ -15,7 +15,7 @@ - + @@ -60,7 +60,7 @@

Python

- 0.4.0 + 32e50eb - - -
- -
-

Python

- -
- 0.3.0 - -
- -
- -

Source code for gcloud.datastore.dataset

-# Copyright 2014 Google Inc. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-"""Create / interact with gcloud datastore datasets."""
-
-
-
[docs]class Dataset(object): - """A dataset in the Cloud Datastore. - - This class acts as an abstraction of a single dataset in the Cloud - Datastore. - - A dataset is analogous to a database in relational database world, - and corresponds to a single project using the Cloud Datastore. - - Typically, you would only have one of these per connection however - it didn't seem right to collapse the functionality of a connection - and a dataset together into a single class. - - Datasets (like :class:`gcloud.datastore.query.Query`) are immutable. - That is, you cannot change the ID and connection references. If you - need to modify the connection or ID, it's recommended to construct a - new :class:`Dataset`. - - :type id: string - :param id: The ID of the dataset (your project ID) - - :type connection: :class:`gcloud.datastore.connection.Connection` - :param connection: The connection to use for executing API calls. - """ - - def __init__(self, id, connection=None): - self._connection = connection - self._id = id - -
[docs] def connection(self): - """Get the current connection. - - >>> dataset = Dataset('dataset-id', connection=conn) - >>> dataset.connection() - <Connection object> - - :rtype: :class:`gcloud.datastore.connection.Connection` - :returns: Returns the current connection. - """ - - return self._connection -
-
[docs] def id(self): - """Get the current dataset ID. - - >>> dataset = Dataset('dataset-id', connection=conn) - >>> dataset.id() - 'dataset-id' - - :rtype: string - :returns: The current dataset ID. - """ - - return self._id
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/master/_modules/gcloud/datastore/entity.html b/master/_modules/gcloud/datastore/entity.html index 95b8423993d0..1d3ad994e30f 100644 --- a/master/_modules/gcloud/datastore/entity.html +++ b/master/_modules/gcloud/datastore/entity.html @@ -5,7 +5,7 @@ - gcloud.datastore.entity — gcloud 0.4.0 documentation + gcloud.datastore.entity — gcloud 32e50eb documentation @@ -15,7 +15,7 @@ - + @@ -60,7 +60,7 @@

Python

- 0.4.0 + 32e50eb - - -
- -
-

Python

- -
- 0.3.0 - -
-
- -
- -

Source code for gcloud.storage.exceptions

-# Copyright 2014 Google Inc. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-"""Custom exceptions for gcloud.storage package.
-
-See: https://cloud.google.com/storage/docs/json_api/v1/status-codes
-"""
-
-import json
-
-_HTTP_CODE_TO_EXCEPTION = {}  # populated at end of module
-
-
-
[docs]class StorageError(Exception): - """Base error class for gcloud errors (abstract). - - Each subclass represents a single type of HTTP error response. - """ - code = None - """HTTP status code. Concrete subclasses *must* define. - - See: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html - """ - - def __init__(self, message, errors=()): - super(StorageError, self).__init__() - # suppress deprecation warning under 2.6.x - self.message = message - self._errors = [error.copy() for error in errors] - - def __str__(self): - return '%d %s' % (self.code, self.message) - - @property -
[docs] def errors(self): - """Detailed error information. - - :rtype: list(dict) - :returns: a list of mappings describing each error. - """ - return [error.copy() for error in self._errors] - -
-
[docs]class Redirection(StorageError): - """Base for 3xx responses - - This class is abstract. - """ - -
-
[docs]class MovedPermanently(Redirection): - """Exception mapping a '301 Moved Permanently' response.""" - code = 301 - -
-
[docs]class NotModified(Redirection): - """Exception mapping a '304 Not Modified' response.""" - code = 304 - -
-
[docs]class TemporaryRedirect(Redirection): - """Exception mapping a '307 Temporary Redirect' response.""" - code = 307 - -
-
[docs]class ResumeIncomplete(Redirection): - """Exception mapping a '308 Resume Incomplete' response.""" - code = 308 - -
-
[docs]class ClientError(StorageError): - """Base for 4xx responses - - This class is abstract - """ - -
-
[docs]class BadRequest(ClientError): - """Exception mapping a '400 Bad Request' response.""" - code = 400 - -
-
[docs]class Unauthorized(ClientError): - """Exception mapping a '401 Unauthorized' response.""" - code = 400 - -
-
[docs]class Forbidden(ClientError): - """Exception mapping a '403 Forbidden' response.""" - code = 400 - -
-
[docs]class NotFound(ClientError): - """Exception mapping a '404 Not Found' response.""" - code = 404 - -
-
[docs]class MethodNotAllowed(ClientError): - """Exception mapping a '405 Method Not Allowed' response.""" - code = 405 - -
-
[docs]class Conflict(ClientError): - """Exception mapping a '409 Conflict' response.""" - code = 409 - -
-
[docs]class LengthRequired(ClientError): - """Exception mapping a '411 Length Required' response.""" - code = 411 - -
-
[docs]class PreconditionFailed(ClientError): - """Exception mapping a '412 Precondition Failed' response.""" - code = 412 - -
-
[docs]class RequestRangeNotSatisfiable(ClientError): - """Exception mapping a '416 Request Range Not Satisfiable' response.""" - code = 416 - -
-
[docs]class TooManyRequests(ClientError): - """Exception mapping a '429 Too Many Requests' response.""" - code = 429 - -
-
[docs]class ServerError(StorageError): - """Base for 5xx responses: (abstract)""" - -
-
[docs]class InternalServerError(ServerError): - """Exception mapping a '500 Internal Server Error' response.""" - code = 500 - -
-
[docs]class NotImplemented(ServerError): - """Exception mapping a '501 Not Implemented' response.""" - code = 501 - -
-
[docs]class ServiceUnavailable(ServerError): - """Exception mapping a '503 Service Unavailable' response.""" - code = 503 - -
-
[docs]def make_exception(response, content): - """Factory: create exception based on HTTP response code. - - :rtype: instance of :class:`StorageError`, or a concrete subclass. - """ - - if isinstance(content, str): - content = json.loads(content) - - message = content.get('message') - error = content.get('error', {}) - errors = error.get('errors', ()) - - try: - klass = _HTTP_CODE_TO_EXCEPTION[response.status] - except KeyError: - error = StorageError(message, errors) - error.code = response.status - else: - error = klass(message, errors) - return error - -
-def _walk_subclasses(klass): - """Recursively walk subclass tree.""" - for sub in klass.__subclasses__(): - yield sub - for subsub in _walk_subclasses(sub): - yield subsub - - -# Build the code->exception class mapping. -for eklass in _walk_subclasses(StorageError): - code = getattr(eklass, 'code', None) - if code is not None: - _HTTP_CODE_TO_EXCEPTION[code] = eklass -
- -
- -
- - - - - - - \ No newline at end of file diff --git a/master/_modules/gcloud/storage/iterator.html b/master/_modules/gcloud/storage/iterator.html index 7e5b0995e3b7..393ad5a2c87f 100644 --- a/master/_modules/gcloud/storage/iterator.html +++ b/master/_modules/gcloud/storage/iterator.html @@ -5,7 +5,7 @@ - gcloud.storage.iterator — gcloud 0.4.0 documentation + gcloud.storage.iterator — gcloud 32e50eb documentation @@ -15,7 +15,7 @@ - + @@ -60,7 +60,7 @@

Python

- 0.4.0 + 32e50eb - - -
- -
-

Python

- -
- 0.3.0 - -
-
- -
- -

Source code for gcloud.storage.key

-# Copyright 2014 Google Inc. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-"""Create / interact with gcloud storage keys."""
-
-import copy
-import mimetypes
-import os
-import time
-import datetime
-from StringIO import StringIO
-import urllib
-
-from _gcloud_vendor.apitools.base.py import http_wrapper
-from _gcloud_vendor.apitools.base.py import transfer
-
-from gcloud.storage._helpers import _PropertyMixin
-from gcloud.storage._helpers import _scalar_property
-from gcloud.storage.acl import ObjectACL
-
-
-
[docs]class Key(_PropertyMixin): - """A wrapper around Cloud Storage's concept of an ``Object``.""" - - CUSTOM_PROPERTY_ACCESSORS = { - 'acl': 'acl', - 'cacheControl': 'cache_control', - 'contentDisposition': 'content_disposition', - 'contentEncoding': 'content_encoding', - 'contentLanguage': 'content_language', - 'contentType': 'content_type', - 'componentCount': 'component_count', - 'etag': 'etag', - 'generation': 'generation', - 'id': 'id', - 'mediaLink': 'media_link', - 'metageneration': 'metageneration', - 'name': 'name', - 'owner': 'owner', - 'selfLink': 'self_link', - 'size': 'size', - 'storageClass': 'storage_class', - 'timeDeleted': 'time_deleted', - 'updated': 'updated', - } - """Map field name -> accessor for fields w/ custom accessors.""" - - CHUNK_SIZE = 1024 * 1024 # 1 MB. - """The size of a chunk of data whenever iterating (1 MB). - - This must be a multiple of 256 KB per the API specification. - """ - # ACL rules are lazily retrieved. - _acl = None - - def __init__(self, bucket=None, name=None, properties=None): - """Key constructor. - - :type bucket: :class:`gcloud.storage.bucket.Bucket` - :param bucket: The bucket to which this key belongs. - - :type name: string - :param name: The name of the key. This corresponds to the - unique path of the object in the bucket. - - :type properties: dict - :param properties: All the other data provided by Cloud Storage. - """ - super(Key, self).__init__(name=name, properties=properties) - self.bucket = bucket - - @property -
[docs] def acl(self): - """Create our ACL on demand.""" - if self._acl is None: - self._acl = ObjectACL(self) - return self._acl -
- @classmethod -
[docs] def from_dict(cls, key_dict, bucket=None): - """Instantiate a :class:`Key` from data returned by the JSON API. - - :type key_dict: dict - :param key_dict: A dictionary of data returned from getting an - Cloud Storage object. - - :type bucket: :class:`gcloud.storage.bucket.Bucket` - :param bucket: The bucket to which this key belongs (and by - proxy, which connection to use). - - :rtype: :class:`Key` - :returns: A key based on the data provided. - """ - - return cls(bucket=bucket, name=key_dict['name'], properties=key_dict) -
- def __repr__(self): - if self.bucket: - bucket_name = self.bucket.name - else: - bucket_name = None - - return '<Key: %s, %s>' % (bucket_name, self.name) - - @property -
[docs] def connection(self): - """Getter property for the connection to use with this Key. - - :rtype: :class:`gcloud.storage.connection.Connection` or None - :returns: The connection to use, or None if no connection is set. - """ - if self.bucket and self.bucket.connection: - return self.bucket.connection -
- @property -
[docs] def path(self): - """Getter property for the URL path to this Key. - - :rtype: string - :returns: The URL path to this Key. - """ - if not self.bucket: - raise ValueError('Cannot determine path without a bucket defined.') - elif not self.name: - raise ValueError('Cannot determine path without a key name.') - - return self.bucket.path + '/o/' + urllib.quote(self.name, safe='') -
- @property -
[docs] def public_url(self): - """The public URL for this key's object. - - :rtype: `string` - :returns: The public URL for this key. - """ - return '{storage_base_url}/{bucket_name}/{quoted_name}'.format( - storage_base_url='http://commondatastorage.googleapis.com', - bucket_name=self.bucket.name, - quoted_name=urllib.quote(self.name, safe='')) -
-
[docs] def generate_signed_url(self, expiration, method='GET'): - """Generates a signed URL for this key. - - If you have a key that you want to allow access to for a set - amount of time, you can use this method to generate a URL that - is only valid within a certain time period. - - This is particularly useful if you don't want publicly - accessible keys, but don't want to require users to explicitly - log in. - - :type expiration: int, long, datetime.datetime, datetime.timedelta - :param expiration: When the signed URL should expire. - - :type method: string - :param method: The HTTP verb that will be used when requesting the URL. - - :rtype: string - :returns: A signed URL you can use to access the resource - until expiration. - """ - resource = '/{bucket_name}/{quoted_name}'.format( - bucket_name=self.bucket.name, - quoted_name=urllib.quote(self.name, safe='')) - return self.connection.generate_signed_url(resource=resource, - expiration=expiration, - method=method) -
-
[docs] def exists(self): - """Determines whether or not this key exists. - - :rtype: boolean - :returns: True if the key exists in Cloud Storage. - """ - return self.bucket.get_key(self.name) is not None -
-
[docs] def rename(self, new_name): - """Renames this key using copy and delete operations. - - Effectively, copies key to the same bucket with a new name, then - deletes the key. - - .. warning:: - This method will first duplicate the data and then delete the - old key. This means that with very large objects renaming - could be a very (temporarily) costly or a very slow operation. - - :type new_name: string - :param new_name: The new name for this key. - - :rtype: :class:`Key` - :returns: The newly-copied key. - """ - new_key = self.bucket.copy_key(self, self.bucket, new_name) - self.bucket.delete_key(self) - return new_key -
-
[docs] def delete(self): - """Deletes a key from Cloud Storage. - - :rtype: :class:`Key` - :returns: The key that was just deleted. - :raises: :class:`gcloud.storage.exceptions.NotFound` - (propagated from - :meth:`gcloud.storage.bucket.Bucket.delete_key`). - """ - return self.bucket.delete_key(self) -
-
[docs] def download_to_file(self, file_obj): - """Download the contents of this key into a file-like object. - - :type file_obj: file - :param file_obj: A file handle to which to write the key's data. - - :raises: :class:`gcloud.storage.exceptions.NotFound` - """ - - download_url = self.media_link - - # Use apitools 'Download' facility. - download = transfer.Download.FromStream(file_obj, auto_transfer=False) - download.chunksize = self.CHUNK_SIZE - headers = {'Range': 'bytes=0-%d' % (self.CHUNK_SIZE - 1)} - request = http_wrapper.Request(download_url, 'GET', headers) - - download.InitializeDownload(request, self.connection.http) - - # Should we be passing callbacks through from caller? We can't - # pass them as None, because apitools wants to print to the console - # by default. - download.StreamInChunks(callback=lambda *args: None, - finish_callback=lambda *args: None) - - # NOTE: Alias for boto-like API.
- get_contents_to_file = download_to_file - -
[docs] def download_to_filename(self, filename): - """Download the contents of this key into a named file. - - :type filename: string - :param filename: A filename to be passed to ``open``. - - :raises: :class:`gcloud.storage.exceptions.NotFound` - """ - with open(filename, 'wb') as file_obj: - self.download_to_file(file_obj) - - mtime = time.mktime( - datetime.datetime.strptime( - self.properties['updated'], - '%Y-%m-%dT%H:%M:%S.%fz').timetuple() - ) - os.utime(file_obj.name, (mtime, mtime)) - - # NOTE: Alias for boto-like API.
- get_contents_to_filename = download_to_filename - -
[docs] def download_as_string(self): - """Download the contents of this key as a string. - - :rtype: string - :returns: The data stored in this key. - :raises: :class:`gcloud.storage.exceptions.NotFound` - """ - string_buffer = StringIO() - self.download_to_file(string_buffer) - return string_buffer.getvalue() - - # NOTE: Alias for boto-like API.
- get_contents_as_string = download_as_string - -
[docs] def upload_from_file(self, file_obj, rewind=False, size=None, - content_type=None, num_retries=6): - """Upload the contents of this key from a file-like object. - - .. note:: - The effect of uploading to an existing key depends on the - "versioning" and "lifecycle" policies defined on the key's - bucket. In the absence of those policies, upload will - overwrite any existing contents. - - See the `object versioning - <https://cloud.google.com/storage/docs/object-versioning>`_ and - `lifecycle <https://cloud.google.com/storage/docs/lifecycle>`_ - API documents for details. - - :type file_obj: file - :param file_obj: A file handle open for reading. - - :type rewind: boolean - :param rewind: If True, seek to the beginning of the file handle before - writing the file to Cloud Storage. - - :type size: int - :param size: The number of bytes to read from the file handle. - If not provided, we'll try to guess the size using - :func:`os.fstat` - """ - # Rewind the file if desired. - if rewind: - file_obj.seek(0, os.SEEK_SET) - - # Get the basic stats about the file. - total_bytes = size or os.fstat(file_obj.fileno()).st_size - conn = self.connection - headers = { - 'Accept': 'application/json', - 'Accept-Encoding': 'gzip, deflate', - 'User-Agent': conn.USER_AGENT, - } - - upload = transfer.Upload(file_obj, - content_type or 'application/unknown', - total_bytes, auto_transfer=False, - chunksize=self.CHUNK_SIZE) - - url_builder = _UrlBuilder(bucket_name=self.bucket.name, - object_name=self.name) - upload_config = _UploadConfig() - - # Temporary URL, until we know simple vs. resumable. - upload_url = conn.build_api_url( - path=self.bucket.path + '/o', upload=True) - - # Use apitools 'Upload' facility. - request = http_wrapper.Request(upload_url, 'POST', headers) - - upload.ConfigureRequest(upload_config, request, url_builder) - query_params = url_builder.query_params - request.url = conn.build_api_url(path=self.bucket.path + '/o', - query_params=query_params, - upload=True) - upload.InitializeUpload(request, conn.http) - - # Should we be passing callbacks through from caller? We can't - # pass them as None, because apitools wants to print to the console - # by default. - if upload.strategy == transfer._RESUMABLE_UPLOAD: - upload.StreamInChunks(callback=lambda *args: None, - finish_callback=lambda *args: None) - else: - http_wrapper.MakeRequest(conn.http, request, retries=num_retries) - - # NOTE: Alias for boto-like API.
- set_contents_from_file = upload_from_file - -
[docs] def upload_from_filename(self, filename): - """Upload this key's contents from the content of f named file. - - .. note:: - The effect of uploading to an existing key depends on the - "versioning" and "lifecycle" policies defined on the key's - bucket. In the absence of those policies, upload will - overwrite any existing contents. - - See the `object versioning - <https://cloud.google.com/storage/docs/object-versioning>`_ and - `lifecycle <https://cloud.google.com/storage/docs/lifecycle>`_ - API documents for details. - - :type filename: string - :param filename: The path to the file. - """ - content_type, _ = mimetypes.guess_type(filename) - - with open(filename, 'rb') as file_obj: - self.upload_from_file(file_obj, content_type=content_type) - - # NOTE: Alias for boto-like API.
- set_contents_from_filename = upload_from_filename - -
[docs] def upload_from_string(self, data, content_type='text/plain'): - """Upload contents of this key from the provided string. - - .. note:: - The effect of uploading to an existing key depends on the - "versioning" and "lifecycle" policies defined on the key's - bucket. In the absence of those policies, upload will - overwrite any existing contents. - - See the `object versioning - <https://cloud.google.com/storage/docs/object-versioning>`_ and - `lifecycle <https://cloud.google.com/storage/docs/lifecycle>`_ - API documents for details. - - :type data: string - :param data: The data to store in this key. - - :rtype: :class:`Key` - :returns: The updated Key object. - """ - string_buffer = StringIO() - string_buffer.write(data) - self.upload_from_file(file_obj=string_buffer, rewind=True, - size=string_buffer.len, - content_type=content_type) - return self - - # NOTE: Alias for boto-like API.
- set_contents_from_string = upload_from_string - -
[docs] def make_public(self): - """Make this key public giving all users read access. - - :returns: The current object. - """ - self.acl.all().grant_read() - self.acl.save() - return self -
- cache_control = _scalar_property('cacheControl') - """HTTP 'Cache-Control' header for this object. - - See: https://tools.ietf.org/html/rfc7234#section-5.2 and - https://cloud.google.com/storage/docs/json_api/v1/objects - - :rtype: string - """ - - content_disposition = _scalar_property('contentDisposition') - """HTTP 'Content-Disposition' header for this object. - - See: https://tools.ietf.org/html/rfc6266 and - https://cloud.google.com/storage/docs/json_api/v1/objects - - :rtype: string - """ - - content_encoding = _scalar_property('contentEncoding') - """HTTP 'Content-Encoding' header for this object. - - See: https://tools.ietf.org/html/rfc7231#section-3.1.2.2 and - https://cloud.google.com/storage/docs/json_api/v1/objects - - :rtype: string - """ - - content_language = _scalar_property('contentLanguage') - """HTTP 'Content-Language' header for this object. - - See: http://tools.ietf.org/html/bcp47 and - https://cloud.google.com/storage/docs/json_api/v1/objects - - :rtype: string - """ - - content_type = _scalar_property('contentType') - """HTTP 'Content-Type' header for this object. - - See: https://tools.ietf.org/html/rfc2616#section-14.17 and - https://cloud.google.com/storage/docs/json_api/v1/objects - - :rtype: string - """ - - crc32c = _scalar_property('crc32c') - """CRC32C checksum for this object. - - See: http://tools.ietf.org/html/rfc4960#appendix-B and - https://cloud.google.com/storage/docs/json_api/v1/objects - - :rtype: string - """ - - @property -
[docs] def component_count(self): - """Number of underlying components that make up this object. - - See: https://cloud.google.com/storage/docs/json_api/v1/objects - - :rtype: integer - """ - return self.properties['componentCount'] -
- @property -
[docs] def etag(self): - """Retrieve the ETag for the object. - - See: http://tools.ietf.org/html/rfc2616#section-3.11 and - https://cloud.google.com/storage/docs/json_api/v1/objects - - :rtype: string - """ - return self.properties['etag'] -
- @property -
[docs] def generation(self): - """Retrieve the generation for the object. - - See: https://cloud.google.com/storage/docs/json_api/v1/objects - - :rtype: integer - """ - return self.properties['generation'] -
- @property -
[docs] def id(self): - """Retrieve the ID for the object. - - See: https://cloud.google.com/storage/docs/json_api/v1/objects - - :rtype: string - """ - return self.properties['id'] -
- md5_hash = _scalar_property('md5Hash') - """MD5 hash for this object. - - See: http://tools.ietf.org/html/rfc4960#appendix-B and - https://cloud.google.com/storage/docs/json_api/v1/objects - - :rtype: string - """ - - @property - - @property - def metadata(self): - """Retrieve arbitrary/application specific metadata for the object. - - See: https://cloud.google.com/storage/docs/json_api/v1/objects - - :rtype: dict - """ - return copy.deepcopy(self.properties['metadata']) - - @metadata.setter -
[docs] def metadata(self, value): - """Update arbitrary/application specific metadata for the object. - - See: https://cloud.google.com/storage/docs/json_api/v1/objects - - :type value: dict - """ - self._patch_properties({'metadata': value}) -
- @property -
[docs] def metageneration(self): - """Retrieve the metageneration for the object. - - See: https://cloud.google.com/storage/docs/json_api/v1/objects - - :rtype: integer - """ - return self.properties['metageneration'] -
- @property -
[docs] def owner(self): - """Retrieve info about the owner of the object. - - See: https://cloud.google.com/storage/docs/json_api/v1/objects - - :rtype: dict - :returns: mapping of owner's role/ID. - """ - return self.properties['owner'].copy() -
- @property - - @property -
[docs] def size(self): - """Size of the object, in bytes. - - See: https://cloud.google.com/storage/docs/json_api/v1/objects - - :rtype: integer - """ - return self.properties['size'] -
- @property -
[docs] def storage_class(self): - """Retrieve the storage class for the object. - - See: https://cloud.google.com/storage/docs/json_api/v1/objects and - https://cloud.google.com/storage/docs/durable-reduced-availability#_DRA_Bucket - - :rtype: string - :returns: Currently one of "STANDARD", "DURABLE_REDUCED_AVAILABILITY" - """ - return self.properties['storageClass'] -
- @property -
[docs] def time_deleted(self): - """Retrieve the timestamp at which the object was deleted. - - See: https://cloud.google.com/storage/docs/json_api/v1/objects - - :rtype: string or None - :returns: timestamp in RFC 3339 format, or None if the object - has a "live" version. - """ - return self.properties.get('timeDeleted') -
- @property -
[docs] def updated(self): - """Retrieve the timestamp at which the object was updated. - - See: https://cloud.google.com/storage/docs/json_api/v1/objects - - :rtype: string - :returns: timestamp in RFC 3339 format. - """ - return self.properties['updated'] - -
-class _UploadConfig(object): - """ Faux message FBO apitools' 'ConfigureRequest'. - - Values extracted from apitools - 'samples/storage_sample/storage/storage_v1_client.py' - """ - accept = ['*/*'] - max_size = None - resumable_multipart = True - resumable_path = u'/resumable/upload/storage/v1/b/{bucket}/o' - simple_multipart = True - simple_path = u'/upload/storage/v1/b/{bucket}/o' - - -class _UrlBuilder(object): - """Faux builder FBO apitools' 'ConfigureRequest'""" - def __init__(self, bucket_name, object_name): - self.query_params = {'name': object_name} - self._bucket_name = bucket_name - self._relative_path = '' -
- -
- -
- - - - - - - \ No newline at end of file diff --git a/master/_modules/index.html b/master/_modules/index.html index 440cc7f3f667..29a2f997a770 100644 --- a/master/_modules/index.html +++ b/master/_modules/index.html @@ -5,7 +5,7 @@ - Overview: module code — gcloud 0.4.0 documentation + Overview: module code — gcloud 32e50eb documentation @@ -15,7 +15,7 @@ - + - -
- -
-

Python

- -
- 0.3.0 - -
- -
- -
-

Datasets#

-

Create / interact with gcloud datastore datasets.

-
-
-class gcloud.datastore.dataset.Dataset(id, connection=None)[source]#
-

Bases: object

-

A dataset in the Cloud Datastore.

-

This class acts as an abstraction of a single dataset in the Cloud -Datastore.

-

A dataset is analogous to a database in relational database world, -and corresponds to a single project using the Cloud Datastore.

-

Typically, you would only have one of these per connection however -it didn’t seem right to collapse the functionality of a connection -and a dataset together into a single class.

-

Datasets (like gcloud.datastore.query.Query) are immutable. -That is, you cannot change the ID and connection references. If you -need to modify the connection or ID, it’s recommended to construct a -new Dataset.

- --- - - - -
Parameters: -
-
-
-connection()[source]#
-

Get the current connection.

-
>>> dataset = Dataset('dataset-id', connection=conn)
->>> dataset.connection()
-<Connection object>
-
-
- --- - - - - - -
Return type:gcloud.datastore.connection.Connection
Returns:Returns the current connection.
-
- -
-
-id()[source]#
-

Get the current dataset ID.

-
>>> dataset = Dataset('dataset-id', connection=conn)
->>> dataset.id()
-'dataset-id'
-
-
- --- - - - - - -
Return type:string
Returns:The current dataset ID.
-
- -
- -
- - -
- -
- - - - - - - \ No newline at end of file diff --git a/master/datastore-entities.html b/master/datastore-entities.html index ace9be225ab7..a84bbd4a3877 100644 --- a/master/datastore-entities.html +++ b/master/datastore-entities.html @@ -5,7 +5,7 @@ - Entities — gcloud 0.4.0 documentation + Entities — gcloud 32e50eb documentation @@ -15,7 +15,7 @@ - + @@ -61,7 +61,7 @@

Python

- 0.4.0 + 32e50eb - - -
- -
-

Python

- -
- 0.3.0 - -
-
- -
- -
-

Keys#

-

Create / interact with gcloud storage keys.

-
-
-class gcloud.storage.key.Key(bucket=None, name=None, properties=None)[source]#
-

Bases: gcloud.storage._helpers._PropertyMixin

-

A wrapper around Cloud Storage’s concept of an Object.

-

Key constructor.

- --- - - - -
Parameters:
    -
  • bucket (gcloud.storage.bucket.Bucket) – The bucket to which this key belongs.
  • -
  • name (string) – The name of the key. This corresponds to the -unique path of the object in the bucket.
  • -
  • properties (dict) – All the other data provided by Cloud Storage.
  • -
-
-
-
-CHUNK_SIZE = 1048576#
-

The size of a chunk of data whenever iterating (1 MB).

-

This must be a multiple of 256 KB per the API specification.

-
- -
-
-CUSTOM_PROPERTY_ACCESSORS = {'timeDeleted': 'time_deleted', 'generation': 'generation', 'name': 'name', 'mediaLink': 'media_link', 'contentEncoding': 'content_encoding', 'cacheControl': 'cache_control', 'size': 'size', 'contentType': 'content_type', 'metageneration': 'metageneration', 'updated': 'updated', 'storageClass': 'storage_class', 'owner': 'owner', 'contentDisposition': 'content_disposition', 'id': 'id', 'etag': 'etag', 'selfLink': 'self_link', 'componentCount': 'component_count', 'acl': 'acl', 'contentLanguage': 'content_language'}#
-

Map field name -> accessor for fields w/ custom accessors.

-
- -
-
-acl[source]#
-

Create our ACL on demand.

-
- -
-
-cache_control#
-

HTTP ‘Cache-Control’ header for this object.

-
-
See: https://tools.ietf.org/html/rfc7234#section-5.2 and
-
https://cloud.google.com/storage/docs/json_api/v1/objects
-
- --- - - - -
Return type:string
-
- -
-
-component_count[source]#
-

Number of underlying components that make up this object.

-

See: https://cloud.google.com/storage/docs/json_api/v1/objects

- --- - - - -
Return type:integer
-
- -
-
-connection[source]#
-

Getter property for the connection to use with this Key.

- --- - - - - - -
Return type:gcloud.storage.connection.Connection or None
Returns:The connection to use, or None if no connection is set.
-
- -
-
-content_disposition#
-

HTTP ‘Content-Disposition’ header for this object.

-
-
See: https://tools.ietf.org/html/rfc6266 and
-
https://cloud.google.com/storage/docs/json_api/v1/objects
-
- --- - - - -
Return type:string
-
- -
-
-content_encoding#
-

HTTP ‘Content-Encoding’ header for this object.

-
-
See: https://tools.ietf.org/html/rfc7231#section-3.1.2.2 and
-
https://cloud.google.com/storage/docs/json_api/v1/objects
-
- --- - - - -
Return type:string
-
- -
-
-content_language#
-

HTTP ‘Content-Language’ header for this object.

-
-
See: http://tools.ietf.org/html/bcp47 and
-
https://cloud.google.com/storage/docs/json_api/v1/objects
-
- --- - - - -
Return type:string
-
- -
-
-content_type#
-

HTTP ‘Content-Type’ header for this object.

-
-
See: https://tools.ietf.org/html/rfc2616#section-14.17 and
-
https://cloud.google.com/storage/docs/json_api/v1/objects
-
- --- - - - -
Return type:string
-
- -
-
-crc32c#
-

CRC32C checksum for this object.

-
-
See: http://tools.ietf.org/html/rfc4960#appendix-B and
-
https://cloud.google.com/storage/docs/json_api/v1/objects
-
- --- - - - -
Return type:string
-
- -
-
-delete()[source]#
-

Deletes a key from Cloud Storage.

- --- - - - - - - - -
Return type:Key
Returns:The key that was just deleted.
Raises:gcloud.storage.exceptions.NotFound -(propagated from -gcloud.storage.bucket.Bucket.delete_key()).
-
- -
-
-download_as_string()[source]#
-

Download the contents of this key as a string.

- --- - - - - - - - -
Return type:string
Returns:The data stored in this key.
Raises:gcloud.storage.exceptions.NotFound
-
- -
-
-download_to_file(file_obj)[source]#
-

Download the contents of this key into a file-like object.

- --- - - - - - -
Parameters:file_obj (file) – A file handle to which to write the key’s data.
Raises:gcloud.storage.exceptions.NotFound
-
- -
-
-download_to_filename(filename)[source]#
-

Download the contents of this key into a named file.

- --- - - - - - -
Parameters:filename (string) – A filename to be passed to open.
Raises:gcloud.storage.exceptions.NotFound
-
- -
-
-etag[source]#
-

Retrieve the ETag for the object.

-
-
See: http://tools.ietf.org/html/rfc2616#section-3.11 and
-
https://cloud.google.com/storage/docs/json_api/v1/objects
-
- --- - - - -
Return type:string
-
- -
-
-exists()[source]#
-

Determines whether or not this key exists.

- --- - - - - - -
Return type:boolean
Returns:True if the key exists in Cloud Storage.
-
- -
-
-classmethod from_dict(key_dict, bucket=None)[source]#
-

Instantiate a Key from data returned by the JSON API.

- --- - - - - - - - -
Parameters:
    -
  • key_dict (dict) – A dictionary of data returned from getting an -Cloud Storage object.
  • -
  • bucket (gcloud.storage.bucket.Bucket) – The bucket to which this key belongs (and by -proxy, which connection to use).
  • -
-
Return type:

Key

-
Returns:

A key based on the data provided.

-
-
- -
-
-generate_signed_url(expiration, method='GET')[source]#
-

Generates a signed URL for this key.

-

If you have a key that you want to allow access to for a set -amount of time, you can use this method to generate a URL that -is only valid within a certain time period.

-

This is particularly useful if you don’t want publicly -accessible keys, but don’t want to require users to explicitly -log in.

- --- - - - - - - - -
Parameters:
    -
  • expiration (int, long, datetime.datetime, datetime.timedelta) – When the signed URL should expire.
  • -
  • method (string) – The HTTP verb that will be used when requesting the URL.
  • -
-
Return type:

string

-
Returns:

A signed URL you can use to access the resource -until expiration.

-
-
- -
-
-generation[source]#
-

Retrieve the generation for the object.

-

See: https://cloud.google.com/storage/docs/json_api/v1/objects

- --- - - - -
Return type:integer
-
- -
-
-get_contents_as_string()#
-

Download the contents of this key as a string.

- --- - - - - - - - -
Return type:string
Returns:The data stored in this key.
Raises:gcloud.storage.exceptions.NotFound
-
- -
-
-get_contents_to_file(file_obj)#
-

Download the contents of this key into a file-like object.

- --- - - - - - -
Parameters:file_obj (file) – A file handle to which to write the key’s data.
Raises:gcloud.storage.exceptions.NotFound
-
- -
-
-get_contents_to_filename(filename)#
-

Download the contents of this key into a named file.

- --- - - - - - -
Parameters:filename (string) – A filename to be passed to open.
Raises:gcloud.storage.exceptions.NotFound
-
- -
-
-id[source]#
-

Retrieve the ID for the object.

-

See: https://cloud.google.com/storage/docs/json_api/v1/objects

- --- - - - -
Return type:string
-
- -
-
-make_public()[source]#
-

Make this key public giving all users read access.

- --- - - - -
Returns:The current object.
-
- -
-
-md5_hash#
-

MD5 hash for this object.

-
-
See: http://tools.ietf.org/html/rfc4960#appendix-B and
-
https://cloud.google.com/storage/docs/json_api/v1/objects
-
- --- - - - -
Return type:string
-
- -
- -

Retrieve the media download URI for the object.

-

See: https://cloud.google.com/storage/docs/json_api/v1/objects

- --- - - - -
Return type:string
-
- -
-
-metadata[source]#
-

Retrieve arbitrary/application specific metadata for the object.

-

See: https://cloud.google.com/storage/docs/json_api/v1/objects

- --- - - - -
Return type:dict
-
- -
-
-metageneration[source]#
-

Retrieve the metageneration for the object.

-

See: https://cloud.google.com/storage/docs/json_api/v1/objects

- --- - - - -
Return type:integer
-
- -
-
-owner[source]#
-

Retrieve info about the owner of the object.

-

See: https://cloud.google.com/storage/docs/json_api/v1/objects

- --- - - - - - -
Return type:dict
Returns:mapping of owner’s role/ID.
-
- -
-
-path[source]#
-

Getter property for the URL path to this Key.

- --- - - - - - -
Return type:string
Returns:The URL path to this Key.
-
- -
-
-public_url[source]#
-

The public URL for this key’s object.

- --- - - - - - -
Return type:string
Returns:The public URL for this key.
-
- -
-
-rename(new_name)[source]#
-

Renames this key using copy and delete operations.

-

Effectively, copies key to the same bucket with a new name, then -deletes the key.

-
-

Warning

-

This method will first duplicate the data and then delete the -old key. This means that with very large objects renaming -could be a very (temporarily) costly or a very slow operation.

-
- --- - - - - - - - -
Parameters:new_name (string) – The new name for this key.
Return type:Key
Returns:The newly-copied key.
-
- -
- -

Retrieve the URI for the object.

-

See: https://cloud.google.com/storage/docs/json_api/v1/objects

- --- - - - -
Return type:string
-
- -
-
-set_contents_from_file(file_obj, rewind=False, size=None, content_type=None, num_retries=6)#
-

Upload the contents of this key from a file-like object.

-
-

Note

-

The effect of uploading to an existing key depends on the -“versioning” and “lifecycle” policies defined on the key’s -bucket. In the absence of those policies, upload will -overwrite any existing contents.

-

See the object versioning and -lifecycle -API documents for details.

-
- --- - - - -
Parameters:
    -
  • file_obj (file) – A file handle open for reading.
  • -
  • rewind (boolean) – If True, seek to the beginning of the file handle before -writing the file to Cloud Storage.
  • -
  • size (int) – The number of bytes to read from the file handle. -If not provided, we’ll try to guess the size using -os.fstat()
  • -
-
-
- -
-
-set_contents_from_filename(filename)#
-

Upload this key’s contents from the content of f named file.

-
-

Note

-

The effect of uploading to an existing key depends on the -“versioning” and “lifecycle” policies defined on the key’s -bucket. In the absence of those policies, upload will -overwrite any existing contents.

-

See the object versioning and -lifecycle -API documents for details.

-
- --- - - - -
Parameters:filename (string) – The path to the file.
-
- -
-
-set_contents_from_string(data, content_type='text/plain')#
-

Upload contents of this key from the provided string.

-
-

Note

-

The effect of uploading to an existing key depends on the -“versioning” and “lifecycle” policies defined on the key’s -bucket. In the absence of those policies, upload will -overwrite any existing contents.

-

See the object versioning and -lifecycle -API documents for details.

-
- --- - - - - - - - -
Parameters:data (string) – The data to store in this key.
Return type:Key
Returns:The updated Key object.
-
- -
-
-size[source]#
-

Size of the object, in bytes.

-

See: https://cloud.google.com/storage/docs/json_api/v1/objects

- --- - - - -
Return type:integer
-
- -
-
-storage_class[source]#
-

Retrieve the storage class for the object.

-

See: https://cloud.google.com/storage/docs/json_api/v1/objects and -https://cloud.google.com/storage/docs/durable-reduced-availability#_DRA_Bucket

- --- - - - - - -
Return type:string
Returns:Currently one of “STANDARD”, “DURABLE_REDUCED_AVAILABILITY”
-
- -
-
-time_deleted[source]#
-

Retrieve the timestamp at which the object was deleted.

-

See: https://cloud.google.com/storage/docs/json_api/v1/objects

- --- - - - - - -
Return type:string or None
Returns:timestamp in RFC 3339 format, or None if the object -has a “live” version.
-
- -
-
-updated[source]#
-

Retrieve the timestamp at which the object was updated.

-

See: https://cloud.google.com/storage/docs/json_api/v1/objects

- --- - - - - - -
Return type:string
Returns:timestamp in RFC 3339 format.
-
- -
-
-upload_from_file(file_obj, rewind=False, size=None, content_type=None, num_retries=6)[source]#
-

Upload the contents of this key from a file-like object.

-
-

Note

-

The effect of uploading to an existing key depends on the -“versioning” and “lifecycle” policies defined on the key’s -bucket. In the absence of those policies, upload will -overwrite any existing contents.

-

See the object versioning and -lifecycle -API documents for details.

-
- --- - - - -
Parameters:
    -
  • file_obj (file) – A file handle open for reading.
  • -
  • rewind (boolean) – If True, seek to the beginning of the file handle before -writing the file to Cloud Storage.
  • -
  • size (int) – The number of bytes to read from the file handle. -If not provided, we’ll try to guess the size using -os.fstat()
  • -
-
-
- -
-
-upload_from_filename(filename)[source]#
-

Upload this key’s contents from the content of f named file.

-
-

Note

-

The effect of uploading to an existing key depends on the -“versioning” and “lifecycle” policies defined on the key’s -bucket. In the absence of those policies, upload will -overwrite any existing contents.

-

See the object versioning and -lifecycle -API documents for details.

-
- --- - - - -
Parameters:filename (string) – The path to the file.
-
- -
-
-upload_from_string(data, content_type='text/plain')[source]#
-

Upload contents of this key from the provided string.

-
-

Note

-

The effect of uploading to an existing key depends on the -“versioning” and “lifecycle” policies defined on the key’s -bucket. In the absence of those policies, upload will -overwrite any existing contents.

-

See the object versioning and -lifecycle -API documents for details.

-
- --- - - - - - - - -
Parameters:data (string) – The data to store in this key.
Return type:Key
Returns:The updated Key object.
-
- -
- -
- - -
- -
- - - - - - - \ No newline at end of file