HEX
Server: Apache
System: Linux pdx1-shared-a1-38 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64
User: mmickelson (3396398)
PHP: 8.1.31
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/botocore/__pycache__/discovery.cpython-310.pyc
o

.&�a+�@s�ddlZddlZddlZddlmZddlmZmZmZddl	m
Z
ddlmZe�
e�ZGdd�de�ZGdd	�d	e�ZGd
d�de�Zdd
�ZGdd�de�ZGdd�de�ZGdd�de�ZdS)�N)�
xform_name)�
BotoCoreError�HTTPClientError�ConnectionError)�OperationNotFoundError)�CachedPropertyc@seZdZdS)�EndpointDiscoveryExceptionN)�__name__�
__module__�__qualname__�rr�4/usr/lib/python3/dist-packages/botocore/discovery.pyrsrc@�eZdZdZdZdS)�EndpointDiscoveryRequiredzD Endpoint Discovery is disabled but is required for this operation. zAEndpoint Discovery is not enabled but this operation requires it.N�r	r
r�__doc__�fmtrrrr
r�rc@r)�EndpointDiscoveryRefreshFailedz? Endpoint Discovery failed to the refresh the known endpoints. z<Endpoint Discovery failed to refresh the required endpoints.Nrrrrr
r"rrcKs"|j}|r
|�d�rt��dSdS)N�required)�endpoint_discovery�getr)�model�kwargsrrrr
�,block_endpoint_discovery_required_operations's�rc@sNeZdZdd�Zedd��Zedd��Zdd�Zd	d
�Zdd�Z	ddd�Z
d
S)�EndpointDiscoveryModelcC�
||_dS�N)�_service_model)�self�
service_modelrrr
�__init__.�
zEndpointDiscoveryModel.__init__cCs|jj}t|j�Sr)r�endpoint_discovery_operationr�name)r�discovery_operationrrr
�discovery_operation_name1s
z/EndpointDiscoveryModel.discovery_operation_namecCs&|jj}g}|jrt|jj���}|Sr)rr#�input_shape�list�members�keys)rr%r*rrr
�discovery_operation_keys6s
z/EndpointDiscoveryModel.discovery_operation_keyscCs2z|j�|�}|j�dd�WStyYdSw)NrF)r�operation_modelrrr)r�operation_namer,rrr
�discovery_required_for>s�z-EndpointDiscoveryModel.discovery_required_forcsB|j�|�d�s|�dd�|�dd�t�fdd�|��D��S)N�Identifiers�	Operationc3s$�|]
\}}|�vr||fVqdSrr��.0�k�v��
input_keysrr
�	<genexpr>Ks�"zDEndpointDiscoveryModel.discovery_operation_kwargs.<locals>.<genexpr>)r+r�pop�dict�items�rrrr5r
�discovery_operation_kwargsEs

z1EndpointDiscoveryModel.discovery_operation_kwargscCs|�|j|�Sr)�_gather_idsr'�r�	operation�paramsrrr
�gather_identifiersM�z)EndpointDiscoveryModel.gather_identifiersNcCsb|duri}|j��D]#\}}|j�d�r||||<q|jdkr.||vr.|�||||�q|S)N�endpointdiscoveryid�	structure)r)r:�metadatar�	type_namer=)r�shaper@�ids�member_name�member_shaperrr
r=Ps�z"EndpointDiscoveryModel._gather_idsr)r	r
rr!rr&r+r.r<rAr=rrrr
r-s

rc@sneZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)�EndpointDiscoveryManagerNTcCsP|duri}||_i|_|durtj}||_||_t�|�|_t|j	j
�|_dSr)�_cache�_failed_attempts�time�_time�_always_discover�weakref�proxy�_clientr�metar �_model)r�client�cache�current_time�always_discoverrrr
r!^sz!EndpointDiscoveryManager.__init__cCs8|d}|��}|D]}|�d�}||d|d<q
|S)N�	Endpoints�CachePeriodInMinutes�<�
Expiration)rOr)r�response�	endpointsrX�endpoint�
cache_timerrr
�_parse_endpointsms
z)EndpointDiscoveryManager._parse_endpointscCst|t�r
tt|����S|Sr)�
isinstancer9�tuple�sortedr:)r�valuerrr
�_cache_itemus
z$EndpointDiscoveryManager._cache_itemcs0�jjdi|��}t�fdd�t|���D��S)Nc3s�|]
\}}��|�VqdSr)rgr1�rrr
r7}s�z=EndpointDiscoveryManager._create_cache_key.<locals>.<genexpr>r)rUr<rdrer:r;rrhr
�_create_cache_key{sz*EndpointDiscoveryManager._create_cache_keycCs|j�||�Sr)rUrAr>rrr
rArBz+EndpointDiscoveryManager.gather_identifierscKs*|jdi|��}||jvr|j|=dSdS)Nr)rirL)rr�	cache_keyrrr
�delete_endpoints�s
�z)EndpointDiscoveryManager.delete_endpointscKs@|jjdi|��}|jj}t|j|�}t�d|�|di|��S)Nz%Discovering endpoints with kwargs: %sr)rUr<r&�getattrrS�logger�debug)rrr-r%rrr
�_describe_endpoints�s
z,EndpointDiscoveryManager._describe_endpointscs.||jvrdS|����fdd�|j|D�S)Ncsg|]
}�|dkr|�qS)r]r)r2�e��nowrr
�
<listcomp>�szCEndpointDiscoveryManager._get_current_endpoints.<locals>.<listcomp>)rLrO)r�keyrrqr
�_get_current_endpoints�s
z/EndpointDiscoveryManager._get_current_endpointsc	Kst|jdi|��}z|jdi|��}|�|�}||j|<|j�|d�|WSttfy9|��d|j|<YdSw)Nr\r)	rirorbrLrMr8rrrO)rrrjr^r_rrr
�_refresh_current_endpoints�s

�z3EndpointDiscoveryManager._refresh_current_endpointscCs0||jvr|��}||j|krdS|j|=dS)NTF)rMrO)rrjrrrrr
�_recently_failed�s
z)EndpointDiscoveryManager._recently_failedcCs|ddS)Nr�Addressr)rr_rrr
�_select_endpoint�sz)EndpointDiscoveryManager._select_endpointcKs�|d}|j�|�}|js|st�d|�dS|jdi|��}|�|�}|r,|�|�S|�|�}|sB|j	di|��}|rB|�|�St�d|�|j
�|d�}|rV|�|�S|rl|ri|j	di|��}|ri|�|�St��dS)Nr0zAOptional discovery disabled. Skipping discovery for Operation: %sz%Endpoint Discovery has failed for: %sr)
rUr.rPrmrnriruryrwrvrLrr)rrr?�discovery_requiredrjr_�recently_failed�
stale_entriesrrr
�describe_endpoint�s:
��





z*EndpointDiscoveryManager.describe_endpoint)NNT)r	r
rr!rbrgrirArkrorurvrwryr}rrrr
rK]s
	rKc@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�EndpointDiscoveryHandlercCrr)�_manager)r�managerrrr
r!�r"z!EndpointDiscoveryHandler.__init__cCs:|�d||j�|�d||j�|�d||j�dS)Nzbefore-parameter-build.%szrequest-created.%szneeds-retry.%s)�registerrA�register_first�discover_endpoint�handle_retries)r�events�
service_idrrr
r��s
�
�z!EndpointDiscoveryHandler.registercKs0|j}|dur	dS|j�||�}d|i|d<dS)N�identifiers�	discovery)rrrA)rr@r�contextrrrHrrr
rA�s
z+EndpointDiscoveryHandler.gather_identifierscKsn|j�di��d�}|durdS|jj||d�}|dur#t�d�dS|�d�s,d|}t�d|�||_dS)Nr�r��r0r/z&Failed to discover and inject endpoint�httpzhttps://z!Injecting discovered endpoint: %s)r�rrr}rmrn�
startswith�url)r�requestr-rrHr`rrr
r��s�


z*EndpointDiscoveryHandler.discover_endpointc
Ks�|durdS|\}}|�di��d�}|�di��d�}|dkr&|dkr&dS|�di�}|�di��d	�}	|	dur;dS|jj|j|	d
�dS)N�ResponseMetadata�HTTPStatusCode�Error�Codei��InvalidEndpointExceptionr�r�r�r�r)rrrkr$)
r�request_dictr^r?r�_�status�
error_coder�rHrrr
r��s�z'EndpointDiscoveryHandler.handle_retriesN)r	r
rr!r�rAr�r�rrrr
r~�s	r~)rN�loggingrQ�botocorer�botocore.exceptionsrrr�botocore.modelr�botocore.utilsr�	getLoggerr	rmrrrr�objectrrKr~rrrr
�<module>s
0|