
    _                        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 dddZe
j&                   e
j(                  e
j*                  j,                         G d de
j.                                      Z e
j(                  e
j*                  j2                         G d de             Zee_        y)z,Bare Metal Solution instance update command.    )absolute_import)division)unicode_literals)	BmsClient)waiter)base)flags)labels_util)log)	resourcesa  
          Update a Bare Metal Solution instance.

          This call returns immediately, but the update operation may take
          several minutes to complete. To check if the operation is complete,
          use the `describe` command for the instance.
        aL  
          To update an instance called ``my-instance'' in region ``us-central1'' with
          a new label ``key1=value1'', run:

          $ {command} my-instance  --region=us-central1 --update-labels=key1=value1

          To clear all labels, run:

          $ {command} my-instance --region=us-central1 --clear-labels
        )DESCRIPTIONEXAMPLESc                   ,    e Zd ZdZed        Zd Zd Zy)Update&Update a Bare Metal Solution instance.c                     t        j                  | d       t        j                  |        t        j
                  j                  |        t        j                  | dd       t        j                  | d       y)z Register flags for this command.T)
positionalF)hiddenrequiredr   N)	r	   AddInstanceArgToParserr
   AddUpdateLabelsFlagsr   
ASYNC_FLAGAddToParserAddInstanceOsImageToParser'AddInstanceEnableHyperthreadingToParserparsers    #lib/surface/bms/instances/update.pyArgszUpdate.Args9   sV     
  D9$$V,OO'	$$VEEJ	11&G    c                 :   t         j                  j                  |      }|j                  |      }|j	                  |j
                  j                  j                  |j                        j                         }t        |dd       }t        |dd       }||||g d ddS )Nos_imageenable_hyperthreadingF)instance_resourcelabelsr#   r$   ssh_keyskms_key_versionclear_ssh_keys)r
   DiffFromUpdateArgsGetInstanceApplymessagesInstanceLabelsValuer&   	GetOrNonegetattr)	selfargsclientinstancelabels_difforig_resourcelabels_updater#   r$   s	            r   GetRequestFieldszUpdate.GetRequestFieldsB   s    ""11$7K&&x0M%%foo&>&>&J&J&3&:&:<<EIK tZ.H#D*A4H%!6 r!   c           	         t               }|j                  j                  j                         } |j                  d
i | j                  |||      }|j                  r't        j                  |j                         d       |S |j                  r@t        j                  j                  d|j                          d|j                   d       |S t        j                  j!                  |j                  dd      }t#        j$                  |j&                        }t#        j(                  ||d	j+                  |j                              }t        j                  |j                         d       |S )Nr6   )kindzUpdate request issued for: [z]
Check operation [z] for status.z/baremetalsolution.projects.locations.operationsv2)
collectionapi_versionz&Waiting for operation [{}] to complete )r   CONCEPTSr6   ParseUpdateInstancer:   doner   UpdatedResourceNameasync_statusPrintnamer   REGISTRYParseRelativeNamer   CloudOperationPollerNoResourcesoperation_serviceWaitForformat)r3   r4   r5   r6   op_refop_resourcepollerress           r   Runz
Update.RunS   s5   [F}}%%++-H"V"" 9


fh
79F{{	(--/
;m{{	jj((9 :$kk]-9: m$$66D 7 K 33  "F
..077DFC j9Jr!   N)__name__
__module____qualname____doc__staticmethodr    r:   rU   r@   r!   r   r   r   4   s%     /H H"r!   r   c                   2     e Zd ZdZed        Z fdZ xZS )UpdateAlphar   c                     t        j                  | dd       t        j                  | d       t        j	                  |        y )NFT)r   pluralr   )r	    AddProvisioningSshKeyArgToParserAddKMSCryptoKeyVersionToParserr   r    r   s    r   r    zUpdateAlpha.Argsr   s0    	**6E$O	((>
KKr!   c                     i t         |   |||      |j                  |j                  j                  j                         t        |dd      dS )Nr)   F)r(   r'   r)   )superr:   kms_crypto_key_versionrA   r'   rB   r2   )r3   r4   r5   r6   	__class__s       r   r:   zUpdateAlpha.GetRequestFieldsy   sT    
'
"4
:66MM**002!$(8%@	 r!   )rV   rW   rX   rY   rZ   r    r:   __classcell__)rd   s   @r   r\   r\   n   s"    .  r!   r\   N)rY   
__future__r   r   r   %googlecloudsdk.api_lib.bms.bms_clientr   googlecloudsdk.api_lib.utilr   googlecloudsdk.callioper   googlecloudsdk.command_lib.bmsr	   $googlecloudsdk.command_lib.util.argsr
   googlecloudsdk.corer   r   DETAILED_HELPUniverseCompatibleReleaseTracksReleaseTrackGAUpdateCommandr   ALPHAr\   detailed_helpr@   r!   r   <module>ru      s    3 &  ' ; . ( 0 < # )			. D%%(()5T 5 * 5p D%%++,&  -$ % r!   