
     hcA                        d dl Z d dlZd dlZd dlZd dlZd dl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 dlmZ d dlmZ d d	lmZ d d
lmZ d dlmZmZmZ  ej8                  e      Z e       ZdZ dZ!d Z" G d d      Z# G d d      Z$y)    N)parsers)create_request_object)get_current_datetime)HTTPClientError)get_global_history_recorder)first_non_none_response)handle_checksum_body)URLLib3Session)StreamingBody)get_environ_proxiesis_valid_endpoint_urlis_valid_ipv6_endpoint_url<   
   c                 R   | j                   | j                  d|j                  id}|d   dk\  r| j                  |d<   |S |j                  r| j
                  |d<   |S |j                  r/|d   j                  d      }t        | j
                  |      |d<   |S | j                  |d<   |S )a  Convert an HTTP response object to a request dict.

    This converts the HTTP response object to a dictionary.

    :type http_response: botocore.awsrequest.AWSResponse
    :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)

    operation_name)headersstatus_codecontextr   ,  bodyr   zcontent-length)	r   r   namecontenthas_event_stream_outputrawhas_streaming_outputgetr   )http_responseoperation_modelresponse_dictlengths       m/home/developers/rajanand/mypropertyqr-fmb-refixing-v2/venv/lib/python3.12/site-packages/botocore/endpoint.pyconvert_to_response_dictr#   +   s      !(($00o22
M ]#s* - 5 5f  
	0	0 - 1 1f  
	-	-y)--.>? -m.?.? Hf  !. 5 5f    c                       e Zd ZdZ	 	 ddZd Zd Zd ZddZd Z	d	 Z
d
 Zd ZddZd Zd Zd Zd Z	 	 ddZd Zy)Endpointa,  
    Represents an endpoint for a particular service in a specific
    region.  Only an endpoint can make requests.

    :ivar service: The Service object that describes this endpoints
        service.
    :ivar host: The fully qualified endpoint hostname.
    :ivar session: The session object.
    Nc                     || _         || _        || _        t        j                         | _        |t        j                         }|| _        || _	        | j                  t               | _	        y y N)_endpoint_prefix_event_emitterhost	threadingLock_lockr   ResponseParserFactory_response_parser_factoryhttp_sessionr
   )selfr+   endpoint_prefixevent_emitterresponse_parser_factoryr1   s         r"   __init__zEndpoint.__init__X   sj     !0+	^^%
"*&-&C&C&E#(?%($ . 0D %r$   c                 :    | j                    d| j                   dS )N())r)   r+   r2   s    r"   __repr__zEndpoint.__repr__k   s     ''($))A66r$   c                 8    | j                   j                          y r(   )r1   closer:   s    r"   r=   zEndpoint.closen   s    !r$   c                 T    t         j                  d||       | j                  ||      S )Nz%Making request for %s with params: %s)loggerdebug_send_request)r2   r   request_dicts      r"   make_requestzEndpoint.make_requestq   s,    3	

 !!,@@r$   c                 J   t        |      }|rt        |j                  |j                  g      |_        |j
                  j                  j                         }d| d|j                   }| j                  j                  |||j                         | j                  |      }|S )Nzrequest-created..)requestr   )r   anyr   r   stream_outputservice_model
service_id	hyphenizer   r*   emitprepare_request)r2   paramsr   rF   rJ   
event_nameprepared_requests          r"   create_requestzEndpoint.create_requesty   s    '/$'#88#;;%G! )66AAKKMJ+J<q9M9M8NOJ$$.33 % 
  //8r$   c                 ~    |j                         D ]*  \  }}t        |t              s|j                  d      ||<   , y )Nzutf-8)items
isinstancestrencode)r2   r   keyvalues       r"   _encode_headerszEndpoint._encode_headers   s7    !--/ 	5JC%%$||G4	5r$   c                 X    | j                  |j                         |j                         S r(   )rY   r   preparer2   rF   s     r"   rM   zEndpoint.prepare_request   s!    W__-  r$   c                     t               }t        j                  j                  |d      }||z
  }|t        j                  |      z   |z   }|j	                  d      S )Nz%a, %d %b %Y %H:%M:%S %Z)secondsz%Y%m%dT%H%M%SZ)r   datetimestrptime	timedeltastrftime)r2   response_received_timestampdate_headerread_timeoutlocal_timestampdate_conversionestimated_skewttls           r"   _calculate_ttlzEndpoint._calculate_ttl   sj     /0"++443
 )+FF  67 	
 ||,--r$   c                     |d   j                   j                  d      }|j                  d      }|r%|s"	 t               }| j                  |||      |d<   y y y # t        $ r t
        j                  dd       Y y w xY w)Nr   Datehas_streaming_inputri   z9Exception received when updating retries context with TTLTexc_info)r   r   r   rj   	Exceptionr?   r@   )r2   retries_contextre   success_responseresponse_date_headerrm   rc   s          r"   _set_ttlzEndpoint._set_ttl   s    /2::>>vF-112GH(;.B.D+)-)<)</( *& )<  O!  s    A  A;:A;c                     |j                  di       }||d<   d|vr t        t        j                               |d<   |r#|d   j                  }| j                  |||       y y )Nretriesattemptzinvocation-idclient_config)
setdefaultrU   uuiduuid4re   rt   )r2   r   rw   rr   rq   re   s         r"   _update_retries_contextz Endpoint._update_retries_context   sd    !,,Y;%,	"/1/24::</@OO,"?3@@LMM/<9IJ r$   c                    d}|d   }| j                  ||       | j                  ||      }| j                  |||      \  }}| j                  |||||      rf|dz  }| j                  |||       |j	                          | j                  ||      }| j                  |||      \  }}| j                  |||||      rf|d|d   v r|dz
  }||d   d   d<   |||S )N   r   ResponseMetadataRetryAttempts)r|   rQ   _get_response_needs_retryreset_stream)	r2   rB   r   attemptsr   rF   rr   	exceptiontotal_retriess	            r"   rA   zEndpoint._send_request   s5   y)$$Wh7%%lOD&*&8&8_g'
#) 
 MH(((<LM
   ")),HG*.*<*<'+'i! 
( ("&6q&99 %qLM Q 23OD  O##r$   c                    | j                  |||      \  }}d d ||d}||\  }}||d<   t        ||      |d<   |j                  j                  j	                         }	 | j
                  j                  d|	 d|j                   fi | ||fS )N)r    parsed_responser   r   r   r    zresponse-received.rE   )_do_get_responser#   rI   rJ   rK   r*   rL   r   )
r2   rF   r   r   rr   r   kwargs_to_emitr   r   rJ   s
             r"   r   zEndpoint._get_response   s     '+&;&;_g'
#) "#"	
 '-=*M?0?N,-.F/N?+ %22==GGI
    Ao.B.B-CD	
	
  **r$   c           	      t   	 t         j                  d|       t        j                  d|j                  |j
                  |j                  |j                  |j                  d       |j                  j                  j                         }d| d|j                   }| j                  j                  ||      }t        |      }|| j!                  |      }t'        ||      }	t)        ||	||       |	j+                         }
|j,                  |
d
<   t        j                  d|
       |j                  j.                  }i }| j                  j                  d| d|j                   ||	|       | j0                  j3                  |      }|j5                  |	|j6                        }|j9                  |       |j:                  dk\  r| j=                  |	|||       t        j                  d|       ||fd fS # 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)NzSending http request: %sHTTP_REQUEST)methodr   	streamingurlr   zbefore-send.rE   )rF   z-Exception received when sending HTTP request.Trn   r   HTTP_RESPONSEzbefore-parse.)r   r    customized_response_dictr   PARSED_RESPONSE)r?   r@   history_recorderrecordr   r   rm   r   r   rI   rJ   rK   r   r*   rL   r   _sendr   rp   r#   r	   copyr   resolved_protocolr0   create_parserparseoutput_shapeupdater   _add_modeled_error_fields)r2   rF   r   r   rJ   rO   	responsesr   er    http_response_record_dictprotocolr   parserr   s                  r"   r   zEndpoint._do_get_response  sD   	LL3W=##%nn&!0!D!D";;#LL	 )66AAKKMJ'
|1_5I5I4JKJ++00W0MI3I>M$ $

7 3 1?
 			
 %2$6$6$8!00 	"+. 	1JK"00BB#%   J<q)=)=(>?+'%=	 	! 	
 ..<<XF ,,?77
 	78 $$+**	 	 1?C/55e  	!9 	LL?$   !9		s0   CG4 4	H7=H H7H7H2,H72H7c                     |j                  di       j                  d      }|y |j                  }|j                  |      }|y |j                  ||      }|j	                  |       y )NErrorCode)r   rI   shape_for_error_coder   r   )	r2   r    r   r   r   
error_coderI   error_shapemodeled_parses	            r"   r   z"Endpoint._add_modeled_error_fieldsL  sl     %(("599&A
'55#88D]K@}-r$   c           	      &   |j                   j                  j                         }d| d|j                   }| j                  j                  ||| ||||      }t        |      }	|	yt        j                  d|	       t        j                  |	       y)Nzneeds-retry.rE   )responseendpoint	operationr   caught_exceptionrB   Fz3Response received to retry, sleeping for %s secondsT)rI   rJ   rK   r   r*   rL   r   r?   r@   timesleep)
r2   r   r   rB   r   r   rJ   rO   r   handler_responses
             r"   r   zEndpoint._needs_retry^  s     %22==GGI
#J<q1E1E0FG
'',,%-% - 
	 39=# LLE  JJ'(r$   c                 8    | j                   j                  |      S r(   )r1   sendr\   s     r"   r   zEndpoint._send~  s      %%g..r$   )NNr(   )__name__
__module____qualname____doc__r6   r;   r=   rC   rQ   rY   rM   rj   rt   r|   rA   r   r   r   r   r    r$   r"   r&   r&   M   sm     !%1&7"A &5!."K'$R+8E6N.. @/r$   r&   c            	       8    e Zd Zd Zddeeeddddf	dZd Zd Z	y)EndpointCreatorc                     || _         y r(   )r*   )r2   r4   s     r"   r6   zEndpointCreator.__init__  s
    +r$   Nc           	      &   t        |      st        |      st        d|       |	| j                  |      }	|j                  }t
        j                  d||        |||	| j                  |      ||
||      }t        ||| j                  ||      S )NzInvalid endpoint: zSetting %s timeout as %s)timeoutproxiesverifymax_pool_connectionssocket_optionsclient_certproxies_config)r3   r4   r5   r1   )
r   r   
ValueError_get_proxiesr3   r?   r@   _get_verify_valuer&   r*   )r2   rI   region_nameendpoint_urlr   r5   r   r   http_session_clsr   r   r   r   r3   r1   s                  r"   create_endpointzEndpointCreator.create_endpoint  s     %
,\:1,@AA?''5G'77/'J'))&1!5)#)
 +--$;%
 	
r$   c                     t        |      S r(   )r   )r2   r   s     r"   r   zEndpointCreator._get_proxies  s     #3''r$   c                 J    ||S t         j                  j                  dd      S )NREQUESTS_CA_BUNDLET)osenvironr   )r2   r   s     r"   r   z!EndpointCreator._get_verify_value  s'     M zz~~2D99r$   )
r   r   r   r6   DEFAULT_TIMEOUTMAX_POOL_CONNECTIONSr
   r   r   r   r   r$   r"   r   r     s4    ,  $1')
V(
:r$   r   )%r_   loggingr   r,   r   rz   botocorer   botocore.awsrequestr   botocore.compatr   botocore.exceptionsr   botocore.historyr   botocore.hooksr   botocore.httpchecksumr	   botocore.httpsessionr
   botocore.responser   botocore.utilsr   r   r   	getLoggerr   r?   r   r   r   r#   r&   r   r   r$   r"   <module>r      s      	     5 0 / 8 2 6 / +  
		8	$.0  Dr/ r/j	?: ?:r$   