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__/util.cpython-39.opt-1.pyc
a

���fA4�@s�ddlmZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
ddlZzddl
mZWney�ddlmZYn0ddlmZddlZe�e�Ze�e�ZdZdZdZd	Zd
ZdZdeZd
eZzddlmZWne�yddl ZYn0e!�Z"dd�Z#dd�Z$dd�Z%dd�Z&Gdd�de!�Z'e'ddd�Z(e'ddd�Z)dd�Z*dd�Z+ee*ee+iZ,d d!�Z-d"d#�Z.efd$d%�Z/d&d'�Z0d(d)�Z1d*d+�Z2d,d-�Z3d.d/�Z4d0d1�Z5d2d3�Z6d4d5�Z7dS)6�)�absolute_importN)�six)�urlparse)�SEEK_SETZinstance_principalZ(delegation_token_with_instance_principalZresource_principalZdelegation_token_fileZauthentication_typei�d�cCs�t|tj�r|S|turdSt|tjtjf�r`|js@tj�	|�}t|tj�rX|j
dd�S|�
�St|tj�rt|�
�St|tj
�r�dd�t�|�D�St|tj�r�dd�|D�St|d�s�|Si}t�|j�D]$}t||t�}|tur�t|�||<q�|S)	z�Helper to flatten models into dicts for rendering.

    The following conversions are applied:

    * datetime.date, datetime.datetime, datetime.time
      are converted into ISO8601 UTC strings
    N�T)�sepcSsi|]\}}|t|��qS���to_dict)�.0�k�vr
r
�,/usr/lib/python3.9/site-packages/oci/util.py�
<dictcomp>I�zto_dict.<locals>.<dictcomp>cSsg|]}t|��qSr
r)r
rr
r
r�
<listcomp>Krzto_dict.<locals>.<listcomp>�
swagger_types)�
isinstancerZstring_types�
NONE_SENTINEL�datetime�timeZtzinfo�pytzZutcZlocalizeZ	isoformat�date�abc�MappingZ	iteritems�Iterable�hasattrZiterkeysr�getattr�missing_attrr)�obj�as_dict�key�valuer
r
rr0s0	
rcCst|�}tj|ddd�S)z9Returns a string of the model flattened as a dict, sorted�T)�indentZ	sort_keys)r�json�dumps)Zmodelr"r
r
r�formatted_flat_dictYs�r)cCs|dup|tup||vS�N)r)Z
value_to_testZallowed_valuesr
r
r�#value_allowed_none_or_none_sentinelcsr+cCsVtj�tj�|��}t|d��}|��}Wd�n1s<0Yt�|��d�S)a�
    Takes a file path and returns a Base64-encoded string which can be provided as the value of the ``user_data`` key
    in the ``metadata`` dictionary when launching an instance(see :py:class:`~oci.core.models.LaunchInstanceDetails`
    for more information).

    :param str file_path:
      The path to the file whose contents will be Base64-encoded

    :return: The Base64-encoded string
    :rtype: str
    �rbNzutf-8)	�os�path�
expandvars�
expanduser�open�read�base64Z	b64encode�decode)Z	file_path�	full_path�fZ
file_contentsr
r
r�)file_content_as_launch_instance_user_datags
&r7csDeZdZdZiZd�fdd�	Zddd�Zdd�Zd	d
�ZeZ	�Z
S)
�Sentinela�Named singletons for clear docstrings.
    Also used to differentiate an explicit param of None from a lack of argument.

    .. code-block:: pycon

        >>> missing = Sentinel("Missing", False)
        >>> also_missing = Sentinel("Missing", False)
        >>> assert missing is also_missing
        >>> repr(missing)
        <Missing>
        >>> assert bool(missing) is False
    TcsNtj�|d�}|dur2tt|��|�}tj|<n|j|urJtd�|���|S)Nz;Tried to get existing Sentinel {!r} with wrong truthy value)r8�_symbols�get�super�__new__�truthy�
ValueError�format)�cls�namer=�sentinel��	__class__r
rr<�s
zSentinel.__new__cCs||_||_dSr*�rAr=)�selfrAr=r
r
r�__init__�szSentinel.__init__cCsd�|j�S)Nz<{}>)r?rA�rFr
r
r�__repr__�szSentinel.__repr__cCs|jSr*)r=rHr
r
r�__bool__�szSentinel.__bool__)T)T)�__name__�
__module__�__qualname__�__doc__r9r<rGrIrJZ__nonzero__�
__classcell__r
r
rCrr8{s
r8�NoneFrEZWaitResourceNotFoundcCs�ddlm}i}|�t�}|dur4tj�d�t���tj	�
|�}tj	�|�s^tj�d�|���t|dd��}|�
���}Wd�n1s�0Y|dur�tj�d��||d<|fi|��S)	Nr)�'InstancePrincipalsDelegationTokenSignerzERROR: {} was not provided.z,ERROR: delegation token file not found at {}�r)�modez)ERROR: delegation_token was not provided.�delegation_token)�oci.auth.signersrQr:� DELEGATION_TOKEN_FILE_FIELD_NAME�oci�
exceptions�
InvalidConfigr?r-r.r0�isfiler1r2�strip)�configrQZ
signer_kwargsZdelegation_token_file_pathZ#expanded_delegation_token_file_pathr6rTr
r
r�4_get_signer_from_delegation_token_instance_principal�s
*r]cCsddlm}|�S)Nr)�get_resource_principal_signer)rUr^)r\r^r
r
r�#_get_signer_from_resource_principal�sr_cCst|�}t�|�}||�Sr*)�#get_authentication_type_from_config� AUTH_TYPE_TO_SIGNER_FUNCTION_MAPr:)r\�	auth_typeZsigner_functionr
r
r�#get_signer_from_authentication_type�s
rccCs`|�t�}|dur td�t���|tkrJt|vr4tStj�	d�tt���ntj�	d�|���dS)Nz{} not providedzAThe authentication type {} requires config values for the keys {}z+The authentication type {} is not supported)
r:�AUTHENTICATION_TYPE_FIELD_NAMEr>r?�1INSTANCE_PRINCIPAL_AUTHENTICATION_TYPE_VALUE_NAMErV�<DELEGATION_TOKEN_WITH_INSTANCE_PRINCIPAL_AUTHENTICATION_TYPErWrXrY)r\rbr
r
rr`�s
r`c	Cs�t�d�z�d}t}d}d}d}|r�t|d�r<|j�|�}nt|d�rR|�|�}ntd��t|�dkrjd	}||7}|t|�7}|r ||kr td
��q ||d�WSt	t
fy�td��Yn0dS)
Nz�Reading the stream to calculate its content-length. Process may freeze for very big streams. Consider passing in content length for big objectsTr�r�bufferr2zuStream object does not contain a 'read' property. Cannot auto calculate content length, please pass in content lengthFz{Stream size is greater than the buffer_limit, please pass in a bigger buffer_limit or pass in content length to the request)�content_length�byte_contentzRStream object's content length cannot be calculated, please pass in content length)�logger�warning�DEFAULT_PART_SIZErrhr2�	TypeError�len�BufferError�IOError�OSError)�streamZbuffer_limitZkeep_readingZ	part_sizeriZcontentrjr
r
r�,back_up_body_calculate_stream_content_length�s,



rtcCs:t|d�s(t|d�s(t|d�s(t|d�r,dSt�d�dS)N�__len__ro�fileno�tellTz�Request did not contain content-length and stream object does not contain fileno or tell property. Stream object will be read to calculate content-lengthF)rrkrl)�or
r
r�(is_content_length_calculable_by_req_utils(
rycCst|�}|jd|jS)a
    Takes a Service Endpoint with base-path embedded and extracts the Service Endpoint from it.

    :param str endpoint_with_base_path:
    Service Endpoint with base-path embedded

    :return: The Service Endpoint without base-path.
    :rtype: str
    z://)r�scheme�netloc)Zendpoint_with_base_pathZparsed_endpointr
r
r�extract_service_endpoints
r|cKs2|j}|dkr.|�d�}|r*t|d�r*dSdSdS)NZcall_api�bodyr2TF)rKr:r)Zfunc_refZfunc_kwargsZ	func_namer}r
r
r�%should_record_body_position_for_retrys
r~c	Csfd}t|dd�durLz|��}Wq^ttfyHd}d}t�d�Yq^0nd}d}t�d�||fS)NTrwFzVUnable to record body position for rewinding. This request will not be retried/rewound)rrwrqrrrkrl)r}Zis_body_rewindable�
body_positionr
r
r�record_body_position_for_rewind!s
r�c	CsVt|dd�durHz|�|t�Wn"ttfyBt�d�YdS0dSt�d�dS)N�seekzUUnable to reset body position for rewinding. This request will not be retried/rewoundFT)rr�rrqrrrkrl)r}rr
r
r�rewind_body4s

r�c	Cs�d}zZd}t|d�r |�t�}nt|d�r6|j�t�}t|�dkrDq\|t|�7}|�|�qWn$ttfy�t�	d�d}Yn0|S)Nrrgr2rhz&Unable to read stream body for signing���)
rr2rmrhro�updaterqrrrkrl)Zsigning_algorithmr}Z
bytes_read�chunkr
r
r�read_stream_for_signingBs



r�cCs t�dd|�}t�dd|���S)Nz(.)([A-Z][a-z]+)z\1_\2z([a-z0-9])([A-Z]))�re�sub�lower)rA�s1r
r
r�camel_to_snakeUsr�cCs&i}|��D]\}}||t|�<q|Sr*)�itemsr�)Z
dictionaryZoutdictrrr
r
r�camel_to_snake_keysZsr�)8Z
__future__rr3rr'r�r-Zos.pathrZoci._vendorrZoci.exceptionsrW�urllib.parser�ImportError�iorZloggingZ	getLoggerrKrkrerfZ&RESOURCE_PRINCIPAL_AUTHENTICATION_TYPErVrdZMEBIBYTE�DEFAULT_BUFFER_SIZErm�collections.abcr�collections�objectr rr)r+r7r8rZWAIT_RESOURCE_NOT_FOUNDr]r_rarcr`rtryr|r~r�r�r�r�r�r
r
r
r�<module>sj

)
%	�