
                             S r SSKrSSKJr  SSKJr  SSKJr  SSKJr  SSK	J
r
  SSK	Jr   " S	 S
\
R                  5      rg)z$The undelete command for the BQ CLI.    N)app)flags)client_dataset)utils)bigquery_command)bq_cached_clientc                   ^   ^  \ rS rSrSrSrS\S\R                  4U 4S jjr	S\4S jr
S	rU =r$ )
Undelete   z-Undelete the dataset described by identifier.zbq undelete datasetnamefvc                 t   > [         TU ]  X5        [        R                  " SS SUS9  U R	                  U5        g )N	timestampzOptional. Time in milliseconds since the POSIX epoch that this replica was marked for deletion. If not specified, it will undelete the most recently deleted version.)flag_values)super__init__r   DEFINE_integer_ProcessCommandRc)selfr   r   	__class__s      (platform/bq/frontend/command_undelete.pyr   Undelete.__init__   s>    	GT		%  	2    
identifierc                    [         R                  R                  5       nU(       d  [        R                  " S5      e[
        R                  " X!S9nU R                  (       aD  [        R                  R                  U R                  S-  [        R                  R                  S9nOSn[        R                  " UR                  X4S9nU(       a  [        SU< S35        gg)	a  Undelete the dataset described by identifier.

Always requires an identifier, unlike the show and ls commands.
By default, also requires confirmation before undeleting.
Supports:
 - timestamp[int]: This signifies the timestamp version of the dataset that
 needs to be restored, this should be in milliseconds

Examples:
  bq undelete dataset
  bq undelete --timestamp 1714720875568 dataset
z(Must provide an identifier for undelete.)id_fallbacksr   i  )tzN)r   zDataset undelete of z successfully started)r   ClientGetr   
UsageErrorbq_client_utilsGetDatasetReferencer   datetimefromtimestamptimezoneutcr   UndeleteDataset	apiclientprint)r   r   clientdatasetr   jobs         r   RunWithArgsUndelete.RunWithArgs#   s     $$((*FNNEFF11G ~~##11
..4
H$5$5$9$9 2 i i

(
('C WFG r    )__name__
__module____qualname____firstlineno____doc__usagestrr   
FlagValuesr   r-   __static_attributes____classcell__)r   s   @r   r
   r
      s8    5
#%
3 
E$4$4 
HC H Hr   r
   )r4   r#   abslr   r   clientsr   r   r!   frontendr   r   BigqueryCmdr
   r/   r   r   <module>r>      s2    *    " , % %/H++ /Hr   