o ?c6Q@sdZddlZddlZddlZddlZddlZddlZddlZddl m Z ddl m Z ddl mZddlmZeeZddgZgd ZGd d d ZdS) 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)Config)EndpointCreator)EndpointResolverBuiltins) RequestSignerlegacyZregional)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@seZdZddZ d,ddZddZdd Zd d Zd d ZddZ ddZ ddZ ddZ ddZ ddZddZddZd,ddZd d!Zd"d#Zd$d%Zd&d'Zd(d)Zd*d+ZdS)-ClientArgsCreatorcCs(||_||_||_||_||_||_dSN)_event_emitter _user_agent_response_parser_factory_loader_exceptions_factory _config_store)self event_emitter user_agentresponse_parser_factoryloaderexceptions_factoryZ config_storerh/private/var/folders/cw/wlscbxl13mj6wd668h7l9g9sllkg5j/T/pip-target-b31awkwq/lib/python/botocore/args.py__init__<s   zClientArgsCreator.__init__Nc  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_nameZ signing_namesignature_versions3 endpoint_url) r$r'verifyrmax_pool_connectionsproxiestimeoutr" client_certproxies_config) serializerendpointresponse_parserrZrequest_signer service_modelr client_configr!rr)compute_client_argsgetcopyr rZ service_idrrZcreate_endpointr r)r*connect_timeout read_timeoutr,r-botocore serializeZcreate_serializerparsersZ create_parserrr)rr1r$ is_securer'r( credentials scoped_configr2endpoint_bridgeZ auth_tokenZ final_argsrrrrrrr!r"r#Zendpoint_region_namerZsignerZ new_configZendpoint_creatorr/r.r0rrrget_client_argsLsx      z!ClientArgsCreator.get_client_argsc Cs|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|j|jd ||||| |} |dv}|rd |vr| duri} d| d<|| | || || |||dS)NrTFrz %s)rr$r'r;r>rr tagsr$r%)r$r%rZ dualstack)use_dualstack_endpointZfips)use_fips_endpoint) r6r7r)r*r-retriesr,inject_host_prefix tcp_keepalive)r&z s3-controlrA)rrrrrrrr")Zendpoint_prefixr rr4r8utilsZensure_booleanr rZuser_agent_extracompute_s3_config_compute_endpoint_configdictupdater6r7r)r*r-rCr,rDrE_compute_retry_config_compute_connect_timeout_compute_socket_options)rr1r2r>r$r'r;r=rrrZ raw_valuerrrZendpoint_variant_tagsrZ is_s3_servicerrrr3s            z%ClientArgsCreator.compute_client_argscCsH|jd}|dur"|jdur"|dur|j}|S|}||j|S)Nr&)rget_config_variabler&r5rJ)rr2Zs3_configurationrrrrGs    z#ClientArgsCreator.compute_s3_configcCsT|||||d}|dkr|jdd|i|S|dkr"|jdi|S|jdi|S)N)rr$r'r;r>r&rstsr)_compute_s3_endpoint_config_compute_sts_endpoint_config_resolve_endpoint)rrr$r'r;r>rresolve_endpoint_kwargsrrrrHs z*ClientArgsCreator._compute_endpoint_configcKsX||d|}|rd|d<|jdi|}|||d|r*|ddkr*d|d<|S)Nr$r>rrr)_should_force_s3_globalrR!_set_region_if_custom_s3_endpoint)rrrSZforce_s3_globalrrrrrPsz-ClientArgsCreator._compute_s3_endpoint_configcCs6d}|rd|vr|d}|||dv}|dko|S)NrZus_east_1_regional_endpoint)rN)_validate_s3_regional_config)rr$rZs3_regional_configZis_global_regionrrrrT3s    z)ClientArgsCreator._should_force_s3_globalcCs|tvr tjj|ddS)N)Z%s3_us_east_1_regional_endpoint_config)VALID_REGIONAL_ENDPOINTS_CONFIGr8 exceptionsZ+InvalidS3UsEast1RegionalEndpointConfigError)rZ config_valrrrrV<s z.ClientArgsCreator._validate_s3_regional_configcCsF|ddur|ddur!|d}|d|d<|d|d<dSdSdS)Nr#r$r&resolve)rrr>r/rrrrUBs    z3ClientArgsCreator._set_region_if_custom_s3_endpointcKs:|jdi|}||d|d|r|||d|S)Nr$r'r;r)rR_should_set_global_sts_endpoint_set_global_sts_endpoint)rrSrrrrrQPsz.ClientArgsCreator._compute_sts_endpoint_configcCs6|o |did}|s|rdS|dko|tvS)Nr r@Fr)r4"_get_sts_regional_endpoints_configLEGACY_GLOBAL_STS_REGIONS)rr$r'rZhas_variant_tagsrrrr[\s z1ClientArgsCreator._should_set_global_sts_endpointcCs.|jd}|s d}|tvrtjj|d|S)NZsts_regional_endpointsr)sts_regional_endpoints_config)rrNrWr8rXZ&InvalidSTSRegionalEndpointsConfigError)rr_rrrr]isz4ClientArgsCreator._get_sts_regional_endpoints_configcCs$|rdnd}d||d<d|d<dS)Nhttpshttpz%s://sts.amazonaws.comr'rr#r)rrr;schemerrrr\xs   z*ClientArgsCreator._set_global_sts_endpointcCs|||||Sr rY)rrr$r'r;r>rrrrR}sz#ClientArgsCreator._resolve_endpointcCsPtjtjdfg}|o |j}|o||dd}|s|r&|tjtjdf|S)NrEF) socket IPPROTO_TCP TCP_NODELAYrE_ensure_booleanr4append SOL_SOCKET SO_KEEPALIVE)rr=r2r"Zclient_keepaliveZscoped_keepaliverrrrMs  z)ClientArgsCreator._compute_socket_optionscCs||||dSr )_compute_retry_max_attempts_compute_retry_mode)rrrrrrKs z'ClientArgsCreator._compute_retry_configcCs|d}|dur&d|vr|dddSd|vr&|d}|d|d<dS|jd}|dur@|dur:i}||d<||d<dSdS)NrCZtotal_max_attempts max_attemptsrc)r4poprrN)rrrCvaluermrrrrks      z-ClientArgsCreator._compute_retry_max_attemptscCsP|d}|duri}||d<nd|vrdS|jd}|dur"d}||d<dS)NrCmode retry_moderr4rrN)rrrCrqrrrrls    z%ClientArgsCreator._compute_retry_modecCs6|d}|dur dS|jd}|r||d<dSdS)Nr6rr)rrr6rrrrLs  z*ClientArgsCreator._compute_connect_timeoutcCst|tr|S|dkS)Ntrue) isinstanceboollower)rvalrrrrgs  z!ClientArgsCreator._ensure_booleancCs|r|}n |jjs |}nd}tj|tj|dpdtj||p!dtj|j |dddtj | ||tj | ddtj| ddktj| ddtj| ddtj| d dtj|i S) NrBF)r$r'rZuse_accelerate_endpointZaddressing_stylepathZuse_arn_regionTZ$s3_disable_multiregion_access_points)Zendpoint_resolverZuses_builtin_data EPRBuiltinsZ AWS_REGIONZ AWS_USE_FIPSZ$_resolve_endpoint_variant_config_varZAWS_USE_DUALSTACKZ_resolve_use_dualstack_endpointZAWS_STS_USE_GLOBAL_ENDPOINTr[ZAWS_S3_USE_GLOBAL_ENDPOINTrTZAWS_S3_ACCELERATEr4ZAWS_S3_FORCE_PATH_STYLEZAWS_S3_USE_ARN_REGIONZAWS_S3CONTROL_USE_ARN_REGIONZAWS_S3_DISABLE_MRAPZ SDK_ENDPOINT)rr$rrr>Zclient_endpoint_urlZlegacy_endpoint_urlZgiven_endpointrrr*compute_endpoint_resolver_builtin_defaultssL    zs$