
    (                     >   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&                  j(                  e
j&                  j*                         G d de
j,                               Zee_        y)z4'Bare Metal Solution boot volumes "restore" command.    )absolute_import)division)unicode_literals)	BmsClient)waiter)base)flags)log)
properties)	resourceszX
          Restore a Bare Metal Solution boot volume from an existing snapshot.
        z
          To restore a boot volume named ``my-boot-volume'' in region
          ``us-central1'' from snapshot named ``my-snapshot'', run:

          $ {command} my-boot-volume --region=us-central1 --snapshot=my-snapshot
    )DESCRIPTIONEXAMPLESc                   &    e Zd ZdZed        Zd Zy)RestorezDRestore a Bare Metal Solution boot volume from an existing snapshot.c                     t        j                  | d       | j                  ddd       t        j                  j                  |        y)z Register flags for this command.T)
positionalz
--snapshotz Name of the snapshot to restore.)requiredhelpN)r	   AddVolumeArgToParseradd_argumentr   
ASYNC_FLAGAddToParser)parsers    "lib/surface/bms/volumes/restore.pyArgszRestore.Args1   sD     
v$7
!%?  A 	OO'    c                    |j                   j                  j                         }t               }t        j
                  j                  |j                  t        j                  j                  j                  j                  |j                  |j                  ddd      }|j                  |j                               }|j                  r't!        j"                  |j%                         d       |S |j&                  rIt         j(                  j+                  dj-                  |j%                         |j.                               |S t        j
                  j1                  |j.                  d	d
      }t3        j4                  |j6                        }t3        j8                  ||dj-                  |j.                              }t!        j"                  |j%                         d       |S )N)
projectsIdlocationsId	volumesIdz6baremetalsolution.projects.locations.volumes.snapshotsv2)params
collectionapi_version)snapshot_namevolume)kindz@Restore request issued for [{}]
Check operation [{}] for status.z/baremetalsolution.projects.locations.operations)r#   r$   z&Waiting for operation [{}] to complete)CONCEPTSr&   Parser   r   REGISTRYsnapshotr   VALUEScoreproject	GetOrFailregionRestoreVolumeSnapshotRelativeNamedoner
   RestoredResourceNameasync_statusPrintformatnameParseRelativeNamer   CloudOperationPollerNoResourcesoperation_serviceWaitFor)	selfargsr&   clientsnapshot_refop_refop_resourcepollerress	            r   RunzRestore.Run:   s   ]]!!'')F[F%%++$++0088BB;;

 L , L ))"//1 * 3F {{	6;;=x8m{{	jj **0&*LNm$$66D 7 K 33  "F
..AHH#[[*+C X6Jr   N)__name__
__module____qualname____doc__staticmethodr   rG    r   r   r   r   -   s    L( ("r   r   N)rK   
__future__r   r   r   %googlecloudsdk.api_lib.bms.bms_clientr   googlecloudsdk.api_lib.utilr   googlecloudsdk.callioper   googlecloudsdk.command_lib.bmsr	   googlecloudsdk.corer
   r   r   DETAILED_HELPReleaseTracksReleaseTrackALPHAGAUpdateCommandr   detailed_helprM   r   r   <module>r[      s    ; &  ' ; . ( 0 # * )
		 D%%++T->->-A-AB.d   . C.b & r   