
    /JfC+                        d dl Z d dlZd dlZd dlmZ d dlmZmZmZ d dl	m
Z
 d dlmZ  e j        e          Z G d de          Z G d d	e          Z G d
 de          Zd Z G d d          Z G d d          Z G d d          ZdS )    N)
xform_name)BotoCoreErrorConnectionErrorHTTPClientError)OperationNotFoundError)CachedPropertyc                       e Zd ZdS )EndpointDiscoveryExceptionN)__name__
__module____qualname__     U/home/alex/cs2snipeproduction/venv/lib/python3.11/site-packages/botocore/discovery.pyr
   r
      s        Dr   r
   c                       e Zd ZdZdZdS )EndpointDiscoveryRequiredzBEndpoint 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      s        LL
MCCCr   r   c                       e Zd ZdZdZdS )EndpointDiscoveryRefreshFailedz=Endpoint Discovery failed to the refresh the known endpoints.z<Endpoint Discovery failed to refresh the required endpoints.Nr   r   r   r   r   r   #   s        GG
HCCCr   r   c                 b    | j         }|r#|                    d          rt                      d S d S )Nrequired)endpoint_discoverygetr   )modelkwargsr   s      r   ,block_endpoint_discovery_required_operationsr   )   sI    1 *044Z@@ *')))* * * *r   c                   Z    e Zd Zd Zed             Zed             Zd Zd Zd Z	d	dZ
dS )
EndpointDiscoveryModelc                     || _         d S N)_service_model)selfservice_models     r   __init__zEndpointDiscoveryModel.__init__0   s    +r   c                 B    | j         j        }t          |j                  S r"   )r#   endpoint_discovery_operationr   name)r$   discovery_operations     r   discovery_operation_namez/EndpointDiscoveryModel.discovery_operation_name3   s     "1N-2333r   c                     | j         j        }g }|j        r+t          |j        j                                                  }|S r"   )r#   r(   input_shapelistmemberskeys)r$   r*   r0   s      r   discovery_operation_keysz/EndpointDiscoveryModel.discovery_operation_keys8   sD    "1N* 	H+7?DDFFGGDr   c                     	 | j                             |          }|j                            dd          S # t          $ r Y dS w xY w)Nr   F)r#   operation_modelr   r   r   )r$   operation_namer3   s      r   discovery_required_forz-EndpointDiscoveryModel.discovery_required_for@   s_    	"1AA O #599*eLLL% 	 	 	55	s   47 
AAc                     | j         |                    d          s,|                    dd            |                    dd            fd|                                D             S )NIdentifiers	Operationc                 $    i | ]\  }}|v 	||S r   r   ).0kv
input_keyss      r   
<dictcomp>zEEndpointDiscoveryModel.discovery_operation_kwargs.<locals>.<dictcomp>O   s$    CCCA1
??1???r   )r1   r   popitems)r$   r   r=   s     @r   discovery_operation_kwargsz1EndpointDiscoveryModel.discovery_operation_kwargsI   si    2
zz-(( 	,JJ{D)))JJ}d+++CCCCCCCCr   c                 8    |                      |j        |          S r"   )_gather_idsr-   r$   	operationparamss      r   gather_identifiersz)EndpointDiscoveryModel.gather_identifiersQ   s    	 5v>>>r   Nc                     |i }|j                                         D ]W\  }}|j                            d          r||         ||<   +|j        dk    r!||v r|                     |||         |           X|S )Nendpointdiscoveryid	structure)r/   r@   metadatar   	type_namerC   )r$   shaperF   idsmember_namemember_shapes         r   rC   z"EndpointDiscoveryModel._gather_idsT   s     ;C).)<)<)>)> 	I 	I%K$(()>?? I#)+#6K  &+55+:O:O  vk/BCHHH
r   r"   )r   r   r   r&   r   r+   r1   r5   rA   rG   rC   r   r   r   r    r    /   s        , , , 4 4 ^4   ^  D D D? ? ?     r   r    c                   Z    e Zd Z	 ddZd Zd Zd Zd Zd Zd	 Z	d
 Z
d Zd Zd Zd ZdS )EndpointDiscoveryManagerNTc                     |i }|| _         i | _        |t          j        }|| _        || _        t          j        |          | _        t          |j	        j
                  | _        d S r"   )_cache_failed_attemptstime_time_always_discoverweakrefproxy_clientr    metar%   _model)r$   clientcachecurrent_timealways_discovers        r   r&   z!EndpointDiscoveryManager.__init__d   sd     =E "9L!
 / }V,,,V[-FGGr   c                     |d         }|                                  }|D ]"}|                    d          }||dz  z   |d<   #|S )N	EndpointsCachePeriodInMinutes<   
Expiration)rW   r   )r$   response	endpointsr`   endpoint
cache_times         r   _parse_endpointsz)EndpointDiscoveryManager._parse_endpointsu   sX    [)	zz||! 	D 	DH!&<==J%1JO%CH\""r   c                     t          |t                    r.t          t          |                                                    S |S r"   )
isinstancedicttuplesortedr@   )r$   values     r   _cache_itemz$EndpointDiscoveryManager._cache_item}   s7    eT"" 	..///Lr   c                        j         j        di |}t           fdt          |                                          D                       S )Nc              3   H   K   | ]\  }}                     |          V  d S r"   )rr   )r:   r;   r<   r$   s      r   	<genexpr>z=EndpointDiscoveryManager._create_cache_key.<locals>.<genexpr>   s5      LLTQT%%a((LLLLLLr   r   )r]   rA   ro   rp   r@   )r$   r   s   ` r   _create_cache_keyz*EndpointDiscoveryManager._create_cache_key   sP    77AA&AALLLLVFLLNN5K5KLLLLLLr   c                 8    | j                             ||          S r"   )r]   rG   rD   s      r   rG   z+EndpointDiscoveryManager.gather_identifiers   s    {--i@@@r   c                 F     | j         di |}|| j        v r
| j        |= d S d S )Nr   )rv   rT   )r$   r   	cache_keys      r   delete_endpointsz)EndpointDiscoveryManager.delete_endpoints   s?    *D*44V44	##I&&& $#r   c                      | j         j        di |}| j         j        }t          | j        |          }t
                              d|            |di |S )Nz%Discovering endpoints with kwargs: %sr   )r]   rA   r+   getattrr[   loggerdebug)r$   r   r4   r*   s       r   _describe_endpointsz,EndpointDiscoveryManager._describe_endpoints   sf     87AA&AA=%dlNCC<fEEE"",,V,,,r   c                 t    || j         vrd S |                                 fd| j         |         D             S )Nc                 ,    g | ]}|d          k     |S )rf   r   )r:   enows     r   
<listcomp>zCEndpointDiscoveryManager._get_current_endpoints.<locals>.<listcomp>   s'    EEEasQ|_/D/D/D/D/Dr   )rT   rW   )r$   keyr   s     @r   _get_current_endpointsz/EndpointDiscoveryManager._get_current_endpoints   sC    dk!!4jjllEEEE4;s+EEEEr   c                     | j         di |}	  | j        di |}|                     |          }|| j        |<   | j                            |d            |S # t          t          f$ r# |                                 dz   | j        |<   Y d S w xY w)Nre   r   )	rv   r   rk   rT   rU   r?   r   r   rW   )r$   r   ry   rg   rh   s        r   _refresh_current_endpointsz3EndpointDiscoveryManager._refresh_current_endpoints   s    *D*44V44		/t/99&99H--h77I%.DK	"!%%i6661 	 	 	/3zz||b/@D!),44	s   AA 0BBc                 v    || j         v r/|                                 }|| j         |         k     rdS | j         |= dS )NTF)rU   rW   )r$   ry   r   s      r   _recently_failedz)EndpointDiscoveryManager._recently_failed   sE    ---**,,CT*9555t%i0ur   c                     |d         d         S )Nr   Addressr   )r$   rh   s     r   _select_endpointz)EndpointDiscoveryManager._select_endpoint   s    |I&&r   c                    |d         }| j                             |          }| j        s!|st                              d|z             d S  | j        di |}|                     |          }|r|                     |          S |                     |          }|s$ | j	        di |}|r|                     |          S t                              d|           | j
                            |d           }|r|                     |          S |r4|r$ | j	        di |}|r|                     |          S t                      d S )Nr8   zAOptional discovery disabled. Skipping discovery for Operation: %sz%Endpoint Discovery has failed for: %sr   )r]   r5   rX   r}   r~   rv   r   r   r   r   rT   r   r   )r$   r   rE   discovery_requiredry   rh   recently_failedstale_entriess           r   describe_endpointz*EndpointDiscoveryManager.describe_endpoint   s   ;'	![??	JJ$ 	-? 	LLS   4 +D*44V44	//	::	 	4((333//	:: 	877AA&AAI 8,,Y777<fEEE	488 	8((777 		3  <;D;EEfEE	 <00;;;0222tr   )NNT)r   r   r   r&   rk   rr   rv   rG   rz   r   r   r   r   r   r   r   r   r   rR   rR   c   s        EIH H H H"    M M MA A A' ' '
- - -F F F
 
 
  ' ' ') ) ) ) )r   rR   c                   ,    e Zd Zd Zd Zd Zd Zd ZdS )EndpointDiscoveryHandlerc                     || _         d S r"   )_manager)r$   managers     r   r&   z!EndpointDiscoveryHandler.__init__   s    r   c                     |                     d|z  | j                   |                    d|z  | j                   |                     d|z  | j                   d S )Nzbefore-parameter-build.%szrequest-created.%szneeds-retry.%s)registerrG   register_firstdiscover_endpointhandle_retries)r$   events
service_ids      r   r   z!EndpointDiscoveryHandler.register   sq    '*4d6M	
 	
 	
 	 :-t/E	
 	
 	
 	(:5t7JKKKKKr   c                 `    |j         }|d S | j                            ||          }d|i|d<   d S )Nidentifiers	discovery)r   r   rG   )r$   rF   r   contextr   r   rN   s          r   rG   z+EndpointDiscoveryHandler.gather_identifiers   sB    "5%Fm..uf== -s3r   c                 V   |j                             di                               d          }|d S | j                            ||          }|t                              d           d S |                    d          sd|z   }t                              d|           ||_        d S )Nr   r   r8   r7   z&Failed to discover and inject endpointhttpzhttps://z!Injecting discovered endpoint: %s)r   r   r   r   r}   r~   
startswithurl)r$   requestr4   r   rN   ri   s         r   r   z*EndpointDiscoveryHandler.discover_endpoint   s    o!!+r2266}EE;F=22$# 3 
 
 LLABBBF""6** 	-!H,H8(CCCr   c                    |d S |\  }}|                     di                                d          }|                     di                                d          }|dk    r|dk    rd S |                     di           }|                     di                                d	          }	|	d S | j                            |j        |	
           dS )NResponseMetadataHTTPStatusCodeErrorCodei  InvalidEndpointExceptionr   r   r   r   r   )r   r   rz   r)   )
r$   request_dictrg   rE   r   _status
error_coder   rN   s
             r   r   z'EndpointDiscoveryHandler.handle_retries  s    480"5599:JKK\\'2..226::
S==Z+EEE4""9b11kk+r**..}==;4
 	&&n# 	' 	
 	
 	
 qr   N)r   r   r   r&   r   rG   r   r   r   r   r   r   r      sb             L L L4 4 4      r   r   )loggingrV   rY   botocorer   botocore.exceptionsr   r   r   botocore.modelr   botocore.utilsr   	getLoggerr   r}   r
   r   r   r   r    rR   r   r   r   r   <module>r      s            O O O O O O O O O O 1 1 1 1 1 1 ) ) ) ) ) )		8	$	$	 	 	 	 	 	 	 	N N N N N : N N NI I I I I%? I I I* * *1 1 1 1 1 1 1 1h{ { { { { { { {|9 9 9 9 9 9 9 9 9 9r   