Statistics
| Branch: | Tag: | Revision:

root / snf-pithos-backend / pithos / backends / base.py @ 6e0f3e65

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 d50ed8d4 Sofia Papagiannaki
72 8ee4ec50 Vangelis Koukis
class BaseBackend(object):
73 29148653 Sofia Papagiannaki
    """Abstract backend class.
74 29148653 Sofia Papagiannaki

75 29148653 Sofia Papagiannaki
    This class serves as a reference for actual implementations.
76 d50ed8d4 Sofia Papagiannaki

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

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

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

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

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

91 22dab079 Antony Chazapis
        'block_size': Suggested is 4MB
92 d50ed8d4 Sofia Papagiannaki

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

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

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

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

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

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

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

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

128 29148653 Sofia Papagiannaki
            'external_quota': The quota computed from external quota holder
129 29148653 Sofia Papagiannaki
                              mechanism
130 29148653 Sofia Papagiannaki

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

139 b956618e Antony Chazapis
        Parameters:
140 cb69c154 Antony Chazapis
            'domain': Metadata domain
141 d50ed8d4 Sofia Papagiannaki

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

145 22dab079 Antony Chazapis
            'replace': Replace instead of update
146 d50ed8d4 Sofia Papagiannaki

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

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

163 b956618e Antony Chazapis
        Raises:
164 cca6c617 Antony Chazapis
            NotAllowedError: Operation not permitted
165 d50ed8d4 Sofia Papagiannaki

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

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

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

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

186 b2832c6a Antony Chazapis
        Raises:
187 b2832c6a Antony Chazapis
            NotAllowedError: Operation not permitted
188 d50ed8d4 Sofia Papagiannaki

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

196 a9b3f29d Antony Chazapis
        Raises:
197 a9b3f29d Antony Chazapis
            NotAllowedError: Operation not permitted
198 d50ed8d4 Sofia Papagiannaki

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

206 b956618e Antony Chazapis
        Raises:
207 cca6c617 Antony Chazapis
            NotAllowedError: Operation not permitted
208 d50ed8d4 Sofia Papagiannaki

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

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

220 02c0c3fa Antony Chazapis
            'limit': Number of containers to return
221 d50ed8d4 Sofia Papagiannaki

222 b18ef3ad Antony Chazapis
            'shared': Only list containers with permissions set
223 d50ed8d4 Sofia Papagiannaki

224 4d15c94e Sofia Papagiannaki
            'public': Only list containers containing public objects
225 d50ed8d4 Sofia Papagiannaki

226 d50ed8d4 Sofia Papagiannaki

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

236 371d907a Antony Chazapis
        Raises:
237 371d907a Antony Chazapis
            NotAllowedError: Operation not permitted
238 d50ed8d4 Sofia Papagiannaki

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

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

250 b956618e Antony Chazapis
            'count': The number of objects
251 d50ed8d4 Sofia Papagiannaki

252 b956618e Antony Chazapis
            'bytes': The total data size
253 d50ed8d4 Sofia Papagiannaki

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

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

258 b956618e Antony Chazapis
        Raises:
259 cca6c617 Antony Chazapis
            NotAllowedError: Operation not permitted
260 d50ed8d4 Sofia Papagiannaki

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

269 b956618e Antony Chazapis
        Parameters:
270 cb69c154 Antony Chazapis
            'domain': Metadata domain
271 d50ed8d4 Sofia Papagiannaki

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

275 22dab079 Antony Chazapis
            'replace': Replace instead of update
276 d50ed8d4 Sofia Papagiannaki

277 b956618e Antony Chazapis
        Raises:
278 cca6c617 Antony Chazapis
            NotAllowedError: Operation not permitted
279 d50ed8d4 Sofia Papagiannaki

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

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

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

292 02c0c3fa Antony Chazapis
        Raises:
293 02c0c3fa Antony Chazapis
            NotAllowedError: Operation not permitted
294 d50ed8d4 Sofia Papagiannaki

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

303 02c0c3fa Antony Chazapis
        Raises:
304 02c0c3fa Antony Chazapis
            NotAllowedError: Operation not permitted
305 d50ed8d4 Sofia Papagiannaki

306 7efc9f86 Sofia Papagiannaki
            ItemNotExists: Container does not exist
307 d50ed8d4 Sofia Papagiannaki

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

315 02c0c3fa Antony Chazapis
        Raises:
316 02c0c3fa Antony Chazapis
            NotAllowedError: Operation not permitted
317 d50ed8d4 Sofia Papagiannaki

318 7efc9f86 Sofia Papagiannaki
            ContainerExists: Container already exists
319 d50ed8d4 Sofia Papagiannaki

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

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

332 02c0c3fa Antony Chazapis
        Raises:
333 02c0c3fa Antony Chazapis
            NotAllowedError: Operation not permitted
334 d50ed8d4 Sofia Papagiannaki

335 7efc9f86 Sofia Papagiannaki
            ItemNotExists: Container does not exist
336 d50ed8d4 Sofia Papagiannaki

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

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

350 29148653 Sofia Papagiannaki
            'delimiter': Return unique names before 'delimiter' and
351 29148653 Sofia Papagiannaki
                         after 'prefix'
352 d50ed8d4 Sofia Papagiannaki

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

355 b956618e Antony Chazapis
            'limit': Number of objects to return
356 d50ed8d4 Sofia Papagiannaki

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

363 cb69c154 Antony Chazapis
            'domain': Metadata domain for keys
364 d50ed8d4 Sofia Papagiannaki

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

369 b18ef3ad Antony Chazapis
            'shared': Only list objects with permissions set
370 d50ed8d4 Sofia Papagiannaki

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

374 4d15c94e Sofia Papagiannaki
            'public': Only list public objects
375 d50ed8d4 Sofia Papagiannaki

376 d50ed8d4 Sofia Papagiannaki

377 22dab079 Antony Chazapis
        Raises:
378 cca6c617 Antony Chazapis
            NotAllowedError: Operation not permitted
379 d50ed8d4 Sofia Papagiannaki

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

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

393 15a96c3e Antony Chazapis
        Raises:
394 15a96c3e Antony Chazapis
            NotAllowedError: Operation not permitted
395 d50ed8d4 Sofia Papagiannaki

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

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

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

419 b956618e Antony Chazapis
            'bytes': The total data size
420 d50ed8d4 Sofia Papagiannaki

421 66ce2ca5 Antony Chazapis
            'type': The content type
422 d50ed8d4 Sofia Papagiannaki

423 4a1c29ea Antony Chazapis
            'hash': The hashmap hash
424 d50ed8d4 Sofia Papagiannaki

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

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

430 58a6c894 Antony Chazapis
            'version': The version identifier
431 d50ed8d4 Sofia Papagiannaki

432 58a6c894 Antony Chazapis
            'version_timestamp': The version's modification timestamp
433 d50ed8d4 Sofia Papagiannaki

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

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

439 b956618e Antony Chazapis
        Raises:
440 cca6c617 Antony Chazapis
            NotAllowedError: Operation not permitted
441 d50ed8d4 Sofia Papagiannaki

442 7efc9f86 Sofia Papagiannaki
            ItemNotExists: Container/object does not exist
443 d50ed8d4 Sofia Papagiannaki

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

452 b956618e Antony Chazapis
        Parameters:
453 cb69c154 Antony Chazapis
            'domain': Metadata domain
454 d50ed8d4 Sofia Papagiannaki

455 a6eb13e9 Antony Chazapis
            'meta': Dictionary with metadata to update
456 d50ed8d4 Sofia Papagiannaki

457 22dab079 Antony Chazapis
            'replace': Replace instead of update
458 d50ed8d4 Sofia Papagiannaki

459 b956618e Antony Chazapis
        Raises:
460 cca6c617 Antony Chazapis
            NotAllowedError: Operation not permitted
461 d50ed8d4 Sofia Papagiannaki

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

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

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

476 3436eeb0 Antony Chazapis
        Raises:
477 cca6c617 Antony Chazapis
            NotAllowedError: Operation not permitted
478 d50ed8d4 Sofia Papagiannaki

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

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

490 3436eeb0 Antony Chazapis
        Raises:
491 cca6c617 Antony Chazapis
            NotAllowedError: Operation not permitted
492 d50ed8d4 Sofia Papagiannaki

493 7efc9f86 Sofia Papagiannaki
            ItemNotExists: Container/object does not exist
494 d50ed8d4 Sofia Papagiannaki

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

502 02c0c3fa Antony Chazapis
        Raises:
503 02c0c3fa Antony Chazapis
            NotAllowedError: Operation not permitted
504 d50ed8d4 Sofia Papagiannaki

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

512 02c0c3fa Antony Chazapis
        Parameters:
513 02c0c3fa Antony Chazapis
            'public': Boolean value
514 d50ed8d4 Sofia Papagiannaki

515 02c0c3fa Antony Chazapis
        Raises:
516 02c0c3fa Antony Chazapis
            NotAllowedError: Operation not permitted
517 d50ed8d4 Sofia Papagiannaki

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

525 b956618e Antony Chazapis
        Raises:
526 cca6c617 Antony Chazapis
            NotAllowedError: Operation not permitted
527 d50ed8d4 Sofia Papagiannaki

528 7efc9f86 Sofia Papagiannaki
            ItemNotExists: Container/object does not exist
529 d50ed8d4 Sofia Papagiannaki

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

539 3436eeb0 Antony Chazapis
        Parameters:
540 cb69c154 Antony Chazapis
            'domain': Metadata domain
541 d50ed8d4 Sofia Papagiannaki

542 cb69c154 Antony Chazapis
            'meta': Dictionary with metadata to change
543 d50ed8d4 Sofia Papagiannaki

544 3436eeb0 Antony Chazapis
            'replace_meta': Replace metadata instead of update
545 d50ed8d4 Sofia Papagiannaki

546 3436eeb0 Antony Chazapis
            'permissions': Updated object permissions
547 d50ed8d4 Sofia Papagiannaki

548 b956618e Antony Chazapis
        Raises:
549 cca6c617 Antony Chazapis
            NotAllowedError: Operation not permitted
550 d50ed8d4 Sofia Papagiannaki

551 7efc9f86 Sofia Papagiannaki
            ItemNotExists: Container does not exist
552 d50ed8d4 Sofia Papagiannaki

553 3436eeb0 Antony Chazapis
            ValueError: Invalid users/groups in permissions
554 d50ed8d4 Sofia Papagiannaki

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

570 b956618e Antony Chazapis
        Parameters:
571 cb69c154 Antony Chazapis
            'domain': Metadata domain
572 d50ed8d4 Sofia Papagiannaki

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

576 22dab079 Antony Chazapis
            'replace_meta': Replace metadata instead of update
577 d50ed8d4 Sofia Papagiannaki

578 3436eeb0 Antony Chazapis
            'permissions': New object permissions
579 d50ed8d4 Sofia Papagiannaki

580 3436eeb0 Antony Chazapis
            'src_version': Copy from the version provided
581 d50ed8d4 Sofia Papagiannaki

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

585 b956618e Antony Chazapis
        Raises:
586 cca6c617 Antony Chazapis
            NotAllowedError: Operation not permitted
587 d50ed8d4 Sofia Papagiannaki

588 7efc9f86 Sofia Papagiannaki
            ItemNotExists: Container/object does not exist
589 d50ed8d4 Sofia Papagiannaki

590 7efc9f86 Sofia Papagiannaki
            VersionNotExists: Version does not exist
591 d50ed8d4 Sofia Papagiannaki

592 3436eeb0 Antony Chazapis
            ValueError: Invalid users/groups in permissions
593 d50ed8d4 Sofia Papagiannaki

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

604 b956618e Antony Chazapis
        Parameters:
605 cb69c154 Antony Chazapis
            'domain': Metadata domain
606 d50ed8d4 Sofia Papagiannaki

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

610 22dab079 Antony Chazapis
            'replace_meta': Replace metadata instead of update
611 d50ed8d4 Sofia Papagiannaki

612 3436eeb0 Antony Chazapis
            'permissions': New object permissions
613 d50ed8d4 Sofia Papagiannaki

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

617 b956618e Antony Chazapis
        Raises:
618 cca6c617 Antony Chazapis
            NotAllowedError: Operation not permitted
619 d50ed8d4 Sofia Papagiannaki

620 7efc9f86 Sofia Papagiannaki
            ItemNotExists: Container/object does not exist
621 d50ed8d4 Sofia Papagiannaki

622 3436eeb0 Antony Chazapis
            ValueError: Invalid users/groups in permissions
623 d50ed8d4 Sofia Papagiannaki

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

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

636 b956618e Antony Chazapis
        Raises:
637 cca6c617 Antony Chazapis
            NotAllowedError: Operation not permitted
638 d50ed8d4 Sofia Papagiannaki

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

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

654 37bee317 Antony Chazapis
        Raises:
655 37bee317 Antony Chazapis
            NotAllowedError: Operation not permitted
656 d50ed8d4 Sofia Papagiannaki

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

664 bb4eafc6 Antony Chazapis
        Raises:
665 bb4eafc6 Antony Chazapis
            NotAllowedError: Operation not permitted
666 d50ed8d4 Sofia Papagiannaki

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

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

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

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