1 class BaseBackend(object):
2 """Abstract backend class that serves as a reference for actual implementations
4 The purpose of the backend is to provide the necessary functions for handling data
5 and metadata. It is responsible for the actual storage and retrieval of information.
7 Note that the account level is always valid as it is checked from another subsystem.
10 def get_account_meta(self, account):
11 """Return a dictionary with the account metadata
13 The keys returned are all user-defined, except:
14 'name': The account name
15 'count': The number of containers (or 0)
16 'bytes': The total data size (or 0)
17 'modified': Last modification timestamp
21 def update_account_meta(self, account, meta):
22 """Update the metadata associated with the account
25 'meta': Dictionary with metadata to update
29 def create_container(self, account, name):
30 """Create a new container with the given name
33 NameError: Container already exists
37 def delete_container(self, account, name):
38 """Delete the container with the given name
41 NameError: Container does not exist
42 IndexError: Container is not empty
46 def get_container_meta(self, account, name):
47 """Return a dictionary with the container metadata
49 The keys returned are all user-defined, except:
50 'name': The container name
51 'count': The number of objects
52 'bytes': The total data size
53 'modified': Last modification timestamp
56 NameError: Container does not exist
60 def update_container_meta(self, account, name, meta):
61 """Update the metadata associated with the container
64 'meta': Dictionary with metadata to update
67 NameError: Container does not exist
71 def list_containers(self, account, marker=None, limit=10000):
72 """Return a list of containers existing under an account
75 'marker': Start list from the next item after 'marker'
76 'limit': Number of containers to return
80 def list_objects(self, account, container, prefix='', delimiter=None, marker=None, limit=10000, virtual=True):
81 """Return a list of objects existing under a container
84 'prefix': List objects starting with 'prefix'
85 'delimiter': Return unique names before 'delimiter' and after 'prefix'
86 'marker': Start list from the next item after 'marker'
87 'limit': Number of objects to return
88 'virtual': If not set, the result will only include names starting
89 with 'prefix' and ending without a 'delimiter' or with the first
90 occurance of the 'delimiter' after 'prefix'.
91 If set, the result will include all names after 'prefix', up to and
92 including the 'delimiter' if it is found
95 NameError: Container does not exist
99 def get_object_meta(self, account, container, name):
100 """Return a dictionary with the object metadata
102 The keys returned are all user-defined, except:
103 'name': The account name
104 'bytes': The total data size
105 'modified': Last modification timestamp
108 NameError: Container/object does not exist
112 def update_object_meta(self, account, container, name, meta):
113 """Update the metadata associated with the object
116 'meta': Dictionary with metadata to update
119 NameError: Container/object does not exist
123 def get_object(self, account, container, name, offset=0, length=-1):
124 """Return the object data
127 'offset': Offset in the object to start reading from
128 'length': Number of bytes to return
131 NameError: Container/object does not exist
135 def update_object(self, account, container, name, data, offset=0):
136 """Create/update an object with the specified data
139 'offset': Offset in the object to start writing from
142 NameError: Container does not exist
146 def copy_object(self, account, src_container, src_name, dest_container, dest_name, dest_meta={}):
147 """Copy an object's data and metadata
150 'dest_meta': Dictionary with metadata to changes from source to destination
153 NameError: Container/object does not exist
157 def move_object(self, account, src_container, src_name, dest_container, dest_name, dest_meta={}):
158 """Move an object's data and metadata
161 'dest_meta': Dictionary with metadata to changes from source to destination
164 NameError: Container/object does not exist
168 def delete_object(self, account, container, name):
172 NameError: Container/object does not exist