o <&a!B@sdZddlZddlZddlZddlZddlZddlZddlm Z ddl m Z ddl m Z eeZddgZgdZGd d d eZdS) zInternal module to help with normalizing botocore client args. This module (and all function/classes within this module) should be considered internal, and *not* a public API. N) RequestSigner)Config)EndpointCreatorlegacyregional)zap-northeast-1z ap-south-1zap-southeast-1zap-southeast-2 aws-globalz ca-central-1z eu-central-1z eu-north-1z eu-west-1z eu-west-2z eu-west-3z sa-east-1 us-east-1z us-east-2z us-west-1z us-west-2c@seZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'S)(ClientArgsCreatorcCs(||_||_||_||_||_||_dSN)_event_emitter _user_agent_response_parser_factory_loader_exceptions_factory _config_store)self event_emitter user_agentresponse_parser_factoryloaderexceptions_factory config_storer//usr/lib/python3/dist-packages/botocore/args.py__init__;s  zClientArgsCreator.__init__c  Cs"|||| ||||} | d} | d} | d} | d}| d}| d}| ddd}| d }| d }| d }t|j}t|j|| d | d ||}||d<tdi|}t|}|j||| d||j |j |j |j |j f||j|jd }tj|| }tj|}|||||||j|||jd S)N service_nameparameter_validationendpoint_configprotocol config_kwargs s3_configmetadata partitionsocket_optionssigning_region region_name signing_namesignature_versions3 endpoint_url) r%r)verifyrmax_pool_connectionsproxiestimeoutr# client_certproxies_config) serializerendpointresponse_parserrrequest_signer service_modelr client_configr"rr)compute_client_argsgetcopyr r service_idrrcreate_endpointr r+r,connect_timeout read_timeoutr.r/botocore serializecreate_serializerparsers create_parserrr)rr4r% is_securer)r* credentials scoped_configr5endpoint_bridge final_argsrrrrrr r"r#r$endpoint_region_namersigner new_configendpoint_creatorr1r0r2rrrget_client_argsDsd    z!ClientArgsCreator.get_client_argsc Cst|j}|jd} d} |r|jsd} n|r#|d} | dur#tj| } |j} |dur>|jdur2|j} |j dur>| d|j 7} | |} |j |||||| d}|ddg}t |d |d | d }d |vrk|j dd d|vru|j dd|dur|j |j|j|j|j|j|j|j|jd||| |} |dv}|rd |vr| duri} d| d<|| | || || ||dS)NrTFrz %s)rr%r)rBrEr r!tagsr%r')r%r'r dualstack)use_dualstack_endpointfips)use_fips_endpoint)r;r<r+r,r/retriesr.inject_host_prefix)r(z s3-controlrN)rrrrrrr r#)endpoint_prefixr!rr7r=utilsensure_booleanr ruser_agent_extracompute_s3_config_compute_endpoint_configdictupdater;r<r+r,r/rQr.rR_compute_retry_config_compute_socket_options)rr4r5rEr%r)rBrDrrr raw_valuerr rendpoint_variant_tagsr is_s3_servicerrrr6~sz           z%ClientArgsCreator.compute_client_argscCsH|jd}|dur"|jdur"|dur|j}|S|}||j|S)Nr()rget_config_variabler(r8rZ)rr5s3_configurationrrrrWs    z#ClientArgsCreator.compute_s3_configcCsT|||||d}|dkr|jdd|i|S|dkr"|jdi|S|jdi|S)N)rr%r)rBrEr(r stsr)_compute_s3_endpoint_config_compute_sts_endpoint_config_resolve_endpoint)rrr%r)rBrEr resolve_endpoint_kwargsrrrrXsz*ClientArgsCreator._compute_endpoint_configcKsX||d|}|rd|d<|jdi|}|||d|r*|ddkr*d|d<|S)Nr%rErrr)_should_force_s3_globalre!_set_region_if_custom_s3_endpoint)rr rfforce_s3_globalrrrrrcsz-ClientArgsCreator._compute_s3_endpoint_configcCs2d}|rd|vr|d}|||dko|dvS)Nrus_east_1_regional_endpoint)rN)_validate_s3_regional_config)rr%r s3_regional_configrrrrgs  z)ClientArgsCreator._should_force_s3_globalcCs|tvr tjj|ddS)N)%s3_us_east_1_regional_endpoint_config)VALID_REGIONAL_ENDPOINTS_CONFIGr= exceptions+InvalidS3UsEast1RegionalEndpointConfigError)r config_valrrrrks z.ClientArgsCreator._validate_s3_regional_configcCsF|ddur|ddur!|d}|d|d<|d|d<dSdSdS)Nr$r%r(resolve)rrrEr1rrrrh s    z3ClientArgsCreator._set_region_if_custom_s3_endpointcKs:|jdi|}||d|d|r|||d|S)Nr%r)rBr)re_should_set_global_sts_endpoint_set_global_sts_endpoint)rrfrrrrrdsz.ClientArgsCreator._compute_sts_endpoint_configcCs.|dd}|s |r dS|dko|tvS)Nr!rLFr)r7"_get_sts_regional_endpoints_configLEGACY_GLOBAL_STS_REGIONS)rr%r)rr^rrrrt#s  z1ClientArgsCreator._should_set_global_sts_endpointcCs.|jd}|s d}|tvrtjj|d|S)Nsts_regional_endpointsr)sts_regional_endpoints_config)rr`rnr=ro&InvalidSTSRegionalEndpointsConfigError)rryrrrrv-sz4ClientArgsCreator._get_sts_regional_endpoints_configcCs$|rdnd}d||d<d|d<dS)Nhttpshttpz%s://sts.amazonaws.comr)rr$r)rrrBschemerrrru8s   z*ClientArgsCreator._set_global_sts_endpointcCs|||||Sr rr)rrr%r)rBrErrrre=sz#ClientArgsCreator._resolve_endpointcCs>tjtjdfg}|r||ddr|tjtjdf|S)N tcp_keepaliveF)socket IPPROTO_TCP TCP_NODELAY_ensure_booleanr7append SOL_SOCKET SO_KEEPALIVE)rrDr#rrrr\Bs z)ClientArgsCreator._compute_socket_optionscCs||||dSr )_compute_retry_max_attempts_compute_retry_mode)rrrrrr[Ms z'ClientArgsCreator._compute_retry_configcCs|d}|dur&d|vr|dddSd|vr&|d}|d|d<dS|jd}|dur@|dur:i}||d<||d<dSdS)NrQtotal_max_attempts max_attemptsr~)r7poprr`)rrrQvaluerrrrrQs      z-ClientArgsCreator._compute_retry_max_attemptscCsP|d}|duri}||d<nd|vrdS|jd}|dur"d}||d<dS)NrQmode retry_moder)r7rr`)rrrQrrrrrqs    z%ClientArgsCreator._compute_retry_modecCst|tr|S|dkS)Ntrue) isinstanceboollower)rvalrrrrs  z!ClientArgsCreator._ensure_booleanN)__name__ __module__ __qualname__rrKr6rWrXrcrgrkrhrdrtrvrurer\r[rrrrrrrr :s( :J       r )__doc__r8loggingrbotocore.exceptionsr=botocore.serializebotocore.utilsbotocore.signersrbotocore.configrbotocore.endpointr getLoggerrloggerrnrwobjectr rrrrs