Commit 55c75058 authored by Stavros Sachtouris's avatar Stavros Sachtouris
Browse files

Add output to file copy/move

Also, kamaki.clients.pithos.copy/move_object returns response headers

Refs: #3756 #3732
parent 94bedc5b
......@@ -18,6 +18,8 @@ Changes:
- Disallow moving deleted objects by version [#3737]
This operation was implemented by accident, due to the symetry between
move and copy
- Add optional output for file methods [#3756, #3732]:
mkdir, touch, create, move, create, copy, move
Features:
......@@ -35,6 +37,4 @@ Features:
- Add a download_to_string method in pithos client [#3608]
- Add an upload_from_string method in pithos client [#3608]
- Add pithos client method create_container [#3756]
- Add output for file methods [#3756, #3732]:
mkdir, touch, create
......@@ -727,7 +727,9 @@ class file_copy(_source_destination_command):
default=''),
source_version=ValueArgument(
'copy specific version',
('-S', '--source-version'))
('-S', '--source-version')),
with_output=FlagArgument('show request headers', ('--with-output')),
json_output=FlagArgument('show headers in json', ('-j', '--json'))
)
@errors.generic.all
......@@ -741,7 +743,7 @@ class file_copy(_source_destination_command):
for src_obj, dst_obj in self.src_dst_pairs(
dst_path, self['source_version']):
no_source_object = False
self.dst_client.copy_object(
r = self.dst_client.copy_object(
src_container=self.client.container,
src_object=src_obj,
dst_container=self.dst_client.container,
......@@ -754,6 +756,11 @@ class file_copy(_source_destination_command):
raiseCLIError('No object %s in container %s' % (
self.path,
self.container))
if self['json_output']:
print_json(r)
elif self['with_output']:
print_dict(r)
def main(
self, source_container___path,
......@@ -815,7 +822,9 @@ class file_move(_source_destination_command):
suffix_replace=ValueArgument(
'Suffix of src to replace with add_suffix, if matched',
'--suffix-to-replace',
default='')
default=''),
with_output=FlagArgument('show request headers', ('--with-output')),
json_output=FlagArgument('show headers in json', ('-j', '--json'))
)
@errors.generic.all
......@@ -827,19 +836,22 @@ class file_move(_source_destination_command):
self['destination_account']) else None
for src_obj, dst_obj in self.src_dst_pairs(dst_path):
no_source_object = False
self.dst_client.move_object(
r = self.dst_client.move_object(
src_container=self.container,
src_object=src_obj,
dst_container=self.dst_client.container,
dst_object=dst_obj,
source_account=src_account,
source_version=self['source_version'],
public=self['public'],
content_type=self['content_type'])
if no_source_object:
raiseCLIError('No object %s in container %s' % (
self.path,
self.container))
if self['json_output']:
print_json(r)
elif self['with_output']:
print_dict(r)
def main(
self, source_container___path,
......
......@@ -1363,11 +1363,13 @@ class PithosClient(PithosRestClient):
:param content_type: (str)
:param delimiter: (str)
:returns: (dict) response headers
"""
self._assert_account()
self.container = dst_container
src_path = path4url(src_container, src_object)
self.object_put(
r = self.object_put(
dst_object or src_object,
success=201,
copy_from=src_path,
......@@ -1377,6 +1379,7 @@ class PithosClient(PithosRestClient):
public=public,
content_type=content_type,
delimiter=delimiter)
return r.headers
def move_object(
self, src_container, src_object, dst_container,
......@@ -1404,12 +1407,14 @@ class PithosClient(PithosRestClient):
:param content_type: (str)
:param delimiter: (str)
:returns: (dict) response headers
"""
self._assert_account()
self.container = dst_container
dst_object = dst_object or src_object
src_path = path4url(src_container, src_object)
self.object_put(
r = self.object_put(
dst_object,
success=201,
move_from=src_path,
......@@ -1419,6 +1424,7 @@ class PithosClient(PithosRestClient):
public=public,
content_type=content_type,
delimiter=delimiter)
return r.headers
def get_sharing_accounts(self, limit=None, marker=None, *args, **kwargs):
"""Get accounts that share with self.account
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment