pyrax
Python Bindings for the Rackspace Cloud
|
Represents a CloudFiles container. More...
Public Member Functions | |
def | __init__ |
def | get_objects |
Returns a list of StorageObjects representing the objects in the container. | |
def | get_object |
Return the StorageObject in this container with the specified name. | |
def | get_object_names |
Returns a list of the names of all the objects in this container. | |
def | list_subdirs |
Return a list of StorageObjects representing the pseudo-subdirectories in this container. | |
def | store_object |
Creates a new object in this container, and populates it with the given data. | |
def | upload_file |
Uploads the specified file to this container. | |
def | delete_object |
Deletes the specified object from this container. | |
def | delete_all_objects |
Deletes all objects from this container. | |
def | remove_from_cache |
Removes the object from the cache. | |
def | delete |
Deletes this Container. | |
def | fetch_object |
Fetches the object from storage. | |
def | download_object |
Fetches the object from storage, and writes it to the specified directory. | |
def | get_metadata |
Returns a dictionary containing the metadata for the container. | |
def | set_metadata |
Accepts a dictionary of metadata key/value pairs and updates the specified container metadata with them. | |
def | remove_metadata_key |
Removes the specified key from the container's metadata. | |
def | set_web_index_page |
Sets the header indicating the index page for this container when creating a static website. | |
def | set_web_error_page |
Sets the header indicating the error page for this container when creating a static website. | |
def | make_public |
Enables CDN access for the specified container. | |
def | make_private |
Disables CDN access to this container. | |
def | copy_object |
Copies the object to the new container, optionally giving it a new name. | |
def | move_object |
Works just like copy_object, except that the source object is deleted after a successful copy. | |
def | change_object_content_type |
Copies object to itself, but applies a new content-type. | |
def | get_temp_url |
Returns a URL that can be used to access the specified object in this container. | |
def | delete_object_in_seconds |
Sets the object to be deleted after the specified number of seconds. | |
def | __repr__ |
def | cdn_enabled |
Public Attributes | |
client | |
name | |
object_count | |
total_bytes | |
Static Public Attributes | |
list = get_objects | |
get = get_object | |
list_object_names = get_object_names | |
Properties | |
cdn_log_retention = property(_get_cdn_log_retention, _set_cdn_log_retention) | |
cdn_uri = property(_get_cdn_uri, _set_cdn_uri) | |
cdn_ttl = property(_get_cdn_ttl, _set_cdn_ttl) | |
cdn_ssl_uri = property(_get_cdn_ssl_uri, _set_cdn_ssl_uri) | |
cdn_streaming_uri = property(_get_cdn_streaming_uri, _set_cdn_streaming_uri) | |
cdn_ios_uri = property(_get_cdn_ios_uri, _set_cdn_ios_uri) |
Represents a CloudFiles container.
def __init__ | ( | self, | |
client, | |||
name, | |||
object_count = None , |
|||
total_bytes = None |
|||
) |
def __repr__ | ( | self | ) |
def cdn_enabled | ( | self | ) |
def change_object_content_type | ( | self, | |
obj, | |||
new_ctype, | |||
guess = False |
|||
) |
Copies object to itself, but applies a new content-type.
The guess feature requires the container to be CDN-enabled. If not then the content-type must be supplied. If using guess with a CDN-enabled container, new_ctype can be set to None. Failure during the put will result in a swift exception.
def copy_object | ( | self, | |
obj, | |||
new_container, | |||
new_obj_name = None , |
|||
extra_info = None |
|||
) |
Copies the object to the new container, optionally giving it a new name.
If you copy to the same container, you must supply a different name.
def delete | ( | self, | |
del_objects = False |
|||
) |
Deletes this Container.
If the container contains objects, the command will fail unless 'del_objects' is passed as True. In that case, each object will be deleted first, and then the container.
def delete_all_objects | ( | self, | |
async = False |
|||
) |
Deletes all objects from this container.
By default the call will block until all objects have been deleted. By passing True for the 'async' parameter, this method will not block, and instead return an object that can be used to follow the progress of the deletion. When deletion is complete the bulk deletion object's 'results' attribute will be populated with the information returned from the API call. In synchronous mode this is the value that is returned when the call completes. It is a dictionary with the following keys:
deleted - the number of objects deleted not_found - the number of objects not found status - the HTTP return status code. '200 OK' indicates success errors - a list of any errors returned by the bulk delete call
def delete_object | ( | self, | |
obj | |||
) |
Deletes the specified object from this container.
def delete_object_in_seconds | ( | self, | |
obj, | |||
seconds | |||
) |
Sets the object to be deleted after the specified number of seconds.
def download_object | ( | self, | |
obj_name, | |||
directory, | |||
structure = True |
|||
) |
Fetches the object from storage, and writes it to the specified directory.
The directory must exist before calling this method.
If the object name represents a nested folder structure, such as "foo/bar/baz.txt", that folder structure will be created in the target directory by default. If you do not want the nested folders to be created, pass `structure=False` in the parameters.
def fetch_object | ( | self, | |
obj_name, | |||
include_meta = False , |
|||
chunk_size = None |
|||
) |
Fetches the object from storage.
If 'include_meta' is False, only the bytes representing the file is returned.
Note: if 'chunk_size' is defined, you must fully read the object's contents before making another request.
When 'include_meta' is True, what is returned from this method is a 2-tuple: Element 0: a dictionary containing metadata about the file. Element 1: a stream of bytes representing the object's contents.
def get_metadata | ( | self, | |
prefix = None |
|||
) |
Returns a dictionary containing the metadata for the container.
def get_object | ( | self, | |
name, | |||
cached = True |
|||
) |
Return the StorageObject in this container with the specified name.
By default, if a reference to that object has already been retrieved, a cached reference will be returned. If you need to get an updated version of the object, pass `cached=False` to the method call.
def get_object_names | ( | self, | |
marker = None , |
|||
limit = None , |
|||
prefix = None , |
|||
delimiter = None , |
|||
full_listing = False |
|||
) |
Returns a list of the names of all the objects in this container.
The same pagination parameters apply as in self.get_objects().
def get_objects | ( | self, | |
marker = None , |
|||
limit = None , |
|||
prefix = None , |
|||
delimiter = None , |
|||
full_listing = False |
|||
) |
Returns a list of StorageObjects representing the objects in the container.
You can use the marker and limit params to handle pagination, and the prefix and delimiter params to filter the objects returned. Also, by default only the first 10,000 objects are returned; if you set full_listing to True, all objects in the container are returned.
def get_temp_url | ( | self, | |
obj, | |||
seconds, | |||
method = "GET" |
|||
) |
Returns a URL that can be used to access the specified object in this container.
The URL will expire after `seconds` seconds.
The only methods supported are GET and PUT. Anything else will raise an InvalidTemporaryURLMethod exception.
def list_subdirs | ( | self, | |
marker = None , |
|||
limit = None , |
|||
prefix = None , |
|||
delimiter = None , |
|||
full_listing = False |
|||
) |
Return a list of StorageObjects representing the pseudo-subdirectories in this container.
You can use the marker and limit params to handle pagination, and the prefix and delimiter params to filter the objects returned.
def make_private | ( | self | ) |
Disables CDN access to this container.
It may still appear public until its TTL expires.
def make_public | ( | self, | |
ttl = None |
|||
) |
Enables CDN access for the specified container.
def move_object | ( | self, | |
obj, | |||
new_container, | |||
new_obj_name = None , |
|||
extra_info = None |
|||
) |
Works just like copy_object, except that the source object is deleted after a successful copy.
def remove_from_cache | ( | self, | |
obj | |||
) |
Removes the object from the cache.
def remove_metadata_key | ( | self, | |
key, | |||
prefix = None |
|||
) |
Removes the specified key from the container's metadata.
If the key does not exist in the metadata, nothing is done.
def set_metadata | ( | self, | |
metadata, | |||
clear = False , |
|||
prefix = None |
|||
) |
Accepts a dictionary of metadata key/value pairs and updates the specified container metadata with them.
If 'clear' is True, any existing metadata is deleted and only the passed metadata is retained. Otherwise, the values passed here update the container's metadata.
'extra_info' is an optional dictionary which will be populated with 'status', 'reason', and 'headers' keys from the underlying swiftclient call.
By default, the standard container metadata prefix ('X-Container-Meta-') is prepended to the header name if it isn't present. For non-standard headers, you must include a non-None prefix, such as an empty string.
def set_web_error_page | ( | self, | |
page | |||
) |
Sets the header indicating the error page for this container when creating a static website.
Note: the container must be CDN-enabled for this to have any effect.
def set_web_index_page | ( | self, | |
page | |||
) |
Sets the header indicating the index page for this container when creating a static website.
Note: the container must be CDN-enabled for this to have any effect.
def store_object | ( | self, | |
obj_name, | |||
data, | |||
content_type = None , |
|||
etag = None , |
|||
content_encoding = None , |
|||
ttl = None , |
|||
return_none = False , |
|||
extra_info = None |
|||
) |
Creates a new object in this container, and populates it with the given data.
def upload_file | ( | self, | |
file_or_path, | |||
obj_name = None , |
|||
content_type = None , |
|||
etag = None , |
|||
return_none = False , |
|||
content_encoding = None , |
|||
ttl = None , |
|||
content_length = None |
|||
) |
Uploads the specified file to this container.
If no name is supplied, the file's name will be used. Either a file path or an open file-like object may be supplied. A StorageObject reference to the uploaded file will be returned, unless 'return_none' is set to True.
get = get_object [static] |
list = get_objects [static] |
list_object_names = get_object_names [static] |
cdn_ios_uri = property(_get_cdn_ios_uri, _set_cdn_ios_uri) [static] |
cdn_log_retention = property(_get_cdn_log_retention, _set_cdn_log_retention) [static] |
cdn_ssl_uri = property(_get_cdn_ssl_uri, _set_cdn_ssl_uri) [static] |
cdn_streaming_uri = property(_get_cdn_streaming_uri, _set_cdn_streaming_uri) [static] |
cdn_ttl = property(_get_cdn_ttl, _set_cdn_ttl) [static] |
cdn_uri = property(_get_cdn_uri, _set_cdn_uri) [static] |