Path: blob/develop/awscli/customizations/configservice/putconfigurationrecorder.py
1567 views
# Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.1#2# Licensed under the Apache License, Version 2.0 (the "License"). You3# may not use this file except in compliance with the License. A copy of4# the License is located at5#6# http://aws.amazon.com/apache2.0/7#8# or in the "license" file accompanying this file. This file is9# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF10# ANY KIND, either express or implied. See the License for the specific11# language governing permissions and limitations under the License.12import copy1314from awscli.arguments import CLIArgument151617def register_modify_put_configuration_recorder(cli):18cli.register(19'building-argument-table.configservice.put-configuration-recorder',20extract_recording_group)212223def extract_recording_group(session, argument_table, **kwargs):24# The purpose of this customization is to extract the recordingGroup25# member from ConfigurationRecorder into its own argument.26# This customization is needed because the recordingGroup member27# breaks the shorthand syntax as it is a structure and not a scalar value.28configuration_recorder_argument = argument_table['configuration-recorder']2930configuration_recorder_model = copy.deepcopy(31configuration_recorder_argument.argument_model)32recording_group_model = copy.deepcopy(33configuration_recorder_argument.argument_model.34members['recordingGroup'])3536del configuration_recorder_model.members['recordingGroup']37argument_table['configuration-recorder'] = ConfigurationRecorderArgument(38name='configuration-recorder',39argument_model=configuration_recorder_model,40operation_model=configuration_recorder_argument._operation_model,41is_required=True,42event_emitter=session.get_component('event_emitter'),43serialized_name='ConfigurationRecorder'44)4546argument_table['recording-group'] = RecordingGroupArgument(47name='recording-group',48argument_model=recording_group_model,49operation_model=configuration_recorder_argument._operation_model,50is_required=False,51event_emitter=session.get_component('event_emitter'),52serialized_name='recordingGroup'53)545556class ConfigurationRecorderArgument(CLIArgument):57def add_to_params(self, parameters, value):58if value is None:59return60unpacked = self._unpack_argument(value)61if 'ConfigurationRecorder' in parameters:62current_value = parameters['ConfigurationRecorder']63current_value.update(unpacked)64else:65parameters['ConfigurationRecorder'] = unpacked666768class RecordingGroupArgument(CLIArgument):69def add_to_params(self, parameters, value):70if value is None:71return72unpacked = self._unpack_argument(value)73if 'ConfigurationRecorder' in parameters:74parameters['ConfigurationRecorder']['recordingGroup'] = unpacked75else:76parameters['ConfigurationRecorder'] = {}77parameters['ConfigurationRecorder']['recordingGroup'] = unpacked787980