
    F                     N   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  ej                   ej"                  j$                  ej"                  j&                  ej"                  j(                         G d d	ej*                               Zd
ddde_        y)z?Command for deleting values overridden in all-instances config.    )absolute_import)division)unicode_literals)base_classes)base)flagsc                   2    e Zd ZdZed        Zd Zd Zd Zy)Updatez8Update all-instances-config of a managed instance group.c                 |    t        j                  d      j                  |d       t        j                  |       y )NT)region_flagz*update the all instances configuration for)operation_type)instance_groups_flagsGetInstanceGroupManagerArgAddArgumentmanaged_instance_groups_flags#AddFlagsForUpdateAllInstancesConfig)clsparsers     Jlib/surface/compute/instance_groups/managed/all_instances_config/update.pyArgszUpdate.Args!   s7    44%+#O & Q!EEfM    c                    t        j                  | j                               }|j                  }|j                  }t
        j                  j                  ||t        j                  |            }|j                         dvr(t        dj                  |j                                     | j                  ||      }| j                  |||      S )N)scope_lister)compute.instanceGroupManagersz#compute.regionInstanceGroupManagerszUnknown reference type {0})r   ComputeApiHolderReleaseTrackclient	resourcesr   %MULTISCOPE_INSTANCE_GROUP_MANAGER_ARGResolveAsResourcecompute_flagsGetDefaultScopeLister
Collection
ValueErrorformat _CreateInstanceGroupManagerPatch_MakePatchRequest)selfargsholderr   r   igm_refpatch_instance_group_managers          r   Runz
Update.Run(   s    **4+<+<+>?F]]F  I$JJ!! - C CF K "    $  3::



  ! ! $(#H#Hf$ !!&'3OPPr   c                    |j                   j                  |j                   j                  |j                   j                  |j                   j                  j	                  |j
                  j                         D cg c]6  \  }}|j                   j                  j                  j                  ||      8 c}}      |j                   j                  j                  |j                  j                         D cg c]6  \  }}|j                   j                  j                  j                  ||      8 c}}                        S c c}}w c c}}w )zCreates IGM resource patch.)keyvalue)additionalProperties)metadatalabels)
properties)allInstancesConfig)
messagesInstanceGroupManager&InstanceGroupManagerAllInstancesConfigInstancePropertiesPatchMetadataValuer2   itemsAdditionalPropertyLabelsValuer3   )r(   r)   r   r/   r0   s        r   r&   z'Update._CreateInstanceGroupManagerPatch>   sA   ??//!??	/	/>>@@NN +/--*=*=*?* +@JC ??MM++5+AB*?* O  >>JJ +/++*;*;*=* +>JC ??KK++5+AB*=* K  ?  
0 
 0  
**s   <;E;;Ec                    |j                         dk(  rX|j                  j                  }|j                  j	                  |j                         ||j                  |j                        }nW|j                  j                  }|j                  j                  |j                         ||j                  |j                        }|j                  |d|fg      S )Nr   )instanceGroupManagerinstanceGroupManagerResourceprojectzone)r?   r@   rA   regionPatch)r#   apitools_clientinstanceGroupManagersr6   (ComputeInstanceGroupManagersPatchRequestNamerA   rB   regionInstanceGroupManagers.ComputeRegionInstanceGroupManagersPatchRequestrC   MakeRequests)r(   r   r+   igm_updated_resourceservicerequests         r   r'   zUpdate._MakePatchRequestQ   s    >>&&<<gHH&||~';//||	 I g &&BBgNN&||~';//	 O !g
 '7 ;<==r   N)	__name__
__module____qualname____doc__classmethodr   r-   r&   r'    r   r   r
   r
      s,     AN NQ,&>r   r
   zCUpdate the all-instances configuration of a managed instance group.a)          *{command}* updates the group's all-instances configuration and applies
        it only to new instances that are added to the group.

        To apply a revised all-instances configuration 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`.
        au          To update an all-instances configuration in order to override the
        group's instance template for a label with the key `label-key`
        and metadata with the key `metadata-key` in group `my-group`, run:

          $ {command} my-group
            --metadata=metadata-key=metadata-override-value
            --labels=qlabel-key=label-override-value
        )briefDESCRIPTIONEXAMPLESN)rR   
__future__r   r   r   googlecloudsdk.api_lib.computer   googlecloudsdk.callioper   "googlecloudsdk.command_lib.computer   r!   2googlecloudsdk.command_lib.compute.instance_groupsr   :googlecloudsdk.command_lib.compute.instance_groups.managedr   ReleaseTracksr   GABETAALPHAUpdateCommandr
   detailed_helprT   r   r   <module>rd      s    F &  ' 7 ( E ] m D%%(($*;*;*@*@%%++-B>T B>-B>N 	N		# r   