cloudfiles.connection.Connection

Package cloudfiles :: Module connection :: Class Connection |
[frames] | no frames]

# Class Connection

source code

Manages the connection to the storage system and serves as a factory for Container instances.

Instance Methods
__init__(self, username=None, api_key=None, timeout=5, **kwargs) Accepts keyword arguments for Mosso username and api key. | source code
tuple |
get_info(self) Return tuple for number of containers, total bytes in the account and account metadata | source code
update_account_metadata(self, metadata) Update account metadata >>> metadata = {'x-account-meta-foo' : 'bar'} >>> connection.update_account_metadata(metadata) | source code
Container |
create_container(self, container_name, error_on_existing=False) Given a container name, returns a Container item, creating a new Container if one does not already exist. | source code
delete_container(self, container_name) Given a container name, delete it. | source code
ContainerResults |
get_all_containers(self, limit=None, marker=None, **parms) Returns a Container item result set. | source code
Container |
get_container(self, container_name) Return a single Container item for the given Container. | source code
list(str) |
list_public_containers(self) Returns a list of containers that have been published to the CDN. | source code
list({"name":"...", "count":..., "bytes":...}) |
list_containers_info(self, limit=None, marker=None, **parms) Returns a list of Containers, including object count and size. | source code
list(str) |
list_containers(self, limit=None, marker=None, **parms) Returns a list of Containers. | source code
Container |
__getitem__(self, key) Container objects can be grabbed from a connection using index syntax. | source code
Inherited from `object`: `__delattr__`, `__format__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__repr__`, `__setattr__`, `__sizeof__`, `__str__`, `__subclasshook__`

Properties
Inherited from `object`: `__class__`

Method Details

### __init__(self, username=None, api_key=None, timeout=5, **kwargs) (Constructor) | source code
Accepts keyword arguments for Mosso username and api key. Optionally, you can omit these keywords and supply an Authentication object using the auth keyword. Setting the argument servicenet to True will make use of Rackspace servicenet network. Parameters: `username` (str) - a Mosso username `api_key` (str) - a Mosso API key `servicenet` (bool) - Use Rackspace servicenet to access Cloud Files. `cdn_log_retention` (bool) - set logs retention for this cdn enabled container. Overrides: object.__init__

### get_info(self) | source code
Return tuple for number of containers, total bytes in the account and account metadata
    >>> connection.get_info()
    (5, 2309749)
Returns: tuple a tuple containing the number of containers, total bytes used by the account and a dictionary containing account metadata

### update_account_metadata(self, metadata) | source code
Update account metadata >>> metadata = {'x-account-meta-foo' : 'bar'} >>> connection.update_account_metadata(metadata) Parameters: `metadata` - Dictionary of metadata `metdada` (dict)

### create_container(self, container_name, error_on_existing=False) | source code
Given a container name, returns a Container item, creating a new Container if one does not already exist.
    >>> connection.create_container('new_container')
    <cloudfiles.container.Container object at 0xb77d628c>
Parameters: `container_name` (str) - name of the container to create `error_on_existing` (bool) - raise ContainerExists if container already exists Returns: Container an object representing the newly created container

### delete_container(self, container_name) | source code
Given a container name, delete it.
    >>> connection.delete_container('old_container')
Parameters: `container_name` (str) - name of the container to delete

### get_all_containers(self, limit=None, marker=None, **parms) | source code
Returns a Container item result set.
    >>> connection.get_all_containers()
    ContainerResults: 4 containers
    >>> print ', '.join([container.name for container in
                         connection.get_all_containers()])
    new_container, old_container, pictures, music
Parameters: `limit` (int) - number of results to return, up to 10,000 `marker` (str) - return only results whose name is greater than "marker" Returns: ContainerResults an iterable set of objects representing all containers on the account

### get_container(self, container_name) | source code
Return a single Container item for the given Container.
    >>> connection.get_container('old_container')
    <cloudfiles.container.Container object at 0xb77d628c>
    >>> container = connection.get_container('old_container')
    >>> container.size_used
    23074
Parameters: `container_name` (str) - name of the container to create Returns: Container an object representing the container

### list_public_containers(self) | source code
Returns a list of containers that have been published to the CDN.
    >>> connection.list_public_containers()
    ['container1', 'container2', 'container3']
Returns: list(str) a list of all CDN-enabled container names as strings

### list_containers_info(self, limit=None, marker=None, **parms) | source code
Returns a list of Containers, including object count and size.
    >>> connection.list_containers_info()
    [{u'count': 510, u'bytes': 2081717, u'name': u'new_container'},
     {u'count': 12, u'bytes': 23074, u'name': u'old_container'},
     {u'count': 0, u'bytes': 0, u'name': u'container1'},
     {u'count': 0, u'bytes': 0, u'name': u'container2'},
     {u'count': 0, u'bytes': 0, u'name': u'container3'},
     {u'count': 3, u'bytes': 2306, u'name': u'test'}]
Parameters: `limit` (int) - number of results to return, up to 10,000 `marker` (str) - return only results whose name is greater than "marker" Returns: list({"name":"...", "count":..., "bytes":...}) a list of all container info as dictionaries with the keys "name", "count", and "bytes"

### list_containers(self, limit=None, marker=None, **parms) | source code
Returns a list of Containers.
    >>> connection.list_containers()
    ['new_container',
     'old_container',
     'container1',
     'container2',
     'container3',
     'test']
Parameters: `limit` (int) - number of results to return, up to 10,000 `marker` (str) - return only results whose name is greater than "marker" Returns: list(str) a list of all containers names as strings

### __getitem__(self, key) (Indexing operator) | source code
Container objects can be grabbed from a connection using index syntax.
    >>> container = conn['old_container']
    >>> container.size_used
    23074
Returns: Container an object representing the container