
                         &   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dZe
j"                   e
j$                  e
j&                  j(                         G d de
j*                                      Zee_        y)z-Bare Metal Solution instance reimage command.    )absolute_import)division)unicode_literals)	BmsClient)waiter)base)flags)log)	resourcesa  
          Reimage a Bare Metal Solution instance.

          This call returns immediately, but the reimage operation may take
          several minutes to complete. To check if the operation is complete,
          use the `describe` command for the instance.
        a  
          To reimage an instance called ``my-instance'' in region ``us-central1'' with
          the OS image code ``RHEL9x'', run:

          $ {command} my-instance  --region=us-central1 --os-image=RHEL9x

          To set KMS key and ssh keys in order to connect the instance.
          Please use corresponding flags:

          $ {command} my-instance  --region=us-central1 --os-image=RHEL9x --ssh-keys=ssh-key-1,ssh-key-2 --kms-key-version=sample-kms-key-version
        )DESCRIPTIONEXAMPLESc                   &    e Zd ZdZed        Zd Zy)Reimagez'Reimage a Bare Metal Solution instance.c                     t        j                  | d       t        j                  j	                  |        t        j
                  | dd       t        j                  | d       t        j                  | ddd       y)z Register flags for this command.T)
positionalF)hiddenrequired)r   )r   r   pluralN)r	   AddInstanceArgToParserr   
ASYNC_FLAGAddToParserAddInstanceOsImageToParserAddKMSCryptoKeyVersionToParserAddSshKeyArgToParser)parsers    $lib/surface/bms/instances/reimage.pyArgszReimage.Args7   s_     
  D9OO'	$$VEDI	((>	55    c           
      8   t               }|j                  j                  j                         }|j	                  ||j
                  |j                  j                  j                         t        |dd             }|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 )Nkms_crypto_key_version)os_imagessh_keysr    instance)kindzReimage request issued for: [z]
Check operation [z] for status.z/baremetalsolution.projects.locations.operationsv2)
collectionapi_versionz&Waiting for operation [{}] to complete)r   CONCEPTSr#   ParseReimageInstancer!   r"   getattrdoner
   UpdatedResourceNameasync_statusPrintnamer   REGISTRYParseRelativeNamer   CloudOperationPollerNoResourcesoperation_serviceWaitForformat)selfargsclientr#   op_refop_resourcepollerress           r   RunzReimage.RunB   sM   [F}}%%++-H##''--/&t-EtL	 $ F {{	(--/
;m{{	jj)(--/): ;$kk]-9 m$$66D 7 K 33F4L4LMF
..077DC
 j9Jr   N)__name__
__module____qualname____doc__staticmethodr   r@    r   r   r   r   2   s     0 r   r   N)rD   
__future__r   r   r   %googlecloudsdk.api_lib.bms.bms_clientr   googlecloudsdk.api_lib.utilr   googlecloudsdk.callioper   googlecloudsdk.command_lib.bmsr	   googlecloudsdk.corer
   r   DETAILED_HELPUniverseCompatibleReleaseTracksReleaseTrackALPHAUpdateCommandr   detailed_helprF   r   r   <module>rT      s    4 &  ' ; . ( 0 # )
, D%%++,-d   - - -` & r   