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__/config.cpython-39.pyc
a

���f�'�@sXdZddlmZddlZddlZddlZddlZddlmZddl	m
Z
mZmZm
Z
ddlmZddlmZmZmZmZgd	�Zd
ddd�Zej�d
dd�Zej�d
dd�ZdZe�d�e�d�e�d�d�Zhd�ZddiZdhZ dZ!dZ"dZ#dZ$e�%e&�Z'dd�Z(ee(iZ)eefdd�Z*d d!�Z+d"d#�Z,d$d%�Z-d&d'�Z.d(d)�Z/d*d+�Z0d,d-�Z1dS).a�
Helpers for loading and validating service configuration.

You can configure services by passing a config dict directly, or by loading
one from a configuration file.

The following keys are required::

    fingerprint
    key_file
    region
    tenancy
    user

Additionally, the following keys are optional::

    additional_user_agent (default "")
    log_requests (default False)
    pass_phrase (required if your key_file has a passphrase)

�)�absolute_importN)�six�)�ConfigFileNotFound�ProfileNotFound�
InvalidConfig�InvalidKeyFilePath)�signers)�AUTHENTICATION_TYPE_FIELD_NAME�#get_authentication_type_from_config� DELEGATION_TOKEN_FILE_FIELD_NAME�<DELEGATION_TOKEN_WITH_INSTANCE_PRINCIPAL_AUTHENTICATION_TYPE)�DEFAULT_CONFIG�	from_file�validate_configF�)�log_requestsZadditional_user_agentZpass_phrase�~z.oci�configz
.oraclebmcZDEFAULTz>^([0-9a-zA-Z-_]+[.:])([0-9a-zA-Z-_]*[.:]){3,}([0-9a-zA-Z-_]+)$z^([0-9a-f]{2}:){15}[0-9a-f]{2}$)�tenancy�user�fingerprint>�key_file�regionrrrrZkey_contentZOCI_CONFIG_FILEZ
OCI_REGIONrz�For more info about config file and how to get required information, see https://docs.oracle.com/en-us/iaas/Content/API/Concepts/sdkconfig.htmcCsD|�t�}|durtd��tj�|�}tj�|�s@td�|���dS)NzNERROR: Please specify the location of the delegation_token_file in the config.z%Delegation token file not found at {})�getrr�os�path�
expanduser�isfile�format)rZdelegation_token_file_pathZ#expanded_delegation_token_file_path�r �./usr/lib/python3.9/site-packages/oci/config.py�2_validate_delegation_token_with_instance_principalLs
r"cCs�t|�}tjdd�}|�|�s,td�|���||vrHtd�||�t��tt	�}|�
||�t|d�|d<tD]}||vrrt
d�|�t��qrt|||�|S)a�Create a config dict from a file.

    :param file_location: Path to the config file.  Defaults to ~/.oci/config and with a fallback
                            to environment variable OCI_CONFIG_FILE, then ~/.oraclebmc/config.
    :param profile_name: The profile to load from the config file.  Defaults to "DEFAULT"
    :return: A config dict that can be used to create clients.
    N)Z
interpolationz�Could not find config file at {}, please follow the instructions in the link to setup the config file https://docs.cloud.oracle.com/en-us/iaas/Content/API/Concepts/sdkconfig.htmz)Profile '{}' not found in config file {} rz�'{}' cannot be specified in a config file for security reasons. To use this key you must add it to the config programmatically. )�_get_config_path_with_fallback�configparserZConfigParser�readrrr�!CONFIG_FILE_DEBUG_INFORMATION_LOG�dictr�update�_as_bool�CONFIG_FILE_BLACKLISTED_KEYS�
ValueError�invalid_key_file_path_checker)�
file_location�profile_name�expanded_file_location�parserr�keyr r r!r_s
rc
KsDd|vr<t|dtj�s8t|dtj�s8t|dtj�r<dSt|vrbt|�}t�|�}||�dSi}t	D]�}t
�|�}||vs�||durj||vs�||durj|tkr�t�
d�t��tj�t�}|r�t�
d�t��||t<q�d||<qjd||<qjt�t�D]0\}}	||v�r�q|	�||��sd||<�q|�r@t|��dS)NZsignerz<Region not found in config, checking environment variable {}z+Setting region from environment variable {}�missingZ	malformed)�
isinstancer	Z%InstancePrincipalsSecurityTokenSignerZSecurityTokenSignerZ
KeyPairSignerr
r�$AUTH_TYPE_TO_VALIDATION_FUNCTION_MAPr�REQUIRED�REQUIRED_FALLBACKS�REGION_KEY_NAME�logger�debugr�REGION_ENV_VAR_NAMEr�environrZ	iteritems�PATTERNS�matchr)
r�kwargsZ	auth_typeZvalidator_function�errorsZrequired_keyZfallback_keyZregion_from_env_varr1�patternr r r!r}s60

(



rcCs|�|t�|��S)N)rr)rr1r r r!�get_config_value_or_default�srAcCs>|dvr|S|��dvrdS|��dvr,dStd�|���dS)N)TF)�1Zyes�trueZonT)�0�noZfalseZoffFz({!r} is not a valid alias for True/False)�lowerr+r)�xr r r!r)�sr)cCs6t|�dkr td�|d���n|r2td�|���dS)NrzError in config: {}rz'Found the following config errors: {!r})�lenr+r)r?r r r!�_raise_on_errors�srIcCs�tj�|�}tj�t�}|tks4|tkrHtj�|�rHt�d�|��|Stj	�
t�r|t�d�t��tj�tj	�
t��}|Stj�|�r�|}|St�d�|��|S)NzConfig file found at {}znNo file location specified and default file does not exist. Getting path info from the environment variable {})rrr�FALLBACK_DEFAULT_LOCATION�DEFAULT_LOCATIONrr8r9rr;r�CONFIG_FILE_PATH_ENV_VAR_NAME)r-r/Z'expanded_fallback_default_file_locationr r r!r#�s$��r#cCshd|vrdtj�|�d��}tj�|�sdt|�d�||�}|rFd�|�nd}d�|||�t}t|��dS)Nrz at line {}rzRConfig file {} is invalid: the key_file's value '{}'{} must be a valid file path. )	rrrrr�get_linenum_from_filerr&r)rr/r.Z
key_file_path�line_numberZline_message�messager r r!r,�sr,cCs�t|d���}d}d|d}t|�D]\\}}|��}t|�dkrN|ddkrNq$||vrZd}|r$||vr$|dWd�Sq$Wd�n1s�0YdS)	N�rF�[�]rr�#T)�open�	enumerate�striprH)r1�filenameZprofile�fZ
profile_foundZ
profile_tokenrN�liner r r!rM�s:rM)2�__doc__Z
__future__rr$r�reZloggingZoci._vendorr�
exceptionsrrrrZauthr	�utilr
rrr
�__all__rr�joinrKrJZDEFAULT_PROFILE�compiler<r5r6r*rLr:r7r&Z	getLogger�__name__r8r"r4rrrAr)rIr#r,rMr r r r!�<module>sT����
�*