
    8                        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  \R"                  " \R$                  R&                  5       " S	 S
\R(                  5      5       rSSSS.\l        \R"                  " \R$                  R.                  \R$                  R0                  5       " S S\5      5       r\R,                  \l        g)@Command for setting instance template of managed instance group.    )absolute_import)division)unicode_literals)base_classes)base)flags)scopec                   4    \ rS rSrSr\S 5       rS rS rSr	g)SetInstanceTemplateGA   r   c                     [         R                  R                  U5        [        R                  R                  U5        g N)managed_flagsINSTANCE_TEMPLATE_ARGAddArgumentinstance_groups_flags%MULTISCOPE_INSTANCE_GROUP_MANAGER_ARG)clsparsers     Dlib/surface/compute/instance_groups/managed/set_instance_template.pyArgsSetInstanceTemplateGA.Args"   s-    ''33F;??KK    c                    [         R                  " U R                  5       5      nUR                  n[        R
                  n[        R                  R                  n[        R                  " U5      nUR                  UUR                  UUS9n[        R                  R                  UUR                  [        R                  R                  R                  S9nU R!                  X7U5      $ )N)default_scopescope_lister)r   )r   ComputeApiHolderReleaseTrackclientr   r   compute_scope	ScopeEnumZONEr	   GetDefaultScopeListerResolveAsResource	resourcesr   r   GLOBAL_MakePatchRequest)	selfargsholderr    resource_argr   r   igm_reftemplate_refs	            r   RunSetInstanceTemplateGA.Run(   s    **4+<+<+>?F]]F(NNL!++00M..v6L,,#!	 - #G !66HH))33:: I L !!&<@@r   c                    UR                   nUR                  UR                  5       UR                  UR                  5       S9/S9nUR	                  5       S:X  a#  UR
                  R                  nUR                  nO_UR	                  5       S:X  a#  UR
                  R                  nUR                  nO([        SR                  UR	                  5       5      5      eU" S0 UR                  5       D6nXXl        UR                  USU4/5      $ )N)instanceTemplate)r2   versionszcompute.instanceGroupManagersz#compute.regionInstanceGroupManagerszUnknown reference type {0}Patch )messagesInstanceGroupManagerSelfLinkInstanceGroupManagerVersion
Collectionapitools_clientinstanceGroupManagers(ComputeInstanceGroupManagersPatchRequestregionInstanceGroupManagers.ComputeRegionInstanceGroupManagersPatchRequest
ValueErrorformatAsDictinstanceGroupManagerResourceMakeRequests)	r)   r    r-   r.   r6   igm_resourceservicerequest_typerequests	            r   r(   'SetInstanceTemplateGA._MakePatchRequest=   s   H00%..000!-!6!6!8 1 :
 1 L >>&&<<gFFl				!F	F&&BBgLLl3::



  ! ! .W^^-.G+7('7 ;<==r   r5   N)
__name__
__module____qualname____firstlineno____doc__classmethodr   r/   r(   __static_attributes__r5   r   r   r   r      s"    I 
A*>r   r   z7Set the instance template for a managed instance group.a!  
      *{command}* sets the instance template for an existing managed instance
    group.

    The new template applies to all new instances added to the managed instance
    group.

    To apply the new template to existing instances in the group, use one of the
    following methods:

    - Update instances using the `update-instances` command.
    - Recreate instances using the `recreate-instances` command.
    - Use the `rolling-action start-update` command.
    - Use the API to set the group's `updatePolicy.type` to `PROACTIVE`.

    a  
    Running:

          {command} \
          example-managed-instance-group --template=example-global-instance-template

    Sets the instance template for the 'example-managed-instance-group' group
    to a global resource 'example-global-instance-template'.

    To use a regional instance template, specify the full or partial URL of the template.

    Running:

          {command} \
          example-managed-instance-group \
          --template=projects/example-project/regions/us-central1/instanceTemplates/example-regional-instance-template

    Sets the instance template for the 'example-managed-instance-group' group
    to a regional resource 'example-regional-instance-template'.
    )briefDESCRIPTIONEXAMPLESc                   B   ^  \ rS rSrSr\U 4S j5       rU 4S jrSrU =r	$ )SetInstanceTemplate   r   c                 ,   > [         [        U ]  U5        g r   )superrU   r   )r   r   	__class__s     r   r   SetInstanceTemplate.Args   s    	
s(0r   c                 .   > [         [        U ]  U5      nU$ r   )rX   rU   r/   )r)   r*   patch_requestrY   s      r   r/   SetInstanceTemplate.Run   s    -t8>Mr   r5   )
rJ   rK   rL   rM   rN   rO   r   r/   rP   __classcell__)rY   s   @r   rU   rU      s"    I1 1 r   rU   N)rN   
__future__r   r   r   googlecloudsdk.api_lib.computer   googlecloudsdk.callioper   "googlecloudsdk.command_lib.computer	   r
   r!   2googlecloudsdk.command_lib.compute.instance_groupsr   :googlecloudsdk.command_lib.compute.instance_groups.managedr   ReleaseTracksr   GACommandr   detailed_helpALPHABETArU   r5   r   r   <module>rk      s     G &  ' 7 ( 4 E ] ] D%%(()5>DLL 5> *5>r G %&'  #R D%%++T->->-C-CD
/ 
 E
 %:$G$G  !r   