U m^(@sddlZddlZddlZddlmZddlmZmZmZddl m Z e e Z GdddeZGdddeZGd d d eZd d ZGd ddeZGdddeZGdddeZdS)N) xform_name) BotoCoreErrorHTTPClientErrorConnectionError)CachedPropertyc@s eZdZdS)EndpointDiscoveryExceptionN)__name__ __module__ __qualname__r r l/private/var/folders/sd/whlwsn6x1_qgglc0mjv25_695qk2gl/T/pip-install-4zq3fp6i/botocore/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.Nrr r __doc__fmtr r r r r sr c@seZdZdZdZdS)EndpointDiscoveryRefreshFailedz? Endpoint Discovery failed to the refresh the known endpoints. zGszDEndpointDiscoveryModel.discovery_operation_kwargs..)r&rpopdictitemsrrr r0r discovery_operation_kwargsAs    z1EndpointDiscoveryModel.discovery_operation_kwargscCs||j|Sr) _gather_idsr"r operationparamsr r r gather_identifiersIsz)EndpointDiscoveryModel.gather_identifiersNcCsZ|dkr i}|jD]>\}}|jdr8||||<q|jdkr|||||q|S)NZendpointdiscoveryidZ structure)r$r4metadatarZ type_namer7)rshaper:ids member_nameZ member_shaper r r r7Ls  z"EndpointDiscoveryModel._gather_ids)N) rr r rrr!r&r)r6r;r7r r r r r,s  rc@sneZdZdddZddZddZdd Zd d Zd d ZddZ ddZ ddZ ddZ ddZ ddZdS)EndpointDiscoveryManagerNcCsJ|dkr i}||_i|_|dkr&tj}||_t||_t|jj |_ dSr) _cache_failed_attemptstime_timeweakrefproxy_clientrmetar_model)rclientcache current_timer r r rZs z!EndpointDiscoveryManager.__init__cCs8|d}|}|D]}|d}||d|d<q|S)NZ EndpointsZCachePeriodInMinutes< Expiration)rDr)rresponse endpointsrLendpointZ cache_timer r r _parse_endpointshs  z)EndpointDiscoveryManager._parse_endpointscCs"t|trtt|S|SdSr) isinstancer3tuplesortedr4)rvaluer r r _cache_itemps z$EndpointDiscoveryManager._cache_itemc s,jjf|}tfddt|DS)Nc3s|]\}}|VqdSr)rWr,rr r r1xsz=EndpointDiscoveryManager._create_cache_key..)rIr6rTrUr4r5r rXr _create_cache_keyvsz*EndpointDiscoveryManager._create_cache_keycCs|j||Sr)rIr;r8r r r r;zsz+EndpointDiscoveryManager.gather_identifierscKs"|jf|}||jkr|j|=dSr)rYrA)rr cache_keyr r r delete_endpoints}s  z)EndpointDiscoveryManager.delete_endpointscKs8|jjf|}|jj}t|j|}td||f|S)Nz%Discovering endpoints with kwargs: %s)rIr6r!getattrrGloggerdebug)rrr(r r r r _describe_endpointss   z,EndpointDiscoveryManager._describe_endpointscs.||jkrdS|fdd|j|DS)Ncsg|]}|dkr|qS)rNr )r-enowr r s zCEndpointDiscoveryManager._get_current_endpoints..)rArD)rkeyr rar _get_current_endpointss z/EndpointDiscoveryManager._get_current_endpointsc Ksr|jf|}z4|jf|}||}||j|<|j|d|WSttfk rl|d|j|<YdSXdS)NrM) rYr_rRrArBr2rrrD)rrrZrOrPr r r _refresh_current_endpointss    z3EndpointDiscoveryManager._refresh_current_endpointscCs0||jkr,|}||j|kr$dS|j|=dS)NTF)rBrD)rrZrbr r r _recently_faileds  z)EndpointDiscoveryManager._recently_failedcCs |ddS)NrZAddressr )rrPr r r _select_endpointsz)EndpointDiscoveryManager._select_endpointcKs|jf|}||}|r$||S||}|sL|jf|}|rL||Std||j|d}|rt||S|j |dr|r|jf|}|r||St dS)Nz%Endpoint Discovery has failed for: %sr+) rYrerhrgrfr]r^rArrIr)r)rrrZrPZrecently_failedZ stale_entriesr r r describe_endpoints(          z*EndpointDiscoveryManager.describe_endpoint)NN)rr r rrRrWrYr;r[r_rerfrgrhrir r r r r@Ys   r@c@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 rmsz!EndpointDiscoveryHandler.registercKs0|j}|dkrdS|j||}d|i|d<dS)N identifiers discovery)rrkr;)rr:rcontextrrr>r r r r;s z+EndpointDiscoveryHandler.gather_identifierscKsn|jdid}|dkr dS|jj||d}|dkrFtddS|dsXd|}td|||_dS)Nrrrqr+r*z&Failed to discover and inject endpointhttpzhttps://z!Injecting discovered endpoint: %s)rsrrkrir]r^ startswithurl)rrequestr(rr>rQr r r rns   z*EndpointDiscoveryHandler.discover_endpointc Ks|dkr dS|\}}|did}|did}|dkrL|dkrLdS|di}|did } | dkrvdS|jj|j| d d S) NZResponseMetadataZHTTPStatusCodeErrorZCodeiZInvalidEndpointExceptionrsrrrqrtr)rrkr[r) rZ request_dictrOr9r_statusZ error_codersr>r r r ros  z'EndpointDiscoveryHandler.handle_retriesN)rr r rrmr;rnror r r r rjs  rj)rCloggingrEZbotocorerZbotocore.exceptionsrrrZbotocore.utilsr getLoggerrr]rr rrobjectrr@rjr r r r  s   -p