o
    tBhE                     @   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Zddl	m
Z
 ddlmZ ddlmZ eeZddgZg 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)RequestSigner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-2c                   @   s   e Z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d!d" Zd#d$ Zd%d& Zd'd( Zd)S )*ClientArgsCreatorc                 C   s(   || _ || _|| _|| _|| _|| _d S N)_event_emitter_user_agent_response_parser_factory_loader_exceptions_factory_config_store)selfevent_emitter
user_agentresponse_parser_factoryloaderexceptions_factoryconfig_store r   d/var/www/html/riverr-enterprise-integrations-main/venv/lib/python3.10/site-packages/botocore/args.py__init__;   s   	
zClientArgsCreator.__init__c
                 C   s"  |  |||	||||}
|
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||| jd
S )Nservice_nameparameter_validationendpoint_configprotocolconfig_kwargs	s3_configmetadata	partitionsocket_optionssigning_regionregion_namesigning_namesignature_versions3endpoint_url)
r%   r)   verifyr   max_pool_connectionsproxiestimeoutr#   client_certproxies_config)

serializerendpointresponse_parserr   request_signerservice_modelr   client_configr"   r   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_parserr   r   )r   r4   r%   	is_securer)   r*   credentialsscoped_configr5   endpoint_bridge
final_argsr   r   r   r   r   r    r"   r#   r$   endpoint_region_namer   signer
new_configendpoint_creatorr1   r0   r2   r   r   r   get_client_argsK   sv   
	
z!ClientArgsCreator.get_client_argsc              
   C   s~  |j }|jd }	d}
|r|jsd}
n|r#|d}|d ur#tj|}
| j}|d ur>|jd ur2|j}|j	d ur>|d|j	 7 }| 
|}| j||||||d}|d dg }t|d	 |d
 |d}d|v rk|jdd d|v ru|jdd |d ur|j|j|j|j|j|j|j|j|jd | | | | | 
|}|dv }|rd|v r|d u ri }d|d< ||
|||	||| |dS )Nr   TFr   z %s)r   r%   r)   rB   rE   r    r!   tagsr%   r'   )r%   r'   r   	dualstack)use_dualstack_endpointfips)use_fips_endpoint)r;   r<   r+   r,   r/   retriesr.   inject_host_prefix)r(   z
s3-controlrN   )r   r   r   r   r   r   r    r#   )endpoint_prefixr!   r   r7   r=   utilsensure_booleanr   r   user_agent_extracompute_s3_config_compute_endpoint_configdictupdater;   r<   r+   r,   r/   rQ   r.   rR   _compute_retry_config_compute_connect_timeout_compute_socket_options)r   r4   r5   rE   r%   r)   rB   rD   r   r   r   	raw_valuer   r    r   endpoint_variant_tagsr   is_s3_servicer   r   r   r6      s|   










z%ClientArgsCreator.compute_client_argsc                 C   sH   | j d}|d ur"|jd ur"|d u r|j}|S | }||j |S )Nr(   )r   get_config_variabler(   r8   rZ   )r   r5   s3_configurationr   r   r   rW      s   
	z#ClientArgsCreator.compute_s3_configc                 C   sT   |||||d}|dkr| j dd|i|S |dkr"| jdi |S | jdi |S )N)r   r%   r)   rB   rE   r(   r    stsr   )_compute_s3_endpoint_config_compute_sts_endpoint_config_resolve_endpoint)r   r   r%   r)   rB   rE   r    resolve_endpoint_kwargsr   r   r   rX      s   
z*ClientArgsCreator._compute_endpoint_configc                 K   sX   |  |d |}|rd |d< | jdi |}| ||d  |r*|d dkr*d|d< |S )Nr%   rE   r   r   r   )_should_force_s3_globalrf   !_set_region_if_custom_s3_endpoint)r   r    rg   force_s3_globalr   r   r   r   rd     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   r%   r    s3_regional_configis_global_regionr   r   r   rh   -  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_CONFIGr=   
exceptions+InvalidS3UsEast1RegionalEndpointConfigError)r   
config_valr   r   r   rl   6  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 )Nr$   r%   r(   resolve)r   r   rE   r1   r   r   r   ri   <  s   
z3ClientArgsCreator._set_region_if_custom_s3_endpointc                 K   s:   | j di |}| |d |d |r| ||d  |S )Nr%   r)   rB   r   )rf   _should_set_global_sts_endpoint_set_global_sts_endpoint)r   rg   r   r   r   r   re   J  s   z.ClientArgsCreator._compute_sts_endpoint_configc                 C   s.   |d  d}|s|rdS |  dko|tv S )Nr!   rL   Fr   )r7   "_get_sts_regional_endpoints_configLEGACY_GLOBAL_STS_REGIONS)r   r%   r)   r   r_   r   r   r   rv   V  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   ra   rp   r=   rq   &InvalidSTSRegionalEndpointsConfigError)r   r{   r   r   r   rx   a  s   z4ClientArgsCreator._get_sts_regional_endpoints_configc                 C   s$   |rdnd}d| |d< d|d< d S )Nhttpshttpz%s://sts.amazonaws.comr)   r   r$   r   )r   r   rB   schemer   r   r   rw   p  s   z*ClientArgsCreator._set_global_sts_endpointc                 C   s   | ||||S r
   rt   )r   r   r%   r)   rB   rE   r   r   r   rf   u  s   z#ClientArgsCreator._resolve_endpointc                 C   s>   t jt jdfg}|r| |ddr|t jt jdf |S )N   tcp_keepaliveF)socketIPPROTO_TCPTCP_NODELAY_ensure_booleanr7   append
SOL_SOCKETSO_KEEPALIVE)r   rD   r#   r   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 )NrQ   total_max_attemptsmax_attemptsr   )r7   popr   ra   )r   r   rQ   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 )NrQ   mode
retry_moder   r7   r   ra   )r   r   rQ   r   r   r   r   r     s   

z%ClientArgsCreator._compute_retry_modec                 C   s6   | d}|d urd S | jd}|r||d< d S d S )Nr;   r   )r   r   r;   r   r   r   r\     s   
z*ClientArgsCreator._compute_connect_timeoutc                 C   s   t |tr|S | dkS )Ntrue)
isinstanceboollower)r   valr   r   r   r     s   
z!ClientArgsCreator._ensure_booleanN)__name__
__module____qualname__r   rK   r6   rW   rX   rd   rh   rl   ri   re   rv   rx   rw   rf   r]   r[   r   r   r\   r   r   r   r   r   r	   :   s*    OS	 r	   )__doc__r8   loggingr   botocore.exceptionsr=   botocore.parsersbotocore.serializebotocore.utilsbotocore.configr   botocore.endpointr   botocore.signersr   	getLoggerr   loggerrp   ry   r	   r   r   r   r   <module>   s"   
