Skip to content

Commit

Permalink
Update documentation to inject deprecation note on Expires in respons…
Browse files Browse the repository at this point in the history
…e and inject ExpiresString field.
  • Loading branch information
aemous committed Sep 23, 2024
1 parent 7b3a2b5 commit 288d9e9
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
50 changes: 50 additions & 0 deletions awscli/customizations/s3events.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,20 @@ def register_event_stream_arg(event_handlers):
event_handlers.register(
'building-argument-table.s3api.select-object-content',
add_event_stream_output_arg)

event_handlers.register_last(
'doc-output.s3api.select-object-content',
replace_event_stream_docs
)


def register_document_expires_string(event_handlers):
event_handlers.register_last(
'doc-output.s3api',
document_expires_string
)


def add_event_stream_output_arg(argument_table, operation_model,
session, **kwargs):
argument_table['outfile'] = S3SelectStreamOutputArgument(
Expand All @@ -57,6 +65,48 @@ def replace_event_stream_docs(help_command, **kwargs):
"object content is written to the specified outfile.\n")


def document_expires_string(help_command, **kwargs):
doc = help_command.doc
popped = []
current = ''
while current != 'Expires -> (timestamp)':
try:
current = doc.pop_write()
popped.append(current)
except IndexError:
# Do nothing if Expires is not in the modeled response
break
# Put back the expires field and description
doc.push_write(popped.pop())
doc.push_write(popped.pop())
doc.push_write(popped.pop())
doc.push_write(popped.pop())
# TODO add note about deprecation

# ..note::
#
#
#
# This functionality is not supported for directory buckets.
#
#
doc.push_write('\n\n\n' + doc.style.spaces())
doc.push_write('.. note::')
doc.style.indent()
doc.push_write('\n\n\n' + doc.style.spaces())
doc.push_write('This member has been deprecated. Please use `ExpiresString` instead.\n')
doc.style.dedent()
doc.push_write('\n\n' + doc.style.spaces())
doc.push_write('\n\n' + doc.style.spaces())
doc.push_write('ExpiresString -> (string)\n\n')
doc.push_write('\tThe raw, unparsed value of the ``Expires`` field.')
doc.push_write('\n\n' + doc.style.spaces())

# Write rest of document
while len(popped) > 0:
doc.push_write(popped.pop())


class S3SelectStreamOutputArgument(CustomArgument):
_DOCUMENT_AS_REQUIRED = True

Expand Down
3 changes: 2 additions & 1 deletion awscli/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
from awscli.customizations.waiters import register_add_waiters
from awscli.customizations.opsworkscm import register_alias_opsworks_cm
from awscli.customizations.servicecatalog import register_servicecatalog_commands
from awscli.customizations.s3events import register_event_stream_arg
from awscli.customizations.s3events import register_event_stream_arg, register_document_expires_string
from awscli.customizations.sessionmanager import register_ssm_session
from awscli.customizations.logs import register_logs_commands
from awscli.customizations.devcommands import register_dev_commands
Expand Down Expand Up @@ -191,6 +191,7 @@ def awscli_initialize(event_handlers):
register_history_mode(event_handlers)
register_history_commands(event_handlers)
register_event_stream_arg(event_handlers)
register_document_expires_string(event_handlers)
dlm_initialize(event_handlers)
register_ssm_session(event_handlers)
register_logs_commands(event_handlers)
Expand Down

0 comments on commit 288d9e9

Please sign in to comment.