
    a                        d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlm	Z	 ddlm
Z
 dd	lmZ dd
lmZ dd	lmZ e
j"                   e
j$                  e
j&                  j(                  e
j&                  j*                  e
j&                  j,                         G d de
j.                                      Zdddde_        y)zCCommand for suspending instances owned by a managed instance group.    )absolute_import)division)unicode_literals)base_classes)instance_groups_utils)arg_parsers)base)flags)scopec                   &    e Zd ZdZed        Zd Zy)SuspendInstances4Suspend instances owned by a managed instance group.c                     | j                   j                  d       | j                  dt        j                  d      ddd       | j                  d	d
dd       t
        j                  j                  |        y )Nzp
        table(project(),
              zone(),
              instanceName:label=INSTANCE,
              status)z--instances   )
min_lengthINSTANCETzNames of instances to suspend.)typemetavarrequiredhelpz--forceF
store_truez
          Immediately suspend the specified instances, skipping the initial
          delay, if one is specified in the standby policy.)defaultactionr   )display_info	AddFormatadd_argumentr   ArgListinstance_groups_flags%MULTISCOPE_INSTANCE_GROUP_MANAGER_ARGAddArgument)parsers    @lib/surface/compute/instance_groups/managed/suspend_instances.pyArgszSuspendInstances.Args%   s    
!! # 
 (00A> *!%=	  ?
 ?	  @ ??KK    c                 0   t        j                  | j                               }|j                  }t        j
                  }t        j                  j                  }t        j                  |      }|j                  ||j                  ||      }|j                         dk(  r^d}|j                  j                  |j!                         |j                  j#                  g       |j$                  |j&                        }	n|j                         dk(  r^d}|j                  j)                  |j!                         |j                  j+                  g       |j$                  |j,                        }	n(t/        d	j1                  |j                                     |j3                  d
      rJ|j                         dk(  r|j4                  |	j6                  _        n|j4                  |	j:                  _        t=        j>                  |d|	|||j@                        S )N)default_scopescope_listerzcompute.instanceGroupManagers,instanceGroupManagersSuspendInstancesRequest)	instances)instanceGroupManagerr(   projectzonez#compute.regionInstanceGroupManagers2regionInstanceGroupManagersSuspendInstancesRequest)r*   r-   r+   regionzUnknown reference type {0}forcer   )
api_holdermethod_namerequest_templateinstances_holder_fieldigm_refr)   )!r   ComputeApiHolderReleaseTrackclientr   r   compute_scope	ScopeEnumZONEr
   GetDefaultScopeListerResolveAsResource	resources
Collectionmessages3ComputeInstanceGroupManagersSuspendInstancesRequestName,InstanceGroupManagersSuspendInstancesRequestr+   r,   9ComputeRegionInstanceGroupManagersSuspendInstancesRequest2RegionInstanceGroupManagersSuspendInstancesRequestr.   
ValueErrorformatIsSpecifiedr/   r(   forceSuspendr-   r   *SendInstancesRequestsAndPostProcessOutputsr)   )
selfargsholderr7   resource_argr&   r'   r4   r3   requests
             r"   RunzSuspendInstances.Run;   s   **4+<+<+>?F]]F(NNL!++00M..v6L,,#!	 - #G >>MSS&||~7=77"7E//|| T g 
			!F	FSYY&||~=C__===K// Z g 3::



  ! !  				!@	@LPJJ<<IRVR\R\BBO KK& 5.." "r$   N)__name__
__module____qualname____doc__staticmethodr#   rO    r$   r"   r   r      s    
 = *."r$   r   r   a  
        *{command}* suspends one or more instances from a managed instance
group, thereby reducing the targetSize and increasing the targetSuspendedSize
of the group.

The command returns the operation status per instance, which might be ``FAIL'',
``SUCCESS'', or ``MEMBER_NOT_FOUND''. ``MEMBER_NOT_FOUND'' is returned only for
regional groups when the gcloud command-line tool wasn't able to resolve the
zone from the instance name.
z      To suspend an instance from a managed instance group in the us-central1-a
      zone, run:

              $ {command} example-managed-instance-group --zone=us-central1-a \
              --instances=example-instance
    )briefDESCRIPTIONEXAMPLESN)rS   
__future__r   r   r   googlecloudsdk.api_lib.computer   r   googlecloudsdk.callioper   r	   "googlecloudsdk.command_lib.computer
   r   r8   2googlecloudsdk.command_lib.compute.instance_groupsr   UniverseCompatibleReleaseTracksr6   ALPHABETAGACommandr   detailed_helprU   r$   r"   <module>re      s    J &  ' 7 @ / ( 4 E ] T..33T5F5F5I5IG"t|| G" G"V D	"  r$   