libcloud.storage.drivers.atmos module
- class libcloud.storage.drivers.atmos.AtmosConnection(user_id, key, secure=True, host=None, port=None, url=None, timeout=None, proxy_url=None, backoff=None, retry_delay=None)[source]
Bases:
ConnectionUserAndKey
Initialize user_id and key; set secure to an
int
based on passed value.- add_default_headers(headers)[source]
Adds default headers (such as Authorization, X-Foo-Bar) to the passed headers
Should return a dictionary.
- pre_connect_hook(params, headers)[source]
A hook which is called before connecting to the remote server. This hook can perform a final manipulation on the params, headers and url parameters.
- Parameters:
params (
dict
) – Request parameters.headers (
dict
) – Request headers.
- responseCls
alias of
AtmosResponse
- class libcloud.storage.drivers.atmos.AtmosDriver(key, secret=None, secure=True, host=None, port=None)[source]
Bases:
StorageDriver
- Parameters:
key (
str
) – API key or username to be used (required)secret (
str
) – Secret password to be used (required)secure (
bool
) – Whether to use HTTPS or HTTP. Note: Some providers only support HTTPS, and it is on by default.host (
str
) – Override hostname used for connections.port (
int
) – Override port used for connections.api_version (
str
) – Optional API version. Only used by drivers which support multiple API versions.region (
str
) – Optional driver region. Only used by drivers which support multiple regions.
- Return type:
None
- DEFAULT_CDN_TTL = 604800
- api_name = 'atmos'
- connectionCls
alias of
AtmosConnection
- create_container(container_name)[source]
Create a new container.
- Parameters:
container_name (
str
) – Container name.- Returns:
Container instance on success.
- Return type:
- delete_container(container)[source]
Delete a container.
- Parameters:
container (
libcloud.storage.base.Container
) – Container instance- Returns:
True
on success,False
otherwise.- Return type:
bool
- delete_object(obj)[source]
Delete an object.
- Parameters:
obj (
libcloud.storage.base.Object
) – Object instance.- Returns:
bool
True on success.- Return type:
bool
- download_object(obj, destination_path, overwrite_existing=False, delete_on_failure=True)[source]
Download an object to the specified destination path.
- Parameters:
obj (
libcloud.storage.base.Object
) – Object instance.destination_path (
str
) – Full path to a file or a directory where the incoming file will be saved.overwrite_existing (
bool
) – True to overwrite an existing file, defaults to False.delete_on_failure (
bool
) – True to delete a partially downloaded file if the download was not successful (hash mismatch / file size).
- Returns:
True if an object has been successfully downloaded, False otherwise.
- Return type:
bool
- download_object_as_stream(obj, chunk_size=None)[source]
Return a iterator which yields object data.
- Parameters:
obj (
libcloud.storage.base.Object
) – Object instancechunk_size (
int
) – Optional chunk size (in bytes).
- Return type:
iterator
ofbytes
- enable_object_cdn(obj)[source]
Enable object CDN.
- Parameters:
obj (
libcloud.storage.base.Object
) – Object instance- Return type:
bool
- get_container(container_name)[source]
Return a container instance.
- Parameters:
container_name (
str
) – Container name.- Returns:
Container
instance.- Return type:
- get_object(container_name, object_name)[source]
Return an object instance.
- Parameters:
container_name (
str
) – Container name.object_name (
str
) – Object name.
- Returns:
Object
instance.- Return type:
- get_object_cdn_url(obj, expiry=None, use_object=False)[source]
Return an object CDN URL.
- Parameters:
obj (
Object
) – Object instanceexpiry (
str
) – Expiryuse_object (
bool
) – Use object
- Return type:
str
- iterate_container_objects(container, prefix=None, ex_prefix=None)[source]
Return a generator of objects for the given container.
- Parameters:
container (
Container
) – Container instanceprefix (
str
) – Filter objects starting with a prefix. Filtering is performed client-side.ex_prefix (
str
) – (Deprecated.) Filter objects starting with a prefix. Filtering is performed client-side.
- Returns:
A generator of Object instances.
- Return type:
generator
ofObject
- iterate_containers()[source]
Return a iterator of containers for the given account
- Returns:
A iterator of Container instances.
- Return type:
iterator
oflibcloud.storage.base.Container
- upload_object(file_path, container, object_name, extra=None, verify_hash=True, headers=None)[source]
Upload an object currently located on a disk.
- Parameters:
file_path (
str
) – Path to the object on disk.container (
libcloud.storage.base.Container
) – Destination container.object_name (
str
) – Object name.verify_hash (
bool
) – Verify hashextra (
dict
) – Extra attributes (driver specific). (optional)headers (
dict
) – (optional) Additional request headers, such as CORS headers. For example: headers = {‘Access-Control-Allow-Origin’: ‘http://mozilla.com’}
- Return type:
- upload_object_via_stream(iterator, container, object_name, extra=None, headers=None)[source]
Upload an object using an iterator.
If a provider supports it, chunked transfer encoding is used and you don’t need to know in advance the amount of data to be uploaded.
Otherwise if a provider doesn’t support it, iterator will be exhausted so a total size for data to be uploaded can be determined.
Note: Exhausting the iterator means that the whole data must be buffered in memory which might result in memory exhausting when uploading a very large object.
If a file is located on a disk you are advised to use upload_object function which uses fs.stat function to determine the file size and it doesn’t need to buffer whole object in the memory.
- Parameters:
iterator (
object
) – An object which implements the iterator interface.container (
libcloud.storage.base.Container
) – Destination container.object_name (
str
) – Object name.extra (
dict
) – (optional) Extra attributes (driver specific). Note: This dictionary must contain a ‘content_type’ key which represents a content type of the stored object.headers (
dict
) – (optional) Additional request headers, such as CORS headers. For example: headers = {‘Access-Control-Allow-Origin’: ‘http://mozilla.com’}
- Return type:
libcloud.storage.base.Object
- website = 'http://atmosonline.com/'
- exception libcloud.storage.drivers.atmos.AtmosError(code, message, driver=None)[source]
Bases:
LibcloudError
- class libcloud.storage.drivers.atmos.AtmosResponse(response, connection)[source]
Bases:
XmlResponse
- Parameters:
response (
httplib.HTTPResponse
) – HTTP response object. (optional)connection (
Connection
) – Parent connection object.