o .&a@sVddlZddlZddlmZddlmZddZddZd dd ZGd d d eZ dS) N) ServiceModel) BasicCommandcCs*i}|D] }||}|||j<q|SN)get_available_servicesget_service_modelendpoint_prefix)sessionprefixes_to_services service_name service_modelr J/usr/lib/python3/dist-packages/awscli/customizations/configure/addmodel.py%_get_endpoint_prefix_to_name_mappingss    rcCs$||vr|St|}|||Sr)rrget)rr name_mappingsr r r _get_service_names  rcCs\t|}|dur|j}t||}|j}|dj}dtt|dd}t j ||||S)a_Gets the path of where a service-2.json file should go in ~/.aws/models :type session: botocore.session.Session :param session: A session object :type service_definition: dict :param service_definition: The json loaded service definition :type service_name: str :param service_name: The service name to use. If this not provided, this will be determined from a combination of available services and the service definition. :returns: The path to where are model should be placed based on the service defintion and the current services in botocore. N data_loaderzservice-%d.jsonversionz2.0) rrr api_version get_componentCUSTOMER_DATA_PATHintfloatrospathjoin)rservice_definitionr r rr data_pathservice_model_namer r r get_model_location0s   rc@s2eZdZdZdZddddddd gZd d Zd S) AddModelCommandz add-modelzAdds a service JSON model to the appropriate location in ~/.aws/models. Once the model gets added, CLI commands and Boto3 clients will be immediately available for the service JSON model provided.z service-modelTz'The contents of the service JSON model.)namerequired help_textz service-namezmOverrides the default name used by the service JSON model to generate CLI service commands and Boto3 clients.)r!r#cCst|j}t|j||j}tj|}tj |st |t |d}| |j dWddS1s9wYdS)Nwbzutf-8r)jsonloadsr r_sessionr rrdirnameexistsmakedirsopenwriteencode)self parsed_argsparsed_globalsrmodel_locationmodel_directoryfr r r _run_mainfs       zAddModelCommand._run_mainN)__name__ __module__ __qualname__NAME DESCRIPTION ARG_TABLEr4r r r r r Vs r r) r%rbotocore.modelrawscli.customizations.commandsrrrrr r r r r s    &