Statistics
| Branch: | Tag: | Revision:

root / kamaki / clients / pithos / rest_api.py @ da17a63d

History | View | Annotate | Download (31.6 kB)

1 fce31e83 Stavros Sachtouris
# Copyright 2012-2013 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 06eccea2 Stavros Sachtouris
from kamaki.clients.utils import path4url
36 afd9d603 Stavros Sachtouris
37 3dabe5d2 Stavros Sachtouris
38 55faa0bc Stavros Sachtouris
class PithosRestClient(StorageClient):
39 afd9d603 Stavros Sachtouris
40 24ff0a35 Stavros Sachtouris
    def account_head(
41 24ff0a35 Stavros Sachtouris
            self,
42 24ff0a35 Stavros Sachtouris
            until=None,
43 24ff0a35 Stavros Sachtouris
            if_modified_since=None,
44 24ff0a35 Stavros Sachtouris
            if_unmodified_since=None,
45 24ff0a35 Stavros Sachtouris
            *args, **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 24ff0a35 Stavros Sachtouris
        self.set_param('until', until, iff=until)
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 24ff0a35 Stavros Sachtouris
    def account_get(
74 24ff0a35 Stavros Sachtouris
            self,
75 24ff0a35 Stavros Sachtouris
            limit=None,
76 24ff0a35 Stavros Sachtouris
            marker=None,
77 24ff0a35 Stavros Sachtouris
            format='json',
78 24ff0a35 Stavros Sachtouris
            show_only_shared=False,
79 1c366ac9 Stavros Sachtouris
            public=False,
80 24ff0a35 Stavros Sachtouris
            until=None,
81 24ff0a35 Stavros Sachtouris
            if_modified_since=None,
82 24ff0a35 Stavros Sachtouris
            if_unmodified_since=None,
83 24ff0a35 Stavros Sachtouris
            *args, **kwargs):
84 afd9d603 Stavros Sachtouris
        """  Full Pithos+ GET at account level
85 9e4508df Stavros Sachtouris

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

189 afd9d603 Stavros Sachtouris
        --- request params ---
190 9e4508df Stavros Sachtouris

191 9e4508df Stavros Sachtouris
        :param until: (string) optional timestamp
192 9e4508df Stavros Sachtouris

193 9e4508df Stavros Sachtouris
        --- request headers ---
194 9e4508df Stavros Sachtouris

195 9e4508df Stavros Sachtouris
        :param if_modified_since: (string) Retrieve if account has changed
196 9e4508df Stavros Sachtouris
            since provided timestamp
197 9e4508df Stavros Sachtouris

198 9e4508df Stavros Sachtouris
        :param if_unmodified_since: (string) Retrieve if account has not
199 9e4508df Stavros Sachtouris
            changed since provided timestamp
200 9e4508df Stavros Sachtouris

201 9e4508df Stavros Sachtouris
        :returns: ConnectionResponse
202 afd9d603 Stavros Sachtouris
        """
203 4067cdaf Stavros Sachtouris
204 d88ba587 Stavros Sachtouris
        self._assert_container()
205 afd9d603 Stavros Sachtouris
206 24ff0a35 Stavros Sachtouris
        self.set_param('until', until, iff=until)
207 afd9d603 Stavros Sachtouris
208 afd9d603 Stavros Sachtouris
        self.set_header('If-Modified-Since', if_modified_since)
209 afd9d603 Stavros Sachtouris
        self.set_header('If-Unmodified-Since', if_unmodified_since)
210 afd9d603 Stavros Sachtouris
211 afd9d603 Stavros Sachtouris
        path = path4url(self.account, self.container)
212 afd9d603 Stavros Sachtouris
        success = kwargs.pop('success', 204)
213 afd9d603 Stavros Sachtouris
        return self.head(path, *args, success=success, **kwargs)
214 afd9d603 Stavros Sachtouris
215 24ff0a35 Stavros Sachtouris
    def container_get(
216 24ff0a35 Stavros Sachtouris
            self,
217 24ff0a35 Stavros Sachtouris
            limit=None,
218 24ff0a35 Stavros Sachtouris
            marker=None,
219 24ff0a35 Stavros Sachtouris
            prefix=None,
220 24ff0a35 Stavros Sachtouris
            delimiter=None,
221 24ff0a35 Stavros Sachtouris
            path=None,
222 24ff0a35 Stavros Sachtouris
            format='json',
223 24ff0a35 Stavros Sachtouris
            meta=[],
224 24ff0a35 Stavros Sachtouris
            show_only_shared=False,
225 1c366ac9 Stavros Sachtouris
            public=False,
226 24ff0a35 Stavros Sachtouris
            until=None,
227 24ff0a35 Stavros Sachtouris
            if_modified_since=None,
228 24ff0a35 Stavros Sachtouris
            if_unmodified_since=None,
229 24ff0a35 Stavros Sachtouris
            *args, **kwargs):
230 afd9d603 Stavros Sachtouris
        """ Full Pithos+ GET at container level
231 9e4508df Stavros Sachtouris

232 afd9d603 Stavros Sachtouris
        --- request parameters ---
233 9e4508df Stavros Sachtouris

234 9e4508df Stavros Sachtouris
        :param limit: (integer) The amount of results requested
235 9e4508df Stavros Sachtouris
            (server will use default value if None)
236 9e4508df Stavros Sachtouris

237 9e4508df Stavros Sachtouris
        :param marker: (string) Return containers with name lexicographically
238 9e4508df Stavros Sachtouris
            after marker
239 9e4508df Stavros Sachtouris

240 9e4508df Stavros Sachtouris
        :param prefix: (string) Return objects starting with prefix
241 9e4508df Stavros Sachtouris

242 9e4508df Stavros Sachtouris
        :param delimiter: (string) Return objects up to the delimiter
243 9e4508df Stavros Sachtouris

244 9e4508df Stavros Sachtouris
        :param path: (string) assume prefix = path and delimiter = /
245 9e4508df Stavros Sachtouris
            (overwrites prefix and delimiter)
246 9e4508df Stavros Sachtouris

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

249 9e4508df Stavros Sachtouris
        :param meta: (list) Return objects that satisfy the key queries in
250 9e4508df Stavros Sachtouris
            the specified comma separated list (use <key>, !<key> for
251 9e4508df Stavros Sachtouris
            existence queries, <key><op><value> for value queries, where <op>
252 9e4508df Stavros Sachtouris
            can be one of =, !=, <=, >=, <, >)
253 9e4508df Stavros Sachtouris

254 c7e9c644 Stavros Sachtouris
        :param show_only_shared: (bool) If true, only shared containers will
255 c7e9c644 Stavros Sachtouris
            be included in results
256 9e4508df Stavros Sachtouris

257 9e4508df Stavros Sachtouris
        :param until: (string) optional timestamp
258 9e4508df Stavros Sachtouris

259 9e4508df Stavros Sachtouris
        --- request headers ---
260 9e4508df Stavros Sachtouris

261 9e4508df Stavros Sachtouris
        :param if_modified_since: (string) Retrieve if account has changed
262 9e4508df Stavros Sachtouris
            since provided timestamp
263 9e4508df Stavros Sachtouris

264 9e4508df Stavros Sachtouris
        :param if_unmodified_since: (string) Retrieve if account has not
265 9e4508df Stavros Sachtouris
            changed since provided timestamp
266 9e4508df Stavros Sachtouris

267 9e4508df Stavros Sachtouris
        :returns: ConnectionResponse
268 afd9d603 Stavros Sachtouris
        """
269 4067cdaf Stavros Sachtouris
270 d88ba587 Stavros Sachtouris
        self._assert_container()
271 afd9d603 Stavros Sachtouris
272 24ff0a35 Stavros Sachtouris
        self.set_param('limit', limit, iff=limit)
273 24ff0a35 Stavros Sachtouris
        self.set_param('marker', marker, iff=marker)
274 24ff0a35 Stavros Sachtouris
        if not path:
275 24ff0a35 Stavros Sachtouris
            self.set_param('prefix', prefix, iff=prefix)
276 24ff0a35 Stavros Sachtouris
            self.set_param('delimiter', delimiter, iff=delimiter)
277 afd9d603 Stavros Sachtouris
        else:
278 afd9d603 Stavros Sachtouris
            self.set_param('path', path)
279 c7e9c644 Stavros Sachtouris
        self.set_param('format', format, iff=format)
280 afd9d603 Stavros Sachtouris
        self.set_param('shared', iff=show_only_shared)
281 1c366ac9 Stavros Sachtouris
        self.set_param('public', iff=public)
282 b58c1078 Stavros Sachtouris
        if meta:
283 b58c1078 Stavros Sachtouris
            self.set_param('meta',  ','.join(meta))
284 24ff0a35 Stavros Sachtouris
        self.set_param('until', until, iff=until)
285 afd9d603 Stavros Sachtouris
286 afd9d603 Stavros Sachtouris
        self.set_header('If-Modified-Since', if_modified_since)
287 afd9d603 Stavros Sachtouris
        self.set_header('If-Unmodified-Since', if_unmodified_since)
288 afd9d603 Stavros Sachtouris
289 afd9d603 Stavros Sachtouris
        path = path4url(self.account, self.container)
290 afd9d603 Stavros Sachtouris
        success = kwargs.pop('success', 200)
291 afd9d603 Stavros Sachtouris
        return self.get(path, *args, success=success, **kwargs)
292 afd9d603 Stavros Sachtouris
293 24ff0a35 Stavros Sachtouris
    def container_put(
294 24ff0a35 Stavros Sachtouris
            self,
295 24ff0a35 Stavros Sachtouris
            quota=None, versioning=None, metadata=None,
296 24ff0a35 Stavros Sachtouris
            *args, **kwargs):
297 afd9d603 Stavros Sachtouris
        """ Full Pithos+ PUT at container level
298 9e4508df Stavros Sachtouris

299 afd9d603 Stavros Sachtouris
        --- request headers ---
300 9e4508df Stavros Sachtouris

301 9e4508df Stavros Sachtouris
        :param quota: (integer) Size limit in KB
302 9e4508df Stavros Sachtouris

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

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

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

335 afd9d603 Stavros Sachtouris
        --- request params ---
336 9e4508df Stavros Sachtouris

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

339 9e4508df Stavros Sachtouris
        :param format: (string) json (default) or xml
340 9e4508df Stavros Sachtouris

341 afd9d603 Stavros Sachtouris
        --- request headers ---
342 9e4508df Stavros Sachtouris

343 9e4508df Stavros Sachtouris
        :param quota: (integer) Size limit in KB
344 9e4508df Stavros Sachtouris

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

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

350 9e4508df Stavros Sachtouris
        :param content_type: (string) set a custom content type
351 9e4508df Stavros Sachtouris

352 9e4508df Stavros Sachtouris
        :param content_length: (string) set a custrom content length
353 9e4508df Stavros Sachtouris

354 7702c429 Stavros Sachtouris
        :param transfer_encoding: (string) set a custom transfer encoding
355 9e4508df Stavros Sachtouris

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

379 afd9d603 Stavros Sachtouris
        --- request parameters ---
380 9e4508df Stavros Sachtouris

381 9e4508df Stavros Sachtouris
        :param until: (timestamp string) if defined, container is purged up to
382 9e4508df Stavros Sachtouris
            that time
383 9e4508df Stavros Sachtouris

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

406 afd9d603 Stavros Sachtouris
        --- request parameters ---
407 9e4508df Stavros Sachtouris

408 9e4508df Stavros Sachtouris
        :param version: (string) optional version identified
409 9e4508df Stavros Sachtouris

410 afd9d603 Stavros Sachtouris
        --- request headers ---
411 9e4508df Stavros Sachtouris

412 9e4508df Stavros Sachtouris
        :param if_etag_match: (string) if provided, return only results
413 9e4508df Stavros Sachtouris
            with etag matching with this
414 9e4508df Stavros Sachtouris

415 9e4508df Stavros Sachtouris
        :param if_etag_not_match: (string) if provided, return only results
416 9e4508df Stavros Sachtouris
            with etag not matching with this
417 9e4508df Stavros Sachtouris

418 9e4508df Stavros Sachtouris
        :param if_modified_since: (string) Retrieve if account has changed
419 9e4508df Stavros Sachtouris
            since provided timestamp
420 9e4508df Stavros Sachtouris

421 9e4508df Stavros Sachtouris
        :param if_unmodified_since: (string) Retrieve if account has not
422 9e4508df Stavros Sachtouris
            changed since provided timestamp
423 9e4508df Stavros Sachtouris

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

454 afd9d603 Stavros Sachtouris
        --- request parameters ---
455 9e4508df Stavros Sachtouris

456 9e4508df Stavros Sachtouris
        :param format: (string) json (default) or xml
457 9e4508df Stavros Sachtouris

458 9e4508df Stavros Sachtouris
        :param hashmap: (bool) Optional request for hashmap
459 9e4508df Stavros Sachtouris

460 9e4508df Stavros Sachtouris
        :param version: (string) optional version identified
461 9e4508df Stavros Sachtouris

462 afd9d603 Stavros Sachtouris
        --- request headers ---
463 9e4508df Stavros Sachtouris

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

466 9e4508df Stavros Sachtouris
        :param if_range: (bool)
467 9e4508df Stavros Sachtouris

468 9e4508df Stavros Sachtouris
        :param if_etag_match: (string) if provided, return only results
469 9e4508df Stavros Sachtouris
            with etag matching with this
470 9e4508df Stavros Sachtouris

471 9e4508df Stavros Sachtouris
        :param if_etag_not_match: (string) if provided, return only results
472 9e4508df Stavros Sachtouris
            with etag not matching with this
473 9e4508df Stavros Sachtouris

474 9e4508df Stavros Sachtouris
        :param if_modified_since: (string) Retrieve if account has changed
475 9e4508df Stavros Sachtouris
            since provided timestamp
476 9e4508df Stavros Sachtouris

477 9e4508df Stavros Sachtouris
        :param if_unmodified_since: (string) Retrieve if account has not
478 9e4508df Stavros Sachtouris
            changed since provided timestamp
479 9e4508df Stavros Sachtouris

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

524 afd9d603 Stavros Sachtouris
        --- request parameters ---
525 9e4508df Stavros Sachtouris

526 9e4508df Stavros Sachtouris
        :param format: (string) json (default) or xml
527 9e4508df Stavros Sachtouris

528 9e4508df Stavros Sachtouris
        :param hashmap: (bool) Optional hashmap provided instead of data
529 9e4508df Stavros Sachtouris

530 afd9d603 Stavros Sachtouris
        --- request headers ---
531 9e4508df Stavros Sachtouris

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

535 9e4508df Stavros Sachtouris
        :param if_etag_not_match: (string) if provided, return only results
536 9e4508df Stavros Sachtouris
            with etag not matching with this
537 9e4508df Stavros Sachtouris

538 9e4508df Stavros Sachtouris
        :param etag: (string) The MD5 hash of the object (optional to check
539 9e4508df Stavros Sachtouris
            written data)
540 9e4508df Stavros Sachtouris

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

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

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

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

551 9e4508df Stavros Sachtouris
        :param move_from: (string) The source path in the form
552 9e4508df Stavros Sachtouris
            /<container>/<object>
553 9e4508df Stavros Sachtouris

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

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

558 9e4508df Stavros Sachtouris
        :param conent_encoding: (string) The encoding of the object
559 9e4508df Stavros Sachtouris

560 9e4508df Stavros Sachtouris
        :param content_disposition: (string) Presentation style of the object
561 9e4508df Stavros Sachtouris

562 9e4508df Stavros Sachtouris
        :param manifest: (string) Object parts prefix in
563 9e4508df Stavros Sachtouris
            /<container>/<object> form
564 9e4508df Stavros Sachtouris

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

570 6aadd6e1 Stavros Sachtouris
        :param public: (bool) If true, Object is published, False, unpublished
571 9e4508df Stavros Sachtouris

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

665 6aadd6e1 Stavros Sachtouris
        :param public: (bool) If true, Object is published, False, unpublished
666 9e4508df Stavros Sachtouris

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

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

723 afd9d603 Stavros Sachtouris
        --- request parameters ---
724 9e4508df Stavros Sachtouris

725 9e4508df Stavros Sachtouris
        :param format: (string) json (default) or xml
726 9e4508df Stavros Sachtouris

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

729 afd9d603 Stavros Sachtouris
        --- request headers ---
730 9e4508df Stavros Sachtouris

731 9e4508df Stavros Sachtouris
        :param if_etag_match: (string) if provided, return only results
732 9e4508df Stavros Sachtouris
            with etag matching with this
733 9e4508df Stavros Sachtouris

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

737 9e4508df Stavros Sachtouris
        :param destination: (string) The destination path in the form
738 9e4508df Stavros Sachtouris
            /<container>/<object>
739 9e4508df Stavros Sachtouris

740 9e4508df Stavros Sachtouris
        :param destination_account: (string) The destination account to copy to
741 9e4508df Stavros Sachtouris

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

744 9e4508df Stavros Sachtouris
        :param content_encoding: (string) The encoding of the object
745 9e4508df Stavros Sachtouris

746 9e4508df Stavros Sachtouris
        :param content_disposition: (string) Object presentation style
747 9e4508df Stavros Sachtouris

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

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

755 6aadd6e1 Stavros Sachtouris
        :param public: (bool) If true, Object is published, False, unpublished
756 9e4508df Stavros Sachtouris

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

760 9e4508df Stavros Sachtouris
        :returns: ConnectionResponse
761 afd9d603 Stavros Sachtouris
        """
762 4067cdaf Stavros Sachtouris
763 d88ba587 Stavros Sachtouris
        self._assert_container()
764 afd9d603 Stavros Sachtouris
765 24ff0a35 Stavros Sachtouris
        self.set_param('format', format, iff=format)
766 afd9d603 Stavros Sachtouris
        self.set_param('ignore_content_type', iff=ignore_content_type)
767 afd9d603 Stavros Sachtouris
768 afd9d603 Stavros Sachtouris
        self.set_header('If-Match', if_etag_match)
769 afd9d603 Stavros Sachtouris
        self.set_header('If-None-Match', if_etag_not_match)
770 afd9d603 Stavros Sachtouris
        self.set_header('Destination', destination)
771 afd9d603 Stavros Sachtouris
        self.set_header('Destination-Account', destination_account)
772 afd9d603 Stavros Sachtouris
        self.set_header('Content-Type', content_type)
773 afd9d603 Stavros Sachtouris
        self.set_header('Content-Encoding', content_encoding)
774 afd9d603 Stavros Sachtouris
        self.set_header('Content-Disposition', content_disposition)
775 b773795c Stavros Sachtouris
        perms = ';'.join(
776 b773795c Stavros Sachtouris
            ['%s=%s' % (k, ','.join(v)) for k, v in permissions.items() if (
777 b773795c Stavros Sachtouris
                v)]) if (permissions) else ''
778 b773795c Stavros Sachtouris
        self.set_header('X-Object-Sharing', perms, iff=permissions)
779 6aadd6e1 Stavros Sachtouris
        self.set_header('X-Object-Public', public, public is not None)
780 b58c1078 Stavros Sachtouris
        if metadata:
781 b58c1078 Stavros Sachtouris
            for key, val in metadata.items():
782 b58c1078 Stavros Sachtouris
                self.set_header('X-Object-Meta-' + key, val)
783 afd9d603 Stavros Sachtouris
784 afd9d603 Stavros Sachtouris
        path = path4url(self.account, self.container, object)
785 afd9d603 Stavros Sachtouris
        success = kwargs.pop('success', 201)
786 afd9d603 Stavros Sachtouris
        return self.move(path, *args, success=success, **kwargs)
787 afd9d603 Stavros Sachtouris
788 24ff0a35 Stavros Sachtouris
    def object_post(
789 c639293b Stavros Sachtouris
            self, obj,
790 24ff0a35 Stavros Sachtouris
            format='json',
791 24ff0a35 Stavros Sachtouris
            update=True,
792 24ff0a35 Stavros Sachtouris
            if_etag_match=None,
793 24ff0a35 Stavros Sachtouris
            if_etag_not_match=None,
794 24ff0a35 Stavros Sachtouris
            content_length=None,
795 24ff0a35 Stavros Sachtouris
            content_type=None,
796 24ff0a35 Stavros Sachtouris
            content_range=None,
797 24ff0a35 Stavros Sachtouris
            transfer_encoding=None,
798 24ff0a35 Stavros Sachtouris
            content_encoding=None,
799 24ff0a35 Stavros Sachtouris
            content_disposition=None,
800 24ff0a35 Stavros Sachtouris
            source_object=None,
801 24ff0a35 Stavros Sachtouris
            source_account=None,
802 24ff0a35 Stavros Sachtouris
            source_version=None,
803 24ff0a35 Stavros Sachtouris
            object_bytes=None,
804 24ff0a35 Stavros Sachtouris
            manifest=None,
805 24ff0a35 Stavros Sachtouris
            permissions={},
806 6aadd6e1 Stavros Sachtouris
            public=None,
807 24ff0a35 Stavros Sachtouris
            metadata={},
808 24ff0a35 Stavros Sachtouris
            *args, **kwargs):
809 afd9d603 Stavros Sachtouris
        """ Full Pithos+ POST at object level
810 9e4508df Stavros Sachtouris

811 afd9d603 Stavros Sachtouris
        --- request parameters ---
812 9e4508df Stavros Sachtouris

813 9e4508df Stavros Sachtouris
        :param format: (string) json (default) or xml
814 9e4508df Stavros Sachtouris

815 9e4508df Stavros Sachtouris
        :param update: (bool) Do not replace metadata
816 9e4508df Stavros Sachtouris

817 afd9d603 Stavros Sachtouris
        --- request headers ---
818 9e4508df Stavros Sachtouris

819 9e4508df Stavros Sachtouris
        :param if_etag_match: (string) if provided, return only results
820 9e4508df Stavros Sachtouris
            with etag matching with this
821 9e4508df Stavros Sachtouris

822 9e4508df Stavros Sachtouris
        :param if_etag_not_match: (string) if provided, return only results
823 9e4508df Stavros Sachtouris
            with etag not matching with this
824 9e4508df Stavros Sachtouris

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

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

829 9e4508df Stavros Sachtouris
        :param content_range: (string) The range of data supplied
830 9e4508df Stavros Sachtouris

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

834 9e4508df Stavros Sachtouris
        :param content_encoding: (string) The encoding of the object
835 9e4508df Stavros Sachtouris

836 9e4508df Stavros Sachtouris
        :param content_disposition: (string) Object presentation style
837 9e4508df Stavros Sachtouris

838 9e4508df Stavros Sachtouris
        :param source_object: (string) Update with data from the object at
839 9e4508df Stavros Sachtouris
            path /<container>/<object>
840 9e4508df Stavros Sachtouris

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

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

845 9e4508df Stavros Sachtouris
        :param object_bytes: (integer) The updated objects final size
846 9e4508df Stavros Sachtouris

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

849 9e4508df Stavros Sachtouris
        :param permissions: (dict) Object permissions in the form (all fields
850 9e4508df Stavros Sachtouris
            are optional)
851 9e4508df Stavros Sachtouris
            { 'read':[user1, group1, user2, ...],
852 9e4508df Stavros Sachtouris
            'write':['user3, group2, group3, ...] }
853 9e4508df Stavros Sachtouris

854 6aadd6e1 Stavros Sachtouris
        :param public: (bool) If true, Object is published, False, unpublished
855 9e4508df Stavros Sachtouris

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

859 9e4508df Stavros Sachtouris
        :returns: ConnectionResponse
860 afd9d603 Stavros Sachtouris
        """
861 4067cdaf Stavros Sachtouris
862 d88ba587 Stavros Sachtouris
        self._assert_container()
863 afd9d603 Stavros Sachtouris
864 24ff0a35 Stavros Sachtouris
        self.set_param('format', format, iff=format)
865 b773795c Stavros Sachtouris
        self.set_param('update', '', iff=update)
866 afd9d603 Stavros Sachtouris
867 afd9d603 Stavros Sachtouris
        self.set_header('If-Match', if_etag_match)
868 afd9d603 Stavros Sachtouris
        self.set_header('If-None-Match', if_etag_not_match)
869 24ff0a35 Stavros Sachtouris
        self.set_header(
870 b773795c Stavros Sachtouris
            'Content-Length', content_length, iff=not transfer_encoding)
871 afd9d603 Stavros Sachtouris
        self.set_header('Content-Type', content_type)
872 afd9d603 Stavros Sachtouris
        self.set_header('Content-Range', content_range)
873 afd9d603 Stavros Sachtouris
        self.set_header('Transfer-Encoding', transfer_encoding)
874 afd9d603 Stavros Sachtouris
        self.set_header('Content-Encoding', content_encoding)
875 afd9d603 Stavros Sachtouris
        self.set_header('Content-Disposition', content_disposition)
876 afd9d603 Stavros Sachtouris
        self.set_header('X-Source-Object', source_object)
877 afd9d603 Stavros Sachtouris
        self.set_header('X-Source-Account', source_account)
878 afd9d603 Stavros Sachtouris
        self.set_header('X-Source-Version', source_version)
879 afd9d603 Stavros Sachtouris
        self.set_header('X-Object-Bytes', object_bytes)
880 afd9d603 Stavros Sachtouris
        self.set_header('X-Object-Manifest', manifest)
881 b773795c Stavros Sachtouris
        perms = ';'.join(
882 b773795c Stavros Sachtouris
            ['%s=%s' % (k, ','.join(v)) for k, v in permissions.items() if (
883 b773795c Stavros Sachtouris
                v)]) if (permissions) else ''
884 b773795c Stavros Sachtouris
        self.set_header('X-Object-Sharing', perms, iff=permissions)
885 6aadd6e1 Stavros Sachtouris
        self.set_header('X-Object-Public', public, public is not None)
886 afd9d603 Stavros Sachtouris
        for key, val in metadata.items():
887 3dabe5d2 Stavros Sachtouris
            self.set_header('X-Object-Meta-' + key, val)
888 afd9d603 Stavros Sachtouris
889 c639293b Stavros Sachtouris
        path = path4url(self.account, self.container, obj)
890 3dabe5d2 Stavros Sachtouris
        success = kwargs.pop('success', (202, 204))
891 afd9d603 Stavros Sachtouris
        return self.post(path, *args, success=success, **kwargs)
892 3dabe5d2 Stavros Sachtouris
893 24ff0a35 Stavros Sachtouris
    def object_delete(
894 24ff0a35 Stavros Sachtouris
            self, object,
895 24ff0a35 Stavros Sachtouris
            until=None, delimiter=None,
896 24ff0a35 Stavros Sachtouris
            *args, **kwargs):
897 afd9d603 Stavros Sachtouris
        """ Full Pithos+ DELETE at object level
898 9e4508df Stavros Sachtouris

899 3dabe5d2 Stavros Sachtouris
        --- request parameters ---
900 9e4508df Stavros Sachtouris

901 9e4508df Stavros Sachtouris
        :param until: (string) Optional timestamp
902 9e4508df Stavros Sachtouris

903 9e4508df Stavros Sachtouris
        :returns: ConnectionResponse
904 afd9d603 Stavros Sachtouris
        """
905 d88ba587 Stavros Sachtouris
        self._assert_container()
906 afd9d603 Stavros Sachtouris
907 24ff0a35 Stavros Sachtouris
        self.set_param('until', until, iff=until)
908 24ff0a35 Stavros Sachtouris
        self.set_param('delimiter', delimiter, iff=delimiter)
909 afd9d603 Stavros Sachtouris
910 afd9d603 Stavros Sachtouris
        path = path4url(self.account, self.container, object)
911 afd9d603 Stavros Sachtouris
        success = kwargs.pop('success', 204)
912 3dabe5d2 Stavros Sachtouris
        return self.delete(path, *args, success=success, **kwargs)