Statistics
| Branch: | Tag: | Revision:

root / snf-pithos-backend / pithos / backends / base.py @ 4a7b190f

History | View | Annotate | Download (21.1 kB)

1 2e662088 Antony Chazapis
# Copyright 2011-2012 GRNET S.A. All rights reserved.
2 d50ed8d4 Sofia Papagiannaki
#
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 d50ed8d4 Sofia Papagiannaki
#
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 d50ed8d4 Sofia Papagiannaki
#
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 d50ed8d4 Sofia Papagiannaki
#
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 d50ed8d4 Sofia Papagiannaki
#
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 19ddd41b Sofia Papagiannaki
DEFAULT_ACCOUNT_QUOTA = 0  # No quota.
36 19ddd41b Sofia Papagiannaki
DEFAULT_CONTAINER_QUOTA = 0  # No quota.
37 19ddd41b Sofia Papagiannaki
DEFAULT_CONTAINER_VERSIONING = 'auto'
38 228de81b Antony Chazapis
39 228de81b Antony Chazapis
40 cca6c617 Antony Chazapis
class NotAllowedError(Exception):
41 cca6c617 Antony Chazapis
    pass
42 cca6c617 Antony Chazapis
43 d50ed8d4 Sofia Papagiannaki
44 5df6c6d1 Antony Chazapis
class QuotaError(Exception):
45 5df6c6d1 Antony Chazapis
    pass
46 5df6c6d1 Antony Chazapis
47 d50ed8d4 Sofia Papagiannaki
48 7efc9f86 Sofia Papagiannaki
class AccountExists(NameError):
49 7efc9f86 Sofia Papagiannaki
    pass
50 d50ed8d4 Sofia Papagiannaki
51 d50ed8d4 Sofia Papagiannaki
52 7efc9f86 Sofia Papagiannaki
class ContainerExists(NameError):
53 7efc9f86 Sofia Papagiannaki
    pass
54 7efc9f86 Sofia Papagiannaki
55 d50ed8d4 Sofia Papagiannaki
56 7efc9f86 Sofia Papagiannaki
class AccountNotEmpty(IndexError):
57 7efc9f86 Sofia Papagiannaki
    pass
58 7efc9f86 Sofia Papagiannaki
59 d50ed8d4 Sofia Papagiannaki
60 7efc9f86 Sofia Papagiannaki
class ContainerNotEmpty(IndexError):
61 7efc9f86 Sofia Papagiannaki
    pass
62 7efc9f86 Sofia Papagiannaki
63 d50ed8d4 Sofia Papagiannaki
64 7efc9f86 Sofia Papagiannaki
class ItemNotExists(NameError):
65 7efc9f86 Sofia Papagiannaki
    pass
66 7efc9f86 Sofia Papagiannaki
67 d50ed8d4 Sofia Papagiannaki
68 7efc9f86 Sofia Papagiannaki
class VersionNotExists(IndexError):
69 7efc9f86 Sofia Papagiannaki
    pass
70 7efc9f86 Sofia Papagiannaki
71 3a5994a8 Sofia Papagiannaki
class InvalidHash(TypeError):
72 3a5994a8 Sofia Papagiannaki
    pass
73 d50ed8d4 Sofia Papagiannaki
74 8ee4ec50 Vangelis Koukis
class BaseBackend(object):
75 29148653 Sofia Papagiannaki
    """Abstract backend class.
76 29148653 Sofia Papagiannaki

77 29148653 Sofia Papagiannaki
    This class serves as a reference for actual implementations.
78 d50ed8d4 Sofia Papagiannaki

79 29148653 Sofia Papagiannaki
    The purpose of the backend is to provide the necessary functions
80 29148653 Sofia Papagiannaki
    for handling data and metadata.
81 d50ed8d4 Sofia Papagiannaki

82 29148653 Sofia Papagiannaki
    It is responsible for the actual storage and retrieval of information.
83 d50ed8d4 Sofia Papagiannaki

84 29148653 Sofia Papagiannaki
    Note that the account level is always valid as it is checked
85 29148653 Sofia Papagiannaki
    from another subsystem.
86 29148653 Sofia Papagiannaki

87 29148653 Sofia Papagiannaki
    When not replacing metadata/groups/policy, keys with empty values
88 29148653 Sofia Papagiannaki
    should be deleted.
89 d50ed8d4 Sofia Papagiannaki

90 22dab079 Antony Chazapis
    The following variables should be available:
91 22dab079 Antony Chazapis
        'hash_algorithm': Suggested is 'sha256'
92 d50ed8d4 Sofia Papagiannaki

93 22dab079 Antony Chazapis
        'block_size': Suggested is 4MB
94 d50ed8d4 Sofia Papagiannaki

95 29148653 Sofia Papagiannaki
        'default_account_policy': A dictionary with default account policy
96 29148653 Sofia Papagiannaki
                                  settings
97 29148653 Sofia Papagiannaki
        'default_container_policy': A dictionary with default container policy
98 29148653 Sofia Papagiannaki
                                    settings
99 b956618e Antony Chazapis
    """
100 d50ed8d4 Sofia Papagiannaki
101 d14fe290 Antony Chazapis
    def close(self):
102 d14fe290 Antony Chazapis
        """Close the backend connection."""
103 d14fe290 Antony Chazapis
        pass
104 d50ed8d4 Sofia Papagiannaki
105 f6c97079 Antony Chazapis
    def list_accounts(self, user, marker=None, limit=10000):
106 f6c97079 Antony Chazapis
        """Return a list of accounts the user can access.
107 d50ed8d4 Sofia Papagiannaki

108 29148653 Sofia Papagiannaki
        Keyword arguments:
109 f6c97079 Antony Chazapis
            'marker': Start list from the next item after 'marker'
110 d50ed8d4 Sofia Papagiannaki

111 f6c97079 Antony Chazapis
            'limit': Number of containers to return
112 f6c97079 Antony Chazapis
        """
113 f6c97079 Antony Chazapis
        return []
114 d50ed8d4 Sofia Papagiannaki
115 29148653 Sofia Papagiannaki
    def get_account_meta(self, user, account, domain, until=None,
116 29148653 Sofia Papagiannaki
                         include_user_defined=True, external_quota=None):
117 cb69c154 Antony Chazapis
        """Return a dictionary with the account metadata for the domain.
118 d50ed8d4 Sofia Papagiannaki

119 b956618e Antony Chazapis
        The keys returned are all user-defined, except:
120 b956618e Antony Chazapis
            'name': The account name
121 d50ed8d4 Sofia Papagiannaki

122 b956618e Antony Chazapis
            'count': The number of containers (or 0)
123 d50ed8d4 Sofia Papagiannaki

124 b956618e Antony Chazapis
            'bytes': The total data size (or 0)
125 d50ed8d4 Sofia Papagiannaki

126 58a6c894 Antony Chazapis
            'modified': Last modification timestamp (overall)
127 d50ed8d4 Sofia Papagiannaki

128 58a6c894 Antony Chazapis
            'until_timestamp': Last modification until the timestamp provided
129 d50ed8d4 Sofia Papagiannaki

130 29148653 Sofia Papagiannaki
            'external_quota': The quota computed from external quota holder
131 29148653 Sofia Papagiannaki
                              mechanism
132 29148653 Sofia Papagiannaki

133 cca6c617 Antony Chazapis
        Raises:
134 cca6c617 Antony Chazapis
            NotAllowedError: Operation not permitted
135 b956618e Antony Chazapis
        """
136 b956618e Antony Chazapis
        return {}
137 d50ed8d4 Sofia Papagiannaki
138 cb69c154 Antony Chazapis
    def update_account_meta(self, user, account, domain, meta, replace=False):
139 cb69c154 Antony Chazapis
        """Update the metadata associated with the account for the domain.
140 d50ed8d4 Sofia Papagiannaki

141 b956618e Antony Chazapis
        Parameters:
142 cb69c154 Antony Chazapis
            'domain': Metadata domain
143 d50ed8d4 Sofia Papagiannaki

144 29148653 Sofia Papagiannaki
        Keyword arguments:
145 b956618e Antony Chazapis
            'meta': Dictionary with metadata to update
146 d50ed8d4 Sofia Papagiannaki

147 22dab079 Antony Chazapis
            'replace': Replace instead of update
148 d50ed8d4 Sofia Papagiannaki

149 cca6c617 Antony Chazapis
        Raises:
150 cca6c617 Antony Chazapis
            NotAllowedError: Operation not permitted
151 b956618e Antony Chazapis
        """
152 b956618e Antony Chazapis
        return
153 d50ed8d4 Sofia Papagiannaki
154 02c0c3fa Antony Chazapis
    def get_account_groups(self, user, account):
155 29148653 Sofia Papagiannaki
        """Return a dictionary with the user groups defined for the account.
156 d50ed8d4 Sofia Papagiannaki

157 cca6c617 Antony Chazapis
        Raises:
158 cca6c617 Antony Chazapis
            NotAllowedError: Operation not permitted
159 58a6c894 Antony Chazapis
        """
160 02c0c3fa Antony Chazapis
        return {}
161 d50ed8d4 Sofia Papagiannaki
162 02c0c3fa Antony Chazapis
    def update_account_groups(self, user, account, groups, replace=False):
163 02c0c3fa Antony Chazapis
        """Update the groups associated with the account.
164 d50ed8d4 Sofia Papagiannaki

165 b956618e Antony Chazapis
        Raises:
166 cca6c617 Antony Chazapis
            NotAllowedError: Operation not permitted
167 d50ed8d4 Sofia Papagiannaki

168 02c0c3fa Antony Chazapis
            ValueError: Invalid data in groups
169 b956618e Antony Chazapis
        """
170 b956618e Antony Chazapis
        return
171 d50ed8d4 Sofia Papagiannaki
172 b2832c6a Antony Chazapis
    def get_account_policy(self, user, account):
173 b2832c6a Antony Chazapis
        """Return a dictionary with the account policy.
174 d50ed8d4 Sofia Papagiannaki

175 b2832c6a Antony Chazapis
        The keys returned are:
176 b2832c6a Antony Chazapis
            'quota': The maximum bytes allowed (default is 0 - unlimited)
177 d50ed8d4 Sofia Papagiannaki

178 29148653 Sofia Papagiannaki
            'versioning': Can be 'auto', 'manual' or 'none' (default: 'manual')
179 d50ed8d4 Sofia Papagiannaki

180 b2832c6a Antony Chazapis
        Raises:
181 b2832c6a Antony Chazapis
            NotAllowedError: Operation not permitted
182 b2832c6a Antony Chazapis
        """
183 b2832c6a Antony Chazapis
        return {}
184 d50ed8d4 Sofia Papagiannaki
185 b2832c6a Antony Chazapis
    def update_account_policy(self, user, account, policy, replace=False):
186 b2832c6a Antony Chazapis
        """Update the policy associated with the account.
187 d50ed8d4 Sofia Papagiannaki

188 b2832c6a Antony Chazapis
        Raises:
189 b2832c6a Antony Chazapis
            NotAllowedError: Operation not permitted
190 d50ed8d4 Sofia Papagiannaki

191 b2832c6a Antony Chazapis
            ValueError: Invalid policy defined
192 b2832c6a Antony Chazapis
        """
193 b2832c6a Antony Chazapis
        return
194 d50ed8d4 Sofia Papagiannaki
195 78348987 Sofia Papagiannaki
    def put_account(self, user, account, policy=None):
196 a9b3f29d Antony Chazapis
        """Create a new account with the given name.
197 d50ed8d4 Sofia Papagiannaki

198 a9b3f29d Antony Chazapis
        Raises:
199 a9b3f29d Antony Chazapis
            NotAllowedError: Operation not permitted
200 d50ed8d4 Sofia Papagiannaki

201 b2832c6a Antony Chazapis
            ValueError: Invalid policy defined
202 a9b3f29d Antony Chazapis
        """
203 a9b3f29d Antony Chazapis
        return
204 d50ed8d4 Sofia Papagiannaki
205 02c0c3fa Antony Chazapis
    def delete_account(self, user, account):
206 02c0c3fa Antony Chazapis
        """Delete the account with the given name.
207 d50ed8d4 Sofia Papagiannaki

208 b956618e Antony Chazapis
        Raises:
209 cca6c617 Antony Chazapis
            NotAllowedError: Operation not permitted
210 d50ed8d4 Sofia Papagiannaki

211 7efc9f86 Sofia Papagiannaki
            AccountNotEmpty: Account is not empty
212 b956618e Antony Chazapis
        """
213 b956618e Antony Chazapis
        return
214 d50ed8d4 Sofia Papagiannaki
215 29148653 Sofia Papagiannaki
    def list_containers(self, user, account, marker=None, limit=10000,
216 29148653 Sofia Papagiannaki
                        shared=False, until=None, public=False):
217 f6c97079 Antony Chazapis
        """Return a list of container names existing under an account.
218 d50ed8d4 Sofia Papagiannaki

219 29148653 Sofia Papagiannaki
        Keyword arguments:
220 02c0c3fa Antony Chazapis
            'marker': Start list from the next item after 'marker'
221 d50ed8d4 Sofia Papagiannaki

222 02c0c3fa Antony Chazapis
            'limit': Number of containers to return
223 d50ed8d4 Sofia Papagiannaki

224 b18ef3ad Antony Chazapis
            'shared': Only list containers with permissions set
225 d50ed8d4 Sofia Papagiannaki

226 4d15c94e Sofia Papagiannaki
            'public': Only list containers containing public objects
227 d50ed8d4 Sofia Papagiannaki

228 d50ed8d4 Sofia Papagiannaki

229 02c0c3fa Antony Chazapis
        Raises:
230 02c0c3fa Antony Chazapis
            NotAllowedError: Operation not permitted
231 02c0c3fa Antony Chazapis
        """
232 02c0c3fa Antony Chazapis
        return []
233 d50ed8d4 Sofia Papagiannaki
234 29148653 Sofia Papagiannaki
    def list_container_meta(self, user, account, container, domain,
235 29148653 Sofia Papagiannaki
                            until=None):
236 29148653 Sofia Papagiannaki
        """Return a list of the container's object meta keys for a domain.
237 d50ed8d4 Sofia Papagiannaki

238 371d907a Antony Chazapis
        Raises:
239 371d907a Antony Chazapis
            NotAllowedError: Operation not permitted
240 d50ed8d4 Sofia Papagiannaki

241 7efc9f86 Sofia Papagiannaki
            ItemNotExists: Container does not exist
242 371d907a Antony Chazapis
        """
243 371d907a Antony Chazapis
        return []
244 d50ed8d4 Sofia Papagiannaki
245 29148653 Sofia Papagiannaki
    def get_container_meta(self, user, account, container, domain, until=None,
246 29148653 Sofia Papagiannaki
                           include_user_defined=True):
247 cb69c154 Antony Chazapis
        """Return a dictionary with the container metadata for the domain.
248 d50ed8d4 Sofia Papagiannaki

249 b956618e Antony Chazapis
        The keys returned are all user-defined, except:
250 b956618e Antony Chazapis
            'name': The container name
251 d50ed8d4 Sofia Papagiannaki

252 b956618e Antony Chazapis
            'count': The number of objects
253 d50ed8d4 Sofia Papagiannaki

254 b956618e Antony Chazapis
            'bytes': The total data size
255 d50ed8d4 Sofia Papagiannaki

256 58a6c894 Antony Chazapis
            'modified': Last modification timestamp (overall)
257 d50ed8d4 Sofia Papagiannaki

258 58a6c894 Antony Chazapis
            'until_timestamp': Last modification until the timestamp provided
259 d50ed8d4 Sofia Papagiannaki

260 b956618e Antony Chazapis
        Raises:
261 cca6c617 Antony Chazapis
            NotAllowedError: Operation not permitted
262 d50ed8d4 Sofia Papagiannaki

263 7efc9f86 Sofia Papagiannaki
            ItemNotExists: Container does not exist
264 b956618e Antony Chazapis
        """
265 b956618e Antony Chazapis
        return {}
266 d50ed8d4 Sofia Papagiannaki
267 29148653 Sofia Papagiannaki
    def update_container_meta(self, user, account, container, domain, meta,
268 29148653 Sofia Papagiannaki
                              replace=False):
269 cb69c154 Antony Chazapis
        """Update the metadata associated with the container for the domain.
270 d50ed8d4 Sofia Papagiannaki

271 b956618e Antony Chazapis
        Parameters:
272 cb69c154 Antony Chazapis
            'domain': Metadata domain
273 d50ed8d4 Sofia Papagiannaki

274 29148653 Sofia Papagiannaki
        Keyword arguments:
275 b956618e Antony Chazapis
            'meta': Dictionary with metadata to update
276 d50ed8d4 Sofia Papagiannaki

277 22dab079 Antony Chazapis
            'replace': Replace instead of update
278 d50ed8d4 Sofia Papagiannaki

279 b956618e Antony Chazapis
        Raises:
280 cca6c617 Antony Chazapis
            NotAllowedError: Operation not permitted
281 d50ed8d4 Sofia Papagiannaki

282 7efc9f86 Sofia Papagiannaki
            ItemNotExists: Container does not exist
283 b956618e Antony Chazapis
        """
284 b956618e Antony Chazapis
        return
285 d50ed8d4 Sofia Papagiannaki
286 02c0c3fa Antony Chazapis
    def get_container_policy(self, user, account, container):
287 02c0c3fa Antony Chazapis
        """Return a dictionary with the container policy.
288 d50ed8d4 Sofia Papagiannaki

289 02c0c3fa Antony Chazapis
        The keys returned are:
290 02c0c3fa Antony Chazapis
            'quota': The maximum bytes allowed (default is 0 - unlimited)
291 d50ed8d4 Sofia Papagiannaki

292 29148653 Sofia Papagiannaki
            'versioning': Can be 'auto', 'manual' or 'none' (default: 'manual')
293 d50ed8d4 Sofia Papagiannaki

294 02c0c3fa Antony Chazapis
        Raises:
295 02c0c3fa Antony Chazapis
            NotAllowedError: Operation not permitted
296 d50ed8d4 Sofia Papagiannaki

297 7efc9f86 Sofia Papagiannaki
            ItemNotExists: Container does not exist
298 02c0c3fa Antony Chazapis
        """
299 02c0c3fa Antony Chazapis
        return {}
300 d50ed8d4 Sofia Papagiannaki
301 29148653 Sofia Papagiannaki
    def update_container_policy(self, user, account, container, policy,
302 29148653 Sofia Papagiannaki
                                replace=False):
303 b2832c6a Antony Chazapis
        """Update the policy associated with the container.
304 d50ed8d4 Sofia Papagiannaki

305 02c0c3fa Antony Chazapis
        Raises:
306 02c0c3fa Antony Chazapis
            NotAllowedError: Operation not permitted
307 d50ed8d4 Sofia Papagiannaki

308 7efc9f86 Sofia Papagiannaki
            ItemNotExists: Container does not exist
309 d50ed8d4 Sofia Papagiannaki

310 02c0c3fa Antony Chazapis
            ValueError: Invalid policy defined
311 02c0c3fa Antony Chazapis
        """
312 02c0c3fa Antony Chazapis
        return
313 d50ed8d4 Sofia Papagiannaki
314 29148653 Sofia Papagiannaki
    def put_container(self, user, account, container, policy=None):
315 02c0c3fa Antony Chazapis
        """Create a new container with the given name.
316 d50ed8d4 Sofia Papagiannaki

317 02c0c3fa Antony Chazapis
        Raises:
318 02c0c3fa Antony Chazapis
            NotAllowedError: Operation not permitted
319 d50ed8d4 Sofia Papagiannaki

320 7efc9f86 Sofia Papagiannaki
            ContainerExists: Container already exists
321 d50ed8d4 Sofia Papagiannaki

322 02c0c3fa Antony Chazapis
            ValueError: Invalid policy defined
323 02c0c3fa Antony Chazapis
        """
324 02c0c3fa Antony Chazapis
        return
325 d50ed8d4 Sofia Papagiannaki
326 29148653 Sofia Papagiannaki
    def delete_container(self, user, account, container, until=None,
327 29148653 Sofia Papagiannaki
                         delimiter=None):
328 84846143 Antony Chazapis
        """Delete/purge the container with the given name.
329 d50ed8d4 Sofia Papagiannaki

330 29148653 Sofia Papagiannaki
        Keyword arguments:
331 29148653 Sofia Papagiannaki
            'delimiter': If not None, deletes the container contents starting
332 29148653 Sofia Papagiannaki
                         with the delimiter
333 29148653 Sofia Papagiannaki

334 02c0c3fa Antony Chazapis
        Raises:
335 02c0c3fa Antony Chazapis
            NotAllowedError: Operation not permitted
336 d50ed8d4 Sofia Papagiannaki

337 7efc9f86 Sofia Papagiannaki
            ItemNotExists: Container does not exist
338 d50ed8d4 Sofia Papagiannaki

339 7efc9f86 Sofia Papagiannaki
            ContainerNotEmpty: Container is not empty
340 02c0c3fa Antony Chazapis
        """
341 02c0c3fa Antony Chazapis
        return
342 d50ed8d4 Sofia Papagiannaki
343 29148653 Sofia Papagiannaki
    def list_objects(self, user, account, container, prefix='', delimiter=None,
344 29148653 Sofia Papagiannaki
                     marker=None, limit=10000, virtual=True, domain=None,
345 29148653 Sofia Papagiannaki
                     keys=None, shared=False, until=None, size_range=None,
346 29148653 Sofia Papagiannaki
                     public=False):
347 29148653 Sofia Papagiannaki
        """List (object name, object version_id) under a container.
348 d50ed8d4 Sofia Papagiannaki

349 29148653 Sofia Papagiannaki
        Keyword arguments:
350 b956618e Antony Chazapis
            'prefix': List objects starting with 'prefix'
351 d50ed8d4 Sofia Papagiannaki

352 29148653 Sofia Papagiannaki
            'delimiter': Return unique names before 'delimiter' and
353 29148653 Sofia Papagiannaki
                         after 'prefix'
354 d50ed8d4 Sofia Papagiannaki

355 b956618e Antony Chazapis
            'marker': Start list from the next item after 'marker'
356 d50ed8d4 Sofia Papagiannaki

357 b956618e Antony Chazapis
            'limit': Number of objects to return
358 d50ed8d4 Sofia Papagiannaki

359 f4b61e0c Antony Chazapis
            'virtual': If not set, the result will only include names starting
360 f4b61e0c Antony Chazapis
                       with 'prefix' and ending without a 'delimiter' or with
361 f4b61e0c Antony Chazapis
                       the first occurance of the 'delimiter' after 'prefix'.
362 29148653 Sofia Papagiannaki
                       If set, the result will include all names after 'prefix'
363 3f839f59 Antony Chazapis
                       up to and including the 'delimiter' if it is found
364 d50ed8d4 Sofia Papagiannaki

365 cb69c154 Antony Chazapis
            'domain': Metadata domain for keys
366 d50ed8d4 Sofia Papagiannaki

367 95d47e1a Antony Chazapis
            'keys': Include objects that satisfy the key queries in the list.
368 95d47e1a Antony Chazapis
                    Use 'key', '!key' for existence queries, 'key op value' for
369 4e5673a0 Antony Chazapis
                    value queries, where 'op' can be one of =, !=, <=, >=, <, >
370 d50ed8d4 Sofia Papagiannaki

371 b18ef3ad Antony Chazapis
            'shared': Only list objects with permissions set
372 d50ed8d4 Sofia Papagiannaki

373 7ff57991 Antony Chazapis
            'size_range': Include objects with byte size in (from, to).
374 7ff57991 Antony Chazapis
                          Use None to specify unlimited
375 d50ed8d4 Sofia Papagiannaki

376 4d15c94e Sofia Papagiannaki
            'public': Only list public objects
377 d50ed8d4 Sofia Papagiannaki

378 d50ed8d4 Sofia Papagiannaki

379 22dab079 Antony Chazapis
        Raises:
380 cca6c617 Antony Chazapis
            NotAllowedError: Operation not permitted
381 d50ed8d4 Sofia Papagiannaki

382 7efc9f86 Sofia Papagiannaki
            ItemNotExists: Container does not exist
383 22dab079 Antony Chazapis
        """
384 22dab079 Antony Chazapis
        return []
385 d50ed8d4 Sofia Papagiannaki
386 29148653 Sofia Papagiannaki
    def list_object_meta(self, user, account, container, prefix='',
387 29148653 Sofia Papagiannaki
                         delimiter=None, marker=None, limit=10000,
388 29148653 Sofia Papagiannaki
                         virtual=True, domain=None, keys=None, shared=False,
389 29148653 Sofia Papagiannaki
                         until=None, size_range=None, public=False):
390 29148653 Sofia Papagiannaki
        """Return a list of metadata dicts of objects under a container.
391 d50ed8d4 Sofia Papagiannaki

392 371d907a Antony Chazapis
        Same parameters with list_objects. Returned dicts have no user-defined
393 371d907a Antony Chazapis
        metadata and, if until is not None, a None 'modified' timestamp.
394 d50ed8d4 Sofia Papagiannaki

395 15a96c3e Antony Chazapis
        Raises:
396 15a96c3e Antony Chazapis
            NotAllowedError: Operation not permitted
397 d50ed8d4 Sofia Papagiannaki

398 7efc9f86 Sofia Papagiannaki
            ItemNotExists: Container does not exist
399 b956618e Antony Chazapis
        """
400 b956618e Antony Chazapis
        return []
401 d50ed8d4 Sofia Papagiannaki
402 15a96c3e Antony Chazapis
    def list_object_permissions(self, user, account, container, prefix=''):
403 29148653 Sofia Papagiannaki
        """Return a list of paths enforce permissions under a container.
404 d50ed8d4 Sofia Papagiannaki

405 15a96c3e Antony Chazapis
        Raises:
406 15a96c3e Antony Chazapis
            NotAllowedError: Operation not permitted
407 15a96c3e Antony Chazapis
        """
408 15a96c3e Antony Chazapis
        return []
409 d50ed8d4 Sofia Papagiannaki
410 15a96c3e Antony Chazapis
    def list_object_public(self, user, account, container, prefix=''):
411 29148653 Sofia Papagiannaki
        """Return a mapping of object paths to public ids under a container."""
412 15a96c3e Antony Chazapis
        return {}
413 d50ed8d4 Sofia Papagiannaki
414 29148653 Sofia Papagiannaki
    def get_object_meta(self, user, account, container, name, domain,
415 29148653 Sofia Papagiannaki
                        version=None, include_user_defined=True):
416 cb69c154 Antony Chazapis
        """Return a dictionary with the object metadata for the domain.
417 d50ed8d4 Sofia Papagiannaki

418 b956618e Antony Chazapis
        The keys returned are all user-defined, except:
419 58a6c894 Antony Chazapis
            'name': The object name
420 d50ed8d4 Sofia Papagiannaki

421 b956618e Antony Chazapis
            'bytes': The total data size
422 d50ed8d4 Sofia Papagiannaki

423 66ce2ca5 Antony Chazapis
            'type': The content type
424 d50ed8d4 Sofia Papagiannaki

425 4a1c29ea Antony Chazapis
            'hash': The hashmap hash
426 d50ed8d4 Sofia Papagiannaki

427 58a6c894 Antony Chazapis
            'modified': Last modification timestamp (overall)
428 d50ed8d4 Sofia Papagiannaki

429 29148653 Sofia Papagiannaki
            'modified_by': The user that committed the object
430 29148653 Sofia Papagiannaki
                           (version requested)
431 d50ed8d4 Sofia Papagiannaki

432 58a6c894 Antony Chazapis
            'version': The version identifier
433 d50ed8d4 Sofia Papagiannaki

434 58a6c894 Antony Chazapis
            'version_timestamp': The version's modification timestamp
435 d50ed8d4 Sofia Papagiannaki

436 29148653 Sofia Papagiannaki
            'uuid': A unique identifier that persists data or metadata updates
437 29148653 Sofia Papagiannaki
                    and renames
438 d50ed8d4 Sofia Papagiannaki

439 33b4e4a6 Antony Chazapis
            'checksum': The MD5 sum of the object (may be empty)
440 d50ed8d4 Sofia Papagiannaki

441 b956618e Antony Chazapis
        Raises:
442 cca6c617 Antony Chazapis
            NotAllowedError: Operation not permitted
443 d50ed8d4 Sofia Papagiannaki

444 7efc9f86 Sofia Papagiannaki
            ItemNotExists: Container/object does not exist
445 d50ed8d4 Sofia Papagiannaki

446 7efc9f86 Sofia Papagiannaki
            VersionNotExists: Version does not exist
447 b956618e Antony Chazapis
        """
448 b956618e Antony Chazapis
        return {}
449 d50ed8d4 Sofia Papagiannaki
450 29148653 Sofia Papagiannaki
    def update_object_meta(self, user, account, container, name, domain, meta,
451 29148653 Sofia Papagiannaki
                           replace=False):
452 29148653 Sofia Papagiannaki
        """Update object metadata for a domain and return the new version.
453 d50ed8d4 Sofia Papagiannaki

454 b956618e Antony Chazapis
        Parameters:
455 cb69c154 Antony Chazapis
            'domain': Metadata domain
456 d50ed8d4 Sofia Papagiannaki

457 a6eb13e9 Antony Chazapis
            'meta': Dictionary with metadata to update
458 d50ed8d4 Sofia Papagiannaki

459 22dab079 Antony Chazapis
            'replace': Replace instead of update
460 d50ed8d4 Sofia Papagiannaki

461 b956618e Antony Chazapis
        Raises:
462 cca6c617 Antony Chazapis
            NotAllowedError: Operation not permitted
463 d50ed8d4 Sofia Papagiannaki

464 7efc9f86 Sofia Papagiannaki
            ItemNotExists: Container/object does not exist
465 b956618e Antony Chazapis
        """
466 02c4d2ba Antony Chazapis
        return ''
467 d50ed8d4 Sofia Papagiannaki
468 3436eeb0 Antony Chazapis
    def get_object_permissions(self, user, account, container, name):
469 067cf1fc Antony Chazapis
        """Return the action allowed on the object, the path
470 067cf1fc Antony Chazapis
        from which the object gets its permissions from,
471 cca6c617 Antony Chazapis
        along with a dictionary containing the permissions.
472 d50ed8d4 Sofia Papagiannaki

473 067cf1fc Antony Chazapis
        The dictionary keys are (also used for defining the action):
474 3436eeb0 Antony Chazapis
            'read': The object is readable by the users/groups in the list
475 d50ed8d4 Sofia Papagiannaki

476 3436eeb0 Antony Chazapis
            'write': The object is writable by the users/groups in the list
477 d50ed8d4 Sofia Papagiannaki

478 3436eeb0 Antony Chazapis
        Raises:
479 cca6c617 Antony Chazapis
            NotAllowedError: Operation not permitted
480 d50ed8d4 Sofia Papagiannaki

481 7efc9f86 Sofia Papagiannaki
            ItemNotExists: Container/object does not exist
482 3436eeb0 Antony Chazapis
        """
483 3436eeb0 Antony Chazapis
        return {}
484 d50ed8d4 Sofia Papagiannaki
485 29148653 Sofia Papagiannaki
    def update_object_permissions(self, user, account, container, name,
486 29148653 Sofia Papagiannaki
                                  permissions):
487 345dcf39 Antony Chazapis
        """Update (set) the permissions associated with the object.
488 d50ed8d4 Sofia Papagiannaki

489 3436eeb0 Antony Chazapis
        Parameters:
490 345dcf39 Antony Chazapis
            'permissions': Dictionary with permissions to set
491 d50ed8d4 Sofia Papagiannaki

492 3436eeb0 Antony Chazapis
        Raises:
493 cca6c617 Antony Chazapis
            NotAllowedError: Operation not permitted
494 d50ed8d4 Sofia Papagiannaki

495 7efc9f86 Sofia Papagiannaki
            ItemNotExists: Container/object does not exist
496 d50ed8d4 Sofia Papagiannaki

497 3436eeb0 Antony Chazapis
            ValueError: Invalid users/groups in permissions
498 3436eeb0 Antony Chazapis
        """
499 3436eeb0 Antony Chazapis
        return
500 d50ed8d4 Sofia Papagiannaki
501 02c0c3fa Antony Chazapis
    def get_object_public(self, user, account, container, name):
502 bb4eafc6 Antony Chazapis
        """Return the public id of the object if applicable.
503 d50ed8d4 Sofia Papagiannaki

504 02c0c3fa Antony Chazapis
        Raises:
505 02c0c3fa Antony Chazapis
            NotAllowedError: Operation not permitted
506 d50ed8d4 Sofia Papagiannaki

507 7efc9f86 Sofia Papagiannaki
            ItemNotExists: Container/object does not exist
508 02c0c3fa Antony Chazapis
        """
509 02c0c3fa Antony Chazapis
        return None
510 d50ed8d4 Sofia Papagiannaki
511 02c0c3fa Antony Chazapis
    def update_object_public(self, user, account, container, name, public):
512 02c0c3fa Antony Chazapis
        """Update the public status of the object.
513 d50ed8d4 Sofia Papagiannaki

514 02c0c3fa Antony Chazapis
        Parameters:
515 02c0c3fa Antony Chazapis
            'public': Boolean value
516 d50ed8d4 Sofia Papagiannaki

517 02c0c3fa Antony Chazapis
        Raises:
518 02c0c3fa Antony Chazapis
            NotAllowedError: Operation not permitted
519 d50ed8d4 Sofia Papagiannaki

520 7efc9f86 Sofia Papagiannaki
            ItemNotExists: Container/object does not exist
521 02c0c3fa Antony Chazapis
        """
522 02c0c3fa Antony Chazapis
        return
523 d50ed8d4 Sofia Papagiannaki
524 83dd59c5 Antony Chazapis
    def get_object_hashmap(self, user, account, container, name, version=None):
525 22dab079 Antony Chazapis
        """Return the object's size and a list with partial hashes.
526 d50ed8d4 Sofia Papagiannaki

527 b956618e Antony Chazapis
        Raises:
528 cca6c617 Antony Chazapis
            NotAllowedError: Operation not permitted
529 d50ed8d4 Sofia Papagiannaki

530 7efc9f86 Sofia Papagiannaki
            ItemNotExists: Container/object does not exist
531 d50ed8d4 Sofia Papagiannaki

532 7efc9f86 Sofia Papagiannaki
            VersionNotExists: Version does not exist
533 b956618e Antony Chazapis
        """
534 22dab079 Antony Chazapis
        return 0, []
535 d50ed8d4 Sofia Papagiannaki
536 29148653 Sofia Papagiannaki
    def update_object_hashmap(self, user, account, container, name, size, type,
537 29148653 Sofia Papagiannaki
                              hashmap, checksum, domain, meta=None,
538 29148653 Sofia Papagiannaki
                              replace_meta=False, permissions=None):
539 29148653 Sofia Papagiannaki
        """Create/update an object's hashmap and return the new version.
540 d50ed8d4 Sofia Papagiannaki

541 3436eeb0 Antony Chazapis
        Parameters:
542 cb69c154 Antony Chazapis
            'domain': Metadata domain
543 d50ed8d4 Sofia Papagiannaki

544 cb69c154 Antony Chazapis
            'meta': Dictionary with metadata to change
545 d50ed8d4 Sofia Papagiannaki

546 3436eeb0 Antony Chazapis
            'replace_meta': Replace metadata instead of update
547 d50ed8d4 Sofia Papagiannaki

548 3436eeb0 Antony Chazapis
            'permissions': Updated object permissions
549 d50ed8d4 Sofia Papagiannaki

550 b956618e Antony Chazapis
        Raises:
551 cca6c617 Antony Chazapis
            NotAllowedError: Operation not permitted
552 d50ed8d4 Sofia Papagiannaki

553 7efc9f86 Sofia Papagiannaki
            ItemNotExists: Container does not exist
554 d50ed8d4 Sofia Papagiannaki

555 3436eeb0 Antony Chazapis
            ValueError: Invalid users/groups in permissions
556 d50ed8d4 Sofia Papagiannaki

557 5df6c6d1 Antony Chazapis
            QuotaError: Account or container quota exceeded
558 b956618e Antony Chazapis
        """
559 02c4d2ba Antony Chazapis
        return ''
560 d50ed8d4 Sofia Papagiannaki
561 29148653 Sofia Papagiannaki
    def update_object_checksum(self, user, account, container, name, version,
562 29148653 Sofia Papagiannaki
                               checksum):
563 33b4e4a6 Antony Chazapis
        """Update an object's checksum."""
564 33b4e4a6 Antony Chazapis
        return
565 d50ed8d4 Sofia Papagiannaki
566 29148653 Sofia Papagiannaki
    def copy_object(self, user, src_account, src_container, src_name,
567 29148653 Sofia Papagiannaki
                    dest_account, dest_container, dest_name, type, domain,
568 29148653 Sofia Papagiannaki
                    meta=None, replace_meta=False, permissions=None,
569 29148653 Sofia Papagiannaki
                    src_version=None, delimiter=None):
570 02c4d2ba Antony Chazapis
        """Copy an object's data and metadata and return the new version.
571 d50ed8d4 Sofia Papagiannaki

572 b956618e Antony Chazapis
        Parameters:
573 cb69c154 Antony Chazapis
            'domain': Metadata domain
574 d50ed8d4 Sofia Papagiannaki

575 29148653 Sofia Papagiannaki
            'meta': Dictionary with metadata to change from source
576 29148653 Sofia Papagiannaki
                    to destination
577 d50ed8d4 Sofia Papagiannaki

578 22dab079 Antony Chazapis
            'replace_meta': Replace metadata instead of update
579 d50ed8d4 Sofia Papagiannaki

580 3436eeb0 Antony Chazapis
            'permissions': New object permissions
581 d50ed8d4 Sofia Papagiannaki

582 3436eeb0 Antony Chazapis
            'src_version': Copy from the version provided
583 d50ed8d4 Sofia Papagiannaki

584 29148653 Sofia Papagiannaki
            'delimiter': Copy objects whose path starts with
585 29148653 Sofia Papagiannaki
                         src_name + delimiter
586 d50ed8d4 Sofia Papagiannaki

587 b956618e Antony Chazapis
        Raises:
588 cca6c617 Antony Chazapis
            NotAllowedError: Operation not permitted
589 d50ed8d4 Sofia Papagiannaki

590 7efc9f86 Sofia Papagiannaki
            ItemNotExists: Container/object does not exist
591 d50ed8d4 Sofia Papagiannaki

592 7efc9f86 Sofia Papagiannaki
            VersionNotExists: Version does not exist
593 d50ed8d4 Sofia Papagiannaki

594 3436eeb0 Antony Chazapis
            ValueError: Invalid users/groups in permissions
595 d50ed8d4 Sofia Papagiannaki

596 5df6c6d1 Antony Chazapis
            QuotaError: Account or container quota exceeded
597 b956618e Antony Chazapis
        """
598 02c4d2ba Antony Chazapis
        return ''
599 d50ed8d4 Sofia Papagiannaki
600 29148653 Sofia Papagiannaki
    def move_object(self, user, src_account, src_container, src_name,
601 29148653 Sofia Papagiannaki
                    dest_account, dest_container, dest_name, type, domain,
602 29148653 Sofia Papagiannaki
                    meta=None, replace_meta=False, permissions=None,
603 29148653 Sofia Papagiannaki
                    delimiter=None):
604 02c4d2ba Antony Chazapis
        """Move an object's data and metadata and return the new version.
605 d50ed8d4 Sofia Papagiannaki

606 b956618e Antony Chazapis
        Parameters:
607 cb69c154 Antony Chazapis
            'domain': Metadata domain
608 d50ed8d4 Sofia Papagiannaki

609 29148653 Sofia Papagiannaki
            'meta': Dictionary with metadata to change from source
610 29148653 Sofia Papagiannaki
                    to destination
611 d50ed8d4 Sofia Papagiannaki

612 22dab079 Antony Chazapis
            'replace_meta': Replace metadata instead of update
613 d50ed8d4 Sofia Papagiannaki

614 3436eeb0 Antony Chazapis
            'permissions': New object permissions
615 d50ed8d4 Sofia Papagiannaki

616 29148653 Sofia Papagiannaki
            'delimiter': Move objects whose path starts with
617 29148653 Sofia Papagiannaki
                         src_name + delimiter
618 d50ed8d4 Sofia Papagiannaki

619 b956618e Antony Chazapis
        Raises:
620 cca6c617 Antony Chazapis
            NotAllowedError: Operation not permitted
621 d50ed8d4 Sofia Papagiannaki

622 7efc9f86 Sofia Papagiannaki
            ItemNotExists: Container/object does not exist
623 d50ed8d4 Sofia Papagiannaki

624 3436eeb0 Antony Chazapis
            ValueError: Invalid users/groups in permissions
625 d50ed8d4 Sofia Papagiannaki

626 5df6c6d1 Antony Chazapis
            QuotaError: Account or container quota exceeded
627 b956618e Antony Chazapis
        """
628 02c4d2ba Antony Chazapis
        return ''
629 d50ed8d4 Sofia Papagiannaki
630 29148653 Sofia Papagiannaki
    def delete_object(self, user, account, container, name, until=None,
631 29148653 Sofia Papagiannaki
                      delimiter=None):
632 84846143 Antony Chazapis
        """Delete/purge an object.
633 d50ed8d4 Sofia Papagiannaki

634 4d15c94e Sofia Papagiannaki
        Parameters:
635 29148653 Sofia Papagiannaki
            'delimiter': Delete objects whose path starting with
636 29148653 Sofia Papagiannaki
                         name + delimiter
637 d50ed8d4 Sofia Papagiannaki

638 b956618e Antony Chazapis
        Raises:
639 cca6c617 Antony Chazapis
            NotAllowedError: Operation not permitted
640 d50ed8d4 Sofia Papagiannaki

641 7efc9f86 Sofia Papagiannaki
            ItemNotExists: Container/object does not exist
642 b956618e Antony Chazapis
        """
643 b956618e Antony Chazapis
        return
644 d50ed8d4 Sofia Papagiannaki
645 83dd59c5 Antony Chazapis
    def list_versions(self, user, account, container, name):
646 29148653 Sofia Papagiannaki
        """Return a list of all object (version, version_timestamp) tuples.
647 d50ed8d4 Sofia Papagiannaki

648 cca6c617 Antony Chazapis
        Raises:
649 cca6c617 Antony Chazapis
            NotAllowedError: Operation not permitted
650 cca6c617 Antony Chazapis
        """
651 58a6c894 Antony Chazapis
        return []
652 d50ed8d4 Sofia Papagiannaki
653 37bee317 Antony Chazapis
    def get_uuid(self, user, uuid):
654 37bee317 Antony Chazapis
        """Return the (account, container, name) for the UUID given.
655 d50ed8d4 Sofia Papagiannaki

656 37bee317 Antony Chazapis
        Raises:
657 37bee317 Antony Chazapis
            NotAllowedError: Operation not permitted
658 d50ed8d4 Sofia Papagiannaki

659 37bee317 Antony Chazapis
            NameError: UUID does not exist
660 37bee317 Antony Chazapis
        """
661 37bee317 Antony Chazapis
        return None
662 d50ed8d4 Sofia Papagiannaki
663 bb4eafc6 Antony Chazapis
    def get_public(self, user, public):
664 bb4eafc6 Antony Chazapis
        """Return the (account, container, name) for the public id given.
665 d50ed8d4 Sofia Papagiannaki

666 bb4eafc6 Antony Chazapis
        Raises:
667 bb4eafc6 Antony Chazapis
            NotAllowedError: Operation not permitted
668 d50ed8d4 Sofia Papagiannaki

669 bb4eafc6 Antony Chazapis
            NameError: Public id does not exist
670 bb4eafc6 Antony Chazapis
        """
671 bb4eafc6 Antony Chazapis
        return None
672 d50ed8d4 Sofia Papagiannaki
673 22dab079 Antony Chazapis
    def get_block(self, hash):
674 22dab079 Antony Chazapis
        """Return a block's data.
675 d50ed8d4 Sofia Papagiannaki

676 22dab079 Antony Chazapis
        Raises:
677 7efc9f86 Sofia Papagiannaki
            ItemNotExists: Block does not exist
678 22dab079 Antony Chazapis
        """
679 22dab079 Antony Chazapis
        return ''
680 d50ed8d4 Sofia Papagiannaki
681 22dab079 Antony Chazapis
    def put_block(self, data):
682 22dab079 Antony Chazapis
        """Store a block and return the hash."""
683 22dab079 Antony Chazapis
        return 0
684 d50ed8d4 Sofia Papagiannaki
685 22dab079 Antony Chazapis
    def update_block(self, hash, data, offset=0):
686 22dab079 Antony Chazapis
        """Update a known block and return the hash.
687 d50ed8d4 Sofia Papagiannaki

688 22dab079 Antony Chazapis
        Raises:
689 22dab079 Antony Chazapis
            IndexError: Offset or data outside block limits
690 22dab079 Antony Chazapis
        """
691 22dab079 Antony Chazapis
        return 0
692 29148653 Sofia Papagiannaki
693 29148653 Sofia Papagiannaki
    def get_domain_objects(self, domain, user=None):
694 29148653 Sofia Papagiannaki
        """Return a list of tuples for objects under the domain.
695 29148653 Sofia Papagiannaki

696 29148653 Sofia Papagiannaki
        Parameters:
697 29148653 Sofia Papagiannaki
            'user': return only objects accessible to the user.
698 29148653 Sofia Papagiannaki
        """