Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
aws
GitHub Repository: aws/aws-cli
Path: blob/develop/awscli/customizations/configservice/putconfigurationrecorder.py
1567 views
1
# Copyright 2015 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
import copy
14
15
from awscli.arguments import CLIArgument
16
17
18
def register_modify_put_configuration_recorder(cli):
19
cli.register(
20
'building-argument-table.configservice.put-configuration-recorder',
21
extract_recording_group)
22
23
24
def extract_recording_group(session, argument_table, **kwargs):
25
# The purpose of this customization is to extract the recordingGroup
26
# member from ConfigurationRecorder into its own argument.
27
# This customization is needed because the recordingGroup member
28
# breaks the shorthand syntax as it is a structure and not a scalar value.
29
configuration_recorder_argument = argument_table['configuration-recorder']
30
31
configuration_recorder_model = copy.deepcopy(
32
configuration_recorder_argument.argument_model)
33
recording_group_model = copy.deepcopy(
34
configuration_recorder_argument.argument_model.
35
members['recordingGroup'])
36
37
del configuration_recorder_model.members['recordingGroup']
38
argument_table['configuration-recorder'] = ConfigurationRecorderArgument(
39
name='configuration-recorder',
40
argument_model=configuration_recorder_model,
41
operation_model=configuration_recorder_argument._operation_model,
42
is_required=True,
43
event_emitter=session.get_component('event_emitter'),
44
serialized_name='ConfigurationRecorder'
45
)
46
47
argument_table['recording-group'] = RecordingGroupArgument(
48
name='recording-group',
49
argument_model=recording_group_model,
50
operation_model=configuration_recorder_argument._operation_model,
51
is_required=False,
52
event_emitter=session.get_component('event_emitter'),
53
serialized_name='recordingGroup'
54
)
55
56
57
class ConfigurationRecorderArgument(CLIArgument):
58
def add_to_params(self, parameters, value):
59
if value is None:
60
return
61
unpacked = self._unpack_argument(value)
62
if 'ConfigurationRecorder' in parameters:
63
current_value = parameters['ConfigurationRecorder']
64
current_value.update(unpacked)
65
else:
66
parameters['ConfigurationRecorder'] = unpacked
67
68
69
class RecordingGroupArgument(CLIArgument):
70
def add_to_params(self, parameters, value):
71
if value is None:
72
return
73
unpacked = self._unpack_argument(value)
74
if 'ConfigurationRecorder' in parameters:
75
parameters['ConfigurationRecorder']['recordingGroup'] = unpacked
76
else:
77
parameters['ConfigurationRecorder'] = {}
78
parameters['ConfigurationRecorder']['recordingGroup'] = unpacked
79
80