
    ohM                         d dl Z d dlmZ d dlmZ ddlmZ  e j                  d      Z G d de      Z	d	e	d
dfdZ
ddZd
ee	   fdZd
ee   fdZd
efdZy)    N)Optional)	BaseModel   )get_auth_pathfastapi_clic                       e Zd ZU eed<   y)
AuthConfigaccess_tokenN)__name__
__module____qualname__str__annotations__     n/var/www/pru.catia.catastroantioquia-mas.com/tasa/lib/python3.12/site-packages/fastapi_cloud_cli/utils/auth.pyr	   r	      s    r   r	   	auth_datareturnc                     t               }t        j                  d|       |j                  | j	                         d       t        j                  d       y )NzWriting auth config to: %sutf-8encodingz Auth config written successfully)r   loggerdebug
write_textmodel_dump_json)r   	auth_paths     r   write_auth_configr      sA    I
LL-y9224wG
LL34r   c                      t               } t        j                  d|        | j                         r&| j	                          t        j                  d       y t        j                  d       y )NzDeleting auth config at: %sz Auth config deleted successfullyz1Auth config file doesn't exist, nothing to delete)r   r   r   existsunlinkr   s    r   delete_auth_configr#      sJ    I
LL.	:78HIr   c                     t               } t        j                  d|        | j                         st        j                  d       y t        j                  d       t        j                  | j                  d            S )NzReading auth config from: %szAuth config file doesn't existzAuth config loaded successfullyr   r   )r   r   r   r    r	   model_validate_json	read_textr"   s    r   read_auth_configr'   "   s`    I
LL/;56
LL23)))*=*=w*=*OPPr   c                      t         j                  d       t               } | t         j                  d       y t         j                  d       | j                  S )NzGetting auth tokenzNo auth data foundz!Auth token retrieved successfully)r   r   r'   r
   )r   s    r   get_auth_tokenr)   .   sF    
LL%& "I)*
LL45!!!r   c                  J    t               d u} t        j                  d|        | S )NzLogin status: %s)r)   r   r   )results    r   is_logged_inr,   :   s#    T)F
LL#V,Mr   )r   N)loggingtypingr   pydanticr   configr   	getLoggerr   r	   r   r#   r'   r   r)   boolr,   r   r   r   <module>r3      sw       !			=	) 5 5 5J	Q(:. 	Q	" 	"d r   