Statistics
| Branch: | Tag: | Revision:

root / snf-pithos-backend / pithos / backends / base.py @ daf4fb05

History | View | Annotate | Download (19.3 kB)

1 5635f9ef Antony Chazapis
# Copyright 2011 GRNET S.A. All rights reserved.
2 5635f9ef Antony Chazapis
# 
3 5635f9ef Antony Chazapis
# Redistribution and use in source and binary forms, with or
4 5635f9ef Antony Chazapis
# without modification, are permitted provided that the following
5 5635f9ef Antony Chazapis
# conditions are met:
6 5635f9ef Antony Chazapis
# 
7 5635f9ef Antony Chazapis
#   1. Redistributions of source code must retain the above
8 5635f9ef Antony Chazapis
#      copyright notice, this list of conditions and the following
9 5635f9ef Antony Chazapis
#      disclaimer.
10 5635f9ef Antony Chazapis
# 
11 5635f9ef Antony Chazapis
#   2. Redistributions in binary form must reproduce the above
12 5635f9ef Antony Chazapis
#      copyright notice, this list of conditions and the following
13 5635f9ef Antony Chazapis
#      disclaimer in the documentation and/or other materials
14 5635f9ef Antony Chazapis
#      provided with the distribution.
15 5635f9ef Antony Chazapis
# 
16 5635f9ef Antony Chazapis
# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
17 5635f9ef Antony Chazapis
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 5635f9ef Antony Chazapis
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 5635f9ef Antony Chazapis
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
20 5635f9ef Antony Chazapis
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 5635f9ef Antony Chazapis
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 5635f9ef Antony Chazapis
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
23 5635f9ef Antony Chazapis
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
24 5635f9ef Antony Chazapis
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 5635f9ef Antony Chazapis
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
26 5635f9ef Antony Chazapis
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 5635f9ef Antony Chazapis
# POSSIBILITY OF SUCH DAMAGE.
28 5635f9ef Antony Chazapis
# 
29 5635f9ef Antony Chazapis
# The views and conclusions contained in the software and
30 5635f9ef Antony Chazapis
# documentation are those of the authors and should not be
31 5635f9ef Antony Chazapis
# interpreted as representing official policies, either expressed
32 5635f9ef Antony Chazapis
# or implied, of GRNET S.A.
33 5635f9ef Antony Chazapis
34 228de81b Antony Chazapis
# Default setting for new accounts.
35 228de81b Antony Chazapis
DEFAULT_QUOTA = 0 # No quota.
36 228de81b Antony Chazapis
DEFAULT_VERSIONING = 'auto'
37 228de81b Antony Chazapis
38 228de81b Antony Chazapis
39 cca6c617 Antony Chazapis
class NotAllowedError(Exception):
40 cca6c617 Antony Chazapis
    pass
41 cca6c617 Antony Chazapis
42 5df6c6d1 Antony Chazapis
class QuotaError(Exception):
43 5df6c6d1 Antony Chazapis
    pass
44 5df6c6d1 Antony Chazapis
45 b956618e Antony Chazapis
class BaseBackend(object):
46 22dab079 Antony Chazapis
    """Abstract backend class that serves as a reference for actual implementations.
47 b956618e Antony Chazapis
    
48 b956618e Antony Chazapis
    The purpose of the backend is to provide the necessary functions for handling data
49 b956618e Antony Chazapis
    and metadata. It is responsible for the actual storage and retrieval of information.
50 b956618e Antony Chazapis
    
51 b956618e Antony Chazapis
    Note that the account level is always valid as it is checked from another subsystem.
52 22dab079 Antony Chazapis
    
53 02c0c3fa Antony Chazapis
    When not replacing metadata/groups/policy, keys with empty values should be deleted.
54 a6eb13e9 Antony Chazapis
    
55 22dab079 Antony Chazapis
    The following variables should be available:
56 22dab079 Antony Chazapis
        'hash_algorithm': Suggested is 'sha256'
57 f4b61e0c Antony Chazapis
        
58 22dab079 Antony Chazapis
        'block_size': Suggested is 4MB
59 b2832c6a Antony Chazapis
        
60 b2832c6a Antony Chazapis
        'default_policy': A dictionary with default policy settings
61 b956618e Antony Chazapis
    """
62 b956618e Antony Chazapis
    
63 d14fe290 Antony Chazapis
    def close(self):
64 d14fe290 Antony Chazapis
        """Close the backend connection."""
65 d14fe290 Antony Chazapis
        pass
66 d14fe290 Antony Chazapis
    
67 f6c97079 Antony Chazapis
    def list_accounts(self, user, marker=None, limit=10000):
68 f6c97079 Antony Chazapis
        """Return a list of accounts the user can access.
69 f6c97079 Antony Chazapis
        
70 f6c97079 Antony Chazapis
        Parameters:
71 f6c97079 Antony Chazapis
            'marker': Start list from the next item after 'marker'
72 f4b61e0c Antony Chazapis
            
73 f6c97079 Antony Chazapis
            'limit': Number of containers to return
74 f6c97079 Antony Chazapis
        """
75 f6c97079 Antony Chazapis
        return []
76 f6c97079 Antony Chazapis
    
77 cb69c154 Antony Chazapis
    def get_account_meta(self, user, account, domain, until=None):
78 cb69c154 Antony Chazapis
        """Return a dictionary with the account metadata for the domain.
79 b956618e Antony Chazapis
        
80 b956618e Antony Chazapis
        The keys returned are all user-defined, except:
81 b956618e Antony Chazapis
            'name': The account name
82 f4b61e0c Antony Chazapis
            
83 b956618e Antony Chazapis
            'count': The number of containers (or 0)
84 f4b61e0c Antony Chazapis
            
85 b956618e Antony Chazapis
            'bytes': The total data size (or 0)
86 f4b61e0c Antony Chazapis
            
87 58a6c894 Antony Chazapis
            'modified': Last modification timestamp (overall)
88 f4b61e0c Antony Chazapis
            
89 58a6c894 Antony Chazapis
            'until_timestamp': Last modification until the timestamp provided
90 cca6c617 Antony Chazapis
        
91 cca6c617 Antony Chazapis
        Raises:
92 cca6c617 Antony Chazapis
            NotAllowedError: Operation not permitted
93 b956618e Antony Chazapis
        """
94 b956618e Antony Chazapis
        return {}
95 b956618e Antony Chazapis
    
96 cb69c154 Antony Chazapis
    def update_account_meta(self, user, account, domain, meta, replace=False):
97 cb69c154 Antony Chazapis
        """Update the metadata associated with the account for the domain.
98 b956618e Antony Chazapis
        
99 b956618e Antony Chazapis
        Parameters:
100 cb69c154 Antony Chazapis
            'domain': Metadata domain
101 cb69c154 Antony Chazapis
            
102 b956618e Antony Chazapis
            'meta': Dictionary with metadata to update
103 f4b61e0c Antony Chazapis
            
104 22dab079 Antony Chazapis
            'replace': Replace instead of update
105 cca6c617 Antony Chazapis
        
106 cca6c617 Antony Chazapis
        Raises:
107 cca6c617 Antony Chazapis
            NotAllowedError: Operation not permitted
108 b956618e Antony Chazapis
        """
109 b956618e Antony Chazapis
        return
110 b956618e Antony Chazapis
    
111 02c0c3fa Antony Chazapis
    def get_account_groups(self, user, account):
112 02c0c3fa Antony Chazapis
        """Return a dictionary with the user groups defined for this account.
113 cca6c617 Antony Chazapis
        
114 cca6c617 Antony Chazapis
        Raises:
115 cca6c617 Antony Chazapis
            NotAllowedError: Operation not permitted
116 58a6c894 Antony Chazapis
        """
117 02c0c3fa Antony Chazapis
        return {}
118 58a6c894 Antony Chazapis
    
119 02c0c3fa Antony Chazapis
    def update_account_groups(self, user, account, groups, replace=False):
120 02c0c3fa Antony Chazapis
        """Update the groups associated with the account.
121 83dd59c5 Antony Chazapis
        
122 b956618e Antony Chazapis
        Raises:
123 cca6c617 Antony Chazapis
            NotAllowedError: Operation not permitted
124 f4b61e0c Antony Chazapis
            
125 02c0c3fa Antony Chazapis
            ValueError: Invalid data in groups
126 b956618e Antony Chazapis
        """
127 b956618e Antony Chazapis
        return
128 b956618e Antony Chazapis
    
129 b2832c6a Antony Chazapis
    def get_account_policy(self, user, account):
130 b2832c6a Antony Chazapis
        """Return a dictionary with the account policy.
131 b2832c6a Antony Chazapis
        
132 b2832c6a Antony Chazapis
        The keys returned are:
133 b2832c6a Antony Chazapis
            'quota': The maximum bytes allowed (default is 0 - unlimited)
134 b2832c6a Antony Chazapis
            
135 b2832c6a Antony Chazapis
            'versioning': Can be 'auto', 'manual' or 'none' (default is 'manual')
136 b2832c6a Antony Chazapis
        
137 b2832c6a Antony Chazapis
        Raises:
138 b2832c6a Antony Chazapis
            NotAllowedError: Operation not permitted
139 b2832c6a Antony Chazapis
        """
140 b2832c6a Antony Chazapis
        return {}
141 b2832c6a Antony Chazapis
    
142 b2832c6a Antony Chazapis
    def update_account_policy(self, user, account, policy, replace=False):
143 b2832c6a Antony Chazapis
        """Update the policy associated with the account.
144 b2832c6a Antony Chazapis
        
145 b2832c6a Antony Chazapis
        Raises:
146 b2832c6a Antony Chazapis
            NotAllowedError: Operation not permitted
147 b2832c6a Antony Chazapis
            
148 b2832c6a Antony Chazapis
            ValueError: Invalid policy defined
149 b2832c6a Antony Chazapis
        """
150 b2832c6a Antony Chazapis
        return
151 b2832c6a Antony Chazapis
    
152 1c50a9e5 Sofia Papagiannaki
    def put_account(self, user, account, policy={}):
153 a9b3f29d Antony Chazapis
        """Create a new account with the given name.
154 a9b3f29d Antony Chazapis
        
155 a9b3f29d Antony Chazapis
        Raises:
156 a9b3f29d Antony Chazapis
            NotAllowedError: Operation not permitted
157 b2832c6a Antony Chazapis
            
158 b2832c6a Antony Chazapis
            ValueError: Invalid policy defined
159 a9b3f29d Antony Chazapis
        """
160 a9b3f29d Antony Chazapis
        return
161 a9b3f29d Antony Chazapis
    
162 02c0c3fa Antony Chazapis
    def delete_account(self, user, account):
163 02c0c3fa Antony Chazapis
        """Delete the account with the given name.
164 83dd59c5 Antony Chazapis
        
165 b956618e Antony Chazapis
        Raises:
166 cca6c617 Antony Chazapis
            NotAllowedError: Operation not permitted
167 f4b61e0c Antony Chazapis
            
168 02c0c3fa Antony Chazapis
            IndexError: Account is not empty
169 b956618e Antony Chazapis
        """
170 b956618e Antony Chazapis
        return
171 b956618e Antony Chazapis
    
172 b18ef3ad Antony Chazapis
    def list_containers(self, user, account, marker=None, limit=10000, shared=False, until=None):
173 f6c97079 Antony Chazapis
        """Return a list of container names existing under an account.
174 02c0c3fa Antony Chazapis
        
175 02c0c3fa Antony Chazapis
        Parameters:
176 02c0c3fa Antony Chazapis
            'marker': Start list from the next item after 'marker'
177 f4b61e0c Antony Chazapis
            
178 02c0c3fa Antony Chazapis
            'limit': Number of containers to return
179 f4b61e0c Antony Chazapis
            
180 b18ef3ad Antony Chazapis
            'shared': Only list containers with permissions set
181 f4b61e0c Antony Chazapis
            
182 02c0c3fa Antony Chazapis
        
183 02c0c3fa Antony Chazapis
        Raises:
184 02c0c3fa Antony Chazapis
            NotAllowedError: Operation not permitted
185 02c0c3fa Antony Chazapis
        """
186 02c0c3fa Antony Chazapis
        return []
187 02c0c3fa Antony Chazapis
    
188 cb69c154 Antony Chazapis
    def get_container_meta(self, user, account, container, domain, until=None):
189 cb69c154 Antony Chazapis
        """Return a dictionary with the container metadata for the domain.
190 83dd59c5 Antony Chazapis
        
191 b956618e Antony Chazapis
        The keys returned are all user-defined, except:
192 b956618e Antony Chazapis
            'name': The container name
193 f4b61e0c Antony Chazapis
            
194 b956618e Antony Chazapis
            'count': The number of objects
195 f4b61e0c Antony Chazapis
            
196 b956618e Antony Chazapis
            'bytes': The total data size
197 f4b61e0c Antony Chazapis
            
198 58a6c894 Antony Chazapis
            'modified': Last modification timestamp (overall)
199 f4b61e0c Antony Chazapis
            
200 58a6c894 Antony Chazapis
            'until_timestamp': Last modification until the timestamp provided
201 b956618e Antony Chazapis
        
202 b956618e Antony Chazapis
        Raises:
203 cca6c617 Antony Chazapis
            NotAllowedError: Operation not permitted
204 f4b61e0c Antony Chazapis
            
205 b956618e Antony Chazapis
            NameError: Container does not exist
206 b956618e Antony Chazapis
        """
207 b956618e Antony Chazapis
        return {}
208 b956618e Antony Chazapis
    
209 cb69c154 Antony Chazapis
    def update_container_meta(self, user, account, container, domain, meta, replace=False):
210 cb69c154 Antony Chazapis
        """Update the metadata associated with the container for the domain.
211 b956618e Antony Chazapis
        
212 b956618e Antony Chazapis
        Parameters:
213 cb69c154 Antony Chazapis
            'domain': Metadata domain
214 cb69c154 Antony Chazapis
            
215 b956618e Antony Chazapis
            'meta': Dictionary with metadata to update
216 f4b61e0c Antony Chazapis
            
217 22dab079 Antony Chazapis
            'replace': Replace instead of update
218 b956618e Antony Chazapis
        
219 b956618e Antony Chazapis
        Raises:
220 cca6c617 Antony Chazapis
            NotAllowedError: Operation not permitted
221 f4b61e0c Antony Chazapis
            
222 b956618e Antony Chazapis
            NameError: Container does not exist
223 b956618e Antony Chazapis
        """
224 b956618e Antony Chazapis
        return
225 b956618e Antony Chazapis
    
226 02c0c3fa Antony Chazapis
    def get_container_policy(self, user, account, container):
227 02c0c3fa Antony Chazapis
        """Return a dictionary with the container policy.
228 02c0c3fa Antony Chazapis
        
229 02c0c3fa Antony Chazapis
        The keys returned are:
230 02c0c3fa Antony Chazapis
            'quota': The maximum bytes allowed (default is 0 - unlimited)
231 f4b61e0c Antony Chazapis
            
232 02c0c3fa Antony Chazapis
            'versioning': Can be 'auto', 'manual' or 'none' (default is 'manual')
233 02c0c3fa Antony Chazapis
        
234 02c0c3fa Antony Chazapis
        Raises:
235 02c0c3fa Antony Chazapis
            NotAllowedError: Operation not permitted
236 f4b61e0c Antony Chazapis
            
237 02c0c3fa Antony Chazapis
            NameError: Container does not exist
238 02c0c3fa Antony Chazapis
        """
239 02c0c3fa Antony Chazapis
        return {}
240 02c0c3fa Antony Chazapis
    
241 02c0c3fa Antony Chazapis
    def update_container_policy(self, user, account, container, policy, replace=False):
242 b2832c6a Antony Chazapis
        """Update the policy associated with the container.
243 02c0c3fa Antony Chazapis
        
244 02c0c3fa Antony Chazapis
        Raises:
245 02c0c3fa Antony Chazapis
            NotAllowedError: Operation not permitted
246 f4b61e0c Antony Chazapis
            
247 02c0c3fa Antony Chazapis
            NameError: Container does not exist
248 f4b61e0c Antony Chazapis
            
249 02c0c3fa Antony Chazapis
            ValueError: Invalid policy defined
250 02c0c3fa Antony Chazapis
        """
251 02c0c3fa Antony Chazapis
        return
252 02c0c3fa Antony Chazapis
    
253 1c50a9e5 Sofia Papagiannaki
    def put_container(self, user, account, container, policy={}):
254 02c0c3fa Antony Chazapis
        """Create a new container with the given name.
255 02c0c3fa Antony Chazapis
        
256 02c0c3fa Antony Chazapis
        Raises:
257 02c0c3fa Antony Chazapis
            NotAllowedError: Operation not permitted
258 f4b61e0c Antony Chazapis
            
259 02c0c3fa Antony Chazapis
            NameError: Container already exists
260 f4b61e0c Antony Chazapis
            
261 02c0c3fa Antony Chazapis
            ValueError: Invalid policy defined
262 02c0c3fa Antony Chazapis
        """
263 02c0c3fa Antony Chazapis
        return
264 02c0c3fa Antony Chazapis
    
265 84846143 Antony Chazapis
    def delete_container(self, user, account, container, until=None):
266 84846143 Antony Chazapis
        """Delete/purge the container with the given name.
267 02c0c3fa Antony Chazapis
        
268 02c0c3fa Antony Chazapis
        Raises:
269 02c0c3fa Antony Chazapis
            NotAllowedError: Operation not permitted
270 f4b61e0c Antony Chazapis
            
271 02c0c3fa Antony Chazapis
            NameError: Container does not exist
272 f4b61e0c Antony Chazapis
            
273 02c0c3fa Antony Chazapis
            IndexError: Container is not empty
274 02c0c3fa Antony Chazapis
        """
275 02c0c3fa Antony Chazapis
        return
276 02c0c3fa Antony Chazapis
    
277 7ff57991 Antony Chazapis
    def list_objects(self, user, account, container, prefix='', delimiter=None, marker=None, limit=10000, virtual=True, domain=None, keys=[], shared=False, until=None, size_range=None):
278 58a6c894 Antony Chazapis
        """Return a list of object (name, version_id) tuples existing under a container.
279 b956618e Antony Chazapis
        
280 b956618e Antony Chazapis
        Parameters:
281 b956618e Antony Chazapis
            'prefix': List objects starting with 'prefix'
282 f4b61e0c Antony Chazapis
            
283 b956618e Antony Chazapis
            'delimiter': Return unique names before 'delimiter' and after 'prefix'
284 f4b61e0c Antony Chazapis
            
285 b956618e Antony Chazapis
            'marker': Start list from the next item after 'marker'
286 f4b61e0c Antony Chazapis
            
287 b956618e Antony Chazapis
            'limit': Number of objects to return
288 f4b61e0c Antony Chazapis
            
289 f4b61e0c Antony Chazapis
            'virtual': If not set, the result will only include names starting
290 f4b61e0c Antony Chazapis
                       with 'prefix' and ending without a 'delimiter' or with
291 f4b61e0c Antony Chazapis
                       the first occurance of the 'delimiter' after 'prefix'.
292 f4b61e0c Antony Chazapis
                       If set, the result will include all names after 'prefix',
293 3f839f59 Antony Chazapis
                       up to and including the 'delimiter' if it is found
294 f4b61e0c Antony Chazapis
            
295 cb69c154 Antony Chazapis
            'domain': Metadata domain for keys
296 cb69c154 Antony Chazapis
            
297 95d47e1a Antony Chazapis
            'keys': Include objects that satisfy the key queries in the list.
298 95d47e1a Antony Chazapis
                    Use 'key', '!key' for existence queries, 'key op value' for
299 4e5673a0 Antony Chazapis
                    value queries, where 'op' can be one of =, !=, <=, >=, <, >
300 f4b61e0c Antony Chazapis
            
301 b18ef3ad Antony Chazapis
            'shared': Only list objects with permissions set
302 7ff57991 Antony Chazapis
             
303 7ff57991 Antony Chazapis
            'size_range': Include objects with byte size in (from, to).
304 7ff57991 Antony Chazapis
                          Use None to specify unlimited
305 22dab079 Antony Chazapis
        
306 22dab079 Antony Chazapis
        Raises:
307 cca6c617 Antony Chazapis
            NotAllowedError: Operation not permitted
308 f4b61e0c Antony Chazapis
            
309 22dab079 Antony Chazapis
            NameError: Container does not exist
310 22dab079 Antony Chazapis
        """
311 22dab079 Antony Chazapis
        return []
312 22dab079 Antony Chazapis
    
313 cb69c154 Antony Chazapis
    def list_object_meta(self, user, account, container, domain, until=None):
314 cb69c154 Antony Chazapis
        """Return a list with all the container's object meta keys for the domain.
315 b956618e Antony Chazapis
        
316 b956618e Antony Chazapis
        Raises:
317 cca6c617 Antony Chazapis
            NotAllowedError: Operation not permitted
318 f4b61e0c Antony Chazapis
            
319 b956618e Antony Chazapis
            NameError: Container does not exist
320 b956618e Antony Chazapis
        """
321 b956618e Antony Chazapis
        return []
322 b956618e Antony Chazapis
    
323 cb69c154 Antony Chazapis
    def get_object_meta(self, user, account, container, name, domain, version=None):
324 cb69c154 Antony Chazapis
        """Return a dictionary with the object metadata for the domain.
325 b956618e Antony Chazapis
        
326 b956618e Antony Chazapis
        The keys returned are all user-defined, except:
327 58a6c894 Antony Chazapis
            'name': The object name
328 f4b61e0c Antony Chazapis
            
329 b956618e Antony Chazapis
            'bytes': The total data size
330 f4b61e0c Antony Chazapis
            
331 4a1c29ea Antony Chazapis
            'hash': The hashmap hash
332 4a1c29ea Antony Chazapis
            
333 58a6c894 Antony Chazapis
            'modified': Last modification timestamp (overall)
334 f4b61e0c Antony Chazapis
            
335 104626e3 Antony Chazapis
            'modified_by': The user that committed the object (version requested)
336 f4b61e0c Antony Chazapis
            
337 58a6c894 Antony Chazapis
            'version': The version identifier
338 f4b61e0c Antony Chazapis
            
339 58a6c894 Antony Chazapis
            'version_timestamp': The version's modification timestamp
340 25ae8b75 Antony Chazapis
            
341 25ae8b75 Antony Chazapis
            'uuid': A unique identifier that persists data or metadata updates and renames
342 b956618e Antony Chazapis
        
343 b956618e Antony Chazapis
        Raises:
344 cca6c617 Antony Chazapis
            NotAllowedError: Operation not permitted
345 f4b61e0c Antony Chazapis
            
346 b956618e Antony Chazapis
            NameError: Container/object does not exist
347 f4b61e0c Antony Chazapis
            
348 58a6c894 Antony Chazapis
            IndexError: Version does not exist
349 b956618e Antony Chazapis
        """
350 b956618e Antony Chazapis
        return {}
351 b956618e Antony Chazapis
    
352 cb69c154 Antony Chazapis
    def update_object_meta(self, user, account, container, name, domain, meta, replace=False):
353 cb69c154 Antony Chazapis
        """Update the metadata associated with the object for the domain and return the new version.
354 b956618e Antony Chazapis
        
355 b956618e Antony Chazapis
        Parameters:
356 cb69c154 Antony Chazapis
            'domain': Metadata domain
357 cb69c154 Antony Chazapis
            
358 a6eb13e9 Antony Chazapis
            'meta': Dictionary with metadata to update
359 f4b61e0c Antony Chazapis
            
360 22dab079 Antony Chazapis
            'replace': Replace instead of update
361 b956618e Antony Chazapis
        
362 b956618e Antony Chazapis
        Raises:
363 cca6c617 Antony Chazapis
            NotAllowedError: Operation not permitted
364 f4b61e0c Antony Chazapis
            
365 b956618e Antony Chazapis
            NameError: Container/object does not exist
366 b956618e Antony Chazapis
        """
367 02c4d2ba Antony Chazapis
        return ''
368 b956618e Antony Chazapis
    
369 3436eeb0 Antony Chazapis
    def get_object_permissions(self, user, account, container, name):
370 067cf1fc Antony Chazapis
        """Return the action allowed on the object, the path
371 067cf1fc Antony Chazapis
        from which the object gets its permissions from,
372 cca6c617 Antony Chazapis
        along with a dictionary containing the permissions.
373 3436eeb0 Antony Chazapis
        
374 067cf1fc Antony Chazapis
        The dictionary keys are (also used for defining the action):
375 3436eeb0 Antony Chazapis
            'read': The object is readable by the users/groups in the list
376 f4b61e0c Antony Chazapis
            
377 3436eeb0 Antony Chazapis
            'write': The object is writable by the users/groups in the list
378 3436eeb0 Antony Chazapis
        
379 3436eeb0 Antony Chazapis
        Raises:
380 cca6c617 Antony Chazapis
            NotAllowedError: Operation not permitted
381 f4b61e0c Antony Chazapis
            
382 3436eeb0 Antony Chazapis
            NameError: Container/object does not exist
383 3436eeb0 Antony Chazapis
        """
384 3436eeb0 Antony Chazapis
        return {}
385 3436eeb0 Antony Chazapis
    
386 3436eeb0 Antony Chazapis
    def update_object_permissions(self, user, account, container, name, permissions):
387 3436eeb0 Antony Chazapis
        """Update the permissions associated with the object.
388 3436eeb0 Antony Chazapis
        
389 3436eeb0 Antony Chazapis
        Parameters:
390 3436eeb0 Antony Chazapis
            'permissions': Dictionary with permissions to update
391 3436eeb0 Antony Chazapis
        
392 3436eeb0 Antony Chazapis
        Raises:
393 cca6c617 Antony Chazapis
            NotAllowedError: Operation not permitted
394 f4b61e0c Antony Chazapis
            
395 3436eeb0 Antony Chazapis
            NameError: Container/object does not exist
396 f4b61e0c Antony Chazapis
            
397 3436eeb0 Antony Chazapis
            ValueError: Invalid users/groups in permissions
398 f4b61e0c Antony Chazapis
            
399 f4b61e0c Antony Chazapis
            AttributeError: Can not set permissions, as this object
400 f4b61e0c Antony Chazapis
                is already shared/private by another object higher
401 f4b61e0c Antony Chazapis
                in the hierarchy, or setting permissions here will
402 3436eeb0 Antony Chazapis
                invalidate other permissions deeper in the hierarchy
403 3436eeb0 Antony Chazapis
        """
404 3436eeb0 Antony Chazapis
        return
405 3436eeb0 Antony Chazapis
    
406 02c0c3fa Antony Chazapis
    def get_object_public(self, user, account, container, name):
407 bb4eafc6 Antony Chazapis
        """Return the public id of the object if applicable.
408 02c0c3fa Antony Chazapis
        
409 02c0c3fa Antony Chazapis
        Raises:
410 02c0c3fa Antony Chazapis
            NotAllowedError: Operation not permitted
411 f4b61e0c Antony Chazapis
            
412 02c0c3fa Antony Chazapis
            NameError: Container/object does not exist
413 02c0c3fa Antony Chazapis
        """
414 02c0c3fa Antony Chazapis
        return None
415 02c0c3fa Antony Chazapis
    
416 02c0c3fa Antony Chazapis
    def update_object_public(self, user, account, container, name, public):
417 02c0c3fa Antony Chazapis
        """Update the public status of the object.
418 02c0c3fa Antony Chazapis
        
419 02c0c3fa Antony Chazapis
        Parameters:
420 02c0c3fa Antony Chazapis
            'public': Boolean value
421 02c0c3fa Antony Chazapis
        
422 02c0c3fa Antony Chazapis
        Raises:
423 02c0c3fa Antony Chazapis
            NotAllowedError: Operation not permitted
424 f4b61e0c Antony Chazapis
            
425 02c0c3fa Antony Chazapis
            NameError: Container/object does not exist
426 02c0c3fa Antony Chazapis
        """
427 02c0c3fa Antony Chazapis
        return
428 02c0c3fa Antony Chazapis
    
429 83dd59c5 Antony Chazapis
    def get_object_hashmap(self, user, account, container, name, version=None):
430 22dab079 Antony Chazapis
        """Return the object's size and a list with partial hashes.
431 b956618e Antony Chazapis
        
432 b956618e Antony Chazapis
        Raises:
433 cca6c617 Antony Chazapis
            NotAllowedError: Operation not permitted
434 f4b61e0c Antony Chazapis
            
435 b956618e Antony Chazapis
            NameError: Container/object does not exist
436 f4b61e0c Antony Chazapis
            
437 22dab079 Antony Chazapis
            IndexError: Version does not exist
438 b956618e Antony Chazapis
        """
439 22dab079 Antony Chazapis
        return 0, []
440 b956618e Antony Chazapis
    
441 cb69c154 Antony Chazapis
    def update_object_hashmap(self, user, account, container, name, size, hashmap, domain, meta={}, replace_meta=False, permissions=None):
442 02c4d2ba Antony Chazapis
        """Create/update an object with the specified size and partial hashes and return the new version.
443 b956618e Antony Chazapis
        
444 3436eeb0 Antony Chazapis
        Parameters:
445 cb69c154 Antony Chazapis
            'domain': Metadata domain
446 cb69c154 Antony Chazapis
            
447 cb69c154 Antony Chazapis
            'meta': Dictionary with metadata to change
448 f4b61e0c Antony Chazapis
            
449 3436eeb0 Antony Chazapis
            'replace_meta': Replace metadata instead of update
450 f4b61e0c Antony Chazapis
            
451 3436eeb0 Antony Chazapis
            'permissions': Updated object permissions
452 3436eeb0 Antony Chazapis
        
453 b956618e Antony Chazapis
        Raises:
454 cca6c617 Antony Chazapis
            NotAllowedError: Operation not permitted
455 f4b61e0c Antony Chazapis
            
456 58a6c894 Antony Chazapis
            NameError: Container does not exist
457 f4b61e0c Antony Chazapis
            
458 3436eeb0 Antony Chazapis
            ValueError: Invalid users/groups in permissions
459 f4b61e0c Antony Chazapis
            
460 3436eeb0 Antony Chazapis
            AttributeError: Can not set permissions
461 5df6c6d1 Antony Chazapis
            
462 5df6c6d1 Antony Chazapis
            QuotaError: Account or container quota exceeded
463 b956618e Antony Chazapis
        """
464 02c4d2ba Antony Chazapis
        return ''
465 b956618e Antony Chazapis
    
466 cb69c154 Antony Chazapis
    def copy_object(self, user, src_account, src_container, src_name, dest_account, dest_container, dest_name, domain, meta={}, replace_meta=False, permissions=None, src_version=None):
467 02c4d2ba Antony Chazapis
        """Copy an object's data and metadata and return the new version.
468 b956618e Antony Chazapis
        
469 b956618e Antony Chazapis
        Parameters:
470 cb69c154 Antony Chazapis
            'domain': Metadata domain
471 cb69c154 Antony Chazapis
            
472 cb69c154 Antony Chazapis
            'meta': Dictionary with metadata to change from source to destination
473 f4b61e0c Antony Chazapis
            
474 22dab079 Antony Chazapis
            'replace_meta': Replace metadata instead of update
475 f4b61e0c Antony Chazapis
            
476 3436eeb0 Antony Chazapis
            'permissions': New object permissions
477 f4b61e0c Antony Chazapis
            
478 3436eeb0 Antony Chazapis
            'src_version': Copy from the version provided
479 b956618e Antony Chazapis
        
480 b956618e Antony Chazapis
        Raises:
481 cca6c617 Antony Chazapis
            NotAllowedError: Operation not permitted
482 f4b61e0c Antony Chazapis
            
483 b956618e Antony Chazapis
            NameError: Container/object does not exist
484 f4b61e0c Antony Chazapis
            
485 58a6c894 Antony Chazapis
            IndexError: Version does not exist
486 f4b61e0c Antony Chazapis
            
487 3436eeb0 Antony Chazapis
            ValueError: Invalid users/groups in permissions
488 f4b61e0c Antony Chazapis
            
489 3436eeb0 Antony Chazapis
            AttributeError: Can not set permissions
490 5df6c6d1 Antony Chazapis
            
491 5df6c6d1 Antony Chazapis
            QuotaError: Account or container quota exceeded
492 b956618e Antony Chazapis
        """
493 02c4d2ba Antony Chazapis
        return ''
494 b956618e Antony Chazapis
    
495 cb69c154 Antony Chazapis
    def move_object(self, user, src_account, src_container, src_name, dest_account, dest_container, dest_name, domain, meta={}, replace_meta=False, permissions=None):
496 02c4d2ba Antony Chazapis
        """Move an object's data and metadata and return the new version.
497 b956618e Antony Chazapis
        
498 b956618e Antony Chazapis
        Parameters:
499 cb69c154 Antony Chazapis
            'domain': Metadata domain
500 cb69c154 Antony Chazapis
            
501 cb69c154 Antony Chazapis
            'meta': Dictionary with metadata to change from source to destination
502 f4b61e0c Antony Chazapis
            
503 22dab079 Antony Chazapis
            'replace_meta': Replace metadata instead of update
504 f4b61e0c Antony Chazapis
            
505 3436eeb0 Antony Chazapis
            'permissions': New object permissions
506 b956618e Antony Chazapis
        
507 b956618e Antony Chazapis
        Raises:
508 cca6c617 Antony Chazapis
            NotAllowedError: Operation not permitted
509 f4b61e0c Antony Chazapis
            
510 b956618e Antony Chazapis
            NameError: Container/object does not exist
511 f4b61e0c Antony Chazapis
            
512 3436eeb0 Antony Chazapis
            ValueError: Invalid users/groups in permissions
513 f4b61e0c Antony Chazapis
            
514 3436eeb0 Antony Chazapis
            AttributeError: Can not set permissions
515 5df6c6d1 Antony Chazapis
            
516 5df6c6d1 Antony Chazapis
            QuotaError: Account or container quota exceeded
517 b956618e Antony Chazapis
        """
518 02c4d2ba Antony Chazapis
        return ''
519 b956618e Antony Chazapis
    
520 84846143 Antony Chazapis
    def delete_object(self, user, account, container, name, until=None):
521 84846143 Antony Chazapis
        """Delete/purge an object.
522 b956618e Antony Chazapis
        
523 b956618e Antony Chazapis
        Raises:
524 cca6c617 Antony Chazapis
            NotAllowedError: Operation not permitted
525 f4b61e0c Antony Chazapis
            
526 b956618e Antony Chazapis
            NameError: Container/object does not exist
527 b956618e Antony Chazapis
        """
528 b956618e Antony Chazapis
        return
529 22dab079 Antony Chazapis
    
530 83dd59c5 Antony Chazapis
    def list_versions(self, user, account, container, name):
531 cca6c617 Antony Chazapis
        """Return a list of all (version, version_timestamp) tuples for an object.
532 cca6c617 Antony Chazapis
        
533 cca6c617 Antony Chazapis
        Raises:
534 cca6c617 Antony Chazapis
            NotAllowedError: Operation not permitted
535 cca6c617 Antony Chazapis
        """
536 58a6c894 Antony Chazapis
        return []
537 58a6c894 Antony Chazapis
    
538 37bee317 Antony Chazapis
    def get_uuid(self, user, uuid):
539 37bee317 Antony Chazapis
        """Return the (account, container, name) for the UUID given.
540 37bee317 Antony Chazapis
        
541 37bee317 Antony Chazapis
        Raises:
542 37bee317 Antony Chazapis
            NotAllowedError: Operation not permitted
543 37bee317 Antony Chazapis
            
544 37bee317 Antony Chazapis
            NameError: UUID does not exist
545 37bee317 Antony Chazapis
        """
546 37bee317 Antony Chazapis
        return None
547 37bee317 Antony Chazapis
    
548 bb4eafc6 Antony Chazapis
    def get_public(self, user, public):
549 bb4eafc6 Antony Chazapis
        """Return the (account, container, name) for the public id given.
550 bb4eafc6 Antony Chazapis
        
551 bb4eafc6 Antony Chazapis
        Raises:
552 bb4eafc6 Antony Chazapis
            NotAllowedError: Operation not permitted
553 bb4eafc6 Antony Chazapis
            
554 bb4eafc6 Antony Chazapis
            NameError: Public id does not exist
555 bb4eafc6 Antony Chazapis
        """
556 bb4eafc6 Antony Chazapis
        return None
557 bb4eafc6 Antony Chazapis
    
558 22dab079 Antony Chazapis
    def get_block(self, hash):
559 22dab079 Antony Chazapis
        """Return a block's data.
560 22dab079 Antony Chazapis
        
561 22dab079 Antony Chazapis
        Raises:
562 22dab079 Antony Chazapis
            NameError: Block does not exist
563 22dab079 Antony Chazapis
        """
564 22dab079 Antony Chazapis
        return ''
565 22dab079 Antony Chazapis
    
566 22dab079 Antony Chazapis
    def put_block(self, data):
567 22dab079 Antony Chazapis
        """Store a block and return the hash."""
568 22dab079 Antony Chazapis
        return 0
569 22dab079 Antony Chazapis
    
570 22dab079 Antony Chazapis
    def update_block(self, hash, data, offset=0):
571 22dab079 Antony Chazapis
        """Update a known block and return the hash.
572 22dab079 Antony Chazapis
        
573 22dab079 Antony Chazapis
        Raises:
574 22dab079 Antony Chazapis
            IndexError: Offset or data outside block limits
575 22dab079 Antony Chazapis
        """
576 22dab079 Antony Chazapis
        return 0