
    s                         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  SS
KJr  SSKJr  SSKJr   " S S\
R"                  5      rg)z)The `app instances enable-debug` command.    )absolute_import)division)unicode_literals)appengine_api_client)env)instances_util)base)
properties)	resources)
console_io)progress_trackerc                   6    \ rS rSrSrSS0r\S 5       rS rSr	g)	EnableDebug    a  Enable debug mode for an instance (only works on the flexible environment).

When in debug mode, SSH will be enabled on the VMs, and you can use
`gcloud compute ssh` to login to them. They will be removed from the health
checking pools, but they still receive requests.

Note that any local changes to an instance will be *lost* if debug mode is
disabled on the instance. New instance(s) may spawn depending on the app's
scaling settings.

Additionally, debug mode doesn't work for applications using the
App Engine standard environment.
EXAMPLESz          To enable debug mode for a particular instance, run:

              $ {command} --service=s1 --version=v1 i1

          To enable debug mode for an instance chosen interactively, run:

              $ {command}
          c                 j    U R                  SSSS9  U R                  SSSS9  U R                  S	S
SS9  g )Ninstance?z        Instance ID to enable debug mode on. If not specified,
        select instance interactively. Must uniquely specify (with other
        flags) exactly one instance)nargshelpz	--servicez-sz        If specified, only match instances belonging to the given service.
        This affects both interactive and non-interactive selection.)r   z	--versionz-vz        If specified, only match instances belonging to the given version.
        This affects both interactive and non-interactive selection.)add_argument)parsers    )lib/surface/app/instances/enable_debug.pyArgsEnableDebug.Args;   sa    
#'  ( TH  I TH  I    c                    [         R                  " U R                  5       5      n[        UR	                  UR
                  UR                  S S95      n [        R                  R                  UR                  5      n[        R                  " X4R                  UR                  UR                  S9n["        R$                  " SR'                  U5      SS9  SR'                  U5      n[        R                  R                  UR(                  [*        R,                  R.                  R0                  R2                  UR                  UR(                  UR
                  S.S	S
9n[4        R6                  " U5         UR9                  U5        S S S 5        g ! [          a8    [        R                  " X1R
                  UR                  UR                  S9n GNf = f! , (       d  f       g = f)Nc                 \    U R                   [        R                  [        R                  4;   $ )N)environmentr   FLEXMANAGED_VMS)vs    r   <lambda>!EnableDebug.Run.<locals>.<lambda>T   s    388S__2M!Mr   )version_filter)serviceversionr   z.About to enable debug mode for instance [{0}].T)cancel_on_noz&Enabling debug mode for instance [{0}])appsId
versionsIdinstancesId
servicesIdz*appengine.apps.services.versions.instances)params
collection)r   GetApiClientForTrackReleaseTracklistGetAllInstancesr&   r'   r   REGISTRYParser   r   GetMatchingInstancer,   r*   r+   	Exceptionr   PromptContinueformatidr
   VALUEScoreproject	GetOrFailr   ProgressTrackerDebugInstance)selfargs
api_clientall_instancesresr   messages          r   RunEnableDebug.RunP   s   %::4;L;L;NOJ33dllM 4 O PM
$$$T]]3c  33
??$h 8??I 7==hGG



"
" '',,44>>"**#;;"**	
 @ # AC 
	)	)'	2s# 
3	2/  "33
t||=="h". 
3	2s   )F 5G>GG
G# N)
__name__
__module____qualname____firstlineno____doc__detailed_helpstaticmethodr   rF   __static_attributes__rH   r   r   r   r       s3      
- I I($r   r   N)rM   
__future__r   r   r   googlecloudsdk.api_lib.appr   r   r   googlecloudsdk.callioper	   googlecloudsdk.corer
   r   googlecloudsdk.core.consoler   r   Commandr   rH   r   r   <module>rW      s=     0 &  ' ; * 5 ( * ) 2 8O$$,, O$r   