o
    di                     @   sH   d dl Z d dlmZmZmZmZmZ G dd deZG dd deZdS )    N)EndpointDiscoveryHandlerEndpointDiscoveryManagerEndpointDiscoveryRefreshFailedHTTPClientErrorloggerc                   @   s   e Zd Zdd Zdd ZdS )AioEndpointDiscoveryManagerc              	      s   | j di |}z&| jdi |}t|r|I d H }| |}|| j|< | j|d  |W S  tt	fyD   | 
 d | j|< Y d S w )N<    )_create_cache_key_describe_endpointsinspectisawaitable_parse_endpoints_cache_failed_attemptspopConnectionErrorr   _time)selfkwargs	cache_keyresponse	endpointsr	   r	   I/home/ubuntu/.local/lib/python3.10/site-packages/aiobotocore/discovery.py_refresh_current_endpoints   s   



z6AioEndpointDiscoveryManager._refresh_current_endpointsc                    s   |d }| j |}| js|std| d S | jdi |}| |}|r,| |S | |}|sE| j	di |I d H }|rE| |S td| | j
|d }|rY| |S |rr|ro| j	di |I d H }|ro| |S t d S )N	OperationzAOptional discovery disabled. Skipping discovery for Operation: %sz%Endpoint Discovery has failed for: %sr	   )_modeldiscovery_required_for_always_discoverr   debugr
   _get_current_endpoints_select_endpoint_recently_failedr   r   getr   )r   r   	operationdiscovery_requiredr   r   recently_failedstale_entriesr	   r	   r   describe_endpoint   s:   






z-AioEndpointDiscoveryManager.describe_endpointN)__name__
__module____qualname__r   r(   r	   r	   r	   r   r      s    r   c                   @   s   e Zd Zdd ZdS )AioEndpointDiscoveryHandlerc                    sv   |j di d}|d u rd S | jj||dI d H }|d u r'td d S |ds0d| }td| ||_d S )N	discoveryidentifiers)r   Identifiersz&Failed to discover and inject endpointhttpzhttps://z!Injecting discovered endpoint: %s)contextr#   _managerr(   r   r   
startswithurl)r   requestoperation_namer   idsendpointr	   r	   r   discover_endpointJ   s   


z-AioEndpointDiscoveryHandler.discover_endpointN)r)   r*   r+   r9   r	   r	   r	   r   r,   I   s    r,   )	r   botocore.discoveryr   r   r   r   r   r   r,   r	   r	   r	   r   <module>   s    	=