a 97a+@sddlZddlZddlZddlmZddlmZmZmZddl m Z ddl m Z e eZGdddeZGdd d eZGd d d eZd d ZGdddeZGdddeZGdddeZdS)N) xform_name) BotoCoreErrorHTTPClientErrorConnectionError)OperationNotFoundError)CachedPropertyc@s eZdZdS)EndpointDiscoveryExceptionN)__name__ __module__ __qualname__r r m/private/var/folders/s6/9n5zrl012gv99k63s4q6ccsd4s6mqz/T/pip-target-f5cq3f2q/lib/python/botocore/discovery.pyrsrc@seZdZdZdZdS)EndpointDiscoveryRequiredzD Endpoint Discovery is disabled but is required for this operation. zAEndpoint Discovery is not enabled but this operation requires it.Nr r r __doc__fmtr r r r rsrc@seZdZdZdZdS)EndpointDiscoveryRefreshFailedz? Endpoint Discovery failed to the refresh the known endpoints. zs   z-EndpointDiscoveryModel.discovery_required_forc sB|j|ds(|dd|ddtfdd|DS)N Identifiers Operationc3s"|]\}}|vr||fVqdSrr .0kvZ input_keysr r KzDEndpointDiscoveryModel.discovery_operation_kwargs..)r'rpopdictitemsrrr r1r discovery_operation_kwargsEs    z1EndpointDiscoveryModel.discovery_operation_kwargscCs||j|Sr) _gather_idsr#r operationparamsr r r gather_identifiersMsz)EndpointDiscoveryModel.gather_identifiersNcCsb|dur i}|jD]F\}}|jdr8||||<q|jdkr||vr|||||q|S)NZendpointdiscoveryidZ structure)r%r6metadatar type_namer9)rshaper<ids member_nameZ member_shaper r r r9Ps z"EndpointDiscoveryModel._gather_ids)N) r r r rrr"r'r*r8r=r9r r r r r-s  rc@sneZdZdddZddZddZd d Zd d Zd dZddZ ddZ ddZ ddZ ddZ ddZdS)EndpointDiscoveryManagerNTcCsP|dur i}||_i|_|dur&tj}||_||_t||_t|j j |_ dSr) _cache_failed_attemptstime_time_always_discoverweakrefproxy_clientrmetar_model)rclientcache current_timeZalways_discoverr r r r^s z!EndpointDiscoveryManager.__init__cCs8|d}|}|D]}|d}||d|d<q|S)NZ EndpointsZCachePeriodInMinutes< Expiration)rGr)rresponse endpointsrPendpointZ cache_timer r r _parse_endpointsms  z)EndpointDiscoveryManager._parse_endpointscCs"t|trtt|S|SdSr) isinstancer5tuplesortedr6)rvaluer r r _cache_itemus z$EndpointDiscoveryManager._cache_itemc s0jjfi|}tfddt|DS)Nc3s|]\}}|VqdSr)r[r-rr r r2}r3z=EndpointDiscoveryManager._create_cache_key..)rMr8rXrYr6r7r r\r _create_cache_key{sz*EndpointDiscoveryManager._create_cache_keycCs|j||Sr)rMr=r:r r r r=sz+EndpointDiscoveryManager.gather_identifierscKs&|jfi|}||jvr"|j|=dSr)r]rD)rr cache_keyr r r delete_endpointss z)EndpointDiscoveryManager.delete_endpointscKs@|jjfi|}|jj}t|j|}td||fi|S)Nz%Discovering endpoints with kwargs: %s)rMr8r"getattrrKloggerdebug)rrr)r!r r r _describe_endpointss   z,EndpointDiscoveryManager._describe_endpointscs.||jvrdS|fdd|j|DS)Ncsg|]}|dkr|qS)rRr )r.enowr r r3zCEndpointDiscoveryManager._get_current_endpoints..)rDrG)rkeyr rer _get_current_endpointss z/EndpointDiscoveryManager._get_current_endpointsc Ksx|jfi|}z8|jfi|}||}||j|<|j|d|WSttfyr|d|j|<YdS0dS)NrQ) r]rcrVrDrEr4rrrG)rrr^rSrTr r r _refresh_current_endpointss  z3EndpointDiscoveryManager._refresh_current_endpointscCs0||jvr,|}||j|kr$dS|j|=dS)NTF)rErG)rr^rfr r r _recently_faileds  z)EndpointDiscoveryManager._recently_failedcCs |ddS)NrZAddressr )rrTr r r _select_endpointsz)EndpointDiscoveryManager._select_endpointcKs|d}|j|}|js0|s0td|dS|jfi|}||}|rX||S||}|s|j fi|}|r||Std||j |d}|r||S|r|r|j fi|}|r||St dS)Nr,zAOptional discovery disabled. Skipping discovery for Operation: %sz%Endpoint Discovery has failed for: %s) rMr*rHrarbr]rirlrkrjrDrr)rrr;Zdiscovery_requiredr^rTZrecently_failedZ stale_entriesr r r describe_endpoints:         z*EndpointDiscoveryManager.describe_endpoint)NNT)r r r rrVr[r]r=r_rcrirjrkrlrmr r r r rC]s   rCc@s4eZdZddZddZddZddZd d Zd S) EndpointDiscoveryHandlercCs ||_dSr)_manager)rmanagerr r r rsz!EndpointDiscoveryHandler.__init__cCs:|d||j|d||j|d||jdS)Nzbefore-parameter-build.%szrequest-created.%szneeds-retry.%s)registerr=Zregister_firstdiscover_endpointhandle_retries)reventsZ service_idr r r rqs  z!EndpointDiscoveryHandler.registercKs0|j}|durdS|j||}d|i|d<dS)N identifiers discovery)rror=)rr<rcontextrrrAr r r r=s z+EndpointDiscoveryHandler.gather_identifierscKsn|jdid}|dur dS|jj||d}|durFtddS|dsXd|}td|||_dS)Nrvrur,r+z&Failed to discover and inject endpointhttpzhttps://z!Injecting discovered endpoint: %s)rwrrormrarb startswithurl)rrequestr)rrArUr r r rrs   z*EndpointDiscoveryHandler.discover_endpointc Ks|dur dS|\}}|did}|did}|dkrL|dkrLdS|di}|did } | durvdS|jj|j| d d S) NZResponseMetadataZHTTPStatusCodeErrorZCodeiZInvalidEndpointExceptionrwrvrurxr)rror_r ) rZ request_dictrSr;r_statusZ error_coderwrAr r r rss z'EndpointDiscoveryHandler.handle_retriesN)r r r rrqr=rrrsr r r r rns  rn)rFloggingrIZbotocorerZbotocore.exceptionsrrrZbotocore.modelrZbotocore.utilsr getLoggerr rarrrrobjectrrCrnr r r r  s    0|