o
    ic                     @   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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"G dd dZ#G dd de$e#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	dJddZ			dKd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dJd&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$dFdG Z%dHdI Z&dS )L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'   S/var/www/html/karishye-ai-python/venv/lib/python3.10/site-packages/botocore/args.py__init__V   s   

zClientArgsCreator.__init__c           &      C   s  |  |||	||||}|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}d| }dtjji} |j|||| d tjj||| d d}!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_configzcreating-serializer.timestamp_precision)protocol_nameservice_modelserializer_kwargs)rA   )
serializerendpointresponse_parserr    request_signerrC   r#   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TIMESTAMP_PRECISION_DEFAULTemitcreate_serializerparserscreate_parser_build_endpoint_resolverr   with_client_configr!   _supplied_user_agentr   r   )&r   rC   r5   	is_securer:   r;   credentialsscoped_configrI   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_creatorrF   
event_namerD   rE   rG   ruleset_resolverclient_ua_creatorsupplied_uar'   r'   r(   get_client_argsj   s   



z!ClientArgsCreator.get_client_argsc                 C   sH  |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d"|j  | !| | "| | #| | $| | %| | &| | '| | (|| | )|| | *|| | |}| +|}|rd|v r|d u ri }d|d#< ||
|||	||| ,||d$S )&NTFr+   )rI   r:   ENDPOINT_OVERRIDE)r*   r5   r:   r\   r_   r/   r0   tagsr5   r8   )r5   r8   r!   	dualstack)use_dualstack_endpointfips)use_fips_endpointrP   rQ   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   auth_scheme_preferencerp   )r*   r+   r3   r,   r-   r.   r/   r2   r'   )-endpoint_prefixresolved_protocolr+   rL   r
   compute_s3_config _compute_configured_endpoint_urlr   _compute_endpoint_configr   rZ   	to_stringdictupdaterP   rQ   r<   r=   r@   rs   r?   rt   ru   rv   rw   rx   ry   rz   r{   r|   r}   r6   r~   _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&_compute_auth_scheme_preference_config!_compute_signature_version_config_is_s3_service_compute_socket_options)r   rC   rI   r_   r5   r:   r\   r^   r*   r-   r+   	raw_valuer/   r3   r,   endpoint_variant_tagspreliminary_ua_stringr.   is_s3_servicer'   r'   r(   rK      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_injectionrt   T)_inject_host_prefixr   get_config_variable)r   rI   r.   (configured_disable_host_prefix_injectionr'   r'   r(   r   d  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   rI   r:   r'   r'   r(   r   w  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   rI   r'   r'   r(   r     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   rM   r   )r   rI   s3_configurationr'   r'   r(   r     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:   r\   r_   r9   r/   stsr'   )_compute_s3_endpoint_config_compute_sts_endpoint_config_resolve_endpoint)r   r*   r5   r:   r\   r_   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   r_   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_CONFIGrR   
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,   r_   rF   r'   r'   r(   r     s   
z3ClientArgsCreator._set_region_if_custom_s3_endpointc                 K   s:   | j di |}| |d |d |r| ||d  |S )Nr5   r:   r\   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   rn   Fr   )rL   "_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   rR   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,   r\   schemer'   r'   r(   r     s   z*ClientArgsCreator._set_global_sts_endpointc                 C   s   | ||||S r   r   )r   r*   r5   r:   r\   r_   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   ru   F)	socketIPPROTO_TCPTCP_NODELAYru   _ensure_booleanrL   append
SOL_SOCKETSO_KEEPALIVE)r   r^   rI   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   9  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 )Nrs   total_max_attemptsmax_attemptsr   )rL   popr   r   )r   r.   rs   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 )Nrs   mode
retry_moder   rL   r   r   )r   r.   rs   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 )NrP   r   )r   r.   rP   r'   r'   r(   r   k  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 )Nrx   ry   )rL   r   r   _validate_min_compression_sizer
   )r   r.   min_sizer   r'   r'   r(   r   x  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typerR   r   InvalidConfigError)r   r   min_allowed_min_sizemax_allowed_min_sizeerror_msg_basemsgr'   r'   r(   r     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/   r_   client_endpoint_urllegacy_endpoint_urlr]   r6   )endpoint_ruleset_datarb   rC   builtinsclient_contextr    use_sslrequested_auth_scheme)	r   r   *compute_endpoint_resolver_builtin_defaultshostrz   r   r   r8   r   )r   ra   rb   rI   rC   rd   r5   r:   rF   r\   r_   r    r]   r6   s3_config_rawservice_name_raweprv2_region_nameresolver_builtinsr   sig_versionr'   r'   r(   rY     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pathrr   )r5   r:   r,   use_arn_regionT$s3_disable_multiregion_access_points
account_id)resolver_uses_builtin_datarL   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/   r_   r   r   r]   r6   given_endpointforce_path_styler'   r'   r(   r     sr   

z<ClientArgsCreator.compute_endpoint_resolver_builtin_defaultsc                 C   sJ   | d}|d u r| jd}|d urt|tkrtdt ||d< d S )Nrw   zVThe configured value for user_agent_appid exceeds the maximum length of %d characters.)rL   r   r   lenUSERAGENT_APPID_MAXLENr   warning)r   r.   rw   r'   r'   r(   r   L  s   
z2ClientArgsCreator._compute_user_agent_appid_configc                 C   s*   | d}|d u r| jd}||d< d S )Nr{   r   )r   r.   r{   r'   r'   r(   r   ]  s   z;ClientArgsCreator._compute_sigv4a_signing_region_set_configc                 C   s$   | j |dtd | j |dtd d S )Nr|   )
config_keyvalid_optionsr}   )_handle_checksum_config)VALID_REQUEST_CHECKSUM_CALCULATION_CONFIG)VALID_RESPONSE_CHECKSUM_VALIDATION_CONFIGr   r'   r'   r(   r   g  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  )
rL   r   r   r   strr   rR   r   InvalidChecksumConfigError%_register_checksum_config_feature_ids)r   r.   r  r  r   r'   r'   r(   r  s  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 )Nr|   FLEXIBLE_CHECKSUMS_REQ_r}   FLEXIBLE_CHECKSUMS_RES_)upperr   )r   r   r  checksum_config_feature_idr'   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   )rL   rR   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_configc                 C   s   d}d}|r|j r|j }d}n| j|}|d u rd ||< d S t|ts6tjj| dt| d| ddd	d	d
 |
dD }|rIt|}|||< d S )Nr~   FTz, must be a comma-delimited string. Received z
 instead: r   r   ,c                 s   s,    | ]}|  r|d dddV  qdS )  	N)stripreplace).0itemr'   r'   r(   	<genexpr>  s    
zKClientArgsCreator._compute_auth_scheme_preference_config.<locals>.<genexpr>)r~   r   r   r   r  rR   r   r   r   joinsplitClientConfigString)r   rI   r.   r  set_in_config_objectr   r'   r'   r(   r     s.   


z8ClientArgsCreator._compute_auth_scheme_preference_configc                 C   s6   |r|j r|j }t|trt||d< d S d S d S d S )Nr8   )r8   r   r  r,  )r   rI   r.   r   r'   r'   r(   r     s   

z3ClientArgsCreator._compute_signature_version_configr   )NNN)'__name__
__module____qualname__r)   rl   rK   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rY   r   r   r   r   r  r  r   r   r   r'   r'   r'   r(   r   U   sR    	

|~

	
 D\
#r   c                   @   s   e Zd ZdZdS )ConfigObjectWrapperz8Base class to mark values set via in-code Config object.N)r.  r/  r0  __doc__r'   r'   r'   r(   r1    s    r1  c                       s   e Zd Zd fdd	Z  ZS )r,  Nc                    s   t  | |S r   )super__new__)clsr   	__class__r'   r(   r4    s   zClientConfigString.__new__r   )r.  r/  r0  r4  __classcell__r'   r'   r6  r(   r,    s    r,  )&r2  rM   loggingr   botocore.exceptionsrR   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   r1  r  r,  r'   r'   r'   r(   <module>   sB   
       