
    ch                        S SK Jr  S SKJrJr  S SKJr  S SKJ	r	J
r
  SSKJr  \	(       a  S SKJq  S SKJq  S S	KJq  S S
KJr  OSqSqSqSS jr " S S\\\
\   4   5      r " S S\5      rSS/rg)    )annotations)IteratorMapping)cached_property)TYPE_CHECKINGOptional   )EnvSettingsSourcedefaultCredentialsSecretManagerServiceClient)BaseSettingsNc                 f     SSK Jq  SSKJq  SSKJq  g ! [         a  n [        S5      U eS n A ff = f)Nr   r   r   r   zjGCP Secret Manager dependencies are not installed, run `pip install pydantic-settings[gcp-secret-manager]`)google.authr   google_auth_defaultgoogle.auth.credentialsr   google.cloud.secretmanagerr   ImportError)es    _/var/www/html/shao/venv/lib/python3.13/site-packages/pydantic_settings/sources/providers/gcp.pyimport_gcp_secret_managerr      s3    
>7I x
	s    
0+0c                      \ rS rSr% S\S'   S\S'   SS jr\SS j5       r\SS j5       r	SSS	 jjr
SS
 jrSS jrSS jrSrg)GoogleSecretManagerMapping$   zdict[str, str | None]_loaded_secretsr   _secret_clientc                6    0 U l         Xl        X l        X0l        g N)r   r   _project_id_case_sensitive)selfsecret_client
project_idcase_sensitives       r   __init__#GoogleSecretManagerMapping.__init__(   s    !+%-    c                L    U R                   R                  U R                  5      $ r!   )r   common_project_pathr"   r$   s    r   _gcp_project_path,GoogleSecretManagerMapping._gcp_project_path.   s    ""66t7G7GHHr*   c                0   / nU R                   R                  U R                  S9nU Hj  nU R                   R                  UR                  5      R                  SS5      nU R                  (       d  UR                  5       nUR                  U5        Ml     U$ )N)parentsecret )	r   list_secretsr.   parse_secret_pathnamegetr#   lowerappend)r$   rvsecretsr2   r6   s        r   _secret_names(GoogleSecretManagerMapping._secret_names2   s~    %%22$:P:P2QF&&88EII(TVWD''zz|IIdO	 
 	r*   c                N    U R                   R                  U R                  X5      $ r!   )r   secret_version_pathr"   )r$   keyversions      r   _secret_version_path/GoogleSecretManagerMapping._secret_version_path>   s!    ""66t7G7GVVr*   c                   U R                   (       d  UR                  5       nXR                  ;  as  XR                  ;  a  [	        U5      e U R
                  R                  U R                  U5      S9R                  R                  R                  S5      U R                  U'   U R                  U   $ ! [         a    [	        U5      ef = f)N)r6   zUTF-8)r#   r8   r   r<   KeyErrorr   access_secret_versionrB   payloaddatadecode	Exception)r$   r@   s     r   __getitem__&GoogleSecretManagerMapping.__getitem__A   s    ##))+C***,,,sm#$,0,?,?,U,U2237 -V -'$$vvg $$S) ##C((  $sm#$s   AB3 3C	c                ,    [        U R                  5      $ r!   )lenr<   r-   s    r   __len__"GoogleSecretManagerMapping.__len__R   s    4%%&&r*   c                ,    [        U R                  5      $ r!   )iterr<   r-   s    r   __iter__#GoogleSecretManagerMapping.__iter__U   s    D&&''r*   )r#   r   r"   r   N)r%   r   r&   strr'   boolreturnNonerW   rU   )rW   z	list[str])latest)r@   rU   rA   rU   rW   rU   )r@   rU   rW   
str | None)rW   int)rW   zIterator[str])__name__
__module____qualname____firstlineno____annotations__r(   propertyr.   r   r<   rB   rK   rO   rS   __static_attributes__ r*   r   r   r   $   sR    **... I I 	 	W)"'(r*   r   c                     ^  \ rS rSr% S\S'   S\S'   S\S'          S                 SU 4S jjjrSS	 jrSS
 jrSrU =r	$ )!GoogleSecretManagerSettingsSourceY   r   _credentialsr   r   rU   r"   c	           	     V  > [         b  [        b  [        c
  [        5         U(       a  U(       d  [        5       u  pUc  W	nUc#  [	        W
[
        5      (       a  U
nO[        S5      eX l        X0l        U(       a  Xpl	        O[        U R                  S9U l	        [        TU ]-  UUUSUUS9  g )Nzproject_id is required to be specified either as an argument or from the google.auth.default. See https://google-auth.readthedocs.io/en/master/reference/google.auth.html#google.auth.default)credentialsF)r'   
env_prefixenv_ignore_emptyenv_parse_none_strenv_parse_enums)r   r   r   r   
isinstancerU   AttributeErrorrh   r"   r   superr(   )r$   settings_clsrj   r&   rk   rm   rn   r%   r'   _credsr"   	__class__s              r   r(   *GoogleSecretManagerSettingsSource.__init__^   s     &-1DH[Hc%' *"5"7F  K+s++(
$ T  *5 *"/"<IZIZ"[D)!"1+ 	 	
r*   c                T    [        U R                  U R                  U R                  S9$ )N)r&   r'   )r   r   r"   r'   r-   s    r   _load_env_vars0GoogleSecretManagerSettingsSource._load_env_vars   s(    )D,<,<TM`M`
 	
r*   c                l    U R                   R                   SU R                  < SU R                  < S3$ )Nz(project_id=z, env_nested_delimiter=))rt   r]   r"   env_nested_delimiterr-   s    r   __repr__*GoogleSecretManagerSettingsSource.__repr__   s=    ..))*,t7G7G6JJabfb{b{a~~  A  	Ar*   )rh   r"   r   )NNNNNNT)rr   ztype[BaseSettings]rj   zCredentials | Noner&   r[   rk   r[   rm   r[   rn   bool | Noner%   z!SecretManagerServiceClient | Noner'   r~   rW   rX   )rW   zMapping[str, Optional[str]]rY   )
r]   r^   r_   r`   ra   r(   rw   r|   rc   __classcell__)rt   s   @r   rf   rf   Y   s    ..
 +/!%!%)-'+;?&*/
(/
 (/
 	/

 /
 '/
 %/
 9/
 $/
 
/
 /
b

A Ar*   rf   )rW   rX   )
__future__r   _annotationscollections.abcr   r   	functoolsr   typingr   r   envr
   r   r   r   r   r   r   r   pydantic_settings.mainr   r   rU   r   rf   __all__rd   r*   r   <module>r      sq    2 - % * ":3E3K!%2(hsm);!< 2(j<A(9 <A~ /0L
Mr*   