o <&aQY @sdZddlZddlZddlmZeeZiddddgddfddd d d d d ddddidfddddddefddddefddddddddej fddddej fd d d!dej fd"d#d$d$d%dej fd&d'd(d)d*efd+d,d-d.d/d0defd1Z d2d3ddej fd4ddej fd5ddej fd6d7gd8dej fd9d:gd;ddfdZ d?d@dAddej fdBZ dCdDZdEdFZGdGdHdHeZGdIdJdJeZGdKdLdLeZGdMdNdNeZGdOdPdPeZGdQdRdReZGdSdTdTeZGdUdVdVeZGdWdXdXeZdS)YzOThis module contains the inteface for controlling how configuration is loaded. N)utilsprofileAWS_DEFAULT_PROFILE AWS_PROFILEregion)rAWS_DEFAULT_REGIONNN data_path)r AWS_DATA_PATHNN config_file)NAWS_CONFIG_FILEz ~/.aws/configN ca_bundle)r AWS_CA_BUNDLENN api_versionscredentials_file)NAWS_SHARED_CREDENTIALS_FILEz~/.aws/credentialsNmetadata_service_timeoutAWS_METADATA_SERVICE_TIMEOUTmetadata_service_num_attempts!AWS_METADATA_SERVICE_NUM_ATTEMPTSec2_metadata_service_endpoint)r!AWS_EC2_METADATA_SERVICE_ENDPOINTNN"ec2_metadata_service_endpoint_mode)r&AWS_EC2_METADATA_SERVICE_ENDPOINT_MODENN imds_use_ipv6AWS_IMDS_USE_IPV6Fuse_dualstack_endpointAWS_USE_DUALSTACK_ENDPOINTuse_fips_endpointAWS_USE_FIPS_ENDPOINTparameter_validation)r NTN csm_enabledAWS_CSM_ENABLEDcsm_host)r# AWS_CSM_HOSTz 127.0.0.1Ncsm_port AWS_CSM_PORTiy) csm_client_idAWS_CSM_CLIENT_IDN)endpoint_discovery_enabledAWS_ENDPOINT_DISCOVERY_ENABLEDautoN)sts_regional_endpointsAWS_STS_REGIONAL_ENDPOINTSlegacyN) retry_modeAWS_RETRY_MODEr/N max_attemptsAWS_MAX_ATTEMPTS)r%r'r*r-r0r2))s3addressing_styleNNN)r4use_accelerate_endpoint)r4r)r4payload_signing_enableds3_use_arn_region)r4use_arn_regionAWS_S3_USE_ARN_REGIONs3_us_east_1_regional_endpoint)r4us_east_1_regional_endpoint"AWS_S3_US_EAST_1_REGIONAL_ENDPOINT)r4$s3_disable_multiregion_access_points(AWS_S3_DISABLE_MULTIREGION_ACCESS_POINTS)r5r6rr7r9r<r>)proxy_ca_bundleNNN)proxy_client_certNNNproxy_use_forwarding_for_https)r@rArBcCsDt|d}t|t}td|t|t|d<td|t|t|d<|S)N)sessionr4proxies_config)ConfigChainFactory_create_config_chain_mapping!BOTOCORE_DEFAUT_SESSION_VARIABLESSectionConfigProviderDEFAULT_S3_CONFIG_VARSDEFAULT_PROXIES_CONFIG_VARS)rC chain_builderconfig_mappingrM9/usr/lib/python3/dist-packages/botocore/configprovider.py&create_botocore_default_config_mappings rOcCsBi}|D]\}}|j||d|d|d|dd||<q|S)Nrr) instance_name env_var_namesconfig_property_namesdefaultconversion_func)itemscreate_config_chain)rKconfig_variablesmapping logical_nameconfigrMrMrNrFs rFc@s:eZdZdZd ddZ   d ddZddZd d ZdS) rEaFactory 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||_|dur tj}||_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)selfrCr_rMrMrN__init__s  zConfigChainFactory.__init__cCstg}|dur|t||jd|dur||||dur(||||dur4|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_varrC)value) providersrV)appendInstanceVarProviderr]extend_get_env_providers_get_scoped_config_providersConstantProvider ChainProvider)rarRrSrTrUrVrerMrMrNrXs((z&ConfigChainFactory.create_config_chaincC6g}t|ts |g}|D] }|t||jdq |S)N)nameenv) isinstancelistrfEnvironmentProviderr`)rarSenv_var_providers env_var_namerMrMrNris  z%ConfigChainFactory._get_env_providerscCrm)N)config_var_namerC)rprqrfScopedConfigProviderr])rarTscoped_config_providersconfig_property_namerMrMrNrjs z/ConfigChainFactory._get_scoped_config_providersN)NNNNN)__name__ __module__ __qualname____doc__rbrXrirjrMrMrMrNrEs  > rEc@s:eZdZdZd ddZddZddZd d Zd d ZdS)ConfigValueStorez8The ConfigValueStore object stores configuration values.NcCs:i|_i|_|dur|D] \}}|||qdSdS)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_mappingrWset_config_provider)rarZr[providerrMrMrNrb(s zConfigValueStore.__init__cCs4||jvr |j|S||jvrdS|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)rrproviderar[rrMrMrNget_config_variable7s    z$ConfigValueStore.get_config_variablecC||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)r)rar[rdrMrMrNset_config_variableLsz$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)rpop)rar[rMrMrNclear_config_variablefsz&ConfigValueStore.clear_config_variablecCr)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)rrrMrMrNrosz$ConfigValueStore.set_config_providerry) rzr{r|r}rbrrrrrMrMrMrNr~&s  r~c@seZdZdZddZdS) BaseProviderzBase class for configuration value providers. A configuration provider has some method of providing a configuration value. cCstd)zProvide a config value.r)NotImplementedErrorrarMrMrNrszBaseProvider.provideN)rzr{r|r}rrMrMrMrNrs rc@s2eZdZdZd ddZddZddZd d ZdS) rlzThis 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|durg}||_||_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)rarerVrMrMrNrbs  zChainProvider.__init__cCs.|jD]}|}|dur||SqdS)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)rr _convert_type)rarrdrMrMrNrs zChainProvider.providecCs|jdur ||S|Sry)rrardrMrMrNrs  zChainProvider._convert_typecCsdddd|jDS)Nz[%s]z, cSsg|]}t|qSrM)str).0prMrMrN sz*ChainProvider.__repr__..)joinrrrMrMrN__repr__szChainProvider.__repr__)NN)rzr{r|r}rbrrrrMrMrMrNrls   rlc@(eZdZdZddZddZddZdS) rgz>This class loads config values from the session instance vars.cC||_||_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_varr])rarcrCrMrMrNrbs zInstanceVarProvider.__init__cCs|j}||j}|S)z6Provide a config value from the session instance vars.)r]instance_variablesgetr)ra instance_varsrdrMrMrNrs  zInstanceVarProvider.providecCd|j|jfS)Nz0InstanceVarProvider(instance_var=%s, session=%s)rrrMrMrNrzInstanceVarProvider.__repr__Nrzr{r|r}rbrrrMrMrMrNrgs  rgc@s$eZdZddZddZddZdS)rvcCr)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_namer])rarurCrMrMrNrbs zScopedConfigProvider.__init__cCsP|j}t|jtr"||jd}t|tsdS||jdS||jS)z,Provide a value from a config file property.rNr)r]get_scoped_configrprtuplerdict)ra scoped_configsection_configrMrMrNrs    zScopedConfigProvider.providecCr)Nz4ScopedConfigProvider(config_var_name=%s, session=%s)rrrMrMrNrrzScopedConfigProvider.__repr__N)rzr{r|rbrrrMrMrMrNrvs rvc@r) rrz:This class loads config values from environment variables.cCr)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)rarnrorMrMrNrbs zEnvironmentProvider.__init__cCs|j|jvr |j|jSdS)z0Provide a config value from a source dictionary.NrrrMrMrNrs  zEnvironmentProvider.providecCr)Nz$EnvironmentProvider(name=%s, env=%s)rrrMrMrNr szEnvironmentProvider.__repr__NrrMrMrMrNrrs  rrc@s*eZdZdZd ddZddZddZdS) rHzProvides 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. NcCs:||_||_t|j|j|_||_|jduri|_dSdSry) _section_namer]rv_scoped_config_provider_override_providers)ra section_namerCoverride_providersrMrMrNrbs  zSectionConfigProvider.__init__cCsh|j}|rt|tstd|j|dS|jD]\}}|}|dur1|dur-i}|||<q|S)NzEThe %s config key is not a dictionary type, ignoring its value of: %s) rrrprloggerdebugrrrW)rarsection_config_varr provider_valrMrMrNrs zSectionConfigProvider.providecCsd|j|j|jfS)NzISectionConfigProvider(section_name=%s, session=%s, override_providers=%s))rr]rrrMrMrNr-s zSectionConfigProvider.__repr__ryrrMrMrMrNrHs   rHc@r) rkz(This provider provides a constant value.cCs ||_dSry_valuerrMrMrNrb9 zConstantProvider.__init__cCs|jS)z7Provide the constant value given during initialization.rrrMrMrNr<szConstantProvider.providecCs d|jS)NzConstantProvider(value=%s)rrrMrMrNr@rzConstantProvider.__repr__NrrMrMrMrNrk7s  rk)r}loggingr^botocorer getLoggerrzrintensure_booleanrGrInormalize_booleanrJrOrFobjectrEr~rrlrgrvrrrHrkrMrMrMrNs     !%)-1 3 4 G     m[ -"(