
    E                        S r SSKJr  SSKJr  SSKJr  SSKJr  SSK	J
r
  SSK	Jr  SSKJr  SS	KJr  \R                   \R"                  " \R$                  R&                  5       " S
 S\R(                  5      5       5       r\R"                  " \R$                  R,                  5       " S S\5      5       r\R"                  " \R$                  R0                  5       " S S\5      5       rg)zMDetach GCF 2nd gen function from GCF and make it a native Cloud Run function.    )client)
exceptions)util)base)flags)run_util)log)
console_ioc                   4    \ rS rSrSr\S 5       rS rS rSr	g)Detach   kDetach a Cloud Functions v2 function from its existing environment and make it a native Cloud Run function.c                 .    [         R                  " U SS9  g )Nz6The name of the Cloud Functions v2 function to detach.)help_text_override)r   AddFunctionResourceArg)parsers    lib/surface/functions/detach.pyArgsDetach.Args    s    	  D    c                    [         R                  " U R                  5       5      nUR                  R                  R                  5       nUR                  5       nSU S3n[        R                  " 5       (       a  [        R                  " USSS9  UR                  U5      nUc%  [        R                  " SR                  U5      5      eUR                  U5      nSn[        R                   " UR"                  UR$                  Xx5        [&        R(                  " U5      n	U	(       d  [        R                  " SU S	35      eU R+                  XIR,                  5        g)
aE  Detach a Cloud Functions v2 function from its existing environment.

  Detach a Cloud Functions v2 function from its existing environment and
  make it a native Cloud Run function.

Args:
  args: The arguments of the command.

Raises:
  FunctionsError: If the function does not exist or the Cloud Run service is
  not found.
z-WARNING: This command detaches your function z from the Cloud Functions API (cloudfunctions.googleapis.com). Detached functions continue to serve traffic, and retain the `cloudfunctions.net` URL. You can only manage your detached functions using the Cloud Run Admin API or the `gcloud run <command>`. T)defaultcancel_on_noNzFunction [{}] does not exist.zRDetaching function from Google Cloud Functions API (cloudfunctions.googleapis.com)z6Failed to get the Cloud Run service for the function [z].)	client_v2FunctionsClientReleaseTrackCONCEPTSnameParseRelativeNamer
   	CanPromptPromptContinueGetFunctionr   FunctionsErrorformatDetachFunctionapi_utilWaitForOperationr   messagesr   
GetService_PrintSuccessMessageurls)
selfargsr   function_reffunction_namemessagefunction	operationdescriptionservices
             r   Run
Detach.Run)   s>    &&t'8'8':;F==%%++-L --/M 8 G 	  DI!!-0H%%
)
0
0
?  %%m4I	+  v	
 !!(+G%%oR!  	m\\:r   c                    [         R                  R                  5         [         R                  R                  SU S35        U H%  n[         R                  R                  SU 35        M'     [         R                  R                  S5        g )Nz	Function zh has been detached successfully! Your function will continue to be available at the following endpoints:z* zAny existing event triggers associated with your function will continue to work and can be managed through Eventarc API.
Reminder, your function can now be managed through the Cloud Run API. )r	   statusPrint)r-   r0   r,   urls       r   r+   Detach._PrintSuccessMessage]   ss    JJJJ
M? #N 	N 	jjC5z" JJ	Qr    N)
__name__
__module____qualname____firstlineno____doc__staticmethodr   r6   r+   __static_attributes__r=   r   r   r   r      s%     t 2;hr   r   c                       \ rS rSrSrSrg)
DetachBetal   r   r=   Nr>   r?   r@   rA   rB   rD   r=   r   r   rF   rF   l       sr   rF   c                       \ rS rSrSrSrg)DetachAlphaq   r   r=   NrH   r=   r   r   rK   rK   q   rI   r   rK   N)rB   #googlecloudsdk.api_lib.functions.v2r   r   r   r   r'   googlecloudsdk.callioper   $googlecloudsdk.command_lib.functionsr   r   googlecloudsdk.corer	   googlecloudsdk.core.consoler
   DefaultUniverseOnlyReleaseTracksr   GACommandr   BETArF   ALPHArK   r=   r   r   <module>rX      s    T C : @ ( 6 9 # 2 D%%(()LT\\ L * L^ D%%**+t t ,t D%%++,t* t -tr   