o
    ;i                     @  sP   d Z ddlmZ ddlmZ ddlmZ ddlmZ dddZ	G dd dZ
dS )zFunction creation status tracking for Modal CLI.

This module contains the FunctionCreationStatus context manager used to
track and display function creation progress.
    )annotations)Optional)api_pb2   )OutputManagerurl_infoapi_pb2.WebUrlInforeturnstrc                 C  s$   | j rd}|S | jrd}|S d}|S )Nz# [grey70](label truncated)[/grey70]z  [grey70](label stolen)[/grey70] )	truncatedlabel_stolen)r   suffix r   H/home/ubuntu/.local/lib/python3.10/site-packages/modal/_output/status.py_get_suffix_from_web_url_info   s   r   c                   @  sJ   e Zd ZU dZded< dZded< dddZd	d
 ZdddZdd Z	dS )FunctionCreationStatuszGContext manager for tracking and displaying function creation progress.r
   tagNz(Optional[api_pb2.FunctionCreateResponse]responsec                 C  s   || _ t | _d S N)r   r   get_output_mgr)selfr   r   r   r   __init__!   s   zFunctionCreationStatus.__init__c                 C  s&   | j  | _| jd| j d | S )NzCreating function z...)r   add_status_row
status_rowmessager   )r   r   r   r   	__enter__%   s   z FunctionCreationStatus.__enter__respapi_pb2.FunctionCreateResponsec                 C  s
   || _ d S r   )r   )r   r   r   r   r   set_response*   s   
z#FunctionCreationStatus.set_responsec              	   C  s  |r|| j s| jd| j  d S | j jj }rk| j jj}| j jjj	}|r)dnd}t
|}| j jD ]}	| j|	 q3| jd| j d| d| |  | j jjD ]}
| j }|d| j d|
j d qSd S | j jjr| jd| j d	 | j jjD ]}| j }|d
| j d| d qd S | j jD ]}	| j|	 q| jd| j d	 | j jjr| j jj D ]<}|jr|j}t
|}| j }|d|j d|j d|  |jD ]}
| j }|d|j d|
j d qqd S d S )Nz%Unknown error when creating function u    🔑r   zCreated web function z => [magenta underline]z[/magenta underline]zCustom domain for zCreated function .z#Created flash service endpoint for zCreated web endpoint for )r   r   finishr   handle_metadataweb_urlfunctionweb_url_infowebhook_configrequires_proxy_authr   server_warningswarncustom_domain_infor   r   urlflash_service_urlsmethod_definitions_setmethod_definitionsvaluesfunction_name)r   exc_typeexc_valexc_tbr$   r   r(   proxy_auth_suffixr   warningcustom_domaincustom_domain_status_rowflash_service_urlflash_service_url_status_rowmethod_definition$class_web_endpoint_method_status_rowr   r   r   __exit__-   sx   










zFunctionCreationStatus.__exit__)r   r
   )r   r   )
__name__
__module____qualname____doc____annotations__r   r   r   r    r=   r   r   r   r   r      s   
 

r   N)r   r   r	   r
   )rA   
__future__r   typingr   modal_protor   managerr   r   r   r   r   r   r   <module>   s   

