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