Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
aws
GitHub Repository: aws/aws-cli
Path: blob/develop/awscli/customizations/removals.py
1566 views
1
# Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
#
3
# Licensed under the Apache License, Version 2.0 (the "License"). You
4
# may not use this file except in compliance with the License. A copy of
5
# the License is located at
6
#
7
# http://aws.amazon.com/apache2.0/
8
#
9
# or in the "license" file accompanying this file. This file is
10
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
# ANY KIND, either express or implied. See the License for the specific
12
# language governing permissions and limitations under the License.
13
"""
14
Remove deprecated commands
15
--------------------------
16
17
This customization removes commands that are either deprecated or not
18
yet fully supported.
19
20
"""
21
import logging
22
from functools import partial
23
24
LOG = logging.getLogger(__name__)
25
26
27
def register_removals(event_handler):
28
cmd_remover = CommandRemover(event_handler)
29
cmd_remover.remove(on_event='building-command-table.ses',
30
remove_commands=['delete-verified-email-address',
31
'list-verified-email-addresses',
32
'verify-email-address'])
33
cmd_remover.remove(on_event='building-command-table.ec2',
34
remove_commands=['import-instance', 'import-volume'])
35
cmd_remover.remove(on_event='building-command-table.emr',
36
remove_commands=['run-job-flow', 'describe-job-flows',
37
'add-job-flow-steps',
38
'terminate-job-flows',
39
'list-bootstrap-actions',
40
'list-instance-groups',
41
'set-termination-protection',
42
'set-keep-job-flow-alive-when-no-steps',
43
'set-visible-to-all-users',
44
'set-unhealthy-node-replacement'])
45
cmd_remover.remove(on_event='building-command-table.kinesis',
46
remove_commands=['subscribe-to-shard'])
47
cmd_remover.remove(on_event='building-command-table.lexv2-runtime',
48
remove_commands=['start-conversation'])
49
cmd_remover.remove(on_event='building-command-table.lambda',
50
remove_commands=['invoke-with-response-stream'])
51
cmd_remover.remove(on_event='building-command-table.sagemaker-runtime',
52
remove_commands=['invoke-endpoint-with-response-stream'])
53
cmd_remover.remove(on_event='building-command-table.bedrock-runtime',
54
remove_commands=['invoke-model-with-response-stream',
55
'invoke-model-with-bidirectional-stream',
56
'converse-stream'])
57
cmd_remover.remove(on_event='building-command-table.bedrock-agent-runtime',
58
remove_commands=['invoke-agent',
59
'invoke-flow',
60
'invoke-inline-agent',
61
'optimize-prompt',
62
'retrieve-and-generate-stream'])
63
cmd_remover.remove(on_event='building-command-table.bedrock-agentcore',
64
remove_commands=['invoke-code-interpreter'])
65
cmd_remover.remove(on_event='building-command-table.qbusiness',
66
remove_commands=['chat'])
67
cmd_remover.remove(on_event='building-command-table.iotsitewise',
68
remove_commands=['invoke-assistant'])
69
cmd_remover.remove(on_event='building-command-table.logs',
70
remove_commands=['get-log-object'])
71
72
73
class CommandRemover(object):
74
def __init__(self, events):
75
self._events = events
76
77
def remove(self, on_event, remove_commands):
78
self._events.register(on_event,
79
self._create_remover(remove_commands))
80
81
def _create_remover(self, commands_to_remove):
82
return partial(_remove_commands, commands_to_remove=commands_to_remove)
83
84
85
def _remove_commands(command_table, commands_to_remove, **kwargs):
86
# Hooked up to building-command-table.<service>
87
for command in commands_to_remove:
88
try:
89
LOG.debug("Removing operation: %s", command)
90
del command_table[command]
91
except KeyError:
92
LOG.warning("Attempting to delete command that does not exist: %s",
93
command)
94
95