
                             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
 r " S S\	R"                  5      rg)z=Command for stopping autoscaling of a managed instance group.    )absolute_import)division)unicode_literals)base_classes)managed_instance_groups_utils)base)flags)scopec                 (    U R                  5       S:H  $ )z/Checks if reference to instance group is zonal.zcompute.instanceGroupManagers)
Collection)refs    ?lib/surface/compute/instance_groups/managed/stop_autoscaling.py_IsZonalGroupr      s    		<	<<    c                   F    \ rS rSrSr\S 5       rS rS rS r	S r
S rS	rg
)StopAutoscaling"   a  Stop autoscaling a managed instance group.

  *{command}* stops autoscaling a managed instance group and deletes the
autoscaler configuration. If autoscaling is not enabled for the managed
instance group, this command does nothing and will report an error.

If you need to keep the autoscaler configuration, you can temporarily disable
an autoscaler by setting its `mode` to `off` using the ``update-autoscaling''
command instead.

c                 B    [         R                  R                  U 5        g N)instance_groups_flags%MULTISCOPE_INSTANCE_GROUP_MANAGER_ARGAddArgument)parsers    r   ArgsStopAutoscaling.Args/   s    ??KKr   c                     [         R                  n[        R                  R                  n[
        R                  " U5      nUR                  X2UUS9$ )N)default_scopescope_lister)r   r   compute_scope	ScopeEnumZONEr	   GetDefaultScopeListerResolveAsResource)selfclient	resourcesargsresource_argr   r   s          r   CreateGroupReference$StopAutoscaling.CreateGroupReference4   sN    (NNL!++00M..v6L))}! * # #r   c                 z    [        U5      (       a  UR                  R                  $ UR                  R                  $ r   )r   apitools_clientautoscalersregionAutoscalers)r$   r%   	group_refs      r   GetAutoscalerServiceForGroup,StopAutoscaling.GetAutoscalerServiceForGroup<   s1    Y##///##555r   c                 j    [        U5      (       a  UR                  Ul        g UR                  Ul        g r   )r   zoneregion)r$   requestigm_refs      r   ScopeRequestStopAutoscaling.ScopeRequestB   s#    W\\gl~~gnr   c           	      4   [        U5      (       a  Sn[        R                  " X#5      nU/S pOSn[        R                  " X#5      nS U/p[        R                  " UR
                  [        R                  " UUUS9UUS9n	U	c  [        R                  " S5      eU	$ )Nr3   r4   )regionszonesr%   )mig_namer-   location
scope_typez-The managed instance group is not autoscaled.)r   r   CreateZoneRefCreateRegionRefAutoscalerForMignameAutoscalersForLocationsResourceNotFoundException)
r$   r%   r&   r6   r'   r>   r=   r;   r:   
autoscalers
             r   GetAutoscalerResource%StopAutoscaling.GetAutoscalerResourceH   s    Wj.<<
h z4Wj.>>
hhZW.??1II J )CC
9; ;r   c                    [         R                  " U R                  5       5      nUR                  nU R	                  X2R
                  U5      nU R                  X45      n[        R                  " XC5        U R                  X2R
                  UU5      nUR                  S5      " UR                  UR                  S9nU R                  Xt5        UR                  USU4/5      $ )NDelete)projectrE   )r   ComputeApiHolderReleaseTrackr%   r)   r&   r0   r   GetInstanceGroupManagerOrThrowrF   GetRequestTyperJ   rB   r7   MakeRequests)r$   r'   holderr%   r6   servicerE   r5   s           r   RunStopAutoscaling.Runa   s    **4+<+<+>?F]]F''0@0@$GG//@G "@@ ++F4D4Dg,02J$$X.??$G 	g'(G <=>>r    N)__name__
__module____qualname____firstlineno____doc__staticmethodr   r)   r0   r7   rF   rR   __static_attributes__rT   r   r   r   r   "   s4    
  #6&2?r   r   N)rY   
__future__r   r   r   googlecloudsdk.api_lib.computer   r   googlecloudsdk.callioper   "googlecloudsdk.command_lib.computer	   r
   r   2googlecloudsdk.command_lib.compute.instance_groupsr   r   Commandr   rT   r   r   <module>rb      s=    D &  ' 7 H ( 4 E ]=
P?dll P?r   