root / snf-pithos-backend / pithos / backends / base.py @ d2869078
History | View | Annotate | Download (21.4 kB)
1 | 2e662088 | Antony Chazapis | # Copyright 2011-2012 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 | d2869078 | Vangelis Koukis | from synnefo.lib.singleton import ArgBasedSingleton |
39 | 228de81b | Antony Chazapis | |
40 | cca6c617 | Antony Chazapis | class NotAllowedError(Exception): |
41 | cca6c617 | Antony Chazapis | pass
|
42 | cca6c617 | Antony Chazapis | |
43 | 5df6c6d1 | Antony Chazapis | class QuotaError(Exception): |
44 | 5df6c6d1 | Antony Chazapis | pass
|
45 | 5df6c6d1 | Antony Chazapis | |
46 | 7efc9f86 | Sofia Papagiannaki | class AccountExists(NameError): |
47 | 7efc9f86 | Sofia Papagiannaki | pass
|
48 | 7efc9f86 | Sofia Papagiannaki | |
49 | 7efc9f86 | Sofia Papagiannaki | class ContainerExists(NameError): |
50 | 7efc9f86 | Sofia Papagiannaki | pass
|
51 | 7efc9f86 | Sofia Papagiannaki | |
52 | 7efc9f86 | Sofia Papagiannaki | class AccountNotEmpty(IndexError): |
53 | 7efc9f86 | Sofia Papagiannaki | pass
|
54 | 7efc9f86 | Sofia Papagiannaki | |
55 | 7efc9f86 | Sofia Papagiannaki | class ContainerNotEmpty(IndexError): |
56 | 7efc9f86 | Sofia Papagiannaki | pass
|
57 | 7efc9f86 | Sofia Papagiannaki | |
58 | 7efc9f86 | Sofia Papagiannaki | class ItemNotExists(NameError): |
59 | 7efc9f86 | Sofia Papagiannaki | pass
|
60 | 7efc9f86 | Sofia Papagiannaki | |
61 | 7efc9f86 | Sofia Papagiannaki | class VersionNotExists(IndexError): |
62 | 7efc9f86 | Sofia Papagiannaki | pass
|
63 | 7efc9f86 | Sofia Papagiannaki | |
64 | d2869078 | Vangelis Koukis | class BaseBackend(ArgBasedSingleton): |
65 | 22dab079 | Antony Chazapis | """Abstract backend class that serves as a reference for actual implementations.
|
66 | b956618e | Antony Chazapis |
|
67 | b956618e | Antony Chazapis | The purpose of the backend is to provide the necessary functions for handling data
|
68 | b956618e | Antony Chazapis | and metadata. It is responsible for the actual storage and retrieval of information.
|
69 | b956618e | Antony Chazapis |
|
70 | b956618e | Antony Chazapis | Note that the account level is always valid as it is checked from another subsystem.
|
71 | 22dab079 | Antony Chazapis |
|
72 | 02c0c3fa | Antony Chazapis | When not replacing metadata/groups/policy, keys with empty values should be deleted.
|
73 | a6eb13e9 | Antony Chazapis |
|
74 | 22dab079 | Antony Chazapis | The following variables should be available:
|
75 | 22dab079 | Antony Chazapis | 'hash_algorithm': Suggested is 'sha256'
|
76 | f4b61e0c | Antony Chazapis |
|
77 | 22dab079 | Antony Chazapis | 'block_size': Suggested is 4MB
|
78 | b2832c6a | Antony Chazapis |
|
79 | b2832c6a | Antony Chazapis | 'default_policy': A dictionary with default policy settings
|
80 | b956618e | Antony Chazapis | """
|
81 | b956618e | Antony Chazapis | |
82 | d14fe290 | Antony Chazapis | def close(self): |
83 | d14fe290 | Antony Chazapis | """Close the backend connection."""
|
84 | d14fe290 | Antony Chazapis | pass
|
85 | d14fe290 | Antony Chazapis | |
86 | f6c97079 | Antony Chazapis | def list_accounts(self, user, marker=None, limit=10000): |
87 | f6c97079 | Antony Chazapis | """Return a list of accounts the user can access.
|
88 | f6c97079 | Antony Chazapis |
|
89 | f6c97079 | Antony Chazapis | Parameters:
|
90 | f6c97079 | Antony Chazapis | 'marker': Start list from the next item after 'marker'
|
91 | f4b61e0c | Antony Chazapis |
|
92 | f6c97079 | Antony Chazapis | 'limit': Number of containers to return
|
93 | f6c97079 | Antony Chazapis | """
|
94 | f6c97079 | Antony Chazapis | return []
|
95 | f6c97079 | Antony Chazapis | |
96 | 82482e2c | Antony Chazapis | def get_account_meta(self, user, account, domain, until=None, include_user_defined=True): |
97 | cb69c154 | Antony Chazapis | """Return a dictionary with the account metadata for the domain.
|
98 | b956618e | Antony Chazapis |
|
99 | b956618e | Antony Chazapis | The keys returned are all user-defined, except:
|
100 | b956618e | Antony Chazapis | 'name': The account name
|
101 | f4b61e0c | Antony Chazapis |
|
102 | b956618e | Antony Chazapis | 'count': The number of containers (or 0)
|
103 | f4b61e0c | Antony Chazapis |
|
104 | b956618e | Antony Chazapis | 'bytes': The total data size (or 0)
|
105 | f4b61e0c | Antony Chazapis |
|
106 | 58a6c894 | Antony Chazapis | 'modified': Last modification timestamp (overall)
|
107 | f4b61e0c | Antony Chazapis |
|
108 | 58a6c894 | Antony Chazapis | 'until_timestamp': Last modification until the timestamp provided
|
109 | cca6c617 | Antony Chazapis |
|
110 | cca6c617 | Antony Chazapis | Raises:
|
111 | cca6c617 | Antony Chazapis | NotAllowedError: Operation not permitted
|
112 | b956618e | Antony Chazapis | """
|
113 | b956618e | Antony Chazapis | return {}
|
114 | b956618e | Antony Chazapis | |
115 | cb69c154 | Antony Chazapis | def update_account_meta(self, user, account, domain, meta, replace=False): |
116 | cb69c154 | Antony Chazapis | """Update the metadata associated with the account for the domain.
|
117 | b956618e | Antony Chazapis |
|
118 | b956618e | Antony Chazapis | Parameters:
|
119 | cb69c154 | Antony Chazapis | 'domain': Metadata domain
|
120 | cb69c154 | Antony Chazapis |
|
121 | b956618e | Antony Chazapis | 'meta': Dictionary with metadata to update
|
122 | f4b61e0c | Antony Chazapis |
|
123 | 22dab079 | Antony Chazapis | 'replace': Replace instead of update
|
124 | cca6c617 | Antony Chazapis |
|
125 | cca6c617 | Antony Chazapis | Raises:
|
126 | cca6c617 | Antony Chazapis | NotAllowedError: Operation not permitted
|
127 | b956618e | Antony Chazapis | """
|
128 | b956618e | Antony Chazapis | return
|
129 | b956618e | Antony Chazapis | |
130 | 02c0c3fa | Antony Chazapis | def get_account_groups(self, user, account): |
131 | 02c0c3fa | Antony Chazapis | """Return a dictionary with the user groups defined for this account.
|
132 | cca6c617 | Antony Chazapis |
|
133 | cca6c617 | Antony Chazapis | Raises:
|
134 | cca6c617 | Antony Chazapis | NotAllowedError: Operation not permitted
|
135 | 58a6c894 | Antony Chazapis | """
|
136 | 02c0c3fa | Antony Chazapis | return {}
|
137 | 58a6c894 | Antony Chazapis | |
138 | 02c0c3fa | Antony Chazapis | def update_account_groups(self, user, account, groups, replace=False): |
139 | 02c0c3fa | Antony Chazapis | """Update the groups associated with the account.
|
140 | 83dd59c5 | Antony Chazapis |
|
141 | b956618e | Antony Chazapis | Raises:
|
142 | cca6c617 | Antony Chazapis | NotAllowedError: Operation not permitted
|
143 | f4b61e0c | Antony Chazapis |
|
144 | 02c0c3fa | Antony Chazapis | ValueError: Invalid data in groups
|
145 | b956618e | Antony Chazapis | """
|
146 | b956618e | Antony Chazapis | return
|
147 | b956618e | Antony Chazapis | |
148 | b2832c6a | Antony Chazapis | def get_account_policy(self, user, account): |
149 | b2832c6a | Antony Chazapis | """Return a dictionary with the account policy.
|
150 | b2832c6a | Antony Chazapis |
|
151 | b2832c6a | Antony Chazapis | The keys returned are:
|
152 | b2832c6a | Antony Chazapis | 'quota': The maximum bytes allowed (default is 0 - unlimited)
|
153 | b2832c6a | Antony Chazapis |
|
154 | b2832c6a | Antony Chazapis | 'versioning': Can be 'auto', 'manual' or 'none' (default is 'manual')
|
155 | b2832c6a | Antony Chazapis |
|
156 | b2832c6a | Antony Chazapis | Raises:
|
157 | b2832c6a | Antony Chazapis | NotAllowedError: Operation not permitted
|
158 | b2832c6a | Antony Chazapis | """
|
159 | b2832c6a | Antony Chazapis | return {}
|
160 | b2832c6a | Antony Chazapis | |
161 | b2832c6a | Antony Chazapis | def update_account_policy(self, user, account, policy, replace=False): |
162 | b2832c6a | Antony Chazapis | """Update the policy associated with the account.
|
163 | b2832c6a | Antony Chazapis |
|
164 | b2832c6a | Antony Chazapis | Raises:
|
165 | b2832c6a | Antony Chazapis | NotAllowedError: Operation not permitted
|
166 | b2832c6a | Antony Chazapis |
|
167 | b2832c6a | Antony Chazapis | ValueError: Invalid policy defined
|
168 | b2832c6a | Antony Chazapis | """
|
169 | b2832c6a | Antony Chazapis | return
|
170 | b2832c6a | Antony Chazapis | |
171 | 1c50a9e5 | Sofia Papagiannaki | def put_account(self, user, account, policy={}): |
172 | a9b3f29d | Antony Chazapis | """Create a new account with the given name.
|
173 | a9b3f29d | Antony Chazapis |
|
174 | a9b3f29d | Antony Chazapis | Raises:
|
175 | a9b3f29d | Antony Chazapis | NotAllowedError: Operation not permitted
|
176 | b2832c6a | Antony Chazapis |
|
177 | b2832c6a | Antony Chazapis | ValueError: Invalid policy defined
|
178 | a9b3f29d | Antony Chazapis | """
|
179 | a9b3f29d | Antony Chazapis | return
|
180 | a9b3f29d | Antony Chazapis | |
181 | 02c0c3fa | Antony Chazapis | def delete_account(self, user, account): |
182 | 02c0c3fa | Antony Chazapis | """Delete the account with the given name.
|
183 | 83dd59c5 | Antony Chazapis |
|
184 | b956618e | Antony Chazapis | Raises:
|
185 | cca6c617 | Antony Chazapis | NotAllowedError: Operation not permitted
|
186 | f4b61e0c | Antony Chazapis |
|
187 | 7efc9f86 | Sofia Papagiannaki | AccountNotEmpty: Account is not empty
|
188 | b956618e | Antony Chazapis | """
|
189 | b956618e | Antony Chazapis | return
|
190 | b956618e | Antony Chazapis | |
191 | 4d15c94e | Sofia Papagiannaki | def list_containers(self, user, account, marker=None, limit=10000, shared=False, until=None, public=False): |
192 | f6c97079 | Antony Chazapis | """Return a list of container names existing under an account.
|
193 | 02c0c3fa | Antony Chazapis |
|
194 | 02c0c3fa | Antony Chazapis | Parameters:
|
195 | 02c0c3fa | Antony Chazapis | 'marker': Start list from the next item after 'marker'
|
196 | f4b61e0c | Antony Chazapis |
|
197 | 02c0c3fa | Antony Chazapis | 'limit': Number of containers to return
|
198 | f4b61e0c | Antony Chazapis |
|
199 | b18ef3ad | Antony Chazapis | 'shared': Only list containers with permissions set
|
200 | f4b61e0c | Antony Chazapis |
|
201 | 4d15c94e | Sofia Papagiannaki | 'public': Only list containers containing public objects
|
202 | 4d15c94e | Sofia Papagiannaki |
|
203 | 02c0c3fa | Antony Chazapis |
|
204 | 02c0c3fa | Antony Chazapis | Raises:
|
205 | 02c0c3fa | Antony Chazapis | NotAllowedError: Operation not permitted
|
206 | 02c0c3fa | Antony Chazapis | """
|
207 | 02c0c3fa | Antony Chazapis | return []
|
208 | 02c0c3fa | Antony Chazapis | |
209 | 371d907a | Antony Chazapis | def list_container_meta(self, user, account, container, domain, until=None): |
210 | 371d907a | Antony Chazapis | """Return a list with all the container's object meta keys for the domain.
|
211 | 371d907a | Antony Chazapis |
|
212 | 371d907a | Antony Chazapis | Raises:
|
213 | 371d907a | Antony Chazapis | NotAllowedError: Operation not permitted
|
214 | 371d907a | Antony Chazapis |
|
215 | 7efc9f86 | Sofia Papagiannaki | ItemNotExists: Container does not exist
|
216 | 371d907a | Antony Chazapis | """
|
217 | 371d907a | Antony Chazapis | return []
|
218 | 371d907a | Antony Chazapis | |
219 | 82482e2c | Antony Chazapis | def get_container_meta(self, user, account, container, domain, until=None, include_user_defined=True): |
220 | cb69c154 | Antony Chazapis | """Return a dictionary with the container metadata for the domain.
|
221 | 83dd59c5 | Antony Chazapis |
|
222 | b956618e | Antony Chazapis | The keys returned are all user-defined, except:
|
223 | b956618e | Antony Chazapis | 'name': The container name
|
224 | f4b61e0c | Antony Chazapis |
|
225 | b956618e | Antony Chazapis | 'count': The number of objects
|
226 | f4b61e0c | Antony Chazapis |
|
227 | b956618e | Antony Chazapis | 'bytes': The total data size
|
228 | f4b61e0c | Antony Chazapis |
|
229 | 58a6c894 | Antony Chazapis | 'modified': Last modification timestamp (overall)
|
230 | f4b61e0c | Antony Chazapis |
|
231 | 58a6c894 | Antony Chazapis | 'until_timestamp': Last modification until the timestamp provided
|
232 | b956618e | Antony Chazapis |
|
233 | b956618e | Antony Chazapis | Raises:
|
234 | cca6c617 | Antony Chazapis | NotAllowedError: Operation not permitted
|
235 | f4b61e0c | Antony Chazapis |
|
236 | 7efc9f86 | Sofia Papagiannaki | ItemNotExists: Container does not exist
|
237 | b956618e | Antony Chazapis | """
|
238 | b956618e | Antony Chazapis | return {}
|
239 | b956618e | Antony Chazapis | |
240 | cb69c154 | Antony Chazapis | def update_container_meta(self, user, account, container, domain, meta, replace=False): |
241 | cb69c154 | Antony Chazapis | """Update the metadata associated with the container for the domain.
|
242 | b956618e | Antony Chazapis |
|
243 | b956618e | Antony Chazapis | Parameters:
|
244 | cb69c154 | Antony Chazapis | 'domain': Metadata domain
|
245 | cb69c154 | Antony Chazapis |
|
246 | b956618e | Antony Chazapis | 'meta': Dictionary with metadata to update
|
247 | f4b61e0c | Antony Chazapis |
|
248 | 22dab079 | Antony Chazapis | 'replace': Replace instead of update
|
249 | b956618e | Antony Chazapis |
|
250 | b956618e | Antony Chazapis | Raises:
|
251 | cca6c617 | Antony Chazapis | NotAllowedError: Operation not permitted
|
252 | f4b61e0c | Antony Chazapis |
|
253 | 7efc9f86 | Sofia Papagiannaki | ItemNotExists: Container does not exist
|
254 | b956618e | Antony Chazapis | """
|
255 | b956618e | Antony Chazapis | return
|
256 | b956618e | Antony Chazapis | |
257 | 02c0c3fa | Antony Chazapis | def get_container_policy(self, user, account, container): |
258 | 02c0c3fa | Antony Chazapis | """Return a dictionary with the container policy.
|
259 | 02c0c3fa | Antony Chazapis |
|
260 | 02c0c3fa | Antony Chazapis | The keys returned are:
|
261 | 02c0c3fa | Antony Chazapis | 'quota': The maximum bytes allowed (default is 0 - unlimited)
|
262 | f4b61e0c | Antony Chazapis |
|
263 | 02c0c3fa | Antony Chazapis | 'versioning': Can be 'auto', 'manual' or 'none' (default is 'manual')
|
264 | 02c0c3fa | Antony Chazapis |
|
265 | 02c0c3fa | Antony Chazapis | Raises:
|
266 | 02c0c3fa | Antony Chazapis | NotAllowedError: Operation not permitted
|
267 | f4b61e0c | Antony Chazapis |
|
268 | 7efc9f86 | Sofia Papagiannaki | ItemNotExists: Container does not exist
|
269 | 02c0c3fa | Antony Chazapis | """
|
270 | 02c0c3fa | Antony Chazapis | return {}
|
271 | 02c0c3fa | Antony Chazapis | |
272 | 02c0c3fa | Antony Chazapis | def update_container_policy(self, user, account, container, policy, replace=False): |
273 | b2832c6a | Antony Chazapis | """Update the policy associated with the container.
|
274 | 02c0c3fa | Antony Chazapis |
|
275 | 02c0c3fa | Antony Chazapis | Raises:
|
276 | 02c0c3fa | Antony Chazapis | NotAllowedError: Operation not permitted
|
277 | f4b61e0c | Antony Chazapis |
|
278 | 7efc9f86 | Sofia Papagiannaki | ItemNotExists: Container does not exist
|
279 | f4b61e0c | Antony Chazapis |
|
280 | 02c0c3fa | Antony Chazapis | ValueError: Invalid policy defined
|
281 | 02c0c3fa | Antony Chazapis | """
|
282 | 02c0c3fa | Antony Chazapis | return
|
283 | 02c0c3fa | Antony Chazapis | |
284 | e46b2bcf | Sofia Papagiannaki | def put_container(self, user, account, container, policy={}, delimiter=None): |
285 | 02c0c3fa | Antony Chazapis | """Create a new container with the given name.
|
286 | 02c0c3fa | Antony Chazapis |
|
287 | e46b2bcf | Sofia Papagiannaki | Parameters:
|
288 | e46b2bcf | Sofia Papagiannaki | 'delimiter': If present deletes container contents instead of the container
|
289 | e46b2bcf | Sofia Papagiannaki |
|
290 | 02c0c3fa | Antony Chazapis | Raises:
|
291 | 02c0c3fa | Antony Chazapis | NotAllowedError: Operation not permitted
|
292 | f4b61e0c | Antony Chazapis |
|
293 | 7efc9f86 | Sofia Papagiannaki | ContainerExists: Container already exists
|
294 | f4b61e0c | Antony Chazapis |
|
295 | 02c0c3fa | Antony Chazapis | ValueError: Invalid policy defined
|
296 | 02c0c3fa | Antony Chazapis | """
|
297 | 02c0c3fa | Antony Chazapis | return
|
298 | 02c0c3fa | Antony Chazapis | |
299 | 84846143 | Antony Chazapis | def delete_container(self, user, account, container, until=None): |
300 | 84846143 | Antony Chazapis | """Delete/purge the container with the given name.
|
301 | 02c0c3fa | Antony Chazapis |
|
302 | 02c0c3fa | Antony Chazapis | Raises:
|
303 | 02c0c3fa | Antony Chazapis | NotAllowedError: Operation not permitted
|
304 | f4b61e0c | Antony Chazapis |
|
305 | 7efc9f86 | Sofia Papagiannaki | ItemNotExists: Container does not exist
|
306 | f4b61e0c | Antony Chazapis |
|
307 | 7efc9f86 | Sofia Papagiannaki | ContainerNotEmpty: Container is not empty
|
308 | 02c0c3fa | Antony Chazapis | """
|
309 | 02c0c3fa | Antony Chazapis | return
|
310 | 02c0c3fa | Antony Chazapis | |
311 | 4d15c94e | Sofia Papagiannaki | 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, public=False): |
312 | 58a6c894 | Antony Chazapis | """Return a list of object (name, version_id) tuples existing under a container.
|
313 | b956618e | Antony Chazapis |
|
314 | b956618e | Antony Chazapis | Parameters:
|
315 | b956618e | Antony Chazapis | 'prefix': List objects starting with 'prefix'
|
316 | f4b61e0c | Antony Chazapis |
|
317 | b956618e | Antony Chazapis | 'delimiter': Return unique names before 'delimiter' and after 'prefix'
|
318 | f4b61e0c | Antony Chazapis |
|
319 | b956618e | Antony Chazapis | 'marker': Start list from the next item after 'marker'
|
320 | f4b61e0c | Antony Chazapis |
|
321 | b956618e | Antony Chazapis | 'limit': Number of objects to return
|
322 | f4b61e0c | Antony Chazapis |
|
323 | f4b61e0c | Antony Chazapis | 'virtual': If not set, the result will only include names starting
|
324 | f4b61e0c | Antony Chazapis | with 'prefix' and ending without a 'delimiter' or with
|
325 | f4b61e0c | Antony Chazapis | the first occurance of the 'delimiter' after 'prefix'.
|
326 | f4b61e0c | Antony Chazapis | If set, the result will include all names after 'prefix',
|
327 | 3f839f59 | Antony Chazapis | up to and including the 'delimiter' if it is found
|
328 | f4b61e0c | Antony Chazapis |
|
329 | cb69c154 | Antony Chazapis | 'domain': Metadata domain for keys
|
330 | cb69c154 | Antony Chazapis |
|
331 | 95d47e1a | Antony Chazapis | 'keys': Include objects that satisfy the key queries in the list.
|
332 | 95d47e1a | Antony Chazapis | Use 'key', '!key' for existence queries, 'key op value' for
|
333 | 4e5673a0 | Antony Chazapis | value queries, where 'op' can be one of =, !=, <=, >=, <, >
|
334 | f4b61e0c | Antony Chazapis |
|
335 | b18ef3ad | Antony Chazapis | 'shared': Only list objects with permissions set
|
336 | 7ff57991 | Antony Chazapis |
|
337 | 7ff57991 | Antony Chazapis | 'size_range': Include objects with byte size in (from, to).
|
338 | 7ff57991 | Antony Chazapis | Use None to specify unlimited
|
339 | 4d15c94e | Sofia Papagiannaki |
|
340 | 4d15c94e | Sofia Papagiannaki | 'public': Only list public objects
|
341 | 4d15c94e | Sofia Papagiannaki |
|
342 | 22dab079 | Antony Chazapis |
|
343 | 22dab079 | Antony Chazapis | Raises:
|
344 | cca6c617 | Antony Chazapis | NotAllowedError: Operation not permitted
|
345 | f4b61e0c | Antony Chazapis |
|
346 | 7efc9f86 | Sofia Papagiannaki | ItemNotExists: Container does not exist
|
347 | 22dab079 | Antony Chazapis | """
|
348 | 22dab079 | Antony Chazapis | return []
|
349 | 22dab079 | Antony Chazapis | |
350 | 371d907a | Antony Chazapis | def list_object_meta(self, user, account, container, prefix='', delimiter=None, marker=None, limit=10000, virtual=True, domain=None, keys=[], shared=False, until=None, size_range=None): |
351 | 371d907a | Antony Chazapis | """Return a list of object metadata dicts existing under a container.
|
352 | b956618e | Antony Chazapis |
|
353 | 371d907a | Antony Chazapis | Same parameters with list_objects. Returned dicts have no user-defined
|
354 | 371d907a | Antony Chazapis | metadata and, if until is not None, a None 'modified' timestamp.
|
355 | 15a96c3e | Antony Chazapis |
|
356 | 15a96c3e | Antony Chazapis | Raises:
|
357 | 15a96c3e | Antony Chazapis | NotAllowedError: Operation not permitted
|
358 | 15a96c3e | Antony Chazapis |
|
359 | 7efc9f86 | Sofia Papagiannaki | ItemNotExists: Container does not exist
|
360 | b956618e | Antony Chazapis | """
|
361 | b956618e | Antony Chazapis | return []
|
362 | b956618e | Antony Chazapis | |
363 | 15a96c3e | Antony Chazapis | def list_object_permissions(self, user, account, container, prefix=''): |
364 | 15a96c3e | Antony Chazapis | """Return a list of paths that enforce permissions under a container.
|
365 | 15a96c3e | Antony Chazapis |
|
366 | 15a96c3e | Antony Chazapis | Raises:
|
367 | 15a96c3e | Antony Chazapis | NotAllowedError: Operation not permitted
|
368 | 15a96c3e | Antony Chazapis | """
|
369 | 15a96c3e | Antony Chazapis | return []
|
370 | 15a96c3e | Antony Chazapis | |
371 | 15a96c3e | Antony Chazapis | def list_object_public(self, user, account, container, prefix=''): |
372 | 15a96c3e | Antony Chazapis | """Return a dict mapping paths to public ids for objects that are public under a container."""
|
373 | 15a96c3e | Antony Chazapis | return {}
|
374 | 15a96c3e | Antony Chazapis | |
375 | 82482e2c | Antony Chazapis | def get_object_meta(self, user, account, container, name, domain, version=None, include_user_defined=True): |
376 | cb69c154 | Antony Chazapis | """Return a dictionary with the object metadata for the domain.
|
377 | b956618e | Antony Chazapis |
|
378 | b956618e | Antony Chazapis | The keys returned are all user-defined, except:
|
379 | 58a6c894 | Antony Chazapis | 'name': The object name
|
380 | f4b61e0c | Antony Chazapis |
|
381 | b956618e | Antony Chazapis | 'bytes': The total data size
|
382 | f4b61e0c | Antony Chazapis |
|
383 | 66ce2ca5 | Antony Chazapis | 'type': The content type
|
384 | 66ce2ca5 | Antony Chazapis |
|
385 | 4a1c29ea | Antony Chazapis | 'hash': The hashmap hash
|
386 | 4a1c29ea | Antony Chazapis |
|
387 | 58a6c894 | Antony Chazapis | 'modified': Last modification timestamp (overall)
|
388 | f4b61e0c | Antony Chazapis |
|
389 | 104626e3 | Antony Chazapis | 'modified_by': The user that committed the object (version requested)
|
390 | f4b61e0c | Antony Chazapis |
|
391 | 58a6c894 | Antony Chazapis | 'version': The version identifier
|
392 | f4b61e0c | Antony Chazapis |
|
393 | 58a6c894 | Antony Chazapis | 'version_timestamp': The version's modification timestamp
|
394 | 25ae8b75 | Antony Chazapis |
|
395 | 25ae8b75 | Antony Chazapis | 'uuid': A unique identifier that persists data or metadata updates and renames
|
396 | 33b4e4a6 | Antony Chazapis |
|
397 | 33b4e4a6 | Antony Chazapis | 'checksum': The MD5 sum of the object (may be empty)
|
398 | b956618e | Antony Chazapis |
|
399 | b956618e | Antony Chazapis | Raises:
|
400 | cca6c617 | Antony Chazapis | NotAllowedError: Operation not permitted
|
401 | f4b61e0c | Antony Chazapis |
|
402 | 7efc9f86 | Sofia Papagiannaki | ItemNotExists: Container/object does not exist
|
403 | f4b61e0c | Antony Chazapis |
|
404 | 7efc9f86 | Sofia Papagiannaki | VersionNotExists: Version does not exist
|
405 | b956618e | Antony Chazapis | """
|
406 | b956618e | Antony Chazapis | return {}
|
407 | b956618e | Antony Chazapis | |
408 | cb69c154 | Antony Chazapis | def update_object_meta(self, user, account, container, name, domain, meta, replace=False): |
409 | cb69c154 | Antony Chazapis | """Update the metadata associated with the object for the domain and return the new version.
|
410 | b956618e | Antony Chazapis |
|
411 | b956618e | Antony Chazapis | Parameters:
|
412 | cb69c154 | Antony Chazapis | 'domain': Metadata domain
|
413 | cb69c154 | Antony Chazapis |
|
414 | a6eb13e9 | Antony Chazapis | 'meta': Dictionary with metadata to update
|
415 | f4b61e0c | Antony Chazapis |
|
416 | 22dab079 | Antony Chazapis | 'replace': Replace instead of update
|
417 | b956618e | Antony Chazapis |
|
418 | b956618e | Antony Chazapis | Raises:
|
419 | cca6c617 | Antony Chazapis | NotAllowedError: Operation not permitted
|
420 | f4b61e0c | Antony Chazapis |
|
421 | 7efc9f86 | Sofia Papagiannaki | ItemNotExists: Container/object does not exist
|
422 | b956618e | Antony Chazapis | """
|
423 | 02c4d2ba | Antony Chazapis | return '' |
424 | b956618e | Antony Chazapis | |
425 | 3436eeb0 | Antony Chazapis | def get_object_permissions(self, user, account, container, name): |
426 | 067cf1fc | Antony Chazapis | """Return the action allowed on the object, the path
|
427 | 067cf1fc | Antony Chazapis | from which the object gets its permissions from,
|
428 | cca6c617 | Antony Chazapis | along with a dictionary containing the permissions.
|
429 | 3436eeb0 | Antony Chazapis |
|
430 | 067cf1fc | Antony Chazapis | The dictionary keys are (also used for defining the action):
|
431 | 3436eeb0 | Antony Chazapis | 'read': The object is readable by the users/groups in the list
|
432 | f4b61e0c | Antony Chazapis |
|
433 | 3436eeb0 | Antony Chazapis | 'write': The object is writable by the users/groups in the list
|
434 | 3436eeb0 | Antony Chazapis |
|
435 | 3436eeb0 | Antony Chazapis | Raises:
|
436 | cca6c617 | Antony Chazapis | NotAllowedError: Operation not permitted
|
437 | f4b61e0c | Antony Chazapis |
|
438 | 7efc9f86 | Sofia Papagiannaki | ItemNotExists: Container/object does not exist
|
439 | 3436eeb0 | Antony Chazapis | """
|
440 | 3436eeb0 | Antony Chazapis | return {}
|
441 | 3436eeb0 | Antony Chazapis | |
442 | 3436eeb0 | Antony Chazapis | def update_object_permissions(self, user, account, container, name, permissions): |
443 | 345dcf39 | Antony Chazapis | """Update (set) the permissions associated with the object.
|
444 | 3436eeb0 | Antony Chazapis |
|
445 | 3436eeb0 | Antony Chazapis | Parameters:
|
446 | 345dcf39 | Antony Chazapis | 'permissions': Dictionary with permissions to set
|
447 | 3436eeb0 | Antony Chazapis |
|
448 | 3436eeb0 | Antony Chazapis | Raises:
|
449 | cca6c617 | Antony Chazapis | NotAllowedError: Operation not permitted
|
450 | f4b61e0c | Antony Chazapis |
|
451 | 7efc9f86 | Sofia Papagiannaki | ItemNotExists: Container/object does not exist
|
452 | f4b61e0c | Antony Chazapis |
|
453 | 3436eeb0 | Antony Chazapis | ValueError: Invalid users/groups in permissions
|
454 | 3436eeb0 | Antony Chazapis | """
|
455 | 3436eeb0 | Antony Chazapis | return
|
456 | 3436eeb0 | Antony Chazapis | |
457 | 02c0c3fa | Antony Chazapis | def get_object_public(self, user, account, container, name): |
458 | bb4eafc6 | Antony Chazapis | """Return the public id of the object if applicable.
|
459 | 02c0c3fa | Antony Chazapis |
|
460 | 02c0c3fa | Antony Chazapis | Raises:
|
461 | 02c0c3fa | Antony Chazapis | NotAllowedError: Operation not permitted
|
462 | f4b61e0c | Antony Chazapis |
|
463 | 7efc9f86 | Sofia Papagiannaki | ItemNotExists: Container/object does not exist
|
464 | 02c0c3fa | Antony Chazapis | """
|
465 | 02c0c3fa | Antony Chazapis | return None |
466 | 02c0c3fa | Antony Chazapis | |
467 | 02c0c3fa | Antony Chazapis | def update_object_public(self, user, account, container, name, public): |
468 | 02c0c3fa | Antony Chazapis | """Update the public status of the object.
|
469 | 02c0c3fa | Antony Chazapis |
|
470 | 02c0c3fa | Antony Chazapis | Parameters:
|
471 | 02c0c3fa | Antony Chazapis | 'public': Boolean value
|
472 | 02c0c3fa | Antony Chazapis |
|
473 | 02c0c3fa | Antony Chazapis | Raises:
|
474 | 02c0c3fa | Antony Chazapis | NotAllowedError: Operation not permitted
|
475 | f4b61e0c | Antony Chazapis |
|
476 | 7efc9f86 | Sofia Papagiannaki | ItemNotExists: Container/object does not exist
|
477 | 02c0c3fa | Antony Chazapis | """
|
478 | 02c0c3fa | Antony Chazapis | return
|
479 | 02c0c3fa | Antony Chazapis | |
480 | 83dd59c5 | Antony Chazapis | def get_object_hashmap(self, user, account, container, name, version=None): |
481 | 22dab079 | Antony Chazapis | """Return the object's size and a list with partial hashes.
|
482 | b956618e | Antony Chazapis |
|
483 | b956618e | Antony Chazapis | Raises:
|
484 | cca6c617 | Antony Chazapis | NotAllowedError: Operation not permitted
|
485 | f4b61e0c | Antony Chazapis |
|
486 | 7efc9f86 | Sofia Papagiannaki | ItemNotExists: Container/object does not exist
|
487 | f4b61e0c | Antony Chazapis |
|
488 | 7efc9f86 | Sofia Papagiannaki | VersionNotExists: Version does not exist
|
489 | b956618e | Antony Chazapis | """
|
490 | 22dab079 | Antony Chazapis | return 0, [] |
491 | b956618e | Antony Chazapis | |
492 | 33b4e4a6 | Antony Chazapis | def update_object_hashmap(self, user, account, container, name, size, type, hashmap, checksum, domain, meta={}, replace_meta=False, permissions=None): |
493 | 02c4d2ba | Antony Chazapis | """Create/update an object with the specified size and partial hashes and return the new version.
|
494 | b956618e | Antony Chazapis |
|
495 | 3436eeb0 | Antony Chazapis | Parameters:
|
496 | cb69c154 | Antony Chazapis | 'domain': Metadata domain
|
497 | cb69c154 | Antony Chazapis |
|
498 | cb69c154 | Antony Chazapis | 'meta': Dictionary with metadata to change
|
499 | f4b61e0c | Antony Chazapis |
|
500 | 3436eeb0 | Antony Chazapis | 'replace_meta': Replace metadata instead of update
|
501 | f4b61e0c | Antony Chazapis |
|
502 | 3436eeb0 | Antony Chazapis | 'permissions': Updated object permissions
|
503 | 3436eeb0 | Antony Chazapis |
|
504 | b956618e | Antony Chazapis | Raises:
|
505 | cca6c617 | Antony Chazapis | NotAllowedError: Operation not permitted
|
506 | f4b61e0c | Antony Chazapis |
|
507 | 7efc9f86 | Sofia Papagiannaki | ItemNotExists: Container does not exist
|
508 | f4b61e0c | Antony Chazapis |
|
509 | 3436eeb0 | Antony Chazapis | ValueError: Invalid users/groups in permissions
|
510 | f4b61e0c | Antony Chazapis |
|
511 | 5df6c6d1 | Antony Chazapis | QuotaError: Account or container quota exceeded
|
512 | b956618e | Antony Chazapis | """
|
513 | 02c4d2ba | Antony Chazapis | return '' |
514 | b956618e | Antony Chazapis | |
515 | 33b4e4a6 | Antony Chazapis | def update_object_checksum(self, user, account, container, name, version, checksum): |
516 | 33b4e4a6 | Antony Chazapis | """Update an object's checksum."""
|
517 | 33b4e4a6 | Antony Chazapis | return
|
518 | 33b4e4a6 | Antony Chazapis | |
519 | 4d15c94e | Sofia Papagiannaki | def copy_object(self, user, src_account, src_container, src_name, dest_account, dest_container, dest_name, type, domain, meta={}, replace_meta=False, permissions=None, src_version=None, delimiter=None): |
520 | 02c4d2ba | Antony Chazapis | """Copy an object's data and metadata and return the new version.
|
521 | b956618e | Antony Chazapis |
|
522 | b956618e | Antony Chazapis | Parameters:
|
523 | cb69c154 | Antony Chazapis | 'domain': Metadata domain
|
524 | cb69c154 | Antony Chazapis |
|
525 | cb69c154 | Antony Chazapis | 'meta': Dictionary with metadata to change from source to destination
|
526 | f4b61e0c | Antony Chazapis |
|
527 | 22dab079 | Antony Chazapis | 'replace_meta': Replace metadata instead of update
|
528 | f4b61e0c | Antony Chazapis |
|
529 | 3436eeb0 | Antony Chazapis | 'permissions': New object permissions
|
530 | f4b61e0c | Antony Chazapis |
|
531 | 3436eeb0 | Antony Chazapis | 'src_version': Copy from the version provided
|
532 | 4d15c94e | Sofia Papagiannaki |
|
533 | 4d15c94e | Sofia Papagiannaki | 'delimiter': Copy objects whose path starts with src_name + delimiter
|
534 | b956618e | Antony Chazapis |
|
535 | b956618e | Antony Chazapis | Raises:
|
536 | cca6c617 | Antony Chazapis | NotAllowedError: Operation not permitted
|
537 | f4b61e0c | Antony Chazapis |
|
538 | 7efc9f86 | Sofia Papagiannaki | ItemNotExists: Container/object does not exist
|
539 | f4b61e0c | Antony Chazapis |
|
540 | 7efc9f86 | Sofia Papagiannaki | VersionNotExists: Version does not exist
|
541 | f4b61e0c | Antony Chazapis |
|
542 | 3436eeb0 | Antony Chazapis | ValueError: Invalid users/groups in permissions
|
543 | f4b61e0c | Antony Chazapis |
|
544 | 5df6c6d1 | Antony Chazapis | QuotaError: Account or container quota exceeded
|
545 | b956618e | Antony Chazapis | """
|
546 | 02c4d2ba | Antony Chazapis | return '' |
547 | b956618e | Antony Chazapis | |
548 | 4d15c94e | Sofia Papagiannaki | def move_object(self, user, src_account, src_container, src_name, dest_account, dest_container, dest_name, type, domain, meta={}, replace_meta=False, permissions=None, delimiter=None): |
549 | 02c4d2ba | Antony Chazapis | """Move an object's data and metadata and return the new version.
|
550 | b956618e | Antony Chazapis |
|
551 | b956618e | Antony Chazapis | Parameters:
|
552 | cb69c154 | Antony Chazapis | 'domain': Metadata domain
|
553 | cb69c154 | Antony Chazapis |
|
554 | cb69c154 | Antony Chazapis | 'meta': Dictionary with metadata to change from source to destination
|
555 | f4b61e0c | Antony Chazapis |
|
556 | 22dab079 | Antony Chazapis | 'replace_meta': Replace metadata instead of update
|
557 | f4b61e0c | Antony Chazapis |
|
558 | 3436eeb0 | Antony Chazapis | 'permissions': New object permissions
|
559 | 4d15c94e | Sofia Papagiannaki |
|
560 | 4d15c94e | Sofia Papagiannaki | 'delimiter': Move objects whose path starts with src_name + delimiter
|
561 | b956618e | Antony Chazapis |
|
562 | b956618e | Antony Chazapis | Raises:
|
563 | cca6c617 | Antony Chazapis | NotAllowedError: Operation not permitted
|
564 | f4b61e0c | Antony Chazapis |
|
565 | 7efc9f86 | Sofia Papagiannaki | ItemNotExists: Container/object does not exist
|
566 | f4b61e0c | Antony Chazapis |
|
567 | 3436eeb0 | Antony Chazapis | ValueError: Invalid users/groups in permissions
|
568 | f4b61e0c | Antony Chazapis |
|
569 | 5df6c6d1 | Antony Chazapis | QuotaError: Account or container quota exceeded
|
570 | b956618e | Antony Chazapis | """
|
571 | 02c4d2ba | Antony Chazapis | return '' |
572 | b956618e | Antony Chazapis | |
573 | 4d15c94e | Sofia Papagiannaki | def delete_object(self, user, account, container, name, until=None, delimiter=None): |
574 | 84846143 | Antony Chazapis | """Delete/purge an object.
|
575 | b956618e | Antony Chazapis |
|
576 | 4d15c94e | Sofia Papagiannaki | Parameters:
|
577 | 4d15c94e | Sofia Papagiannaki | 'delimiter': Delete objects whose path starting with name + delimiter
|
578 | 4d15c94e | Sofia Papagiannaki |
|
579 | b956618e | Antony Chazapis | Raises:
|
580 | cca6c617 | Antony Chazapis | NotAllowedError: Operation not permitted
|
581 | f4b61e0c | Antony Chazapis |
|
582 | 7efc9f86 | Sofia Papagiannaki | ItemNotExists: Container/object does not exist
|
583 | b956618e | Antony Chazapis | """
|
584 | b956618e | Antony Chazapis | return
|
585 | 22dab079 | Antony Chazapis | |
586 | 83dd59c5 | Antony Chazapis | def list_versions(self, user, account, container, name): |
587 | cca6c617 | Antony Chazapis | """Return a list of all (version, version_timestamp) tuples for an object.
|
588 | cca6c617 | Antony Chazapis |
|
589 | cca6c617 | Antony Chazapis | Raises:
|
590 | cca6c617 | Antony Chazapis | NotAllowedError: Operation not permitted
|
591 | cca6c617 | Antony Chazapis | """
|
592 | 58a6c894 | Antony Chazapis | return []
|
593 | 58a6c894 | Antony Chazapis | |
594 | 37bee317 | Antony Chazapis | def get_uuid(self, user, uuid): |
595 | 37bee317 | Antony Chazapis | """Return the (account, container, name) for the UUID given.
|
596 | 37bee317 | Antony Chazapis |
|
597 | 37bee317 | Antony Chazapis | Raises:
|
598 | 37bee317 | Antony Chazapis | NotAllowedError: Operation not permitted
|
599 | 37bee317 | Antony Chazapis |
|
600 | 37bee317 | Antony Chazapis | NameError: UUID does not exist
|
601 | 37bee317 | Antony Chazapis | """
|
602 | 37bee317 | Antony Chazapis | return None |
603 | 37bee317 | Antony Chazapis | |
604 | bb4eafc6 | Antony Chazapis | def get_public(self, user, public): |
605 | bb4eafc6 | Antony Chazapis | """Return the (account, container, name) for the public id given.
|
606 | bb4eafc6 | Antony Chazapis |
|
607 | bb4eafc6 | Antony Chazapis | Raises:
|
608 | bb4eafc6 | Antony Chazapis | NotAllowedError: Operation not permitted
|
609 | bb4eafc6 | Antony Chazapis |
|
610 | bb4eafc6 | Antony Chazapis | NameError: Public id does not exist
|
611 | bb4eafc6 | Antony Chazapis | """
|
612 | bb4eafc6 | Antony Chazapis | return None |
613 | bb4eafc6 | Antony Chazapis | |
614 | 22dab079 | Antony Chazapis | def get_block(self, hash): |
615 | 22dab079 | Antony Chazapis | """Return a block's data.
|
616 | 22dab079 | Antony Chazapis |
|
617 | 22dab079 | Antony Chazapis | Raises:
|
618 | 7efc9f86 | Sofia Papagiannaki | ItemNotExists: Block does not exist
|
619 | 22dab079 | Antony Chazapis | """
|
620 | 22dab079 | Antony Chazapis | return '' |
621 | 22dab079 | Antony Chazapis | |
622 | 22dab079 | Antony Chazapis | def put_block(self, data): |
623 | 22dab079 | Antony Chazapis | """Store a block and return the hash."""
|
624 | 22dab079 | Antony Chazapis | return 0 |
625 | 22dab079 | Antony Chazapis | |
626 | 22dab079 | Antony Chazapis | def update_block(self, hash, data, offset=0): |
627 | 22dab079 | Antony Chazapis | """Update a known block and return the hash.
|
628 | 22dab079 | Antony Chazapis |
|
629 | 22dab079 | Antony Chazapis | Raises:
|
630 | 22dab079 | Antony Chazapis | IndexError: Offset or data outside block limits
|
631 | 22dab079 | Antony Chazapis | """
|
632 | 22dab079 | Antony Chazapis | return 0 |