B ㊇cmx@sdZddlZddlZddlZddlmZeeZdddgddfdddd d didfd d d de fddde fdddddej fdddej fdddej fddddej fdddd e fd!d"d#d$d%d&d'de fd(Z d)d*ddej fd+ddej fd,ddej fd-d.gd/dej fd0d1gd2ddfd3d4dej fd5Z d6d7d8ddej fd9Zd:d;Zdd?d?ZGd@dAdAZGdBdCdCZGdDdEdEZGdFdGdGZGdHdIdIeZGdJdKdKeZGdLdMdMeZGdNdOdOeZGdPdQdQeZGdRdSdSeZdS)TzOThis module contains the inteface for controlling how configuration is loaded. N)utilsZAWS_DEFAULT_PROFILEZ AWS_PROFILE)regionAWS_DEFAULT_REGIONNN) data_pathZ AWS_DATA_PATHNN)NZAWS_CONFIG_FILEz ~/.aws/configN) ca_bundleZ AWS_CA_BUNDLENN api_versions)NZAWS_SHARED_CREDENTIALS_FILEz~/.aws/credentialsNmetadata_service_timeoutZAWS_METADATA_SERVICE_TIMEOUTmetadata_service_num_attemptsZ!AWS_METADATA_SERVICE_NUM_ATTEMPTS)ec2_metadata_service_endpointZ!AWS_EC2_METADATA_SERVICE_ENDPOINTNN)"ec2_metadata_service_endpoint_modeZ&AWS_EC2_METADATA_SERVICE_ENDPOINT_MODENN imds_use_ipv6ZAWS_IMDS_USE_IPV6Fuse_dualstack_endpointZAWS_USE_DUALSTACK_ENDPOINTuse_fips_endpointZAWS_USE_FIPS_ENDPOINT)parameter_validationNTN csm_enabledZAWS_CSM_ENABLED)csm_hostZ AWS_CSM_HOSTz 127.0.0.1Ncsm_portZ AWS_CSM_PORTiy) csm_client_idZAWS_CSM_CLIENT_IDN)endpoint_discovery_enabledZAWS_ENDPOINT_DISCOVERY_ENABLEDautoN)sts_regional_endpointsZAWS_STS_REGIONAL_ENDPOINTSlegacyN) retry_modeZAWS_RETRY_MODErN) defaults_modeZAWS_DEFAULTS_MODErN max_attemptsZAWS_MAX_ATTEMPTS)Zprofilerr config_filerrZcredentials_filerr r r r rrrrrrrrrrrr))s3addressing_styleNNN)ruse_accelerate_endpoint)rr)rpayload_signing_enabledZs3_use_arn_region)ruse_arn_regionZAWS_S3_USE_ARN_REGIONZs3_us_east_1_regional_endpoint)rus_east_1_regional_endpointZ"AWS_S3_US_EAST_1_REGIONAL_ENDPOINT)r$s3_disable_multiregion_access_pointsZ(AWS_S3_DISABLE_MULTIREGION_ACCESS_POINTS)rr rr!r"r#r$)proxy_ca_bundleNNN)proxy_client_certNNNproxy_use_forwarding_for_https)r%r&r'cCsDt|d}t|t}td|t|t|d<td|t|t|d<|S)N)sessionrZproxies_config)ConfigChainFactory_create_config_chain_mapping!BOTOCORE_DEFAUT_SESSION_VARIABLESSectionConfigProviderDEFAULT_S3_CONFIG_VARSDEFAULT_PROXIES_CONFIG_VARS)r( chain_builderZconfig_mappingr0r/private/var/folders/8c/hx9_v10d5x38qmnzt13b7b8j1k3n5b/T/pip-target-x6xd5gna/lib/python/botocore/configprovider.py&create_botocore_default_config_mappings r2cCsFi}x<|D]0\}}|j||d|d|d|dd||<qW|S)Nr r) instance_name env_var_namesconfig_property_namesdefaultconversion_func)itemscreate_config_chain)r/Zconfig_variablesmapping logical_nameconfigr0r0r1r*sr*c@s,eZdZddZddZddZddZd S) DefaultConfigResolvercCs|d|_|d|_i|_dS)Nbasemodes)_base_default_config_modes _resolved_default_configurations)selfZdefault_config_datar0r0r1__init__s  zDefaultConfigResolver.__init__c Cs|j}|j|}xl|D]d}||}||}t|d}||}|dkrZ||9}n|dkrl||7}n |dkrx|}|||<qW|S)Nrmultiplyaddoverride)rBcopyrCgetlistkeys) rEmodeZdefault_configZ modifications config_var default_valueZmodification_dictZ modificationZmodification_valuer0r0r1_resolve_default_values_by_modes      z5DefaultConfigResolver._resolve_default_values_by_modecCsddg}||j|S)Nrr)extendrCrM)rEZ default_modesr0r0r1get_default_modessz'DefaultConfigResolver.get_default_modescCs(||jkr||}||j|<|j|S)N)rDrQ)rErNdefaultsr0r0r1get_default_config_values s   z/DefaultConfigResolver.get_default_config_valuesN)__name__ __module__ __qualname__rFrQrSrUr0r0r0r1r?sr?c@s4eZdZdZd ddZd ddZddZd d ZdS) r)aFactory class to create our most common configuration chain case. This is a convenience class to construct configuration chains that follow our most common pattern. This is to prevent ordering them incorrectly, and to make the config chain construction more readable. NcCs||_|dkrtj}||_dS)aInitialize a ConfigChainFactory. :type session: :class:`botocore.session.Session` :param session: This is the session that should be used to look up values from the config file. :type environ: dict :param environ: A mapping to use for environment variables. If this is not provided it will default to use os.environ. N)_sessionosenviron_environ)rEr(r[r0r0r1rFs zConfigChainFactory.__init__cCstg}|dk r |t||jd|dk r8||||dk rP||||dk rh|t|dt||dS)aBuild a config chain following the standard botocore pattern. In botocore most of our config chains follow the the precendence: session_instance_variables, environment, config_file, default_value. This is a convenience function for creating a chain that follow that precendence. :type instance_name: str :param instance_name: This indicates what session instance variable corresponds to this config value. If it is None it will not be added to the chain. :type env_var_names: str or list of str or None :param env_var_names: One or more environment variable names to search for this value. They are searched in order. If it is None it will not be added to the chain. :type config_property_names: str/tuple or list of str/tuple or None :param config_property_names: One of more strings or tuples representing the name of the key in the config file for this config option. They are searched in order. If it is None it will not be added to the chain. :type default: Any :param default: Any constant value to be returned. :type conversion_func: None or callable :param conversion_func: If this value is None then it has no effect on the return type. Otherwise, it is treated as a function that will conversion_func our provided type. :rvalue: ConfigChain :returns: A ConfigChain that resolves in the order env_var_names -> config_property_name -> default. Any values that were none are omitted form the chain. N) instance_varr()value) providersr9)appendInstanceVarProviderrYrR_get_env_providers_get_scoped_config_providersConstantProvider ChainProvider)rEr5r6r7r8r9r_r0r0r1r;(s- z&ConfigChainFactory.create_config_chaincCs:g}t|ts|g}x |D]}|t||jdqW|S)N)nameenv) isinstancerLr`EnvironmentProviderr\)rEr6Zenv_var_providersZ env_var_namer0r0r1rbjs  z%ConfigChainFactory._get_env_providerscCs:g}t|ts|g}x |D]}|t||jdqW|S)N)config_var_namer()rhrLr`ScopedConfigProviderrY)rEr7Zscoped_config_providersZconfig_property_namer0r0r1rcts  z/ConfigChainFactory._get_scoped_config_providers)N)NNNNN)rVrWrX__doc__rFr;rbrcr0r0r0r1r)s  < r)c@sJeZdZdZdddZddZddZd d Zd d Zd dZ ddZ dS)ConfigValueStorez8The ConfigValueStore object stores configuration values.NcCs:i|_i|_|dk r6x |D]\}}|||qWdS)aNInitialize a ConfigValueStore. :type mapping: dict :param mapping: The mapping parameter is a map of string to a subclass of BaseProvider. When a config variable is asked for via the get_config_variable method, the corresponding provider will be invoked to load the value. N) _overrides_mappingr:set_config_provider)rEr<r=providerr0r0r1rFs zConfigValueStore.__init__cCstt|j|S)N)rmrJdeepcopyro)rEmemor0r0r1 __deepcopy__szConfigValueStore.__deepcopy__cCs4||jkr|j|S||jkr"dS|j|}|S)a Retrieve the value associeated with the specified logical_name from the corresponding provider. If no value is found None will be returned. :type logical_name: str :param logical_name: The logical name of the session variable you want to retrieve. This name will be mapped to the appropriate environment variable name for this session as well as the appropriate config file entry. :returns: value of variable or None if not defined. N)rnroprovide)rEr=rqr0r0r1get_config_variables     z$ConfigValueStore.get_config_variablecCs&||jks||jkrdS|j|}|S)a Retrieve the provider associated with the specified logical_name. If no provider is found None will be returned. :type logical_name: str :param logical_name: The logical name of the session variable you want to retrieve. This name will be mapped to the appropriate environment variable name for this session as well as the appropriate config file entry. :returns: configuration provider or None if not defined. N)rnro)rEr=rqr0r0r1get_config_providers    z$ConfigValueStore.get_config_providercCs||j|<dS)aSet a configuration variable to a specific value. By using this method, you can override the normal lookup process used in ``get_config_variable`` by explicitly setting a value. Subsequent calls to ``get_config_variable`` will use the ``value``. This gives you per-session specific configuration values. :: >>> # Assume logical name 'foo' maps to env var 'FOO' >>> os.environ['FOO'] = 'myvalue' >>> s.get_config_variable('foo') 'myvalue' >>> s.set_config_variable('foo', 'othervalue') >>> s.get_config_variable('foo') 'othervalue' :type logical_name: str :param logical_name: The logical name of the session variable you want to set. These are the keys in ``SESSION_VARIABLES``. :param value: The value to associate with the config variable. N)rn)rEr=r^r0r0r1set_config_variablesz$ConfigValueStore.set_config_variablecCs|j|ddS)zRemove an override config variable from the session. :type logical_name: str :param logical_name: The name of the parameter to clear the override value from. N)rnpop)rEr=r0r0r1clear_config_variablesz&ConfigValueStore.clear_config_variablecCs||j|<dS)a;Set the provider for a config value. This provides control over how a particular configuration value is loaded. This replaces the provider for ``logical_name`` with the new ``provider``. :type logical_name: str :param logical_name: The name of the config value to change the config provider for. :type provider: :class:`botocore.configprovider.BaseProvider` :param provider: The new provider that should be responsible for providing a value for the config named ``logical_name``. N)ro)rEr=rqr0r0r1rpsz$ConfigValueStore.set_config_provider)N) rVrWrXrlrFrtrvrwrxrzrpr0r0r0r1rms  rmc@sTeZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ dS)SmartDefaultsConfigStoreFactorycCs||_||_d|_dS)N)_default_config_resolver_imds_region_provider_instance_metadata_region)rEZdefault_config_resolverZimds_region_providerr0r0r1rFsz(SmartDefaultsConfigStoreFactory.__init__cCsX|dkr||}|j|}x4|D],}||}t|d|d}|r$|||q$WdS)NrZ_set_)resolve_auto_moder|rUgetattr)rE config_storerN region_nameZdefault_configsrOZ config_valuemethodr0r0r1merge_smart_defaultss   z4SmartDefaultsConfigStoreFactory.merge_smart_defaultscCs~d}tjdr*tjd}tjd|}|sf|jr<|j}n*y|j}||_Wntk rdYnX|rz||krvdSdSdS)NZAWS_EXECUTION_ENVrZ AWS_REGIONz in-regionz cross-regionstandard)rZr[rKr~r}ru Exception)rErZcurrent_regionZdefault_regionr0r0r1r s"    z1SmartDefaultsConfigStoreFactory.resolve_auto_modecCsR||}t|}t|tr*||dSt|trBt||gd}|||dS)N)r_)rwrdrhreset_default_provider BaseProviderrp)rErvariabler^rqdefault_providerr0r0r1_update_provider s     z0SmartDefaultsConfigStoreFactory._update_providercCs||}||t|dS)N)rwrrd)rEr section_namerr^Zsection_providerr0r0r1_update_section_provider,s z8SmartDefaultsConfigStoreFactory._update_section_providercCs||d|dS)Nr)r)rErr^r0r0r1_set_retryMode4sz.SmartDefaultsConfigStoreFactory._set_retryModecCs||d|dS)Nr)r)rErr^r0r0r1_set_stsRegionalEndpoints7sz9SmartDefaultsConfigStoreFactory._set_stsRegionalEndpointscCs||dd|dS)Nrr#)r)rErr^r0r0r1_set_s3UsEast1RegionalEndpoints:sz?SmartDefaultsConfigStoreFactory._set_s3UsEast1RegionalEndpointscCs||d|ddS)Nconnect_timeouti)r)rErr^r0r0r1_set_connectTimeoutInMillis?sz;SmartDefaultsConfigStoreFactory._set_connectTimeoutInMillisN) rVrWrXrFrrrrrrrrr0r0r0r1r{s  r{c@seZdZdZddZdS)rzBase class for configuration value providers. A configuration provider has some method of providing a configuration value. cCs tddS)zProvide a config value.ruN)NotImplementedError)rEr0r0r1ruJszBaseProvider.provideN)rVrWrXrlrur0r0r0r1rCsrc@sBeZdZdZdddZddZddZd d Zd d Zd dZ dS)rezThis provider wraps one or more other providers. Each provider in the chain is called, the first one returning a non-None value is then returned. NcCs|dkr g}||_||_dS)aInitalize a ChainProvider. :type providers: list :param providers: The initial list of providers to check for values when invoked. :type conversion_func: None or callable :param conversion_func: If this value is None then it has no affect on the return type. Otherwise, it is treated as a function that will transform provided value. N) _providers_conversion_func)rEr_r9r0r0r1rFVs zChainProvider.__init__cCstt|j||jS)N)rerJrrrr)rErsr0r0r1rtgszChainProvider.__deepcopy__cCs.x(|jD]}|}|dk r||SqWdS)a*Provide the value from the first provider to return non-None. Each provider in the chain has its provide method called. The first one in the chain to return a non-None value is the returned from the ChainProvider. When no non-None value is found, None is returned. N)rru _convert_type)rErqr^r0r0r1ruls  zChainProvider.providecCsX|jr"t|jdtr"||jd<n |j|tdd|jD}|dkrTtddS)Ncss|]}t|tVqdS)N)rhrd).0rqr0r0r1 sz5ChainProvider.set_default_provider..r zLChainProvider object contains multiple instances of ConstantProvider objects)rrhrdr`sumloggerinfo)rErZnum_of_constantsr0r0r1rys   z"ChainProvider.set_default_providercCs|jdk r||S|S)N)r)rEr^r0r0r1rs  zChainProvider._convert_typecCsdddd|jDS)Nz[%s]z, cSsg|] }t|qSr0)str)rpr0r0r1 sz*ChainProvider.__repr__..)joinr)rEr0r0r1__repr__szChainProvider.__repr__)NN) rVrWrXrlrFrtrurrrr0r0r0r1reOs  rec@s0eZdZdZddZddZddZdd Zd S) raz>This class loads config values from the session instance vars.cCs||_||_dS)a>Initialize InstanceVarProvider. :type instance_var: str :param instance_var: The instance variable to load from the session. :type session: :class:`botocore.session.Session` :param session: The botocore session to get the loaded configuration file variables from. N) _instance_varrY)rEr]r(r0r0r1rFs zInstanceVarProvider.__init__cCstt|j||jS)N)rarJrrrrY)rErsr0r0r1rtsz InstanceVarProvider.__deepcopy__cCs|j}||j}|S)z6Provide a config value from the session instance vars.)rYZinstance_variablesrKr)rEZ instance_varsr^r0r0r1rus  zInstanceVarProvider.providecCsd|j|jS)Nz0InstanceVarProvider(instance_var={}, session={}))formatrrY)rEr0r0r1rszInstanceVarProvider.__repr__N)rVrWrXrlrFrtrurr0r0r0r1ras  rac@s,eZdZddZddZddZddZd S) rkcCs||_||_dS)a2Initialize ScopedConfigProvider. :type config_var_name: str or tuple :param config_var_name: The name of the config variable to load from the configuration file. If the value is a tuple, it must only consist of two items, where the first item represents the section and the second item represents the config var name in the section. :type session: :class:`botocore.session.Session` :param session: The botocore session to get the loaded configuration file variables from. N)_config_var_namerY)rErjr(r0r0r1rFs zScopedConfigProvider.__init__cCstt|j||jS)N)rkrJrrrrY)rErsr0r0r1rtsz!ScopedConfigProvider.__deepcopy__cCsP|j}t|jtrD||jd}t|ts4dS||jdS||jS)z,Provide a value from a config file property.rNr )rYZget_scoped_configrhrtuplerKdict)rEZ scoped_configsection_configr0r0r1rus   zScopedConfigProvider.providecCsd|j|jS)Nz4ScopedConfigProvider(config_var_name={}, session={}))rrrY)rEr0r0r1rszScopedConfigProvider.__repr__N)rVrWrXrFrtrurr0r0r0r1rks rkc@s0eZdZdZddZddZddZdd Zd S) riz:This class loads config values from environment variables.cCs||_||_dS)aInitialize with the keys in the dictionary to check. :type name: str :param name: The key with that name will be loaded and returned. :type env: dict :param env: Environment variables dictionary to get variables from. N)_name_env)rErfrgr0r0r1rFs zEnvironmentProvider.__init__cCstt|j|t|j|S)N)rirJrrrr)rErsr0r0r1rtsz EnvironmentProvider.__deepcopy__cCs|j|jkr|j|jSdS)z0Provide a config value from a source dictionary.N)rr)rEr0r0r1rus  zEnvironmentProvider.providecCsd|jd|jdS)NzEnvironmentProvider(name=z, env=))rr)rEr0r0r1rszEnvironmentProvider.__repr__N)rVrWrXrlrFrtrurr0r0r0r1ris  ric@s:eZdZdZd ddZddZddZd d Zd d ZdS)r,zProvides a dictionary from a section in the scoped config This is useful for retrieving scoped config variables (i.e. s3) that have their own set of config variables and resolving logic. NcCs6||_||_t|j|j|_||_|jdkr2i|_dS)N) _section_namerYrk_scoped_config_provider_override_providers)rErr(Zoverride_providersr0r0r1rFs zSectionConfigProvider.__init__cCs"tt|j||jt|j|S)N)r,rJrrrrYr)rErsr0r0r1rt s z"SectionConfigProvider.__deepcopy__cCsl|j}|r,t|ts,td|j|dSx:|jD],\}}|}|dk r8|dkr\i}|||<q8W|S)NzEThe %s config key is not a dictionary type, ignoring its value of: %s) rrurhrrdebugrrr:)rErZsection_config_varrqZ provider_valr0r0r1rus  zSectionConfigProvider.providecCsJ|j|}t|tr$||dSt|trszConstantProvider.__deepcopy__cCs|jS)z7Provide the constant value given during initialization.)r)rEr0r0r1ruAszConstantProvider.providecCs d|jS)NzConstantProvider(value=%s))r)rEr0r0r1rEszConstantProvider.__repr__N)rVrWrXrlrFrtrurr0r0r0r1rd8s rd)rlrJloggingrZZbotocorer getLoggerrVrintZensure_booleanr+r-Znormalize_booleanr.r2r*r?r)rmr{rrerarkrir,rdr0r0r0r1s        $rtM E"'=