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 | 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 |
def | set_metadata |
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 | 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 |
BEGIN - CDN property definitions ##. | |
Public Attributes | |
client | |
name | |
object_count | |
total_bytes | |
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 | ) |
BEGIN - CDN property definitions ##.
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 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 | ) |
Deletes all objects from this container.
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 | ) |
def get_object | ( | self, | |
name | |||
) |
Return the StorageObject in this container with the specified name.
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 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 remove_from_cache | ( | self, | |
obj | |||
) |
Removes the object from the cache.
def remove_metadata_key | ( | self, | |
key | |||
) |
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 |
|||
) |
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 |
|||
) |
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 |
|||
) |
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.
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] |