l.s.b.StorageDriver(object) : class documentation

Part of libcloud.storage.base View Source View In Hierarchy

Known subclasses: libcloud.storage.drivers.cloudfiles.CloudFilesStorageDriver, libcloud.storage.drivers.dummy.DummyStorageDriver, libcloud.storage.drivers.s3.S3StorageDriver

A base StorageDriver to derive from.
Method __init__ Undocumented
Method list_containters Undocumented
Method list_container_objects Return a list of objects for the given container.
Method get_container Return a container instance.
Method get_container_cdn_url Return a container CDN URL.
Method get_object Return an object instance.
Method get_object_cdn_url Return a container CDN URL.
Method enable_container_cdn Undocumented
Method enable_object_cdn Undocumented
Method download_object Download an object to the specified destination path.
Method download_object_as_stream Return a generator which yields object data.
Method upload_object Upload an object.
Method upload_object_via_stream @type iterator: C{object} @param iterator: An object which implements the iterator interface.
Method delete_object Delete an object.
Method create_container Create a new container.
Method delete_container Delete a container.
Method _get_object Call passed callback and start transfer of the object'
Method _save_object Save object to the provided path.
Method _upload_object Helper function for setting common request headers and calling the passed in callback which uploads an object.
Method _stream_data Stream a data over an http connection.
Method _upload_file Upload a file to the server.
def __init__(self, key, secret=None, secure=True, host=None, port=None): (source)
Undocumented
def list_containters(self): (source)
Undocumented
def list_container_objects(self, container): (source)
Return a list of objects for the given container.

@type container: C{Container}
@param container: Container instance

@return A list of Object instances.
def get_container(self, container_name): (source)
Return a container instance.

@type container_name: C{str}
@param container_name: Container name.

@return: C{Container} instance.
def get_container_cdn_url(self, container): (source)
Return a container CDN URL.

@type container: C{Container}
@param container: Container instance

@return A CDN URL for this container.
def get_object(self, container_name, object_name): (source)
Return an object instance.

@type container_name: C{str}
@param container_name: Container name.

@type object_name: C{str}
@param object_name: Object name.

@return: C{Object} instance.
def get_object_cdn_url(self, obj): (source)
Return a container CDN URL.

@type obj: C{Object}
@param obj: Object instance

@return A CDN URL for this object.
def enable_container_cdn(self, container): (source)
Undocumented
def enable_object_cdn(self, obj): (source)
Undocumented
def download_object(self, obj, destination_path, overwrite_existing=False, delete_on_failure=True): (source)
Download an object to the specified destination path.

@type obj; C{Object}
@param obj: Object instance.

@type destination_path: C{str}
@type destination_path: Full path to a file or a directory where the
                        incoming file will be saved.

@type overwrite_existing: C{bool}
@type overwrite_existing: True to overwrite an existing file, defaults to False.

@type delete_on_failure: C{bool}
@param delete_on_failure: True to delete a partially downloaded file if
the download was not successful (hash mismatch / file size).

@return C{bool} True if an object has been successfully downloaded, False
otherwise.
def download_object_as_stream(self, obj, chunk_size=None): (source)
Return a generator which yields object data.

@type obj: C{Object}
@param obj: Object instance

@type chunk_size: C{int}
@param chunk_size: Optional chunk size (in bytes).
def upload_object(self, file_path, container, object_name, extra=None, verify_hash=True): (source)
Upload an object.

@type file_path: C{str}
@param file_path: Path to the object on disk.

@type container: C{Container}
@param container: Destination container.

@type object_name: C{str}
@param object_name: Object name.

@type extra: C{dict}
@param extra: (optional) Extra attributes (driver specific).

@type verify_hash: C{boolean}
@param verify_hash: True to do a file integrity check.
def upload_object_via_stream(self, iterator, container, object_name, extra=None): (source)
@type iterator: C{object}
@param iterator: An object which implements the iterator interface.

@type container: C{Container}
@param container: Destination container.

@type object_name: C{str}
@param object_name: Object name.

@type extra: C{dict}
@param extra: (optional) Extra attributes (driver specific).
def delete_object(self, obj): (source)
Delete an object.

@type obj: C{Object}
@param obj: Object instance.

@return: C{bool} True on success.
def create_container(self, container_name): (source)
Create a new container.

@type container_name: C{str}
@param container_name: Container name.

@return C{Container} instance on success.
def delete_container(self, container): (source)
Delete a container.

@type container: C{Container}
@param container: Container instance

@return C{bool} True on success, False otherwise.
def _get_object(self, obj, callback, callback_kwargs, response, success_status_code=None): (source)
Call passed callback and start transfer of the object'

@type obj: C{Object}
@param obj: Object instance.

@type callback: C{Function}
@param callback: Function which is called with the passed callback_kwargs

@type callback_kwargs: C{dict}
@param callback_kwargs: Keyword arguments which are passed to the callback.

@typed response: C{Response}
@param response: Response instance.

@type success_status_code: C{int}
@param success_status_code: Status code which represents a successful
                            transfer (defaults to httplib.OK)

@return C{bool} True on success, False otherwise.
def _save_object(self, response, obj, destination_path, overwrite_existing=False, delete_on_failure=True, chunk_size=None): (source)
Save object to the provided path.

@type response: C{RawResponse}
@param response: RawResponse instance.

@type obj: C{Object}
@param obj: Object instance.

@type destination_path: C{Str}
@param destination_path: Destination directory.

@type delete_on_failure: C{bool}
@param delete_on_failure: True to delete partially downloaded object if
                          the download fails.
@type overwrite_existing: C{bool}
@param overwrite_existing: True to overwrite a local path if it already
                           exists.

@type chunk_size: C{int}
@param chunk_size: Optional chunk size (defaults to L{libcloud.storage.base.CHUNK_SIZE}, 8kb)

@return C{bool} True on success, False otherwise.
def _upload_object(self, object_name, content_type, upload_func, upload_func_kwargs, request_path, request_method='PUT', headers=None, file_path=None, iterator=None): (source)
Helper function for setting common request headers and calling the
passed in callback which uploads an object.
def _stream_data(self, response, iterator, chunked=False, calculate_hash=True, chunk_size=None): (source)
Stream a data over an http connection.

@type response: C{RawResponse}
@param response: RawResponse object.

@type iterator: C{}
@param response: An object which implements an iterator interface
                 or a File like object with read method.

@type chunk_size: C{int}
@param chunk_size: Optional chunk size (defaults to CHUNK_SIZE)

@return C{tuple} First item is a boolean indicator of success, second
                 one is the uploaded data MD5 hash and the third one
                 is the number of transferred bytes.
def _upload_file(self, response, file_path, chunked=False, calculate_hash=True): (source)
Upload a file to the server.

@type response: C{RawResponse}
@param response: RawResponse object.

@type file_path: C{str}
@param file_path: Path to a local file.

@type iterator: C{}
@param response: An object which implements an iterator interface (File
                 object, etc.)

@return C{tuple} First item is a boolean indicator of success, second
                 one is the uploaded data MD5 hash and the third one
                 is the number of transferred bytes.
API Documentation for libcloud, generated by pydoctor at 2011-07-02 22:19:34.