
    !                     Z   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  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)managed_instance_groups_utils)base)flagsc                   <    e Zd ZdZed        Zd Zd Zed        Z	y)Deletez8Delete all-instances-config of a managed instance group.c                 |    t        j                  d      j                  |d       t        j                  |       y )NT)region_flagz*delete the all instances configuration for)operation_type)instance_groups_flagsGetInstanceGroupManagerArgAddArgumentmanaged_instance_groups_flags#AddFlagsForDeleteAllInstancesConfig)clsparsers     Jlib/surface/compute/instance_groups/managed/all_instances_config/delete.pyArgszDelete.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                  ||      }t        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 _CreateInstanceGroupManagerPatchr   _MakePatchRequest)selfargsholderr   r   igm_refpatch_instance_group_managers          r   Runz
Delete.Run)   s    **4+<+<+>?F]]F  I$JJ!! - C CF K "    $  3::



  ! ! $(#H#Hf$ ##FG$@B Br   c                    t        j                  |       |j                  xs g }|j                  xs g }|j                  j                  |j                  j                  |j                  j                  |j                  j                  j                  |D cg c]3  }|j                  j                  j                  j                  |d      5 c}      |j                  j                  j                  |D cg c]3  }|j                  j                  j                  j                  |d      5 c}                        S c c}w c c}w )zCreates IGM resource patch.N)keyvalue)additionalProperties)metadatalabels)
properties)allInstancesConfig)	mig_utils-RegisterCustomInstancePropertiesPatchEncodersr3   r4   messagesInstanceGroupManager&InstanceGroupManagerAllInstancesConfigInstancePropertiesPatchMetadataValueAdditionalPropertyLabelsValue)r)   r*   r   r3   r4   r0   s         r   r'   z'Delete._CreateInstanceGroupManagerPatch@   sH   ;;FC}}"H[[BF??//!??	/	/>>@@NN $,* $,C ??MM++4+@A#+* O  >>JJ $** $*C ??KK++4+@A#)* K  ?  
0 
 0  
**s   8E	:8E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)rA   rB   rC   regionPatch)r$   apitools_clientinstanceGroupManagersr9   (ComputeInstanceGroupManagersPatchRequestNamerC   rD   regionInstanceGroupManagers.ComputeRegionInstanceGroupManagersPatchRequestrE   MakeRequests)r   r,   igm_updated_resourceservicerequests        r   r(   zDelete._MakePatchRequestW   s    >>&&<<gHH&||~';//||	 I g &&BBgNN&||~';//	 O !g
 '7 ;<==r   N)
__name__
__module____qualname____doc__classmethodr   r.   r'   staticmethodr(    r   r   r   r      s;     AN NB.. > >r   r   zUDelete values defined in the all-instances configuration of a managed instance group.a          *{command}* deletes one or more values defined in the all-instances
        configuration of a managed instance 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`.
        a_          To delete the group's all-instances configuration in order to stop
        overriding 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
            --labels=label-key
        )briefDESCRIPTIONEXAMPLESN)rT   
__future__r   r   r   googlecloudsdk.api_lib.computer   r   r7   googlecloudsdk.callioper   "googlecloudsdk.command_lib.computer	   r"   2googlecloudsdk.command_lib.compute.instance_groupsr   :googlecloudsdk.command_lib.compute.instance_groups.managedr   ReleaseTracksr   GABETAALPHADeleteCommandr   detailed_helprW   r   r   <module>rg      s    F &  ' 7 U ( E ] m D%%(($*;*;*@*@%%++-H>T H>-H>Z				% r   