
    DhD/                         d dl Z d dlmZmZmZmZmZmZmZm	Z	m
Z
mZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d Z G d	 d
e      Z G d de      Zy)    N)
DEFAULT_TIMEOUTMAX_POOL_CONNECTIONSEndpointEndpointCreatorHTTPClientErrorcreate_request_objecthistory_recorderis_valid_endpoint_urlis_valid_ipv6_endpoint_urllogger)first_non_none_response)HTTPHeaderDict)handle_checksum_body)AIOHTTPSession)StreamingBodyc           
      4  K   t        | j                  j                  D ci c]4  \  }}|j                  d      j	                         |j                  d      6 c}}      | j
                  d|j                  id}|d   dk\  r| j                   d{   |d<   |S |j                  r| j                  |d<   |S |j                  r/|d   j                  d	      }t        | j                  |      |d<   |S | j                   d{   |d<   |S c c}}w 7 7 w)
a  Convert an HTTP response object to a request dict.

    This converts the requests library's HTTP response object to
    a dictionary.

    :type http_response: botocore.vendored.requests.model.Response
    :param http_response: The HTTP response from an AWS service request.

    :rtype: dict
    :return: A response dictionary which will contain the following keys:
        * headers (dict)
        * status_code (int)
        * body (string or file-like object)

    zutf-8operation_name)headersstatus_codecontextr   ,  Nbodyr   zcontent-length)r   rawraw_headersdecodelowerr   namecontenthas_event_stream_outputhas_streaming_outputgetr   )http_responseoperation_modelkvresponse_dictlengths         v/var/www/fastuser/data/www/generator.snapmosaic.io/flask_app/venv/lib/python3.12/site-packages/aiobotocore/endpoint.pyconvert_to_response_dictr)      s2    * " *--99Aq !'')188G+<<
 %00o22
M  ]#s*&3&;&; ;f  
	0	0 - 1 1f  
	-	-y)--.>? -m.?.? Hf  '4&;&; ;f' !< !<s/   D9D
9DDA0DDDDc                   D    e Zd Zd Zd
dZd Zd Zd Zd Z	 	 ddZ	d	 Z
y)AioEndpointc                 T   K   | j                   j                          d {    y 7 wN)http_sessionclose)selfs    r(   r/   zAioEndpoint.closeD   s     %%'''s   (&(Nc                 |  K   t        |      }|rt        |j                  |j                  g      |_        |j
                  j                  j                         }dj                  ||j                        }| j                  j                  |||j                         d {    | j                  |      }|S 7 w)Nz&request-created.{service_id}.{op_name})
service_idop_name)requestr   )r   anyr    r   stream_outputservice_modelr2   	hyphenizeformatr   _event_emitteremitprepare_request)r0   paramsr#   r4   r2   
event_nameprepared_requests          r(   create_requestzAioEndpoint.create_requestG   s     '/$'#88#;;%G! )66AAKKMJAHH%/C/C I J %%**.33 +   
  //8s   B B<"B:#B<c                 8  K   d}|d   }| j                  ||       | j                  ||       d {   }| j                  |||       d {   \  }}| j                  |||||       d {   r~|dz  }| j                  |||       |j	                          | j                  ||       d {   }| j                  |||       d {   \  }}| j                  |||||       d {   r~|d|d   v r|dz
  }||d   d   d<   |||S 7 7 7 7 e7 L7 .w)N   r   ResponseMetadataRetryAttempts)_update_retries_contextr@   _get_response_needs_retryreset_stream)	r0   request_dictr#   attemptsr   r4   success_response	exceptiontotal_retriess	            r(   _send_requestzAioEndpoint._send_request\   s    y)$$Wh7++L/JJ,0,>,>_g-
 '
#) %%
 
 
 MH(((<LM
   " //oNNG040B0B'1 +'i! %%
 
 
( ("&6q&99 %qLM  Q 23  O##G K'

 O+!
sp   /DDDDD,D-AD.D/D	D
D)D*D/ DDDDDDc                 `  K   | j                  |||       d {   \  }}d d ||d}|!|\  }}||d<   t        ||       d {   |d<   |j                  j                  j	                         }	 | j
                  j                  d|	 d|j                   fi | d {    ||fS 7 7 f7 w)N)r&   parsed_responser   rL   rP   r&   zresponse-received..)_do_get_responser)   r7   r2   r8   r:   r;   r   )
r0   r4   r#   r   rK   rL   kwargs_to_emitr"   rP   r2   s
             r(   rF   zAioEndpoint._get_response   s      -1,A,A_g-
 '
#) "#"	
 '-=*M?0?N,-4L5 /N?+ %22==GGI
&d!!&& Ao.B.B-CD

 	
 	
  **)'
/	
s4   B.B()B.B*AB.B, 	B.*B.,B.c           	        K   	 t        j                  d|       t        j                  d|j                  |j
                  |j                  |j                  |j                  d       |j                  j                  j                         }d| d|j                   }| j                  j                  ||       d {   }t        |      }|| j!                  |       d {   }t'        ||       d {   }	t)        ||	||       d {    |	j+                         }
|j,                  |
d
<   t        j                  d|
       |j.                  d   }| j0                  j3                  |      }t5        j6                  |j8                        r%|j9                  |	|j:                         d {   }n|j9                  |	|j:                        }|j<                  dk\  r| j?                  |	|||       d {    t        j                  d|       ||fd fS 7 [7 8# t"        $ r}d |fcY d }~S d }~wt$        $ r%}t        j                  dd	       d |fcY d }~S d }~ww xY w7 m7 Z7 7 tw)NzSending http request: %sHTTP_REQUEST)methodr   	streamingurlr   zbefore-send.rQ   )r4   z-Exception received when sending HTTP request.T)exc_inforW   HTTP_RESPONSEprotocolr   PARSED_RESPONSE) r   debugr	   recordrV   r   has_streaming_inputrX   r   r7   r2   r8   r   r:   r;   r   _sendr   	Exceptionr)   r   copyr    metadata_response_parser_factorycreate_parserasyncioiscoroutinefunctionparseoutput_shaper   _add_modeled_error_fields)r0   r4   r#   r   r2   r>   	responsesr"   er&   http_response_record_dictr[   parserrP   s                 r(   rR   zAioEndpoint._do_get_response   so    	LL3W=##%nn&!0!D!D";;#LL	 )66AAKKMJ'
|1_5I5I4JKJ"1166G 7  I 4I>M$&*jj&9 9 7?
 
 #	
 	
 	
 %2$6$6$8! 00 	"	
 	1JK"++J7..<<XF&&v||4$*LL;;% O %ll;;O $$+00	   	 1?C/55g
 !: 	!9 	LL?$ !9		
	
"s   I/B:H >H?%H $H%H )I/8I%9I/I(B!I/0I+1AI/8I-9 I/H H 	I"(H1+I",I/1I"=II"I/I""I/(I/+I/-I/c                 R  K   |j                  di       j                  d      }|y |j                  }|j                  |      }|y t        j                  |j
                        r|j                  ||       d {   }n|j                  ||      }|j                  |       y 7 )w)NErrorCode)r!   r7   shape_for_error_coderf   rg   rh   update)	r0   r&   rP   r#   rn   
error_coder7   error_shapemodeled_parses	            r(   rj   z%AioEndpoint._add_modeled_error_fields   s      %(("599&A
'55#88D&&v||4"(,,}k"JJM"LLDM}-	 Ks   A9B';B%<*B'c           	      V  K   |j                   j                  j                         }d| d|j                   }| j                  j                  ||| ||||       d {   }t        |      }	|	yt        j                  d|	       t        j                  |	       d {    y7 F7 w)Nzneeds-retry.rQ   )responseendpoint	operationrJ   caught_exceptionrI   Fz3Response received to retry, sleeping for %s secondsT)r7   r2   r8   r   r:   r;   r   r   r]   rf   sleep)
r0   rJ   r#   rI   rx   r{   r2   r>   rk   handler_responses
             r(   rG   zAioEndpoint._needs_retry   s      %22==GGI
#J<q1E1E0FG
--22%-% 3 
 
	 39=# LLE  -- 0111)
& 2s%   AB)B%A B)B' B)'B)c                 T   K   | j                   j                  |       d {   S 7 wr-   )r.   send)r0   r4   s     r(   r`   zAioEndpoint._send  s#     &&++G4444s   (&(r-   )NN)__name__
__module____qualname__r/   r@   rN   rF   rR   rj   rG   r`        r(   r+   r+   C   s6    ( *'$R+8B6H.8 @5r   r+   c            
       (    e Zd Zddeeedddddf
dZy)AioEndpointCreatorNc           
      (   t        |      st        |      st        d|z        |	| j                  |      }	|j                  }t        j                  d||        |||	| j                  |      ||
|||      }t        ||| j                  ||      S )NzInvalid endpoint: %szSetting %s timeout as %s)timeoutproxiesverifymax_pool_connectionssocket_optionsclient_certproxies_configconnector_args)endpoint_prefixevent_emitterresponse_parser_factoryr.   )
r
   r   
ValueError_get_proxiesr   r   r]   _get_verify_valuer+   r:   )r0   r7   region_nameendpoint_urlr   r   r   r   http_session_clsr   r   r   r   r   r   r.   s                   r(   create_endpointz"AioEndpointCreator.create_endpoint!  s      %
,\:3lBCC?''5G'77/'J'))&1!5)#))	
 +--$;%
 	
r   )r   r   r   r   r   r   r   r   r   r(   r   r      s'      $1'+
r   r   )rf   botocore.endpointr   r   r   r   r   r   r	   r
   r   r   botocore.hooksr   urllib3.responser   aiobotocore.httpchecksumr   aiobotocore.httpsessionr   aiobotocore.responser   r)   r+   r   r   r   r(   <module>r      sI       3 + 9 2 .)XZ5( Z5z,
 ,
r   