
    U                         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&                  j(                         G d de	j*                               Zy)z@Command for setting instance template of managed instance group.    )absolute_import)division)unicode_literals)base_classes)managed_instance_groups_utils)base)flags)scope)standby_policy_utilsc                   ,    e Zd ZdZed        Zd Zd Zy)SetStandbyPolicyAlphazSet the standby policy for a managed instance group.

    *{command}* sets the fields in the standby policy for a managed instance
  group. The standby policy dictates the behaviour of standby (stopped and
  suspended) instances
  c                 l    t        j                  |        t        j                  j	                  |        y )N)r   AddStandbyPolicyArgsinstance_groups_flags%MULTISCOPE_INSTANCE_GROUP_MANAGER_ARGAddArgument)parsers    Alib/surface/compute/instance_groups/managed/set_standby_policy.pyArgszSetStandbyPolicyAlpha.Args'   s'    --f5??KK    c                    t        j                  | j                               }|j                  }t        j
                  }t        j                  j                  }t        j                  |      }|j                  ||j                  ||      }|j                  xs d }t        j                  |j                   |      }	|	sy | j#                  |||	      S )N)default_scopescope_lister)initial_delay_sec)r   ComputeApiHolderReleaseTrackclientr   r   compute_scope	ScopeEnumZONEr	   GetDefaultScopeListerResolveAsResource	resourcesinitial_delayr   CreateStandbyPolicymessages_MakePatchRequest)
selfargsholderr   resource_argr   r   igm_refr   standby_policys
             r   RunzSetStandbyPolicyAlpha.Run-   s    **4+<+<+>?F]]F(NNL!++00M..v6L,,#!	 - #G
 **2d2FF+<N !!&'>BBr   c                    |j                   }|j                  |      }|j                         dk(  r#|j                  j                  }|j
                  }n^|j                         dk(  r#|j                  j                  }|j                  }n(t        dj                  |j                                      |di |j                         }||_        |j                  |d|fg      S )N)standbyPolicyzcompute.instanceGroupManagersz#compute.regionInstanceGroupManagerszUnknown reference type {0}Patch )r&   InstanceGroupManager
Collectionapitools_clientinstanceGroupManagers(ComputeInstanceGroupManagersPatchRequestregionInstanceGroupManagers.ComputeRegionInstanceGroupManagersPatchRequest
ValueErrorformatAsDictinstanceGroupManagerResourceMakeRequests)	r(   r   r,   r-   r&   igm_resourceservicerequest_typerequests	            r   r'   z'SetStandbyPolicyAlpha._MakePatchRequestB   s    H00~0NL>>&&<<gFFl				!F	F&&BBgLLl3::



  ! ! .W^^-.G+7G('7 ;<==r   N)__name__
__module____qualname____doc__staticmethodr   r.   r'   r2   r   r   r   r      s&      
C*>r   r   N)rF   
__future__r   r   r   googlecloudsdk.api_lib.computer   r   googlecloudsdk.callioper   "googlecloudsdk.command_lib.computer	   r
   r   2googlecloudsdk.command_lib.compute.instance_groupsr   :googlecloudsdk.command_lib.compute.managed_instance_groupsr   ReleaseTracksr   ALPHACommandr   r2   r   r   <module>rQ      sa    G &  ' 7 H ( 4 E ] [ D%%++,5>DLL 5> -5>r   