From 236dd561254d1e3223a1240080052877a6ca6fd1 Mon Sep 17 00:00:00 2001 From: SamRemis Date: Wed, 5 Feb 2025 08:35:43 -0500 Subject: [PATCH] Alias socialmessaging command --- awscli/customizations/socialmessaging.py | 28 +++++++++++++++++++ awscli/handlers.py | 2 ++ tests/functional/socialmessaging/__init__.py | 0 .../functional/socialmessaging/test_alias.py | 24 ++++++++++++++++ 4 files changed, 54 insertions(+) create mode 100644 awscli/customizations/socialmessaging.py create mode 100644 tests/functional/socialmessaging/__init__.py create mode 100644 tests/functional/socialmessaging/test_alias.py diff --git a/awscli/customizations/socialmessaging.py b/awscli/customizations/socialmessaging.py new file mode 100644 index 000000000000..d872fed05c3b --- /dev/null +++ b/awscli/customizations/socialmessaging.py @@ -0,0 +1,28 @@ +# Copyright 2025 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"). You +# may not use this file except in compliance with the License. A copy of +# the License is located at +# +# http://aws.amazon.com/apache2.0/ +# +# or in the "license" file accompanying this file. This file is +# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF +# ANY KIND, either express or implied. See the License for the specific +# language governing permissions and limitations under the License. +from awscli.customizations.utils import make_hidden_command_alias + + +def register_alias_socialmessaging_command(event_emitter): + event_emitter.register( + 'building-command-table.socialmessaging', + alias_socialmessaging_command + ) + + +def alias_socialmessaging_command(command_table, **kwargs): + make_hidden_command_alias( + command_table, + existing_name='delete-whatsapp-message-media', + alias_name='delete-whatsapp-media-message', + ) diff --git a/awscli/handlers.py b/awscli/handlers.py index f6c2c13a7801..b19e0a909d08 100644 --- a/awscli/handlers.py +++ b/awscli/handlers.py @@ -116,6 +116,7 @@ from awscli.customizations.sessendemail import register_ses_send_email from awscli.customizations.sessionmanager import register_ssm_session from awscli.customizations.sms_voice import register_sms_voice_hide +from awscli.customizations.socialmessaging import register_alias_socialmessaging_command from awscli.customizations.streamingoutputarg import add_streaming_output_arg from awscli.customizations.toplevelbool import register_bool_params from awscli.customizations.translate import ( @@ -210,6 +211,7 @@ def awscli_initialize(event_handlers): register_alias_opsworks_cm(event_handlers) register_alias_mturk_command(event_handlers) register_alias_sagemaker_runtime_command(event_handlers) + register_alias_socialmessaging_command(event_handlers) register_servicecatalog_commands(event_handlers) register_translate_import_terminology(event_handlers) register_history_mode(event_handlers) diff --git a/tests/functional/socialmessaging/__init__.py b/tests/functional/socialmessaging/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tests/functional/socialmessaging/test_alias.py b/tests/functional/socialmessaging/test_alias.py new file mode 100644 index 000000000000..5a3a9643a7de --- /dev/null +++ b/tests/functional/socialmessaging/test_alias.py @@ -0,0 +1,24 @@ +# Copyright 2025 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"). You +# may not use this file except in compliance with the License. A copy of +# the License is located at +# +# http://aws.amazon.com/apache2.0/ +# +# or in the "license" file accompanying this file. This file is +# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF +# ANY KIND, either express or implied. See the License for the specific +# language governing permissions and limitations under the License. +from awscli.testutils import BaseAWSCommandParamsTest + + +class TestAlias(BaseAWSCommandParamsTest): + def test_alias(self): + # This command was aliased, both should work + command_template = ('socialmessaging %s --origination-phone-number-id foo ' + '--media-id bar') + old_command = command_template % 'delete-whatsapp-media-message' + new_command = command_template % 'delete-whatsapp-message-media' + self.run_cmd(old_command, expected_rc=0) + self.run_cmd(new_command, expected_rc=0)