HEX
Server: Apache
System: Linux box5514.bluehost.com 5.14.0-162.23.1.9991722448259.nf.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jul 31 18:11:45 UTC 2024 x86_64
User: smqcdvmy (3893)
PHP: 8.3.30
Disabled: NONE
Upload Files
File: //lib/python3.9/site-packages/oci/__pycache__/base_client.cpython-39.pyc
a

���fU��@s�ddlmZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlmZmZmZddlmZddlmZmZmZmZddlmZddlmZddlZdd	lmZdd
l m!Z!m"Z"m#Z#m$Z$ddl%m&Z&ddl'm(Z(m)Z)dd
l*m+Z+ddl,m-Z-ddl.m/Z/m0Z0ddlm1Z1m2Z2ddl3m4Z4ddl5m6Z6m7Z7m8Z8e7d�Z9dZ:dZ;ej<�=e:�Z>d�?e4�Z@e	�Ad�ZBe	�Ad�ZCdZDdZEej<�=dd�ZFeGeFejH��r�eF�I�dk�r�dZEdd�ZJdCd!d"�ZKd#d$�ZLd%d&�ZMd'd(�ZNd)ZOd*ZPd+ZQd,ZRd-ZSd.ZTdd/d0d1d2d3�ZUd4d5�ZVd6d7�ZWd8d9�ZXGd:d;�d;e�ZYGd<d=�d=ejZj[�Z\Gd>d?�d?ej]�Z^eE�r~e^ej_j`d@<GdAdB�dBea�ZbdS)D�)�absolute_importN)�date�datetime�timezone)�
default_timer�)�requests�six�urllib3�	sseclient)�parse)�tz)�HTTPResponse)�	constants�
exceptions�regions�retry)�signers)�get_config_value_or_default�validate_config)�Request)�Response)�CircuitBreakerStrategy�NoCircuitBreakerStrategy)�CircuitBreaker�CircuitBreakerMonitor)�__version__)�
NONE_SENTINEL�Sentinel�extract_service_endpointZMissingZOCI_SDK_APPEND_USER_AGENT�4OCI_REALM_SPECIFIC_SERVICE_ENDPOINT_TEMPLATE_ENABLEDzOracle-PythonSDK/{}zdict\(str, (.+?)\)$zlist\[(.+?)\]$zOhttps://docs.oracle.com/en-us/iaas/Content/API/Concepts/sdk_troubleshooting.htmTZOCI_PYSDK_USING_EXPECT_HEADER�falseFcGsi}|D]}|�|�q|S�N)�update)ZdictionariesZmergedZ
dictionary�r$�3/usr/lib/python3.9/site-packages/oci/base_client.py�merge_type_mappings8sr&�cCs@d�tt��t��t��|pd�}|��}tr<|d�t�7}|S)Nz{} (python {}; {}-{}) {}r'z {})�format�	USER_INFO�platformZpython_version�machine�system�strip�APPEND_USER_AGENT)ZextraZagentr$r$r%�build_user_agent?s�r/cCsdtt���dS)N� z: )�strrZutcnowr$r$r$r%�utc_nowMsr2cCs"|rdtjjj_ndtjjj_dS)Nrr)r	�movesZhttp_clientZHTTPConnection�
debuglevel)Z
is_enabledr$r$r%�is_http_log_enabledQsr5cCs:t�|�D]*\}}t|tj�s(t|t�r
t|�||<q
|Sr")r	�	iteritems�
isinstance�
integer_types�floatr1)�headersZheader_nameZheader_valuer$r$r%�_sanitize_headers_for_requestsXsr;�stream�bytesztext/event-stream�application/jsong$@gN@�,�	r0�|)�multiZcsvZtsvZssvZpipescCsd}|dkr|��}qdS)N�
)�readline)�fp�currentr$r$r%�_read_all_headerszsrGcCsDg}|D],}t|tj�r*|�|�d��q|�|�qd�|�}|S)Nzutf-8rC)r7r	�	text_type�append�encode�join)Zinput_bufferZbytes_buffer�chunk�msgr$r$r%�	_to_bytes�s
rNcCs2|�dd�}t|�dko0|d�d�o0|ddkS)N��r�HTTP/rs100)�split�len�
startswith)�line�partsr$r$r%�_is_100_continue�s
�rWc@seZdZdd�Zdd�ZdS)�OCIHTTPResponsecOs(|�d�|_tj|g|�Ri|��dS)N�status_tuple)�pop�
_status_tupler�__init__��self�args�kwargsr$r$r%r\�szOCIHTTPResponse.__init__cCs(|jdur|j}d|_|St�|�SdSr")r[r�_read_status)r^rYr$r$r%ra�s

zOCIHTTPResponse._read_statusN)�__name__�
__module__�__qualname__r\rar$r$r$r%rX�srXcsReZdZdZ�fdd�Z�fdd�Zddd�Zd	d
�Zdd�Z�fd
d�Z	�Z
S)�
OCIConnectionz+ HTTPConnection with 100 Continue support. csFtt|�j|i|��|j|_d|_d|_t�d�	t
t|���|_dS)NF�{}.{})
�superrer\�response_class�_original_response_cls�_response_received�_using_expect_header�logging�	getLoggerr(rb�id�loggerr]��	__class__r$r%r\�s
zOCIConnection.__init__cs~d|_|�dd�dkr0|jdkr(td�d|_n |jdkrBtd�d|_|j|_tt|�j	||||g|�Ri|��}d|_
|S)	NF�expectr'z100-continuerzUsing Expect header...TzNot using Expect header...)rj�getr4�printrkrirhrgre�
_send_requestZ_expect_header_set)r^�method�url�bodyr:r_r`Zrvalrpr$r%ru�s$


���zOCIConnection._send_requestNcOs�|j�d�t|j�}|jdd�=|js>t|t�r>||7}d}|�|�|jr~|jdkr`td�t	j
�|jd�r~|�
|�dS|dur�|jdkr�td�|�|�dS)N)�ryrz.Waiting 3 seconds for 100-continue response...rPzBTimeout waiting for 100-continue response, sending message body...)�_buffer�extendrNrkr7r=�sendr4rtr
�utilZ
wait_for_read�sock�_handle_expect_response)r^�message_bodyr_r`rMr$r$r%�_send_output�s$





zOCIConnection._send_outputcCs�|j�dd�}z�|��}|�dd�}|jdkr6t|�t|�rd|jdkrPtd�t|�|�|�nlt	|�dkr�|d�
d�r�|jdkr�td�|d�d�t|d	�|d�d�f}t
jt|d
�}||_d|_W|��n
|��0dS)N�rbrrOz7Received 100-continue response, sending message body...rPrQz4Received non-100-continue response, abort request...�asciir)rYT)r~ZmakefilerDrRr4rtrWrG�_send_message_bodyrSrT�decode�int�	functools�partialrXrhrj�close)r^r�rErUrVrYrhr$r$r%r�s.


��z%OCIConnection._handle_expect_responsecCs|dur|�|�dSr")r|)r^r�r$r$r%r��sz OCIConnection._send_message_bodycs|jr
dStt|��|�Sr")rjrgrer|)r^r1rpr$r%r|�szOCIConnection.send)N)rbrcrd�__doc__r\rur�rr�r|�
__classcell__r$r$rpr%re�s
rec@seZdZeZdS)�OCIConnectionPoolN)rbrcrdreZ
ConnectionClsr$r$r$r%r��sr��httpsc
@s�eZdZeeejeee	e
d�ZdZdd�Z
dd�Zedd��Zejd	d��Zd
d�Zdd
�Zedd��Zejdd��Zedd��Zejdd��Zdd�Zdddddddddgf
dd�Zdd�Zdd�Zdd�Zd d!�ZdOd"d#�Zd$d%�ZdPd'd(�Zed)d*��Z d+d,�Z!dQd-d.�Z"d/d0�Z#d1d2�Z$d3d4�Z%d5d6�Z&dRd7d8�Z'dSd9d:�Z(dTd;d<�Z)dUd=d>�Z*d?d@�Z+dAdB�Z,dCdD�Z-dEdF�Z.dGdH�Z/edIdJ��Z0dKdL�Z1dMdN�Z2dS)V�
BaseClient)r�r9r1�boolrr�objectFc	Ks�t||d�||_||_|�dd�|_d|_|�d�|_|�d�|_|�d�|_|�d�|_	|�d�|_
|�d	�|_|jr�|�d
�r�|�d
�|_n`d}d|vr�|dr�|�d�}nt
|d�r�|j}|�||j|j�}tj||||�d�|j	d
�|_n"|�d
��s
t�d��|�d
�|_||_||_t|j|�|_t��|_d|v�rN|�d�nttf|_tt |d��|_!t"�#d�$t%t&|���|_'|j'�(t"�)��t |d��r�d|j'_*|j'�+t"j,�t-d�nd|j'_*t-d�|�d�|_.|�d�|_/d|_0|j/du�st1|j/t2��r|j'�3d�nzt1|j/t4��s(t5d��|j/j6du�rBt7t8�9��n|j/j6|_0t:�|j0�}|du�r�t;|j/j<|j/j=|j/j>|j0d�}||j?�|_?|j'�3d�$|j��dS)N)�signer�regional_clientT�	base_path�service_endpoint_template�#service_endpoint_template_per_realm�endpoint_service_name�allow_control_chars�5client_level_realm_specific_endpoint_template_enabledZservice_endpoint�region�endpoint�r�r�r�r�z>An endpoint must be provided for a non-regional service client�timeoutZadditional_user_agentrfZlog_requestsF�skip_deserialization�circuit_breaker_strategyz$No circuit breaker strategy enabled!z!Invalid Circuit Breaker Strategy!)�failure_threshold�recovery_timeout�expected_exception�namezEndpoint: {})@rr��configrsr��	_endpoint�
_base_pathr�r�r��_allow_control_chars�6_client_level_realm_specific_endpoint_template_enabledr��hasattrr�� handle_service_endpoint_templater�endpoint_forrZ/MissingEndpointForNonRegionalServiceClientError�service�complex_type_mappingsr&�primitive_type_map�
type_mappingsrZSession�session�DEFAULT_CONNECTION_TIMEOUT�DEFAULT_READ_TIMEOUTr�r/r�
user_agentrlrmr(rbrnroZ
addHandlerZNullHandlerZdisabledZsetLevel�DEBUGr5r�r��circuit_breaker_namer7r�debugr�	TypeErrorr�r1�uuid�uuid4rrr�r�r��request)	r^r�r�r�Ztype_mappingr`�
region_to_useZendpoint_template�circuit_breakerr$r$r%r\
s|

�



$
�zBaseClient.__init__cCs4|��}|r0|tjvr0tj|}||vr0||S|Sr")�should_allow_template_per_realmrZ
REGION_REALMS)r^Z	region_idr�r�Zshould_enable_realm_templateZrealmr$r$r%r�gs

z+BaseClient.handle_service_endpoint_templatecCs|jSr")r��r^r$r$r%r�rszBaseClient.endpointcCsR|jdkr||_n<|jrH|�|j�sH|�d�|j��sHd�||j�|_n||_dS)N�/z{}/z{}{})r�r��endswithr()r^r�r$r$r%r�vs

$cCs
t|j�Sr")rr�r�r$r$r%�get_endpoint�szBaseClient.get_endpointcCs>|jr2|�||j|j�}tj|j|||jd�|_nt	d��dS)N)r�r�r�zeSetting the region is not allowed for non-regional service clients. You must instead set the endpoint)
r�r�r�r�rr�r�r�r�r�)r^r�r�r$r$r%�
set_region�szBaseClient.set_regioncCs|jSr"�r�r�r$r$r%r��szBaseClient.allow_control_charscCs
||_dSr"r�)r^r�r$r$r%r��scCs|jSr")r�r�r$r$r%r��sz@BaseClient.client_level_realm_specific_endpoint_template_enabledcCsx||_d}d|jvr,|jdr,|j�d�}nt|jd�r@|jj}|�||j|j�}t	j
|j|||j�d�|jd�|_
dS)Nr�r�r�)r�r�rsr�r�r�r�r�r�rr�r�r�r�)r^r�r�r�r$r$r%r��s
�cCs`t|jtj�sTt|jtj�sTt|jtj�sTt|jtj�sTt|jtj�sTt|jtj�rXdSdSdS�NTF)	r7r�rZ%InstancePrincipalsSecurityTokenSignerZ"ResourcePrincipalsFederationSignerZ EphemeralResourcePrincipalSignerZ#EphemeralResourcePrincipalV21SignerZNestedResourcePrincipalsZ*OkeWorkloadIdentityResourcePrincipalSignerr�r$r$r%�2is_instance_principal_or_resource_principal_signer�s�����z=BaseClient.is_instance_principal_or_resource_principal_signerNTc

Cs |rFtr|��dvr<dd�|D�}
d|
vr<|�|
�d�d�|�|�}|pLi}t|�}t|tj<|j	|tj
<|�tjt�tur�|�
�|tj<tj�d�}|r�||d<|r�|�|�}|��D]6\}}tjjj�t|�|���}|�d|d	|�}q�|�r|�|�}|du�r0|�d
�dk�r0|�|�}t�|�}|�|||�}||}t|||||||d�}|���r�d
}|dk�rz|�||	|
|�WSt j!�y�}z8|d7}|j"dk�r�|dk�r�|j#�$�n�WYd}~n
d}~00�qjn:t%�}|�||	|
|�}t%�}|j&�'d�(t||���|SdS)a5
        Makes the HTTP request and return the deserialized data.

        :param resource_path: Path to the resource (e.g. /instance)
        :param method: HTTP method
        :param path_params: (optional) Path parameters in the url.
        :param query_params: (optional) Query parameters in the url.
        :param header_params: (optional) Request header params.
        :param body: (optional) Request body.
        :param response_type: (optional) Response data type.
        :param enforce_content_headers: (optional) Whether content headers should be added for
            PUT and POST requests when not present.  Defaults to True.
        :param allow_control_chars: (optional) Boolean that allows whether or not the response object can contain control chars
        :param operation_name: (optional) String that represents the operational name of the API call.
        :param api_reference_link: (optional) String that represents the link to the API reference page for this operation.
        :return: A Response object, or throw in the case of an error.

        )ZputZpostZpatchcSsi|]}|��|�qSr$)�lower��.0�kr$r$r%�
<dictcomp>�ryz'BaseClient.call_api.<locals>.<dictcomp>rrNZOCI_DB_OPC_HOST_SERIALzopc-host-serial�{�}�content-typer>)rvrw�query_params�
header_paramsrx�
response_type�enforce_content_headersrrOri�ztime elapsed for request: {}))�enable_expect_headerr�rZrs�sanitize_for_serializationr;r)rZHEADER_CLIENT_INFOr�ZHEADER_USER_AGENT�HEADER_REQUEST_ID�missing�build_request_id�os�environ�itemsr	r3Zurllibr�quoter1�
to_path_value�replace�process_query_params�json�dumps�!handle_service_params_in_endpointrr�r�r�ServiceError�statusr�Zrefresh_security_token�timerror�r()r^�
resource_pathrv�path_paramsr�r�rxr�r�r��operation_name�api_reference_link�required_argumentsZ/map_lowercase_header_params_keys_to_actual_keysZopc_host_serialr��vZreplacementr�rwr�Z
call_attempts�e�start�response�endr$r$r%�call_api�sj


�


�


zBaseClient.call_apic	Cs�i}ttdd�|�dd��d���d���}|D]�}d}d|vrZd}|�d�}	|d|	�}||vr�||vsr||vr�||vr�||n||}
|r�|
d7}
|
||d<q�|
||<q0|r�d||d<q0d||<q0|S)	Nr'�.r�r�Fz+DotTr)�set�filterrKr�rR�find)r^�service_params_urlr�r�r��service_params_mapZservice_params�
service_paramZshould_append_dotZdot_idx�valuer$r$r%�map_service_params_to_valuess$(


z'BaseClient.map_service_params_to_valuescCsr|j}td�}||dkrn|�d�}|||d�}|�||||�}|��D] \}	}
d|	d}	|�|	|
�}qL|S)Nzhttps://r�r�r)r�rS�rfindr�r�r�)r^r�r�r�r�Z	start_idxZend_idxr�r�r�r�r$r$r%r�6s
z,BaseClient.handle_service_params_in_endpointcCsJ|turtS|tvr,td�|tt������|dkr8|St|�|�SdS)Nz6Invalid collection format type {}. Valid types are: {}rB)r��VALID_COLLECTION_FORMAT_TYPES�
ValueErrorr(�list�keysrK)r^Zparam_valueZcollection_format_typer$r$r%� generate_collection_format_paramDsz+BaseClient.generate_collection_format_paramcCs�|�|�}i}|��D]~\}}t|t�r:|r0dnd||<qt|t�s^t|t�s^|�|�||<qt|t�rr|||<q|��D]\}}||d�||�<qzq|S)N�truer!rf)r�r�r7r��dictr�r�r()r^r�Zprocessed_query_paramsr�r�Z	inner_keyZ	inner_valr$r$r%r�Ps



zBaseClient.process_query_paramsc
Cs"|j�t�dt|j�|jf�d}|jrVt�|j�j	}|t
jkrV|j�d�
|��|j}|jsh|j}d}|jtkrzd}t|j�dd�vr�d}z�t�}|jj|j|j||j|j|j||jd�}	t�}
|jtjr�|j�t�d�
|jtjt|
|���|	�r*t|	d	��r*|j�t�d
t|	j��Wn�tj j!�y�}zL|j"�sPd|_"|j"d|jd
|jd�
t#�f|_"t �!|��WYd}~nrd}~0tj j$�y�}zL|j"�s�d|_"|j"d|jd
|jd�
t#�f|_"t �$|��WYd}~n
d}~00|j}|j�t�dt|	j%��d|	j%k�r<dk�sVn|j&}
|jd
|j}t'}t(�)t*j+��,�}|�-|	|�\}}}|	j%dk�r�|dk�r�|j�.d�
|
��|	j/}|	�0�t1�1|j�}|j�0�||_t2|j3t4��r8|j3�5|	j%|��r8t�|j�j	}||k�r|j�.d�
||��|�6||	|||||
||||�n|�7||	|||||
||||�|�r�|	j8�dd��9�tk�r�|j�.d�t:�;|	�}n>|�r�|tk�r�|	j8�dd��9�t<k�r�|�=|	j/||�}n|	}n.|t>k�r�|	j/}n|�r�|�=|	j/||�}nd}t?|	j%|	j8||�}|j�t�d�|S)NzRequest: %s %szCircuit Breaker State is {}!FTZaccept�empty)�auth�paramsr:�datar<r�ztime elapsed for request {}: {}�elapsedztime elapsed in response: )r'zRequest Endpoint: r0zd See {} for help troubleshooting this error, or contact support and provide this full error message.zResponse status: %s��i+i�ZRequestEntityTooLargez?Recieved a 413/RequestEntityTooLarge from {}, resetting sessionz+Circuit Breaker state changed from {} to {}r�z.Received SSE response, returning an SSE clientzResponse returned)@ro�infor2r1rvrwr�rrs�state�circuitbreakerZSTATE_CLOSEDr�r(r�r�Zwithout_content_headersr��STREAM_RESPONSE_TYPE�SSE_RESPONSE_HEADER_VALUEr�r�r�r�r�rxr�rr�r�rrrZConnectTimeoutr_�TROUBLESHOOT_URLZRequestException�status_coder�r)rZnowr�utc�	isoformat�)get_deserialized_service_code_and_messageZwarning�contentr��copyr7r�rZis_transient_error�raise_transient_service_error�raise_service_errorr:r�rZ	SSEClient�%APPLICATION_JSON_CONTENT_HEADER_VALUE�deserialize_response_data�BYTES_RESPONSE_TYPEr)r^r�r�r�r�Zinitial_circuit_breaker_stater�r<r�r�r�r�r��target_service�request_endpoint�client_version�	timestamp�service_code�message�deserialized_data�_Znew_sessionZnew_circuit_breaker_stateZrespr$r$r%r��s�"

�	* (( 
 
 (
zBaseClient.requestcCstt����dd���S)N�-r')r1r�r�r��upperr�r$r$r%r��szBaseClient.build_request_id�cCs(d|vr$d�dd�t|�D��|d<dS)Nzopc-retry-tokenr'css$|]}t���tjtj�VqdSr")�randomZSystemRandom�choice�string�
ascii_letters�digits)r�rr$r$r%�	<genexpr>�ryz;BaseClient.add_opc_retry_token_if_needed.<locals>.<genexpr>)rK�range)r^r�Zretry_token_lengthr$r$r%�add_opc_retry_token_if_needed�sz(BaseClient.add_opc_retry_token_if_neededcCsd|vrd|d<dS)Nzopc-client-retriesr�r$)r�r$r$r%�add_opc_client_retries_header�sz(BaseClient.add_opc_client_retries_headercCs"t|�tkrd�|�St|�SdS)z�
        Takes value and turn it into a string suitable for inclusion in
        the path, by url-encoding.

        :param obj: object or string value.

        :return string: quoted value.
        r?N)�typer�rKr1�r^�objr$r$r%r��s	
zBaseClient.to_path_valuec
s�tjtjtttd�f}tjtttjfttjfd�}�r����s��d�rdt�t	�sd��
����n���d�r�t�t�s�t�t�s���
����nX��j
vr�t�t	�s�t��j
��s��
����n$�|vr�t�|��s��
����t�|�r��S�tu�rdSt�t��st�t��r4���fdd��D�St�t��rl�j�sTtj������tj����dd�St�t��r����St�t	��r��}d}��r������fd	d
�|D�}nZt�d��s�td�t��t��j�����fd
d
��j��D�}�fdd
�t� �j�D�}i}t� |�D]X\}	}
d}|	}|�rN||	d}||	d}��r`d��|�n|}��!|
||�||	<�q |SdS)a�
        Builds a JSON POST object.

        If obj is str, int, float, bool, None, return directly.
        If obj is datetime.datetime, datetime.date
            convert to string in iso8601 format.
        If obj is list, sanitize each element in the list.
        If obj is dict, return the dict.
        If obj is swagger model, return the properties dict.

        :param obj: The data to serialize.
        :return: The serialized form of data.
        N)r1r�r�r9�dict(�list[cs4g|],}��|�r����nd�r*�dnd��qS)Nz[*])r��(extract_list_item_type_from_swagger_type)r�Zsub_obj)�
declared_type�
field_namer^r$r%�
<listcomp>5s��z9BaseClient.sanitize_for_serialization.<locals>.<listcomp>z+00:00�Zcsi|]}|�|f�qSr$r$r�)�dict_value_typer$r%r�Iryz9BaseClient.sanitize_for_serialization.<locals>.<dictcomp>�
swagger_typesz7Not able to serialize data: {} of type: {} in field: {}cs0i|](\}}t�|�dur�j|t�|��qSr")�getattr�
attribute_map)r��attrr�r,r$r%r�Os�cs i|]\}}�j|||f�qSr$)r7)r�r8�swagger_typer9r$r%r�Sryrrrf)"r	�string_typesr8r9r�r*�is_none_or_none_sentinelrTr7r��"raise_type_error_serializing_modelr��tupler�rr�tzinfo�pytzrZlocalizeZ
astimezoner
r�r�)extract_dict_value_type_from_swagger_typer�r�r(r1rbr5r�r6r�)
r^r,r0r1�typesZ0declared_swagger_type_to_acceptable_python_typesZobj_dictZkeys_to_types_and_field_nameZsanitized_dict�key�valZvalue_declared_typeZinner_field_namer$)r0r4r1r,r^r%r�
sh�	


�

�z%BaseClient.sanitize_for_serializationcCs|dup|tuSr")rr+r$r$r%r<bsz#BaseClient.is_none_or_none_sentinelcCs"td�|t|�|t|�j���dS)NzGField {} with value {} was expected to be of type {} but was of type {})r�r(r1r*rb)r^r1r,r0r$r$r%r=esz-BaseClient.raise_type_error_serializing_modelcCs t�|�}d}|r|�d�}|S�Nr)�DICT_VALUE_TYPE_REGEX�search�group�r^r:�m�resultr$r$r%rAhs


z4BaseClient.extract_dict_value_type_from_swagger_typecCs t�|�}d}|r|�d�}|SrE)�LIST_ITEM_TYPE_REGEXrGrHrIr$r$r%r/qs


z3BaseClient.extract_list_item_type_from_swagger_typecCs*tj|j||j|||||||	|
|d��dS�N)Zoriginal_requestr�r�rrrrr)rr�rr:�r^r�r�rrr�r�rrrrrr$r$r%rzs�zBaseClient.raise_service_errorcCs*tj|j||j|||||||	|
|d��dSrM)rZTransientServiceErrorrr:rNr$r$r%r�s�z(BaseClient.raise_transient_service_errorcCsF|�|jd|�}d}d}t|t�r8|�d�}|�d�}n|}|||fS)Nr��coder)rrr7r�rs)r^r�r�rrrr$r$r%r�s

z4BaseClient.get_deserialized_service_code_and_messagec	Cs�|�d�}z8|�|�}tj||d�}|dks<t|�tjkr@|}WntyTYn0|jr`|St	�}|�
||�}t	�}|j�t
�d�t||���|SdS)ai
        Deserializes response into an object.

        :param response_data: object to be deserialized.
        :param response_type: class literal for
            deserialized object, or string of class name.
        :param allow_control_chars: boolean to allow control character in a response. Defaults to None

        :return: deserialized object.
        �utf8)�strictr1z-python SDK time elapsed for deserializing: {}N)r��should_allow_control_charsr��loadsr*r	rHr�r�r��_BaseClient__deserializeror�r2r(r1)	r^Z
response_datar�r�rRZ
json_responser��resr�r$r$r%r�s


 z$BaseClient.deserialize_response_datacs|durdS|�d�r<t�d|��d����fdd�|D�S|�d�rpt�d|��d	����fd
d�|��D�S|�jvr��j|}n��||�St|d�r�|�|�}�j|}|t	t
tjt
fvrΈ�||�S|tkr�|S|tkr��|�S|tk�r��|�S��||�SdS)
z�
        Deserialize a dict, list, or str into an object.

        :param data: dict, list or str
        :param cls: string of class name

        :return: object.
        Nr.zlist\[(.*)\]rcsg|]}��|���qSr$�rT)r�Zsub_data�r^Zsub_klsr$r%r2�s�z,BaseClient.__deserialize.<locals>.<listcomp>r-zdict\(([^,]*), (.*)\)rOcsi|]\}}|��|���qSr$rV)r�r�r�rWr$r%r��s�z,BaseClient.__deserialize.<locals>.<dictcomp>�get_subtype)rT�re�matchrHr�r��"_BaseClient__deserialize_primitiver�rXr�r9r	�ur�r�r�_BaseClient__deserialize_dater�!_BaseClient__deserialize_datetime�_BaseClient__deserialize_model)r^r�clsr$rWr%Z
__deserialize�s6	
�
�






zBaseClient.__deserializecCsBz||�}Wn0ty(t�|�}Ynty<|}Yn0|S)z�
        Deserializes string to primitive type.

        :param data: str.
        :param cls: class literal.

        :return: int, float, str, bool.
        )�UnicodeEncodeErrorr	r\r�)r^rr`r�r$r$r%Z__deserialize_primitive�s	
z"BaseClient.__deserialize_primitivecCsHzt|���WSty$|YStyBtd�|���Yn0dS)zb
        Deserializes string to date.

        :param string: str.
        :return: date.
        z(Failed to parse `{0}` into a date objectN)rr�ImportErrorr��	Exceptionr()r^r#r$r$r%Z__deserialize_dateszBaseClient.__deserialize_datecCs�z"t�|d�}|jt��d�}|WSty|zt|�WYStyX|YYStyvtd�	|���Yn0Ynty�|YS0dS)z�
        Deserializes string to datetime.

        The string should be in iso8601 datetime format.

        :param string: str.
        :return: datetime.
        z%Y-%m-%dT%H:%M:%S.%fZ)r?z,Failed to parse `{0}` into a datetime objectN)
r�strptimer�r
Ztzutcr�rrbrcr()r^r#Z
naivedatetimeZ
awaredatetimer$r$r%Z__deserialize_datetimes	z!BaseClient.__deserialize_datetimecCsL|�}|j��D]6\}}|j|}||vr||}t|||�||��q|S)z�
        Deserializes list or dict to model.

        :param data: dict, list.
        :param cls: class literal.
        :return: model object.
        )r5r�r7�setattrrT)r^rr`�instancer8Z	attr_type�propertyr�r$r$r%Z__deserialize_model7s
zBaseClient.__deserialize_modelcCs(d}|r|}n|r|}ntjr$tj}|S)a

        Gets the preferred Retry Strategy for the client
        :param operation_retry_strategy: (optional) Operation level Retry Strategy
        :param client_retry_strategy: (optional) Client level Retry Strategy
        :return: Preferred Retry Strategy.
        N)rZGLOBAL_RETRY_STRATEGY)Zoperation_retry_strategyZclient_retry_strategyZretry_strategyr$r$r%�get_preferred_retry_strategyIsz'BaseClient.get_preferred_retry_strategycCs8|}|j}tj}|dur|S|dur(|S|dur4dSdSr�)r�r��ALLOW_CONTROL_CHARACTERS)r^r�Zrequest_configuration�client_configurationZglobal_configurationr$r$r%rRZsz%BaseClient.should_allow_control_charscCs6|j}tj�t�}|dur|S|dur2|��dkSdS)z�
        Returns a boolean of whether or not we should use realm specific endpoint templates

        The highest precedence goes in decending order. The order: Client / Environment / Default (False)
        Nr�F)r�r�r�rsr r�)r^rjZenv_configurationr$r$r%r�msz*BaseClient.should_allow_template_per_realm)NNN)r )NN)NNNNNNN)NNNNNNN)N)N)3rbrcrdr�r9r	r\r�rrr�r�rir\r�rgr��setterr�r�r�r�r�r�r�r�r�r�r�r�r(�staticmethodr)r�r�r<r=rAr/rrrrrTr[r]r^r_rhrRr�r$r$r$r%r�s��
Z





�
e>
b


X		



*,
r�)r')cZ
__future__rr�rlr*rr@r!r�rYr#r�rZ	_strptimerrrZtimeitrr�Z_vendorrr	r
rZdateutil.parserrZdateutilr
r�Zsix.moves.http_clientrr'rrrrrrr�rrr�rr�rr�rrrr�versionrr}rrrr�ZAPPEND_USER_AGENT_ENV_VAR_NAMEr r�rsr.r(r)�compilerFrLr
r�Zexpect_header_env_varr7r;r�r&r/r2r5r;rrr	rr�r�r�rGrNrWrXZ
connectionZVerifiedHTTPSConnectionreZHTTPSConnectionPoolr�ZpoolmanagerZpool_classes_by_schemer�r�r$r$r$r%�<module>s�




	�	T