-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add request_payer parameter to sync, cp, and rm subcommands #3016
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,3 +48,5 @@ doc/source/tutorial/services.rst | |
# Pyenv | ||
.python-version | ||
|
||
# virtualenv | ||
.venv |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -725,7 +725,7 @@ class CpCommand(S3TransferCommand): | |||||||||||||||||||
"or <S3Uri> <S3Uri>" | ||||||||||||||||||||
ARG_TABLE = [{'name': 'paths', 'nargs': 2, 'positional_arg': True, | ||||||||||||||||||||
'synopsis': USAGE}] + TRANSFER_ARGS + \ | ||||||||||||||||||||
[METADATA, METADATA_DIRECTIVE, EXPECTED_SIZE, RECURSIVE] | ||||||||||||||||||||
[METADATA, METADATA_DIRECTIVE, EXPECTED_SIZE, RECURSIVE, REQUEST_PAYER] | ||||||||||||||||||||
|
||||||||||||||||||||
|
||||||||||||||||||||
class MvCommand(S3TransferCommand): | ||||||||||||||||||||
|
@@ -744,7 +744,7 @@ class RmCommand(S3TransferCommand): | |||||||||||||||||||
USAGE = "<S3Uri>" | ||||||||||||||||||||
ARG_TABLE = [{'name': 'paths', 'nargs': 1, 'positional_arg': True, | ||||||||||||||||||||
'synopsis': USAGE}, DRYRUN, QUIET, RECURSIVE, INCLUDE, | ||||||||||||||||||||
EXCLUDE, ONLY_SHOW_ERRORS, PAGE_SIZE] | ||||||||||||||||||||
EXCLUDE, ONLY_SHOW_ERRORS, PAGE_SIZE, REQUEST_PAYER] | ||||||||||||||||||||
|
||||||||||||||||||||
|
||||||||||||||||||||
class SyncCommand(S3TransferCommand): | ||||||||||||||||||||
|
@@ -757,7 +757,7 @@ class SyncCommand(S3TransferCommand): | |||||||||||||||||||
"<LocalPath> or <S3Uri> <S3Uri>" | ||||||||||||||||||||
ARG_TABLE = [{'name': 'paths', 'nargs': 2, 'positional_arg': True, | ||||||||||||||||||||
'synopsis': USAGE}] + TRANSFER_ARGS + \ | ||||||||||||||||||||
[METADATA, METADATA_DIRECTIVE] | ||||||||||||||||||||
[METADATA, METADATA_DIRECTIVE, REQUEST_PAYER] | ||||||||||||||||||||
|
||||||||||||||||||||
|
||||||||||||||||||||
class MbCommand(S3Command): | ||||||||||||||||||||
|
@@ -985,11 +985,18 @@ def run(self): | |||||||||||||||||||
'result_queue': result_queue, | ||||||||||||||||||||
} | ||||||||||||||||||||
|
||||||||||||||||||||
fgen_request_parameters = {} | ||||||||||||||||||||
fgen_request_parameters = { | ||||||||||||||||||||
'RequestPayer': self.parameters.get('request_payer'), | ||||||||||||||||||||
} | ||||||||||||||||||||
fgen_head_object_params = {} | ||||||||||||||||||||
fgen_request_parameters['HeadObject'] = fgen_head_object_params | ||||||||||||||||||||
fgen_kwargs['request_parameters'] = fgen_request_parameters | ||||||||||||||||||||
|
||||||||||||||||||||
rgen_request_parameters = { | ||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One question that I have is for a cross-copy |
||||||||||||||||||||
'RequestPayer': self.parameters.get('request_payer'), | ||||||||||||||||||||
} | ||||||||||||||||||||
rgen_kwargs['request_parameters'] = rgen_request_parameters | ||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So for the request parameters that get passed to the aws-cli/awscli/customizations/s3/subcommands.py Lines 999 to 1007 in 9cdd69c
where we:
I am mainly suggesting this because:
|
||||||||||||||||||||
|
||||||||||||||||||||
# SSE-C may be neaded for HeadObject for copies/downloads/deletes | ||||||||||||||||||||
# If the operation is s3 to s3, the FileGenerator should use the | ||||||||||||||||||||
# copy source key and algorithm. Otherwise, use the regular | ||||||||||||||||||||
|
@@ -1111,6 +1118,8 @@ def __init__(self, cmd, parameters, usage): | |||||||||||||||||||
self.parameters['follow_symlinks'] = True | ||||||||||||||||||||
if 'source_region' not in parameters: | ||||||||||||||||||||
self.parameters['source_region'] = None | ||||||||||||||||||||
if 'request_payer' not in parameters: | ||||||||||||||||||||
self.parameters['request_payer'] = None | ||||||||||||||||||||
if self.cmd in ['sync', 'mb', 'rb']: | ||||||||||||||||||||
self.parameters['dir_op'] = True | ||||||||||||||||||||
if self.cmd == 'mv': | ||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -357,10 +357,12 @@ def __init__(self, client, date_parser=_date_parser): | |
self._client = client | ||
self._date_parser = date_parser | ||
|
||
def list_objects(self, bucket, prefix=None, page_size=None): | ||
def list_objects(self, bucket, prefix=None, page_size=None, request_payer=None): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that I would prefer that we made this more generalized such as an |
||
kwargs = {'Bucket': bucket, 'PaginationConfig': {'PageSize': page_size}} | ||
if prefix is not None: | ||
kwargs['Prefix'] = prefix | ||
if request_payer is not None: | ||
kwargs['RequestPayer'] = request_payer | ||
|
||
paginator = self._client.get_paginator('list_objects') | ||
pages = paginator.paginate(**kwargs) | ||
|
@@ -424,11 +426,13 @@ def map_put_object_params(cls, request_params, cli_params): | |
cls._set_metadata_params(request_params, cli_params) | ||
cls._set_sse_request_params(request_params, cli_params) | ||
cls._set_sse_c_request_params(request_params, cli_params) | ||
cls._set_request_payer_param(request_params, cli_params) | ||
|
||
@classmethod | ||
def map_get_object_params(cls, request_params, cli_params): | ||
"""Map CLI params to GetObject request params""" | ||
cls._set_sse_c_request_params(request_params, cli_params) | ||
cls._set_request_payer_param(request_params, cli_params) | ||
|
||
@classmethod | ||
def map_copy_object_params(cls, request_params, cli_params): | ||
|
@@ -440,11 +444,13 @@ def map_copy_object_params(cls, request_params, cli_params): | |
cls._set_sse_request_params(request_params, cli_params) | ||
cls._set_sse_c_and_copy_source_request_params( | ||
request_params, cli_params) | ||
cls._set_request_payer_param(request_params, cli_params) | ||
|
||
@classmethod | ||
def map_head_object_params(cls, request_params, cli_params): | ||
"""Map CLI params to HeadObject request params""" | ||
cls._set_sse_c_request_params(request_params, cli_params) | ||
cls._set_request_payer_param(request_params, cli_params) | ||
|
||
@classmethod | ||
def map_create_multipart_upload_params(cls, request_params, cli_params): | ||
|
@@ -453,21 +459,33 @@ def map_create_multipart_upload_params(cls, request_params, cli_params): | |
cls._set_sse_request_params(request_params, cli_params) | ||
cls._set_sse_c_request_params(request_params, cli_params) | ||
cls._set_metadata_params(request_params, cli_params) | ||
cls._set_request_payer_param(request_params, cli_params) | ||
|
||
@classmethod | ||
def map_upload_part_params(cls, request_params, cli_params): | ||
"""Map CLI params to UploadPart request params""" | ||
cls._set_sse_c_request_params(request_params, cli_params) | ||
cls._set_request_payer_param(request_params, cli_params) | ||
|
||
@classmethod | ||
def map_upload_part_copy_params(cls, request_params, cli_params): | ||
"""Map CLI params to UploadPartCopy request params""" | ||
cls._set_sse_c_and_copy_source_request_params( | ||
request_params, cli_params) | ||
cls._set_request_payer_param(request_params, cli_params) | ||
|
||
@classmethod | ||
def map_delete_params(cls, request_params, cli_params): | ||
cls._set_request_payer_param(request_params, cli_params) | ||
|
||
@classmethod | ||
def _set_request_payer_param(cls, request_params, cli_params): | ||
if cli_params.get('request_payer'): | ||
request_params['RequestPayer'] = cli_params['request_payer'] | ||
|
||
@classmethod | ||
def _set_general_object_params(cls, request_params, cli_params): | ||
# Paramters set in this method should be applicable to the following | ||
# Parameters set in this method should be applicable to the following | ||
# operations involving objects: PutObject, CopyObject, and | ||
# CreateMultipartUpload. | ||
general_param_translation = { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the
cp
andsync
, it would be great if this can be added to theTRANSFER_ARGS
list so it will get included in themv
command as well and it does not have to be explicitly added to each list for those commands.