Statistics
| Branch: | Tag: | Revision:

root / kamaki / clients / pithos_rest_api.py @ 43ee6ae1

History | View | Annotate | Download (31.8 kB)

1 afd9d603 Stavros Sachtouris
# Copyright 2011-2012 GRNET S.A. All rights reserved.
2 afd9d603 Stavros Sachtouris
#
3 afd9d603 Stavros Sachtouris
# Redistribution and use in source and binary forms, with or
4 afd9d603 Stavros Sachtouris
# without modification, are permitted provided that the following
5 afd9d603 Stavros Sachtouris
# conditions are met:
6 afd9d603 Stavros Sachtouris
#
7 afd9d603 Stavros Sachtouris
#   1. Redistributions of source code must retain the above
8 afd9d603 Stavros Sachtouris
#      copyright notice, this list of conditions and the following
9 afd9d603 Stavros Sachtouris
#      disclaimer.
10 afd9d603 Stavros Sachtouris
#
11 afd9d603 Stavros Sachtouris
#   2. Redistributions in binary form must reproduce the above
12 afd9d603 Stavros Sachtouris
#      copyright notice, this list of conditions and the following
13 afd9d603 Stavros Sachtouris
#      disclaimer in the documentation and/or other materials
14 afd9d603 Stavros Sachtouris
#      provided with the distribution.
15 afd9d603 Stavros Sachtouris
#
16 afd9d603 Stavros Sachtouris
# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
17 afd9d603 Stavros Sachtouris
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 afd9d603 Stavros Sachtouris
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 afd9d603 Stavros Sachtouris
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
20 afd9d603 Stavros Sachtouris
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 afd9d603 Stavros Sachtouris
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 afd9d603 Stavros Sachtouris
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
23 afd9d603 Stavros Sachtouris
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
24 afd9d603 Stavros Sachtouris
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 afd9d603 Stavros Sachtouris
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
26 afd9d603 Stavros Sachtouris
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 afd9d603 Stavros Sachtouris
# POSSIBILITY OF SUCH DAMAGE.
28 afd9d603 Stavros Sachtouris
#
29 afd9d603 Stavros Sachtouris
# The views and conclusions contained in the software and
30 afd9d603 Stavros Sachtouris
# documentation are those of the authors and should not be
31 afd9d603 Stavros Sachtouris
# interpreted as representing official policies, either expressed
32 afd9d603 Stavros Sachtouris
# or implied, of GRNET S.A.
33 afd9d603 Stavros Sachtouris
34 3dabe5d2 Stavros Sachtouris
from kamaki.clients.storage import StorageClient
35 436f2ce1 Stavros Sachtouris
from kamaki.clients.utils import path4url, list2str
36 afd9d603 Stavros Sachtouris
37 3dabe5d2 Stavros Sachtouris
38 afd9d603 Stavros Sachtouris
class PithosRestAPI(StorageClient):
39 afd9d603 Stavros Sachtouris
40 3dabe5d2 Stavros Sachtouris
    def account_head(self,
41 3dabe5d2 Stavros Sachtouris
        until=None,
42 3dabe5d2 Stavros Sachtouris
        if_modified_since=None,
43 3dabe5d2 Stavros Sachtouris
        if_unmodified_since=None,
44 3dabe5d2 Stavros Sachtouris
        *args,
45 3dabe5d2 Stavros Sachtouris
        **kwargs):
46 afd9d603 Stavros Sachtouris
        """ Full Pithos+ HEAD at account level
47 9e4508df Stavros Sachtouris

48 afd9d603 Stavros Sachtouris
        --- request parameters ---
49 9e4508df Stavros Sachtouris

50 9e4508df Stavros Sachtouris
        :param until: (string) optional timestamp
51 9e4508df Stavros Sachtouris

52 9e4508df Stavros Sachtouris
        --- request headers ---
53 9e4508df Stavros Sachtouris

54 9e4508df Stavros Sachtouris
        :param if_modified_since: (string) Retrieve if account has changed
55 9e4508df Stavros Sachtouris
            since provided timestamp
56 9e4508df Stavros Sachtouris

57 9e4508df Stavros Sachtouris
        :param if_unmodified_since: (string) Retrieve if account has not
58 9e4508df Stavros Sachtouris
            change since provided timestamp
59 9e4508df Stavros Sachtouris

60 9e4508df Stavros Sachtouris
        :returns: ConnectionResponse
61 afd9d603 Stavros Sachtouris
        """
62 4067cdaf Stavros Sachtouris
63 d88ba587 Stavros Sachtouris
        self._assert_account()
64 afd9d603 Stavros Sachtouris
        path = path4url(self.account)
65 afd9d603 Stavros Sachtouris
66 3dabe5d2 Stavros Sachtouris
        self.set_param('until', until, iff=until is not None)
67 afd9d603 Stavros Sachtouris
        self.set_header('If-Modified-Since', if_modified_since)
68 afd9d603 Stavros Sachtouris
        self.set_header('If-Unmodified-Since', if_unmodified_since)
69 afd9d603 Stavros Sachtouris
70 afd9d603 Stavros Sachtouris
        success = kwargs.pop('success', 204)
71 afd9d603 Stavros Sachtouris
        return self.head(path, *args, success=success, **kwargs)
72 afd9d603 Stavros Sachtouris
73 3dabe5d2 Stavros Sachtouris
    def account_get(self,
74 3dabe5d2 Stavros Sachtouris
        limit=None,
75 3dabe5d2 Stavros Sachtouris
        marker=None,
76 3dabe5d2 Stavros Sachtouris
        format='json',
77 3dabe5d2 Stavros Sachtouris
        show_only_shared=False,
78 3dabe5d2 Stavros Sachtouris
        until=None,
79 3dabe5d2 Stavros Sachtouris
        if_modified_since=None,
80 3dabe5d2 Stavros Sachtouris
        if_unmodified_since=None,
81 3dabe5d2 Stavros Sachtouris
        *args,
82 3dabe5d2 Stavros Sachtouris
        **kwargs):
83 afd9d603 Stavros Sachtouris
        """  Full Pithos+ GET at account level
84 9e4508df Stavros Sachtouris

85 afd9d603 Stavros Sachtouris
        --- request parameters ---
86 9e4508df Stavros Sachtouris

87 9e4508df Stavros Sachtouris
        :param limit: (integer) The amount of results requested
88 9e4508df Stavros Sachtouris
            (server will use default value if None)
89 9e4508df Stavros Sachtouris

90 9e4508df Stavros Sachtouris
        :param marker: string Return containers with name
91 9e4508df Stavros Sachtouris
            lexicographically after marker
92 9e4508df Stavros Sachtouris

93 9e4508df Stavros Sachtouris
        :param format: (string) reply format can be json or xml
94 9e4508df Stavros Sachtouris
            (default: json)
95 9e4508df Stavros Sachtouris

96 9e4508df Stavros Sachtouris
        :param shared: (bool) If true, only shared containers will be
97 9e4508df Stavros Sachtouris
            included in results
98 9e4508df Stavros Sachtouris

99 9e4508df Stavros Sachtouris
        :param until: (string) optional timestamp
100 9e4508df Stavros Sachtouris

101 9e4508df Stavros Sachtouris
        --- request headers ---
102 9e4508df Stavros Sachtouris

103 9e4508df Stavros Sachtouris
        :param if_modified_since: (string) Retrieve if account has changed
104 9e4508df Stavros Sachtouris
            since provided timestamp
105 9e4508df Stavros Sachtouris

106 9e4508df Stavros Sachtouris
        :param if_unmodified_since: (string) Retrieve if account has not
107 9e4508df Stavros Sachtouris
            changed since provided timestamp
108 9e4508df Stavros Sachtouris

109 9e4508df Stavros Sachtouris
        :returns: ConnectionResponse
110 afd9d603 Stavros Sachtouris
        """
111 4067cdaf Stavros Sachtouris
112 d88ba587 Stavros Sachtouris
        self._assert_account()
113 afd9d603 Stavros Sachtouris
114 3dabe5d2 Stavros Sachtouris
        self.set_param('format', format, iff=format is not None)
115 3dabe5d2 Stavros Sachtouris
        self.set_param('limit', limit, iff=limit is not None)
116 3dabe5d2 Stavros Sachtouris
        self.set_param('marker', marker, iff=marker is not None)
117 3dabe5d2 Stavros Sachtouris
        self.set_param('shared', iff=show_only_shared)
118 3dabe5d2 Stavros Sachtouris
        self.set_param('until', until, iff=until is not None)
119 afd9d603 Stavros Sachtouris
120 afd9d603 Stavros Sachtouris
        self.set_header('If-Modified-Since', if_modified_since)
121 afd9d603 Stavros Sachtouris
        self.set_header('If-Unmodified-Since', if_unmodified_since)
122 afd9d603 Stavros Sachtouris
123 afd9d603 Stavros Sachtouris
        path = path4url(self.account)
124 afd9d603 Stavros Sachtouris
        success = kwargs.pop('success', (200, 204))
125 3dabe5d2 Stavros Sachtouris
        return self.get(path, *args, success=success, **kwargs)
126 afd9d603 Stavros Sachtouris
127 3dabe5d2 Stavros Sachtouris
    def account_post(self,
128 3dabe5d2 Stavros Sachtouris
        update=True,
129 3dabe5d2 Stavros Sachtouris
        groups={},
130 3dabe5d2 Stavros Sachtouris
        metadata=None,
131 3dabe5d2 Stavros Sachtouris
        quota=None,
132 3dabe5d2 Stavros Sachtouris
        versioning=None,
133 3dabe5d2 Stavros Sachtouris
        *args,
134 3dabe5d2 Stavros Sachtouris
        **kwargs):
135 afd9d603 Stavros Sachtouris
        """ Full Pithos+ POST at account level
136 9e4508df Stavros Sachtouris

137 afd9d603 Stavros Sachtouris
        --- request parameters ---
138 9e4508df Stavros Sachtouris

139 9e4508df Stavros Sachtouris
        :param update: (bool) if True, Do not replace metadata/groups
140 9e4508df Stavros Sachtouris

141 afd9d603 Stavros Sachtouris
        --- request headers ---
142 9e4508df Stavros Sachtouris

143 9e4508df Stavros Sachtouris
        :param groups: (dict) Optional user defined groups in the form
144 9e4508df Stavros Sachtouris
            { 'group1':['user1', 'user2', ...],
145 9e4508df Stavros Sachtouris
            'group2':['userA', 'userB', ...], }
146 9e4508df Stavros Sachtouris

147 9e4508df Stavros Sachtouris
        :param metadata: (dict) Optional user defined metadata in the form
148 9e4508df Stavros Sachtouris
            { 'name1': 'value1', 'name2': 'value2', ... }
149 9e4508df Stavros Sachtouris

150 9e4508df Stavros Sachtouris
        :param quota: (integer) If supported, sets the Account quota
151 9e4508df Stavros Sachtouris

152 9e4508df Stavros Sachtouris
        :param versioning: (string) If supported, sets the Account versioning
153 9e4508df Stavros Sachtouris
            to 'auto' or some other supported versioning string
154 9e4508df Stavros Sachtouris

155 9e4508df Stavros Sachtouris
        :returns: ConnectionResponse
156 afd9d603 Stavros Sachtouris
        """
157 4067cdaf Stavros Sachtouris
158 d88ba587 Stavros Sachtouris
        self._assert_account()
159 afd9d603 Stavros Sachtouris
160 3dabe5d2 Stavros Sachtouris
        self.set_param('update', iff=update)
161 afd9d603 Stavros Sachtouris
162 afd9d603 Stavros Sachtouris
        for group, usernames in groups.items():
163 afd9d603 Stavros Sachtouris
            userstr = ''
164 afd9d603 Stavros Sachtouris
            dlm = ''
165 afd9d603 Stavros Sachtouris
            for user in usernames:
166 afd9d603 Stavros Sachtouris
                userstr = userstr + dlm + user
167 afd9d603 Stavros Sachtouris
                dlm = ','
168 3dabe5d2 Stavros Sachtouris
            self.set_header('X-Account-Group-' + group, userstr)
169 afd9d603 Stavros Sachtouris
        if metadata is not None:
170 afd9d603 Stavros Sachtouris
            for metaname, metaval in metadata.items():
171 3dabe5d2 Stavros Sachtouris
                self.set_header('X-Account-Meta-' + metaname, metaval)
172 afd9d603 Stavros Sachtouris
        self.set_header('X-Account-Policy-Quota', quota)
173 afd9d603 Stavros Sachtouris
        self.set_header('X-Account-Policy-Versioning', versioning)
174 afd9d603 Stavros Sachtouris
175 afd9d603 Stavros Sachtouris
        path = path4url(self.account)
176 afd9d603 Stavros Sachtouris
        success = kwargs.pop('success', 202)
177 afd9d603 Stavros Sachtouris
        return self.post(path, *args, success=success, **kwargs)
178 afd9d603 Stavros Sachtouris
179 afd9d603 Stavros Sachtouris
    def container_head(self, until=None,
180 afd9d603 Stavros Sachtouris
        if_modified_since=None, if_unmodified_since=None, *args, **kwargs):
181 afd9d603 Stavros Sachtouris
        """ Full Pithos+ HEAD at container level
182 9e4508df Stavros Sachtouris

183 afd9d603 Stavros Sachtouris
        --- request params ---
184 9e4508df Stavros Sachtouris

185 9e4508df Stavros Sachtouris
        :param until: (string) optional timestamp
186 9e4508df Stavros Sachtouris

187 9e4508df Stavros Sachtouris
        --- request headers ---
188 9e4508df Stavros Sachtouris

189 9e4508df Stavros Sachtouris
        :param if_modified_since: (string) Retrieve if account has changed
190 9e4508df Stavros Sachtouris
            since provided timestamp
191 9e4508df Stavros Sachtouris

192 9e4508df Stavros Sachtouris
        :param if_unmodified_since: (string) Retrieve if account has not
193 9e4508df Stavros Sachtouris
            changed since provided timestamp
194 9e4508df Stavros Sachtouris

195 9e4508df Stavros Sachtouris
        :returns: ConnectionResponse
196 afd9d603 Stavros Sachtouris
        """
197 4067cdaf Stavros Sachtouris
198 d88ba587 Stavros Sachtouris
        self._assert_container()
199 afd9d603 Stavros Sachtouris
200 afd9d603 Stavros Sachtouris
        self.set_param('until', until, iff=until is not None)
201 afd9d603 Stavros Sachtouris
202 afd9d603 Stavros Sachtouris
        self.set_header('If-Modified-Since', if_modified_since)
203 afd9d603 Stavros Sachtouris
        self.set_header('If-Unmodified-Since', if_unmodified_since)
204 afd9d603 Stavros Sachtouris
205 afd9d603 Stavros Sachtouris
        path = path4url(self.account, self.container)
206 afd9d603 Stavros Sachtouris
        success = kwargs.pop('success', 204)
207 afd9d603 Stavros Sachtouris
        return self.head(path, *args, success=success, **kwargs)
208 afd9d603 Stavros Sachtouris
209 3dabe5d2 Stavros Sachtouris
    def container_get(self,
210 3dabe5d2 Stavros Sachtouris
        limit=None,
211 3dabe5d2 Stavros Sachtouris
        marker=None,
212 3dabe5d2 Stavros Sachtouris
        prefix=None,
213 3dabe5d2 Stavros Sachtouris
        delimiter=None,
214 3dabe5d2 Stavros Sachtouris
        path=None,
215 3dabe5d2 Stavros Sachtouris
        format='json',
216 3dabe5d2 Stavros Sachtouris
        meta=[],
217 3dabe5d2 Stavros Sachtouris
        show_only_shared=False,
218 3dabe5d2 Stavros Sachtouris
        until=None,
219 3dabe5d2 Stavros Sachtouris
        if_modified_since=None,
220 3dabe5d2 Stavros Sachtouris
        if_unmodified_since=None,
221 3dabe5d2 Stavros Sachtouris
        *args,
222 3dabe5d2 Stavros Sachtouris
        **kwargs):
223 afd9d603 Stavros Sachtouris
        """ Full Pithos+ GET at container level
224 9e4508df Stavros Sachtouris

225 afd9d603 Stavros Sachtouris
        --- request parameters ---
226 9e4508df Stavros Sachtouris

227 9e4508df Stavros Sachtouris
        :param limit: (integer) The amount of results requested
228 9e4508df Stavros Sachtouris
            (server will use default value if None)
229 9e4508df Stavros Sachtouris

230 9e4508df Stavros Sachtouris
        :param marker: (string) Return containers with name lexicographically
231 9e4508df Stavros Sachtouris
            after marker
232 9e4508df Stavros Sachtouris

233 9e4508df Stavros Sachtouris
        :param prefix: (string) Return objects starting with prefix
234 9e4508df Stavros Sachtouris

235 9e4508df Stavros Sachtouris
        :param delimiter: (string) Return objects up to the delimiter
236 9e4508df Stavros Sachtouris

237 9e4508df Stavros Sachtouris
        :param path: (string) assume prefix = path and delimiter = /
238 9e4508df Stavros Sachtouris
            (overwrites prefix and delimiter)
239 9e4508df Stavros Sachtouris

240 9e4508df Stavros Sachtouris
        :param format: (string) reply format can be json or xml (default:json)
241 9e4508df Stavros Sachtouris

242 9e4508df Stavros Sachtouris
        :param meta: (list) Return objects that satisfy the key queries in
243 9e4508df Stavros Sachtouris
            the specified comma separated list (use <key>, !<key> for
244 9e4508df Stavros Sachtouris
            existence queries, <key><op><value> for value queries, where <op>
245 9e4508df Stavros Sachtouris
            can be one of =, !=, <=, >=, <, >)
246 9e4508df Stavros Sachtouris

247 9e4508df Stavros Sachtouris
        :param shared: (bool) If true, only shared containers will be included
248 9e4508df Stavros Sachtouris
            in results
249 9e4508df Stavros Sachtouris

250 9e4508df Stavros Sachtouris
        :param until: (string) optional timestamp
251 9e4508df Stavros Sachtouris

252 9e4508df Stavros Sachtouris
        --- request headers ---
253 9e4508df Stavros Sachtouris

254 9e4508df Stavros Sachtouris
        :param if_modified_since: (string) Retrieve if account has changed
255 9e4508df Stavros Sachtouris
            since provided timestamp
256 9e4508df Stavros Sachtouris

257 9e4508df Stavros Sachtouris
        :param if_unmodified_since: (string) Retrieve if account has not
258 9e4508df Stavros Sachtouris
            changed since provided timestamp
259 9e4508df Stavros Sachtouris

260 9e4508df Stavros Sachtouris
        :returns: ConnectionResponse
261 afd9d603 Stavros Sachtouris
        """
262 4067cdaf Stavros Sachtouris
263 d88ba587 Stavros Sachtouris
        self._assert_container()
264 afd9d603 Stavros Sachtouris
265 afd9d603 Stavros Sachtouris
        self.set_param('format', format, iff=format is not None)
266 afd9d603 Stavros Sachtouris
        self.set_param('limit', limit, iff=limit is not None)
267 afd9d603 Stavros Sachtouris
        self.set_param('marker', marker, iff=marker is not None)
268 afd9d603 Stavros Sachtouris
        if path is None:
269 afd9d603 Stavros Sachtouris
            self.set_param('prefix', prefix, iff=prefix is not None)
270 afd9d603 Stavros Sachtouris
            self.set_param('delimiter', delimiter, iff=delimiter is not None)
271 afd9d603 Stavros Sachtouris
        else:
272 afd9d603 Stavros Sachtouris
            self.set_param('path', path)
273 afd9d603 Stavros Sachtouris
        self.set_param('shared', iff=show_only_shared)
274 3dabe5d2 Stavros Sachtouris
        self.set_param('meta',
275 3dabe5d2 Stavros Sachtouris
            list2str(meta),
276 3dabe5d2 Stavros Sachtouris
            iff=meta is not None and len(meta) > 0)
277 afd9d603 Stavros Sachtouris
        self.set_param('until', until, iff=until is not None)
278 afd9d603 Stavros Sachtouris
279 afd9d603 Stavros Sachtouris
        self.set_header('If-Modified-Since', if_modified_since)
280 afd9d603 Stavros Sachtouris
        self.set_header('If-Unmodified-Since', if_unmodified_since)
281 afd9d603 Stavros Sachtouris
282 afd9d603 Stavros Sachtouris
        path = path4url(self.account, self.container)
283 afd9d603 Stavros Sachtouris
        success = kwargs.pop('success', 200)
284 afd9d603 Stavros Sachtouris
        return self.get(path, *args, success=success, **kwargs)
285 afd9d603 Stavros Sachtouris
286 3dabe5d2 Stavros Sachtouris
    def container_put(self,
287 3dabe5d2 Stavros Sachtouris
        quota=None,
288 3dabe5d2 Stavros Sachtouris
        versioning=None,
289 3dabe5d2 Stavros Sachtouris
        metadata=None,
290 3dabe5d2 Stavros Sachtouris
        *args,
291 3dabe5d2 Stavros Sachtouris
        **kwargs):
292 afd9d603 Stavros Sachtouris
        """ Full Pithos+ PUT at container level
293 9e4508df Stavros Sachtouris

294 afd9d603 Stavros Sachtouris
        --- request headers ---
295 9e4508df Stavros Sachtouris

296 9e4508df Stavros Sachtouris
        :param quota: (integer) Size limit in KB
297 9e4508df Stavros Sachtouris

298 9e4508df Stavros Sachtouris
        :param versioning: (string) 'auto' or other string supported by server
299 9e4508df Stavros Sachtouris

300 9e4508df Stavros Sachtouris
        :param metadata: (dict) Optional user defined metadata in the form
301 9e4508df Stavros Sachtouris
            { 'name1': 'value1', 'name2': 'value2', ... }
302 9e4508df Stavros Sachtouris

303 9e4508df Stavros Sachtouris
        :returns: ConnectionResponse
304 afd9d603 Stavros Sachtouris
        """
305 d88ba587 Stavros Sachtouris
        self._assert_container()
306 afd9d603 Stavros Sachtouris
307 afd9d603 Stavros Sachtouris
        if metadata is not None:
308 afd9d603 Stavros Sachtouris
            for metaname, metaval in metadata.items():
309 3dabe5d2 Stavros Sachtouris
                self.set_header('X-Container-Meta-' + metaname, metaval)
310 afd9d603 Stavros Sachtouris
        self.set_header('X-Container-Policy-Quota', quota)
311 afd9d603 Stavros Sachtouris
        self.set_header('X-Container-Policy-Versioning', versioning)
312 afd9d603 Stavros Sachtouris
313 afd9d603 Stavros Sachtouris
        path = path4url(self.account, self.container)
314 3dabe5d2 Stavros Sachtouris
        success = kwargs.pop('success', (201, 202))
315 afd9d603 Stavros Sachtouris
        return self.put(path, *args, success=success, **kwargs)
316 afd9d603 Stavros Sachtouris
317 3dabe5d2 Stavros Sachtouris
    def container_post(self,
318 3dabe5d2 Stavros Sachtouris
        update=True,
319 3dabe5d2 Stavros Sachtouris
        format='json',
320 3dabe5d2 Stavros Sachtouris
        quota=None,
321 3dabe5d2 Stavros Sachtouris
        versioning=None,
322 3dabe5d2 Stavros Sachtouris
        metadata=None,
323 3dabe5d2 Stavros Sachtouris
        content_type=None,
324 3dabe5d2 Stavros Sachtouris
        content_length=None,
325 3dabe5d2 Stavros Sachtouris
        transfer_encoding=None,
326 3dabe5d2 Stavros Sachtouris
        *args,
327 3dabe5d2 Stavros Sachtouris
        **kwargs):
328 afd9d603 Stavros Sachtouris
        """ Full Pithos+ POST at container level
329 9e4508df Stavros Sachtouris

330 afd9d603 Stavros Sachtouris
        --- request params ---
331 9e4508df Stavros Sachtouris

332 9e4508df Stavros Sachtouris
        :param update: (bool)  if True, Do not replace metadata/groups
333 9e4508df Stavros Sachtouris

334 9e4508df Stavros Sachtouris
        :param format: (string) json (default) or xml
335 9e4508df Stavros Sachtouris

336 afd9d603 Stavros Sachtouris
        --- request headers ---
337 9e4508df Stavros Sachtouris

338 9e4508df Stavros Sachtouris
        :param quota: (integer) Size limit in KB
339 9e4508df Stavros Sachtouris

340 9e4508df Stavros Sachtouris
        :param versioning: (string) 'auto' or other string supported by server
341 9e4508df Stavros Sachtouris

342 9e4508df Stavros Sachtouris
        :param metadata: (dict) Optional user defined metadata in the form
343 9e4508df Stavros Sachtouris
            { 'name1': 'value1', 'name2': 'value2', ... }
344 9e4508df Stavros Sachtouris

345 9e4508df Stavros Sachtouris
        :param content_type: (string) set a custom content type
346 9e4508df Stavros Sachtouris

347 9e4508df Stavros Sachtouris
        :param content_length: (string) set a custrom content length
348 9e4508df Stavros Sachtouris

349 9e4508df Stavros Sachtouris
        :param transfer_encoding: (string) set a custrom transfer encoding
350 9e4508df Stavros Sachtouris

351 9e4508df Stavros Sachtouris
        :returns: ConnectionResponse
352 afd9d603 Stavros Sachtouris
        """
353 d88ba587 Stavros Sachtouris
        self._assert_container()
354 afd9d603 Stavros Sachtouris
355 afd9d603 Stavros Sachtouris
        self.set_param('format', format, iff=format is not None)
356 afd9d603 Stavros Sachtouris
        self.set_param('update', iff=update)
357 afd9d603 Stavros Sachtouris
358 afd9d603 Stavros Sachtouris
        if metadata is not None:
359 afd9d603 Stavros Sachtouris
            for metaname, metaval in metadata.items():
360 3dabe5d2 Stavros Sachtouris
                self.set_header('X-Container-Meta-' + metaname, metaval)
361 afd9d603 Stavros Sachtouris
        self.set_header('X-Container-Policy-Quota', quota)
362 afd9d603 Stavros Sachtouris
        self.set_header('X-Container-Policy-Versioning', versioning)
363 afd9d603 Stavros Sachtouris
        self.set_header('Content-Type', content_type)
364 afd9d603 Stavros Sachtouris
        self.set_header('Content-Length', content_length)
365 afd9d603 Stavros Sachtouris
        self.set_header('Transfer-Encoding', transfer_encoding)
366 afd9d603 Stavros Sachtouris
367 afd9d603 Stavros Sachtouris
        path = path4url(self.account, self.container)
368 afd9d603 Stavros Sachtouris
        success = kwargs.pop('success', 202)
369 afd9d603 Stavros Sachtouris
        return self.post(path, *args, success=success, **kwargs)
370 afd9d603 Stavros Sachtouris
371 afd9d603 Stavros Sachtouris
    def container_delete(self, until=None, delimiter=None, *args, **kwargs):
372 afd9d603 Stavros Sachtouris
        """ Full Pithos+ DELETE at container level
373 9e4508df Stavros Sachtouris

374 afd9d603 Stavros Sachtouris
        --- request parameters ---
375 9e4508df Stavros Sachtouris

376 9e4508df Stavros Sachtouris
        :param until: (timestamp string) if defined, container is purged up to
377 9e4508df Stavros Sachtouris
            that time
378 9e4508df Stavros Sachtouris

379 9e4508df Stavros Sachtouris
        :returns: ConnectionResponse
380 afd9d603 Stavros Sachtouris
        """
381 4067cdaf Stavros Sachtouris
382 d88ba587 Stavros Sachtouris
        self._assert_container()
383 afd9d603 Stavros Sachtouris
384 afd9d603 Stavros Sachtouris
        self.set_param('until', until, iff=until is not None)
385 afd9d603 Stavros Sachtouris
        self.set_param('delimiter', delimiter, iff=delimiter is not None)
386 afd9d603 Stavros Sachtouris
387 3dabe5d2 Stavros Sachtouris
        path = path4url(self.account, self.container)
388 afd9d603 Stavros Sachtouris
        success = kwargs.pop('success', 204)
389 afd9d603 Stavros Sachtouris
        return self.delete(path, success=success)
390 afd9d603 Stavros Sachtouris
391 3dabe5d2 Stavros Sachtouris
    def object_head(self, object,
392 3dabe5d2 Stavros Sachtouris
        version=None,
393 3dabe5d2 Stavros Sachtouris
        if_etag_match=None,
394 3dabe5d2 Stavros Sachtouris
        if_etag_not_match=None,
395 3dabe5d2 Stavros Sachtouris
        if_modified_since=None,
396 3dabe5d2 Stavros Sachtouris
        if_unmodified_since=None,
397 3dabe5d2 Stavros Sachtouris
        *args,
398 3dabe5d2 Stavros Sachtouris
        **kwargs):
399 afd9d603 Stavros Sachtouris
        """ Full Pithos+ HEAD at object level
400 9e4508df Stavros Sachtouris

401 afd9d603 Stavros Sachtouris
        --- request parameters ---
402 9e4508df Stavros Sachtouris

403 9e4508df Stavros Sachtouris
        :param version: (string) optional version identified
404 9e4508df Stavros Sachtouris

405 afd9d603 Stavros Sachtouris
        --- request headers ---
406 9e4508df Stavros Sachtouris

407 9e4508df Stavros Sachtouris
        :param if_etag_match: (string) if provided, return only results
408 9e4508df Stavros Sachtouris
            with etag matching with this
409 9e4508df Stavros Sachtouris

410 9e4508df Stavros Sachtouris
        :param if_etag_not_match: (string) if provided, return only results
411 9e4508df Stavros Sachtouris
            with etag not matching with this
412 9e4508df Stavros Sachtouris

413 9e4508df Stavros Sachtouris
        :param if_modified_since: (string) Retrieve if account has changed
414 9e4508df Stavros Sachtouris
            since provided timestamp
415 9e4508df Stavros Sachtouris

416 9e4508df Stavros Sachtouris
        :param if_unmodified_since: (string) Retrieve if account has not
417 9e4508df Stavros Sachtouris
            changed since provided timestamp
418 9e4508df Stavros Sachtouris

419 9e4508df Stavros Sachtouris
        :returns: ConnectionResponse
420 afd9d603 Stavros Sachtouris
        """
421 4067cdaf Stavros Sachtouris
422 d88ba587 Stavros Sachtouris
        self._assert_container()
423 afd9d603 Stavros Sachtouris
424 afd9d603 Stavros Sachtouris
        self.set_param('version', version, iff=version is not None)
425 afd9d603 Stavros Sachtouris
426 afd9d603 Stavros Sachtouris
        self.set_header('If-Match', if_etag_match)
427 afd9d603 Stavros Sachtouris
        self.set_header('If-None-Match', if_etag_not_match)
428 afd9d603 Stavros Sachtouris
        self.set_header('If-Modified-Since', if_modified_since)
429 afd9d603 Stavros Sachtouris
        self.set_header('If-Unmodified-Since', if_unmodified_since)
430 afd9d603 Stavros Sachtouris
431 3dabe5d2 Stavros Sachtouris
        path = path4url(self.account, self.container, object)
432 afd9d603 Stavros Sachtouris
        success = kwargs.pop('success', 200)
433 afd9d603 Stavros Sachtouris
        return self.head(path, *args, success=success, **kwargs)
434 afd9d603 Stavros Sachtouris
435 3dabe5d2 Stavros Sachtouris
    def object_get(self, object,
436 3dabe5d2 Stavros Sachtouris
        format='json',
437 3dabe5d2 Stavros Sachtouris
        hashmap=False,
438 3dabe5d2 Stavros Sachtouris
        version=None,
439 3dabe5d2 Stavros Sachtouris
        data_range=None,
440 3dabe5d2 Stavros Sachtouris
        if_range=False,
441 3dabe5d2 Stavros Sachtouris
        if_etag_match=None,
442 3dabe5d2 Stavros Sachtouris
        if_etag_not_match=None,
443 3dabe5d2 Stavros Sachtouris
        if_modified_since=None,
444 3dabe5d2 Stavros Sachtouris
        if_unmodified_since=None,
445 3dabe5d2 Stavros Sachtouris
        *args,
446 3dabe5d2 Stavros Sachtouris
        **kwargs):
447 afd9d603 Stavros Sachtouris
        """ Full Pithos+ GET at object level
448 9e4508df Stavros Sachtouris

449 afd9d603 Stavros Sachtouris
        --- request parameters ---
450 9e4508df Stavros Sachtouris

451 9e4508df Stavros Sachtouris
        :param format: (string) json (default) or xml
452 9e4508df Stavros Sachtouris

453 9e4508df Stavros Sachtouris
        :param hashmap: (bool) Optional request for hashmap
454 9e4508df Stavros Sachtouris

455 9e4508df Stavros Sachtouris
        :param version: (string) optional version identified
456 9e4508df Stavros Sachtouris

457 afd9d603 Stavros Sachtouris
        --- request headers ---
458 9e4508df Stavros Sachtouris

459 9e4508df Stavros Sachtouris
        :param data_range: (string) Optional range of data to retrieve
460 9e4508df Stavros Sachtouris

461 9e4508df Stavros Sachtouris
        :param if_range: (bool)
462 9e4508df Stavros Sachtouris

463 9e4508df Stavros Sachtouris
        :param if_etag_match: (string) if provided, return only results
464 9e4508df Stavros Sachtouris
            with etag matching with this
465 9e4508df Stavros Sachtouris

466 9e4508df Stavros Sachtouris
        :param if_etag_not_match: (string) if provided, return only results
467 9e4508df Stavros Sachtouris
            with etag not matching with this
468 9e4508df Stavros Sachtouris

469 9e4508df Stavros Sachtouris
        :param if_modified_since: (string) Retrieve if account has changed
470 9e4508df Stavros Sachtouris
            since provided timestamp
471 9e4508df Stavros Sachtouris

472 9e4508df Stavros Sachtouris
        :param if_unmodified_since: (string) Retrieve if account has not
473 9e4508df Stavros Sachtouris
            changed since provided timestamp
474 9e4508df Stavros Sachtouris

475 9e4508df Stavros Sachtouris
        :returns: ConnectionResponse
476 afd9d603 Stavros Sachtouris
        """
477 4067cdaf Stavros Sachtouris
478 d88ba587 Stavros Sachtouris
        self._assert_container()
479 afd9d603 Stavros Sachtouris
480 afd9d603 Stavros Sachtouris
        self.set_param('format', format, iff=format is not None)
481 afd9d603 Stavros Sachtouris
        self.set_param('version', version, iff=version is not None)
482 afd9d603 Stavros Sachtouris
        self.set_param('hashmap', hashmap, iff=hashmap)
483 afd9d603 Stavros Sachtouris
484 afd9d603 Stavros Sachtouris
        self.set_header('Range', data_range)
485 3dabe5d2 Stavros Sachtouris
        self.set_header('If-Range', '',
486 3dabe5d2 Stavros Sachtouris
            if_range is True and data_range is not None)
487 afd9d603 Stavros Sachtouris
        self.set_header('If-Match', if_etag_match, )
488 afd9d603 Stavros Sachtouris
        self.set_header('If-None-Match', if_etag_not_match)
489 afd9d603 Stavros Sachtouris
        self.set_header('If-Modified-Since', if_modified_since)
490 afd9d603 Stavros Sachtouris
        self.set_header('If-Unmodified-Since', if_unmodified_since)
491 afd9d603 Stavros Sachtouris
492 3dabe5d2 Stavros Sachtouris
        path = path4url(self.account, self.container, object)
493 afd9d603 Stavros Sachtouris
        success = kwargs.pop('success', 200)
494 afd9d603 Stavros Sachtouris
        return self.get(path, *args, success=success, **kwargs)
495 afd9d603 Stavros Sachtouris
496 3dabe5d2 Stavros Sachtouris
    def object_put(self, object,
497 3dabe5d2 Stavros Sachtouris
        format='json',
498 3dabe5d2 Stavros Sachtouris
        hashmap=False,
499 3dabe5d2 Stavros Sachtouris
        delimiter=None,
500 3dabe5d2 Stavros Sachtouris
        if_etag_match=None,
501 3dabe5d2 Stavros Sachtouris
        if_etag_not_match=None,
502 3dabe5d2 Stavros Sachtouris
        etag=None,
503 3dabe5d2 Stavros Sachtouris
        content_length=None,
504 3dabe5d2 Stavros Sachtouris
        content_type=None,
505 3dabe5d2 Stavros Sachtouris
        transfer_encoding=None,
506 3dabe5d2 Stavros Sachtouris
        copy_from=None,
507 3dabe5d2 Stavros Sachtouris
        move_from=None,
508 3dabe5d2 Stavros Sachtouris
        source_account=None,
509 3dabe5d2 Stavros Sachtouris
        source_version=None,
510 3dabe5d2 Stavros Sachtouris
        content_encoding=None,
511 3dabe5d2 Stavros Sachtouris
        content_disposition=None,
512 3dabe5d2 Stavros Sachtouris
        manifest=None,
513 3dabe5d2 Stavros Sachtouris
        permissions=None,
514 3dabe5d2 Stavros Sachtouris
        public=None,
515 3dabe5d2 Stavros Sachtouris
        metadata=None,
516 3dabe5d2 Stavros Sachtouris
        *args,
517 3dabe5d2 Stavros Sachtouris
        **kwargs):
518 afd9d603 Stavros Sachtouris
        """ Full Pithos+ PUT at object level
519 9e4508df Stavros Sachtouris

520 afd9d603 Stavros Sachtouris
        --- request parameters ---
521 9e4508df Stavros Sachtouris

522 9e4508df Stavros Sachtouris
        :param format: (string) json (default) or xml
523 9e4508df Stavros Sachtouris

524 9e4508df Stavros Sachtouris
        :param hashmap: (bool) Optional hashmap provided instead of data
525 9e4508df Stavros Sachtouris

526 afd9d603 Stavros Sachtouris
        --- request headers ---
527 9e4508df Stavros Sachtouris

528 9e4508df Stavros Sachtouris
        :param if_etag_match: (string) if provided, return only results
529 9e4508df Stavros Sachtouris
            with etag matching with this
530 9e4508df Stavros Sachtouris

531 9e4508df Stavros Sachtouris
        :param if_etag_not_match: (string) if provided, return only results
532 9e4508df Stavros Sachtouris
            with etag not matching with this
533 9e4508df Stavros Sachtouris

534 9e4508df Stavros Sachtouris
        :param etag: (string) The MD5 hash of the object (optional to check
535 9e4508df Stavros Sachtouris
            written data)
536 9e4508df Stavros Sachtouris

537 9e4508df Stavros Sachtouris
        :param content_length: (integer) The size of the data written
538 9e4508df Stavros Sachtouris

539 9e4508df Stavros Sachtouris
        :param content_type: (string) The MIME content type of the object
540 9e4508df Stavros Sachtouris

541 9e4508df Stavros Sachtouris
        :param transfer_encoding: (string) Set to chunked to specify
542 9e4508df Stavros Sachtouris
            incremental uploading (if used, Content-Length is ignored)
543 9e4508df Stavros Sachtouris

544 9e4508df Stavros Sachtouris
        :param copy_from: (string) The source path in the form
545 9e4508df Stavros Sachtouris
            /<container>/<object>
546 9e4508df Stavros Sachtouris

547 9e4508df Stavros Sachtouris
        :param move_from: (string) The source path in the form
548 9e4508df Stavros Sachtouris
            /<container>/<object>
549 9e4508df Stavros Sachtouris

550 9e4508df Stavros Sachtouris
        :param source_account: (string) The source account to copy/move from
551 9e4508df Stavros Sachtouris

552 9e4508df Stavros Sachtouris
        :param source_version: (string) The source version to copy from
553 9e4508df Stavros Sachtouris

554 9e4508df Stavros Sachtouris
        :param conent_encoding: (string) The encoding of the object
555 9e4508df Stavros Sachtouris

556 9e4508df Stavros Sachtouris
        :param content_disposition: (string) Presentation style of the object
557 9e4508df Stavros Sachtouris

558 9e4508df Stavros Sachtouris
        :param manifest: (string) Object parts prefix in
559 9e4508df Stavros Sachtouris
            /<container>/<object> form
560 9e4508df Stavros Sachtouris

561 9e4508df Stavros Sachtouris
        :param permissions: (dict) Object permissions in the form (all fields
562 9e4508df Stavros Sachtouris
            are optional)
563 9e4508df Stavros Sachtouris
            { 'read':[user1, group1, user2, ...],
564 9e4508df Stavros Sachtouris
            'write':['user3, group2, group3, ...] }
565 9e4508df Stavros Sachtouris

566 9e4508df Stavros Sachtouris
        :param public: (bool) If true, Object is publicly accessible,
567 9e4508df Stavros Sachtouris
            if false, not
568 9e4508df Stavros Sachtouris

569 9e4508df Stavros Sachtouris
        :param metadata: (dict) Optional user defined metadata in the form
570 9e4508df Stavros Sachtouris
            {'meta-key-1':'meta-value-1', 'meta-key-2':'meta-value-2', ...}
571 9e4508df Stavros Sachtouris

572 9e4508df Stavros Sachtouris
        :returns: ConnectionResponse
573 afd9d603 Stavros Sachtouris
        """
574 4067cdaf Stavros Sachtouris
575 d88ba587 Stavros Sachtouris
        self._assert_container()
576 afd9d603 Stavros Sachtouris
577 afd9d603 Stavros Sachtouris
        self.set_param('format', format, iff=format is not None)
578 afd9d603 Stavros Sachtouris
        self.set_param('hashmap', hashmap, iff=hashmap)
579 afd9d603 Stavros Sachtouris
        self.set_param('delimiter', delimiter, iff=delimiter is not None)
580 afd9d603 Stavros Sachtouris
581 afd9d603 Stavros Sachtouris
        self.set_header('If-Match', if_etag_match)
582 afd9d603 Stavros Sachtouris
        self.set_header('If-None-Match', if_etag_not_match)
583 afd9d603 Stavros Sachtouris
        self.set_header('ETag', etag)
584 afd9d603 Stavros Sachtouris
        self.set_header('Content-Length', content_length)
585 afd9d603 Stavros Sachtouris
        self.set_header('Content-Type', content_type)
586 afd9d603 Stavros Sachtouris
        self.set_header('Transfer-Encoding', transfer_encoding)
587 afd9d603 Stavros Sachtouris
        self.set_header('X-Copy-From', copy_from)
588 afd9d603 Stavros Sachtouris
        self.set_header('X-Move-From', move_from)
589 afd9d603 Stavros Sachtouris
        self.set_header('X-Source-Account', source_account)
590 afd9d603 Stavros Sachtouris
        self.set_header('X-Source-Version', source_version)
591 afd9d603 Stavros Sachtouris
        self.set_header('Content-Encoding', content_encoding)
592 afd9d603 Stavros Sachtouris
        self.set_header('Content-Disposition', content_disposition)
593 afd9d603 Stavros Sachtouris
        self.set_header('X-Object-Manifest', manifest)
594 afd9d603 Stavros Sachtouris
        perms = None
595 3dabe5d2 Stavros Sachtouris
        if permissions:
596 3dabe5d2 Stavros Sachtouris
            for permission_type, permission_list in permissions.items():
597 afd9d603 Stavros Sachtouris
                if perms is None:
598 3dabe5d2 Stavros Sachtouris
                    perms = ''  # Remove permissions
599 3dabe5d2 Stavros Sachtouris
                if len(permission_list) == 0:
600 afd9d603 Stavros Sachtouris
                    continue
601 3dabe5d2 Stavros Sachtouris
                if len(perms):
602 3dabe5d2 Stavros Sachtouris
                    perms += ';'
603 3dabe5d2 Stavros Sachtouris
                perms += '%s=%s'\
604 4cbe00ba Stavros Sachtouris
                % (permission_type, list2str(permission_list, separator=','))
605 afd9d603 Stavros Sachtouris
        self.set_header('X-Object-Sharing', perms)
606 afd9d603 Stavros Sachtouris
        self.set_header('X-Object-Public', public)
607 afd9d603 Stavros Sachtouris
        if metadata is not None:
608 afd9d603 Stavros Sachtouris
            for key, val in metadata.items():
609 3dabe5d2 Stavros Sachtouris
                self.set_header('X-Object-Meta-' + key, val)
610 afd9d603 Stavros Sachtouris
611 3dabe5d2 Stavros Sachtouris
        path = path4url(self.account, self.container, object)
612 afd9d603 Stavros Sachtouris
        success = kwargs.pop('success', 201)
613 afd9d603 Stavros Sachtouris
        return self.put(path, *args, success=success, **kwargs)
614 afd9d603 Stavros Sachtouris
615 3dabe5d2 Stavros Sachtouris
    def object_copy(self, object, destination,
616 3dabe5d2 Stavros Sachtouris
        format='json',
617 3dabe5d2 Stavros Sachtouris
        ignore_content_type=False,
618 3dabe5d2 Stavros Sachtouris
        if_etag_match=None,
619 3dabe5d2 Stavros Sachtouris
        if_etag_not_match=None,
620 3dabe5d2 Stavros Sachtouris
        destination_account=None,
621 3dabe5d2 Stavros Sachtouris
        content_type=None,
622 3dabe5d2 Stavros Sachtouris
        content_encoding=None,
623 3dabe5d2 Stavros Sachtouris
        content_disposition=None,
624 3dabe5d2 Stavros Sachtouris
        source_version=None,
625 3dabe5d2 Stavros Sachtouris
        permissions=None,
626 3dabe5d2 Stavros Sachtouris
        public=False,
627 3dabe5d2 Stavros Sachtouris
        metadata=None,
628 3dabe5d2 Stavros Sachtouris
        *args,
629 3dabe5d2 Stavros Sachtouris
        **kwargs):
630 afd9d603 Stavros Sachtouris
        """ Full Pithos+ COPY at object level
631 9e4508df Stavros Sachtouris

632 afd9d603 Stavros Sachtouris
        --- request parameters ---
633 9e4508df Stavros Sachtouris

634 9e4508df Stavros Sachtouris
        :param format: (string) json (default) or xml
635 9e4508df Stavros Sachtouris

636 9e4508df Stavros Sachtouris
        :param ignore_content_type: (bool) Ignore the supplied Content-Type
637 9e4508df Stavros Sachtouris

638 afd9d603 Stavros Sachtouris
        --- request headers ---
639 9e4508df Stavros Sachtouris

640 9e4508df Stavros Sachtouris
        :param if_etag_match: (string) if provided, copy only results
641 9e4508df Stavros Sachtouris
            with etag matching with this
642 9e4508df Stavros Sachtouris

643 9e4508df Stavros Sachtouris
        :param if_etag_not_match: (string) if provided, copy only results
644 9e4508df Stavros Sachtouris
            with etag not matching with this
645 9e4508df Stavros Sachtouris

646 9e4508df Stavros Sachtouris
        :param destination: (string) The destination path in the form
647 9e4508df Stavros Sachtouris
            /<container>/<object>
648 9e4508df Stavros Sachtouris

649 9e4508df Stavros Sachtouris
        :param destination_account: (string) The destination account to copy to
650 9e4508df Stavros Sachtouris

651 9e4508df Stavros Sachtouris
        :param content_type: (string) The MIME content type of the object
652 9e4508df Stavros Sachtouris

653 9e4508df Stavros Sachtouris
        :param content_encoding: (string) The encoding of the object
654 9e4508df Stavros Sachtouris

655 9e4508df Stavros Sachtouris
        :param content_disposition: (string) Object resentation style
656 9e4508df Stavros Sachtouris

657 9e4508df Stavros Sachtouris
        :param source_version: (string) The source version to copy from
658 9e4508df Stavros Sachtouris

659 9e4508df Stavros Sachtouris
        :param permissions: (dict) Object permissions in the form
660 9e4508df Stavros Sachtouris
            (all fields are optional)
661 9e4508df Stavros Sachtouris
            { 'read':[user1, group1, user2, ...],
662 9e4508df Stavros Sachtouris
            'write':['user3, group2, group3, ...] }
663 9e4508df Stavros Sachtouris

664 9e4508df Stavros Sachtouris
        :param permissions: update permissions
665 9e4508df Stavros Sachtouris

666 9e4508df Stavros Sachtouris
        :param public: (bool) If true, Object is publicly accessible
667 9e4508df Stavros Sachtouris

668 9e4508df Stavros Sachtouris
        :param metadata: (dict) Optional user defined metadata in the form
669 9e4508df Stavros Sachtouris
            {'meta-key-1':'meta-value-1', 'meta-key-2':'meta-value-2', ...}
670 9e4508df Stavros Sachtouris
            Metadata are appended to the source metadata. In case of same
671 9e4508df Stavros Sachtouris
            keys, they replace the old metadata
672 9e4508df Stavros Sachtouris

673 9e4508df Stavros Sachtouris
        :returns: ConnectionResponse
674 afd9d603 Stavros Sachtouris
        """
675 4067cdaf Stavros Sachtouris
676 d88ba587 Stavros Sachtouris
        self._assert_container()
677 afd9d603 Stavros Sachtouris
678 afd9d603 Stavros Sachtouris
        self.set_param('format', format, iff=format is not None)
679 afd9d603 Stavros Sachtouris
        self.set_param('ignore_content_type', iff=ignore_content_type)
680 afd9d603 Stavros Sachtouris
681 afd9d603 Stavros Sachtouris
        self.set_header('If-Match', if_etag_match)
682 afd9d603 Stavros Sachtouris
        self.set_header('If-None-Match', if_etag_not_match)
683 afd9d603 Stavros Sachtouris
        self.set_header('Destination', destination)
684 afd9d603 Stavros Sachtouris
        self.set_header('Destination-Account', destination_account)
685 afd9d603 Stavros Sachtouris
        self.set_header('Content-Type', content_type)
686 afd9d603 Stavros Sachtouris
        self.set_header('Content-Encoding', content_encoding)
687 afd9d603 Stavros Sachtouris
        self.set_header('Content-Disposition', content_disposition)
688 afd9d603 Stavros Sachtouris
        self.set_header('X-Source-Version', source_version)
689 afd9d603 Stavros Sachtouris
        perms = None
690 3dabe5d2 Stavros Sachtouris
        if permissions:
691 3dabe5d2 Stavros Sachtouris
            for permission_type, permission_list in permissions.items():
692 afd9d603 Stavros Sachtouris
                if perms is None:
693 3dabe5d2 Stavros Sachtouris
                    perms = ''  # Remove permissions
694 3dabe5d2 Stavros Sachtouris
                if len(permission_list) == 0:
695 afd9d603 Stavros Sachtouris
                    continue
696 3dabe5d2 Stavros Sachtouris
                if len(perms):
697 3dabe5d2 Stavros Sachtouris
                    perms += ';'
698 3dabe5d2 Stavros Sachtouris
                perms += '%s=%s'\
699 4cbe00ba Stavros Sachtouris
                % (permission_type, list2str(permission_list, separator=','))
700 afd9d603 Stavros Sachtouris
        self.set_header('X-Object-Sharing', perms)
701 afd9d603 Stavros Sachtouris
        self.set_header('X-Object-Public', public)
702 afd9d603 Stavros Sachtouris
        if metadata is not None:
703 afd9d603 Stavros Sachtouris
            for key, val in metadata.items():
704 3dabe5d2 Stavros Sachtouris
                self.set_header('X-Object-Meta-' + key, val)
705 afd9d603 Stavros Sachtouris
706 afd9d603 Stavros Sachtouris
        path = path4url(self.account, self.container, object)
707 afd9d603 Stavros Sachtouris
        success = kwargs.pop('success', 201)
708 afd9d603 Stavros Sachtouris
        return self.copy(path, *args, success=success, **kwargs)
709 afd9d603 Stavros Sachtouris
710 3dabe5d2 Stavros Sachtouris
    def object_move(self, object,
711 3dabe5d2 Stavros Sachtouris
        format='json',
712 3dabe5d2 Stavros Sachtouris
        ignore_content_type=False,
713 3dabe5d2 Stavros Sachtouris
        if_etag_match=None,
714 3dabe5d2 Stavros Sachtouris
        if_etag_not_match=None,
715 3dabe5d2 Stavros Sachtouris
        destination=None,
716 3dabe5d2 Stavros Sachtouris
        destination_account=None,
717 3dabe5d2 Stavros Sachtouris
        content_type=None,
718 3dabe5d2 Stavros Sachtouris
        content_encoding=None,
719 3dabe5d2 Stavros Sachtouris
        content_disposition=None,
720 3dabe5d2 Stavros Sachtouris
        permissions={},
721 3dabe5d2 Stavros Sachtouris
        public=False,
722 3dabe5d2 Stavros Sachtouris
        metadata={},
723 3dabe5d2 Stavros Sachtouris
        *args,
724 3dabe5d2 Stavros Sachtouris
        **kwargs):
725 afd9d603 Stavros Sachtouris
        """ Full Pithos+ COPY at object level
726 9e4508df Stavros Sachtouris

727 afd9d603 Stavros Sachtouris
        --- request parameters ---
728 9e4508df Stavros Sachtouris

729 9e4508df Stavros Sachtouris
        :param format: (string) json (default) or xml
730 9e4508df Stavros Sachtouris

731 9e4508df Stavros Sachtouris
        :param ignore_content_type: (bool) Ignore the supplied Content-Type
732 9e4508df Stavros Sachtouris

733 afd9d603 Stavros Sachtouris
        --- request headers ---
734 9e4508df Stavros Sachtouris

735 9e4508df Stavros Sachtouris
        :param if_etag_match: (string) if provided, return only results
736 9e4508df Stavros Sachtouris
            with etag matching with this
737 9e4508df Stavros Sachtouris

738 9e4508df Stavros Sachtouris
        :param if_etag_not_match: (string) if provided, return only results
739 9e4508df Stavros Sachtouris
            with etag not matching with this
740 9e4508df Stavros Sachtouris

741 9e4508df Stavros Sachtouris
        :param destination: (string) The destination path in the form
742 9e4508df Stavros Sachtouris
            /<container>/<object>
743 9e4508df Stavros Sachtouris

744 9e4508df Stavros Sachtouris
        :param destination_account: (string) The destination account to copy to
745 9e4508df Stavros Sachtouris

746 9e4508df Stavros Sachtouris
        :param content_type: (string) The MIME content type of the object
747 9e4508df Stavros Sachtouris

748 9e4508df Stavros Sachtouris
        :param content_encoding: (string) The encoding of the object
749 9e4508df Stavros Sachtouris

750 9e4508df Stavros Sachtouris
        :param content_disposition: (string) Object presentation style
751 9e4508df Stavros Sachtouris

752 9e4508df Stavros Sachtouris
        :param source_version: (string) The source version to copy from
753 9e4508df Stavros Sachtouris

754 9e4508df Stavros Sachtouris
        :param permissions: (dict) Object permissions in the form
755 9e4508df Stavros Sachtouris
            (all fields are optional)
756 9e4508df Stavros Sachtouris
            { 'read':[user1, group1, user2, ...],
757 9e4508df Stavros Sachtouris
            'write':['user3, group2, group3, ...] }
758 9e4508df Stavros Sachtouris

759 9e4508df Stavros Sachtouris
        :param public: (bool) If true, Object is publicly accessible
760 9e4508df Stavros Sachtouris

761 9e4508df Stavros Sachtouris
        :param metadata: (dict) Optional user defined metadata in the form
762 9e4508df Stavros Sachtouris
            {'meta-key-1':'meta-value-1', 'meta-key-2':'meta-value-2', ...}
763 9e4508df Stavros Sachtouris

764 9e4508df Stavros Sachtouris
        :returns: ConnectionResponse
765 afd9d603 Stavros Sachtouris
        """
766 4067cdaf Stavros Sachtouris
767 d88ba587 Stavros Sachtouris
        self._assert_container()
768 afd9d603 Stavros Sachtouris
769 afd9d603 Stavros Sachtouris
        self.set_param('format', format, iff=format is not None)
770 afd9d603 Stavros Sachtouris
        self.set_param('ignore_content_type', iff=ignore_content_type)
771 afd9d603 Stavros Sachtouris
772 afd9d603 Stavros Sachtouris
        self.set_header('If-Match', if_etag_match)
773 afd9d603 Stavros Sachtouris
        self.set_header('If-None-Match', if_etag_not_match)
774 afd9d603 Stavros Sachtouris
        self.set_header('Destination', destination)
775 afd9d603 Stavros Sachtouris
        self.set_header('Destination-Account', destination_account)
776 afd9d603 Stavros Sachtouris
        self.set_header('Content-Type', content_type)
777 afd9d603 Stavros Sachtouris
        self.set_header('Content-Encoding', content_encoding)
778 afd9d603 Stavros Sachtouris
        self.set_header('Content-Disposition', content_disposition)
779 afd9d603 Stavros Sachtouris
        perms = None
780 3dabe5d2 Stavros Sachtouris
        for permission_type, permission_list in permissions.items():
781 afd9d603 Stavros Sachtouris
            if perms is None:
782 3dabe5d2 Stavros Sachtouris
                perms = ''  # Remove permissions
783 3dabe5d2 Stavros Sachtouris
            if len(permission_list) == 0:
784 afd9d603 Stavros Sachtouris
                continue
785 3dabe5d2 Stavros Sachtouris
            if len(perms):
786 3dabe5d2 Stavros Sachtouris
                perms += ';'
787 3dabe5d2 Stavros Sachtouris
            perms += '%s=%s'\
788 4cbe00ba Stavros Sachtouris
            % (permission_type, list2str(permission_list, separator=','))
789 afd9d603 Stavros Sachtouris
        self.set_header('X-Object-Sharing', perms)
790 afd9d603 Stavros Sachtouris
        self.set_header('X-Object-Public', public)
791 afd9d603 Stavros Sachtouris
        for key, val in metadata.items():
792 3dabe5d2 Stavros Sachtouris
            self.set_header('X-Object-Meta-' + key, val)
793 afd9d603 Stavros Sachtouris
794 afd9d603 Stavros Sachtouris
        path = path4url(self.account, self.container, object)
795 afd9d603 Stavros Sachtouris
        success = kwargs.pop('success', 201)
796 afd9d603 Stavros Sachtouris
        return self.move(path, *args, success=success, **kwargs)
797 afd9d603 Stavros Sachtouris
798 3dabe5d2 Stavros Sachtouris
    def object_post(self, object,
799 3dabe5d2 Stavros Sachtouris
        format='json',
800 3dabe5d2 Stavros Sachtouris
        update=True,
801 3dabe5d2 Stavros Sachtouris
        if_etag_match=None,
802 3dabe5d2 Stavros Sachtouris
        if_etag_not_match=None,
803 3dabe5d2 Stavros Sachtouris
        content_length=None,
804 3dabe5d2 Stavros Sachtouris
        content_type=None,
805 3dabe5d2 Stavros Sachtouris
        content_range=None,
806 3dabe5d2 Stavros Sachtouris
        transfer_encoding=None,
807 3dabe5d2 Stavros Sachtouris
        content_encoding=None,
808 3dabe5d2 Stavros Sachtouris
        content_disposition=None,
809 3dabe5d2 Stavros Sachtouris
        source_object=None,
810 3dabe5d2 Stavros Sachtouris
        source_account=None,
811 3dabe5d2 Stavros Sachtouris
        source_version=None,
812 3dabe5d2 Stavros Sachtouris
        object_bytes=None,
813 3dabe5d2 Stavros Sachtouris
        manifest=None,
814 3dabe5d2 Stavros Sachtouris
        permissions={},
815 3dabe5d2 Stavros Sachtouris
        public=False,
816 3dabe5d2 Stavros Sachtouris
        metadata={},
817 3dabe5d2 Stavros Sachtouris
        *args,
818 3dabe5d2 Stavros Sachtouris
        **kwargs):
819 afd9d603 Stavros Sachtouris
        """ Full Pithos+ POST at object level
820 9e4508df Stavros Sachtouris

821 afd9d603 Stavros Sachtouris
        --- request parameters ---
822 9e4508df Stavros Sachtouris

823 9e4508df Stavros Sachtouris
        :param format: (string) json (default) or xml
824 9e4508df Stavros Sachtouris

825 9e4508df Stavros Sachtouris
        :param update: (bool) Do not replace metadata
826 9e4508df Stavros Sachtouris

827 afd9d603 Stavros Sachtouris
        --- request headers ---
828 9e4508df Stavros Sachtouris

829 9e4508df Stavros Sachtouris
        :param if_etag_match: (string) if provided, return only results
830 9e4508df Stavros Sachtouris
            with etag matching with this
831 9e4508df Stavros Sachtouris

832 9e4508df Stavros Sachtouris
        :param if_etag_not_match: (string) if provided, return only results
833 9e4508df Stavros Sachtouris
            with etag not matching with this
834 9e4508df Stavros Sachtouris

835 9e4508df Stavros Sachtouris
        :param content_length: (string) The size of the data written
836 9e4508df Stavros Sachtouris

837 9e4508df Stavros Sachtouris
        :param content_type: (string) The MIME content type of the object
838 9e4508df Stavros Sachtouris

839 9e4508df Stavros Sachtouris
        :param content_range: (string) The range of data supplied
840 9e4508df Stavros Sachtouris

841 9e4508df Stavros Sachtouris
        :param transfer_encoding: (string) Set to chunked to specify
842 9e4508df Stavros Sachtouris
            incremental uploading (if used, Content-Length is ignored)
843 9e4508df Stavros Sachtouris

844 9e4508df Stavros Sachtouris
        :param content_encoding: (string) The encoding of the object
845 9e4508df Stavros Sachtouris

846 9e4508df Stavros Sachtouris
        :param content_disposition: (string) Object presentation style
847 9e4508df Stavros Sachtouris

848 9e4508df Stavros Sachtouris
        :param source_object: (string) Update with data from the object at
849 9e4508df Stavros Sachtouris
            path /<container>/<object>
850 9e4508df Stavros Sachtouris

851 9e4508df Stavros Sachtouris
        :param source_account: (string) The source account to update from
852 9e4508df Stavros Sachtouris

853 9e4508df Stavros Sachtouris
        :param source_version: (string) The source version to copy from
854 9e4508df Stavros Sachtouris

855 9e4508df Stavros Sachtouris
        :param object_bytes: (integer) The updated objects final size
856 9e4508df Stavros Sachtouris

857 9e4508df Stavros Sachtouris
        :param manifest: (string) Object parts prefix as /<container>/<object>
858 9e4508df Stavros Sachtouris

859 9e4508df Stavros Sachtouris
        :param permissions: (dict) Object permissions in the form (all fields
860 9e4508df Stavros Sachtouris
            are optional)
861 9e4508df Stavros Sachtouris
            { 'read':[user1, group1, user2, ...],
862 9e4508df Stavros Sachtouris
            'write':['user3, group2, group3, ...] }
863 9e4508df Stavros Sachtouris

864 9e4508df Stavros Sachtouris
        :param public: (bool) If true, Object is publicly accessible
865 9e4508df Stavros Sachtouris

866 9e4508df Stavros Sachtouris
        :param metadata: (dict) Optional user defined metadata in the form
867 9e4508df Stavros Sachtouris
            {'meta-key-1':'meta-value-1', 'meta-key-2':'meta-value-2', ...}
868 9e4508df Stavros Sachtouris

869 9e4508df Stavros Sachtouris
        :returns: ConnectionResponse
870 afd9d603 Stavros Sachtouris
        """
871 4067cdaf Stavros Sachtouris
872 d88ba587 Stavros Sachtouris
        self._assert_container()
873 afd9d603 Stavros Sachtouris
874 afd9d603 Stavros Sachtouris
        self.set_param('format', format, iff=format is not None)
875 3dabe5d2 Stavros Sachtouris
        self.set_param('update', iff=update)
876 afd9d603 Stavros Sachtouris
877 afd9d603 Stavros Sachtouris
        self.set_header('If-Match', if_etag_match)
878 afd9d603 Stavros Sachtouris
        self.set_header('If-None-Match', if_etag_not_match)
879 3dabe5d2 Stavros Sachtouris
        self.set_header('Content-Length',
880 3dabe5d2 Stavros Sachtouris
            content_length,
881 3dabe5d2 Stavros Sachtouris
            iff=transfer_encoding is None)
882 afd9d603 Stavros Sachtouris
        self.set_header('Content-Type', content_type)
883 afd9d603 Stavros Sachtouris
        self.set_header('Content-Range', content_range)
884 afd9d603 Stavros Sachtouris
        self.set_header('Transfer-Encoding', transfer_encoding)
885 afd9d603 Stavros Sachtouris
        self.set_header('Content-Encoding', content_encoding)
886 afd9d603 Stavros Sachtouris
        self.set_header('Content-Disposition', content_disposition)
887 afd9d603 Stavros Sachtouris
        self.set_header('X-Source-Object', source_object)
888 afd9d603 Stavros Sachtouris
        self.set_header('X-Source-Account', source_account)
889 afd9d603 Stavros Sachtouris
        self.set_header('X-Source-Version', source_version)
890 afd9d603 Stavros Sachtouris
        self.set_header('X-Object-Bytes', object_bytes)
891 afd9d603 Stavros Sachtouris
        self.set_header('X-Object-Manifest', manifest)
892 afd9d603 Stavros Sachtouris
        perms = None
893 3dabe5d2 Stavros Sachtouris
        for permission_type, permission_list in permissions.items():
894 afd9d603 Stavros Sachtouris
            if perms is None:
895 3dabe5d2 Stavros Sachtouris
                perms = ''  # Remove permissions
896 3dabe5d2 Stavros Sachtouris
            if len(permission_list) == 0:
897 afd9d603 Stavros Sachtouris
                continue
898 3dabe5d2 Stavros Sachtouris
            if len(perms):
899 3dabe5d2 Stavros Sachtouris
                perms += ';'
900 3dabe5d2 Stavros Sachtouris
            perms += '%s=%s'\
901 4cbe00ba Stavros Sachtouris
            % (permission_type, list2str(permission_list, separator=','))
902 afd9d603 Stavros Sachtouris
        self.set_header('X-Object-Sharing', perms)
903 afd9d603 Stavros Sachtouris
        self.set_header('X-Object-Public', public)
904 afd9d603 Stavros Sachtouris
        for key, val in metadata.items():
905 3dabe5d2 Stavros Sachtouris
            self.set_header('X-Object-Meta-' + key, val)
906 afd9d603 Stavros Sachtouris
907 afd9d603 Stavros Sachtouris
        path = path4url(self.account, self.container, object)
908 3dabe5d2 Stavros Sachtouris
        success = kwargs.pop('success', (202, 204))
909 afd9d603 Stavros Sachtouris
        return self.post(path, *args, success=success, **kwargs)
910 3dabe5d2 Stavros Sachtouris
911 3dabe5d2 Stavros Sachtouris
    def object_delete(self, object,
912 3dabe5d2 Stavros Sachtouris
        until=None,
913 3dabe5d2 Stavros Sachtouris
        delimiter=None,
914 3dabe5d2 Stavros Sachtouris
        *args,
915 3dabe5d2 Stavros Sachtouris
        **kwargs):
916 afd9d603 Stavros Sachtouris
        """ Full Pithos+ DELETE at object level
917 9e4508df Stavros Sachtouris

918 3dabe5d2 Stavros Sachtouris
        --- request parameters ---
919 9e4508df Stavros Sachtouris

920 9e4508df Stavros Sachtouris
        :param until: (string) Optional timestamp
921 9e4508df Stavros Sachtouris

922 9e4508df Stavros Sachtouris
        :returns: ConnectionResponse
923 afd9d603 Stavros Sachtouris
        """
924 d88ba587 Stavros Sachtouris
        self._assert_container()
925 afd9d603 Stavros Sachtouris
926 afd9d603 Stavros Sachtouris
        self.set_param('until', until, iff=until is not None)
927 afd9d603 Stavros Sachtouris
        self.set_param('delimiter', delimiter, iff=delimiter is not None)
928 afd9d603 Stavros Sachtouris
929 afd9d603 Stavros Sachtouris
        path = path4url(self.account, self.container, object)
930 afd9d603 Stavros Sachtouris
        success = kwargs.pop('success', 204)
931 3dabe5d2 Stavros Sachtouris
        return self.delete(path, *args, success=success, **kwargs)