HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: //usr/lib/python3.6/site-packages/botocore/__pycache__/endpoint.cpython-36.pyc
3

�T_�5�@s�ddlZddlZddlZddlZddlmZddlmZddlm	Z	ddl
mZddlm
Z
mZddlmZddlmZdd	lmZdd
lmZeje�Ze�ZdZdZd
d�ZGdd�de�ZGdd�de�Z dS)�N)�six)�create_request_object)�HTTPClientError)�URLLib3Session)�is_valid_endpoint_url�get_environ_proxies)�first_non_none_response)�get_global_history_recorder)�
StreamingBody)�parsers�<�
cCst|j|jd|jid�}|ddkr.|j|d<nB|jr@|j|d<n0|jrf|djd�}t|j|�|d<n
|j|d<|S)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)

    �operation_name)�headers�status_code�contextri,�bodyrzcontent-length)	rr�nameZcontent�has_event_stream_output�raw�has_streaming_output�getr
)�
http_response�operation_model�
response_dictZlength�r�/usr/lib/python3.6/endpoint.py�convert_to_response_dict&s
rc@sveZdZdZddd�Zdd�Zdd�Zdd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
ddd�Zdd�ZdS)�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.
    NcCsN||_||_||_tj�|_|dkr,tj�}||_||_	|j	dkrJt
�|_	dS)N)�_endpoint_prefix�_event_emitter�host�	threadingZLock�_lockrZResponseParserFactory�_response_parser_factory�http_sessionr)�selfr!�endpoint_prefix�
event_emitter�response_parser_factoryr%rrr�__init__Ss

zEndpoint.__init__cCsd|j|jfS)Nz%s(%s))rr!)r&rrr�__repr__`szEndpoint.__repr__cCstjd||�|j||�S)Nz%Making request for %s with params: %s)�logger�debug�
_send_request)r&r�request_dictrrr�make_requestcszEndpoint.make_requestcCs\t|�}|rNt|j|jg�|_|jjj�}dj||j	d�}|j
j|||j	d�|j|�}|S)Nz&request-created.{service_id}.{op_name})�
service_idZop_name)�requestr)
r�anyrrZ
stream_output�
service_modelr1�	hyphenize�formatrr �emit�prepare_request)r&Zparamsrr2r1�
event_nameZprepared_requestrrr�create_requesths



zEndpoint.create_requestcCs4x.|j�D]"\}}t|tj�r
|jd�||<q
WdS)Nzutf-8)�items�
isinstancerZ	text_type�encode)r&r�key�valuerrr�_encode_headersxszEndpoint._encode_headerscCs|j|j�|j�S)N)r@rZprepare)r&r2rrrr8~szEndpoint.prepare_requestc	Cs�d}|j||�}|d}|j|||�\}}xD|j|||||�rn|d7}|j�|j||�}|j|||�\}}q,W|dk	r�d|dkr�|d}||ddd<|dk	r�|�n|SdS)N�rZResponseMetadataZ
RetryAttempts)r:�
_get_response�_needs_retryZreset_stream)	r&r/r�attemptsr2r�success_response�	exceptionZ
total_retriesrrrr.�s(zEndpoint._send_requestc
Csr|j||�\}}dd||d�}|dk	rD|\}}||d<t||�|d<|jjj�}	|jjd|	|jff|�||fS)N)r�parsed_responserrFrGrzresponse-received.%s.%s)�_do_get_responserr4r1r5r r7r)
r&r2rrrErFZkwargs_to_emitrrGr1rrrrB�s zEndpoint._get_responsec
CsLyvtjd|�tjd|j|j|j|j|jd��|j	j
j�}d||jf}|j
j||d�}t|�}|dkrt|j|�}WnTtk
r�}zd|fSd}~Xn2tk
r�}ztjddd�d|fSd}~XnXt||�}|j�}	|j|	d	<tjd
|	�|jd}
|jj|
�}|j||j�}|jdk�r4|j||||�tjd
|�||fdfS)NzSending http request: %sZHTTP_REQUEST)�methodr�	streaming�urlrzbefore-send.%s.%s)r2z-Exception received when sending HTTP request.T)�exc_inforJZ
HTTP_RESPONSE�protocoli,ZPARSED_RESPONSE)r,r-�history_recorder�recordrIrZhas_streaming_inputrKrr4r1r5rr r7r�_sendr�	Exceptionr�copyrZmetadatar$Z
create_parser�parseZoutput_shaper�_add_modeled_error_fields)
r&r2rr1r9�	responsesr�erZhttp_response_record_dictrM�parserrGrrrrH�sD



zEndpoint._do_get_responsec	CsT|jdi�jd�}|dkrdS|j}|j|�}|dkr:dS|j||�}|j|�dS)N�ErrorZCode)rr4Zshape_for_error_coderS�update)	r&rrGrrWZ
error_coder4Zerror_shapeZ
modeled_parserrrrT�s
z"Endpoint._add_modeled_error_fieldsc
	Csf|jjj�}d||jf}|jj|||||||d�}t|�}	|	dkrHdStjd|	�t	j
|	�dSdS)Nzneeds-retry.%s.%s)�responseZendpointZ	operationrD�caught_exceptionr/Fz3Response received to retry, sleeping for %s secondsT)r4r1r5rr r7rr,r-�timeZsleep)
r&rDrr/rZr[r1r9rUZhandler_responserrrrC�s


zEndpoint._needs_retrycCs|jj|�S)N)r%�send)r&r2rrrrPszEndpoint._send)NN)N)NN)�__name__�
__module__�__qualname__�__doc__r*r+r0r:r@r8r.rBrHrTrCrPrrrrrIs	

/
rc@s>eZdZdd�Zddeeedddfdd�Zdd�Zdd	�Z	dS)
�EndpointCreatorcCs
||_dS)N)r )r&r(rrrr*szEndpointCreator.__init__NcCsht|�std|��|	dkr&|j|�}	|j}tjd||�|||	|j|�||
|d�}
t|||j||
d�S)NzInvalid endpoint: %szSetting %s timeout as %s)�timeout�proxies�verify�max_pool_connections�socket_options�client_cert)r'r(r)r%)	r�
ValueError�_get_proxiesr'r,r-�_get_verify_valuerr )r&r4Zregion_nameZendpoint_urlrer)rcrfZhttp_session_clsrdrgrhr'r%rrr�create_endpoints&
zEndpointCreator.create_endpointcCst|�S)N)r)r&rKrrrrj5szEndpointCreator._get_proxiescCs|dk	r|Stjjdd�S)NZREQUESTS_CA_BUNDLET)�os�environr)r&rerrrrk:sz!EndpointCreator._get_verify_value)
r^r_r`r*�DEFAULT_TIMEOUT�MAX_POOL_CONNECTIONSrrlrjrkrrrrrbsrb)!rmZloggingr\r"Zbotocore.vendoredrZbotocore.awsrequestrZbotocore.exceptionsrZbotocore.httpsessionrZbotocore.utilsrrZbotocore.hooksrZbotocore.historyr	Zbotocore.responser
ZbotocorerZ	getLoggerr^r,rNrorpr�objectrrbrrrr�<module>s(
#H