o
    Jh                     @   s   d Z ddlZddlZddlZddlZddlZddlZddlm	Z	 ddl
mZ ddlmZ ddlmZ ddlmZ ddlmZmZ dd	lmZ dd
lmZmZ eeZddgZg dZdZdZdZ dZ!G dd dZ"dS )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)EndpointRulesetResolver)RequestSigner)UserAgentStringregister_feature_id)$PRIORITY_ORDERED_SUPPORTED_PROTOCOLS)ensure_booleanis_s3_accelerate_urllegacyregional)zap-northeast-1z
ap-south-1zap-southeast-1zap-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-22   )when_supportedwhen_required)	preferreddisabledrequiredc                   @   s*  e Zd Z	dFddZ			dGddZdd Zdd	 Zd
d Zdd Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd Zdd Zd d! Zd"d# Zd$d% ZdFd&d'Zd(d) Zd*d+ Zd,d- Zd.d/ Zd0d1 Zd2d3 Zd4d5 Zd6d7 Zd8d9 Zd:d; Zd<d= Z d>d? Z!d@dA Z"dBdC Z#dDdE Z$dS )HClientArgsCreatorNc                 C   s>   || _ || _|| _|| _|| _|d u rt | _d S || _d S N)_event_emitter_response_parser_factory_loader_exceptions_factory_config_storer   from_environment_session_ua_creator)selfevent_emitter
user_agentresponse_parser_factoryloaderexceptions_factoryconfig_storeuser_agent_creator r'   m/var/www/vedio/testing/chatpythonscript.ninositsolution.com/env/lib/python3.10/site-packages/botocore/args.py__init__S   s   

zClientArgsCreator.__init__c           $      C   sz  |  |||	||||}|d }|d }|d }|d }|d }|d }|d dd }|d	 }|d
 }|d }|d }|d }t| j}t|j||d |d |||
}||d< tdi |}t|}|j|||d || j	|j
|j|j|jf||j|jd}tj||}tj|} | ||||||||||	|||}!| j|}"|r|jnd }#|#|_||| |||| j||| j|!|"dS )Nservice_nameparameter_validationendpoint_configprotocolconfig_kwargs	s3_configmetadata	partitionsocket_optionsconfigured_endpoint_urlsigning_regionregion_nameaccount_id_endpoint_modesigning_namesignature_versions3endpoint_url)
r5   r:   verifyr"   max_pool_connectionsproxiestimeoutr2   client_certproxies_config)
serializerendpointresponse_parserr    request_signerservice_modelr#   client_configr1   r$   endpoint_ruleset_resolverr&   r'   )compute_client_argsgetcopyr   r   
service_idr   r   create_endpointr   r<   r=   connect_timeoutread_timeoutr?   r@   botocore	serializecreate_serializerparserscreate_parser_build_endpoint_resolverr   with_client_configr!   _supplied_user_agentr   r   )$r   rE   r5   	is_securer:   r;   credentialsscoped_configrF   endpoint_bridge
auth_tokenendpoints_ruleset_datapartition_data
final_argsr*   r+   r,   r-   r.   r/   r1   r2   r3   r4   endpoint_region_namer6   r    signer
new_configendpoint_creatorrB   rA   rC   ruleset_resolverclient_ua_creatorsupplied_uar'   r'   r(   get_client_argsg   s   


z!ClientArgsCreator.get_client_argsc                 C   s(  |j }|j}	d}
|r|jsd}
n|r|d}|d urt|}
| |}| j||d}|d ur3td | j||||||d}|d dg }| j	
| }t|d	 |d
 |d}d|v rc|jdd d|v rm|jdd |d ur|jd$i d|jd|jd|jd|jd|jd|jd|jd|jd|jd|jd|jd|jd|jd|jd|jd|jd |jd!|j |  | | !| | "| | #| | $| | %| | &| | '|| | |}| (|}|rd|v r|d u ri }d|d"< ||
|||	||| )||d#S )%NTFr+   )rF   r:   ENDPOINT_OVERRIDE)r*   r5   r:   rW   rZ   r/   r0   tagsr5   r8   )r5   r8   r!   	dualstack)use_dualstack_endpointfips)use_fips_endpointrM   rN   r<   r=   r@   retriesr?   inject_host_prefixtcp_keepaliveuser_agent_extrauser_agent_appid"request_min_compression_size_bytesdisable_request_compressionclient_context_paramssigv4a_signing_region_setrequest_checksum_calculationresponse_checksum_validationr6   rj   )r*   r+   r3   r,   r-   r.   r/   r2   r'   )*endpoint_prefixresolved_protocolr+   rI   r
   compute_s3_config _compute_configured_endpoint_urlr   _compute_endpoint_configr   rU   	to_stringdictupdaterM   rN   r<   r=   r@   rm   r?   rn   ro   rp   rq   rr   rs   rt   ru   rv   rw   r6   _compute_retry_config_compute_connect_timeout _compute_user_agent_appid_config#_compute_request_compression_config)_compute_sigv4a_signing_region_set_config_compute_checksum_config(_compute_account_id_endpoint_mode_config_compute_inject_host_prefix_is_s3_service_compute_socket_options)r   rE   rF   rZ   r5   r:   rW   rY   r*   r-   r+   	raw_valuer/   r3   r,   endpoint_variant_tagspreliminary_ua_stringr.   is_s3_servicer'   r'   r(   rH      s   




	










z%ClientArgsCreator.compute_client_argsc                 C   sD   |d u s	|j dkr | jd}|d ur| |d< d S d|d< d S d S )NUNSETdisable_host_prefix_injectionrn   T)_inject_host_prefixr   get_config_variable)r   rF   r.   (configured_disable_host_prefix_injectionr'   r'   r(   r   N  s   
z-ClientArgsCreator._compute_inject_host_prefixc                 C   s0   |d ur|S |  |rtd |S | jdS )Nz"Ignoring configured endpoint URLs.r:   ) _ignore_configured_endpoint_urlsloggerdebugr   r   )r   rF   r:   r'   r'   r(   r{   a  s   

z2ClientArgsCreator._compute_configured_endpoint_urlc                 C   s    |r
|j d ur
|j S | jdS )Nignore_configured_endpoint_urls)r   r   r   )r   rF   r'   r'   r(   r   k  s   
z2ClientArgsCreator._ignore_configured_endpoint_urlsc                 C   sH   | j d}|d ur"|jd ur"|d u r|j}|S | }||j |S )Nr9   )r   r   r9   rJ   r   )r   rF   s3_configurationr'   r'   r(   rz   v  s   
	z#ClientArgsCreator.compute_s3_configc                 C   s   |dv S )a,  Whether the service is S3 or S3 Control.

        Note that throughout this class, service_name refers to the endpoint
        prefix, not the folder name of the service in botocore/data. For
        S3 Control, the folder name is 's3control' but the endpoint prefix is
        's3-control'.
        )r9   z
s3-controlr'   )r   r*   r'   r'   r(   r     s   z ClientArgsCreator._is_s3_servicec                 C   sT   |||||d}|dkr| j dd|i|S |dkr"| jdi |S | jdi |S )N)r*   r5   r:   rW   rZ   r9   r/   stsr'   )_compute_s3_endpoint_config_compute_sts_endpoint_config_resolve_endpoint)r   r*   r5   r:   rW   rZ   r/   resolve_endpoint_kwargsr'   r'   r(   r|     s   
z*ClientArgsCreator._compute_endpoint_configc                 K   sX   |  |d |}|rd |d< | jdi |}| ||d  |r*|d dkr*d|d< |S )Nr5   rZ   r   r   r'   )_should_force_s3_globalr   !_set_region_if_custom_s3_endpoint)r   r/   r   force_s3_globalr,   r'   r'   r(   r     s   z-ClientArgsCreator._compute_s3_endpoint_configc                 C   s6   d}|rd|v r|d }|  | |dv }|dko|S )Nr   us_east_1_regional_endpoint)r   N)_validate_s3_regional_config)r   r5   r/   s3_regional_configis_global_regionr'   r'   r(   r     s   
z)ClientArgsCreator._should_force_s3_globalc                 C   s   |t vrtjj|dd S )N)%s3_us_east_1_regional_endpoint_config)VALID_REGIONAL_ENDPOINTS_CONFIGrO   
exceptions+InvalidS3UsEast1RegionalEndpointConfigError)r   
config_valr'   r'   r(   r     s
   z.ClientArgsCreator._validate_s3_regional_configc                 C   sF   |d d u r|d d u r!| d}|d |d< |d |d< d S d S d S )Nr4   r5   r9   resolve)r   r,   rZ   rB   r'   r'   r(   r     s   
z3ClientArgsCreator._set_region_if_custom_s3_endpointc                 K   s:   | j di |}| |d |d |r| ||d  |S )Nr5   r:   rW   r'   )r   _should_set_global_sts_endpoint_set_global_sts_endpoint)r   r   r,   r'   r'   r(   r     s   z.ClientArgsCreator._compute_sts_endpoint_configc                 C   s6   |o
| di  d}|s|rdS |  dko|tv S )Nr0   rh   Fr   )rI   "_get_sts_regional_endpoints_configLEGACY_GLOBAL_STS_REGIONS)r   r5   r:   r,   has_variant_tagsr'   r'   r(   r     s   z1ClientArgsCreator._should_set_global_sts_endpointc                 C   s.   | j d}|s
d}|tvrtjj|d|S )Nsts_regional_endpointsr   )sts_regional_endpoints_config)r   r   r   rO   r   &InvalidSTSRegionalEndpointsConfigError)r   r   r'   r'   r(   r     s   z4ClientArgsCreator._get_sts_regional_endpoints_configc                 C   s&   |rdnd}| d|d< d|d< d S )Nhttpshttpz://sts.amazonaws.comr:   r   r4   r'   )r   r,   rW   schemer'   r'   r(   r     s   z*ClientArgsCreator._set_global_sts_endpointc                 C   s   | ||||S r   r   )r   r*   r5   r:   rW   rZ   r'   r'   r(   r   
  s   z#ClientArgsCreator._resolve_endpointc                 C   sP   t jt jdfg}|o|j}|o| |dd}|s|r&|t jt jdf |S )N   ro   F)	socketIPPROTO_TCPTCP_NODELAYro   _ensure_booleanrI   append
SOL_SOCKETSO_KEEPALIVE)r   rY   rF   r2   client_keepalivescoped_keepaliver'   r'   r(   r     s   

z)ClientArgsCreator._compute_socket_optionsc                 C   s   |  | | | d S r   )_compute_retry_max_attempts_compute_retry_moder   r.   r'   r'   r(   r   #  s   
z'ClientArgsCreator._compute_retry_configc                 C   s   | d}|d ur&d|v r|dd  d S d|v r&|d}|d |d< d S | jd}|d ur@|d u r:i }||d< ||d< d S d S )Nrm   total_max_attemptsmax_attemptsr   )rI   popr   r   )r   r.   rm   valuer   r'   r'   r(   r   '  s    


z-ClientArgsCreator._compute_retry_max_attemptsc                 C   sP   | d}|d u ri }||d< nd|v rd S | jd}|d u r"d}||d< d S )Nrm   mode
retry_moder   rI   r   r   )r   r.   rm   r   r'   r'   r(   r   G  s   

z%ClientArgsCreator._compute_retry_modec                 C   s6   | d}|d urd S | jd}|r||d< d S d S )NrM   r   )r   r.   rM   r'   r'   r(   r   U  s   
z*ClientArgsCreator._compute_connect_timeoutc                 C   sd   | d}| d}|d u r| jd}| |}||d< |d u r(| jd}nt|}||d< d S )Nrr   rs   )rI   r   r   _validate_min_compression_sizer
   )r   r.   min_sizer   r'   r'   r(   r   b  s   


z5ClientArgsCreator._compute_request_compression_configc              	   C   s   d}d}d| d}zt |}W n ttfy*   | dt| d}tjj|dw ||  kr5|ksHn | d| d	| d
}tjj|d|S )Nr   i   zInvalid value "z)" for request_min_compression_size_bytes.z$ Value must be an integer. Received z	 instead.	error_msgz Value must be between z and .)int
ValueError	TypeErrortyperO   r   InvalidConfigError)r   r   min_allowed_min_sizemax_allowed_min_sizeerror_msg_basemsgr'   r'   r(   r   x  s,   
z0ClientArgsCreator._validate_min_compression_sizec                 C   s   t |tr|S | dkS )Ntrue)
isinstanceboollower)r   valr'   r'   r(   r     s   
z!ClientArgsCreator._ensure_booleanc              
   C   s   |d u rd S |  |pi }|j}|dv s|d u r|}n|}| j||||
||j||d}|d ur5|jp3i }ni }| |rA|| |d urH|jnd }t|||||||	|dS )N)r9   r   )r5   r*   r/   rZ   client_endpoint_urllegacy_endpoint_urlrX   r6   )endpoint_ruleset_datar]   rE   builtinsclient_contextr    use_sslrequested_auth_scheme)	rz   rx   *compute_endpoint_resolver_builtin_defaultshostrt   r   r   r8   r   )r   r\   r]   rF   rE   r_   r5   r:   rB   rW   rZ   r    rX   r6   s3_config_rawservice_name_raweprv2_region_nameresolver_builtinsr   sig_versionr'   r'   r(   rT     sH   

z*ClientArgsCreator._build_endpoint_resolverc	                 C   s  |r|}	n	|  s|}	nd }	|ddrd}
n|d ur't|s'|ddk}
n|ddk}
tj|tj|	d u r<|dp=dtj|	d u rH||pIdtj	| j
|d d dtj| ||tj|ddtj|
tj|dd	tj|ddtj|d
dtj|	tj|r|dnd tj|iS )Nuse_accelerate_endpointFaddressing_stylevirtualpathrl   )r5   r:   r,   use_arn_regionT$s3_disable_multiregion_access_points
account_id)resolver_uses_builtin_datarI   r   EPRBuiltins
AWS_REGIONAWS_USE_FIPS$_resolve_endpoint_variant_config_varAWS_USE_DUALSTACK_resolve_use_dualstack_endpointAWS_STS_USE_GLOBAL_ENDPOINTr   AWS_S3_USE_GLOBAL_ENDPOINTr   AWS_S3_ACCELERATEAWS_S3_FORCE_PATH_STYLEAWS_S3_USE_ARN_REGIONAWS_S3CONTROL_USE_ARN_REGIONAWS_S3_DISABLE_MRAPSDK_ENDPOINT
ACCOUNT_IDget_deferred_propertyACCOUNT_ID_ENDPOINT_MODE)r   r5   r*   r/   rZ   r   r   rX   r6   given_endpointforce_path_styler'   r'   r(   r     sr   

z<ClientArgsCreator.compute_endpoint_resolver_builtin_defaultsc                 C   sP   | d}|d u r| jd}|d ur"t|tkr"tdt d ||d< d S )Nrq   zHThe configured value for user_agent_appid exceeds the maximum length of z characters.)rI   r   r   lenUSERAGENT_APPID_MAXLENr   warning)r   r.   rq   r'   r'   r(   r   6  s   
z2ClientArgsCreator._compute_user_agent_appid_configc                 C   s*   | d}|d u r| jd}||d< d S )Nru   r   )r   r.   ru   r'   r'   r(   r   F  s   z;ClientArgsCreator._compute_sigv4a_signing_region_set_configc                 C   s$   | j |dtd | j |dtd d S )Nrv   )
config_keyvalid_optionsrw   )_handle_checksum_config)VALID_REQUEST_CHECKSUM_CALCULATION_CONFIG)VALID_RESPONSE_CHECKSUM_VALIDATION_CONFIGr   r'   r'   r(   r   P  s   
z*ClientArgsCreator._compute_checksum_configc                 C   sb   | |}|d u r| j|}t|tr| }||vr%tjj|||d| 	|| |||< d S )N)r	  config_valuer
  )
rI   r   r   r   strr   rO   r   InvalidChecksumConfigError%_register_checksum_config_feature_ids)r   r.   r	  r
  r   r'   r'   r(   r  \  s   

z)ClientArgsCreator._handle_checksum_configc                 C   sJ   d }|dkrd|   }n|dkrd|   }|d ur#t| d S d S )Nrv   FLEXIBLE_CHECKSUMS_REQ_rw   FLEXIBLE_CHECKSUMS_RES_)upperr   )r   r   r	  checksum_config_feature_idr'   r'   r(   r  r  s   z7ClientArgsCreator._register_checksum_config_feature_idsc                 C   s   d}| d}|tju rd||< d S | |}|d u r!| j|}t|tr*| }|tvr?tj	j
d| d| dt dd|||< d S )	Nr6   r8   r   zThe configured value 'z' for 'z ' is invalid. Valid values are: r   r   )rI   rO   UNSIGNEDr   r   r   r  r   %VALID_ACCOUNT_ID_ENDPOINT_MODE_CONFIGr   r   )r   r.   r	  r8   r6   r'   r'   r(   r     s*   



z:ClientArgsCreator._compute_account_id_endpoint_mode_configr   )NNN)%__name__
__module____qualname__r)   rf   rH   r   r{   r   rz   r   r|   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rT   r   r   r   r   r  r  r   r'   r'   r'   r(   r   R   sN    	

ny

	
 D\
r   )#__doc__rJ   loggingr   botocore.exceptionsrO   botocore.parsersbotocore.serializebotocore.configr   botocore.endpointr   botocore.regionsr   r   r   botocore.signersr   botocore.useragentr   r   botocore.utilsr	   r
   r   	getLoggerr  r   r   r   r  r  r  r  r   r'   r'   r'   r(   <module>   s2   
