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