
    Y                     F   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
Zedz   Z e	j                   e	j"                  j$                  e	j"                  j&                  e	j"                  j(                         G d de	j*                               Zy)z#services api-keys undelete command.    )absolute_import)division)unicode_literals)apikeys)services_util)base)common_flags)logzgcloud services operations zwait {0}c                   &    e Zd ZdZed        Zd Zy)Undeletea>  Undelete an API key.

  API Keys that are deleted will be retained in the system for 30 days. If a
  key is still within this retention window, it can be undeleted with this
  command.

  ## EXAMPLES
  UnDelete an API Key (Key or key-string should be specified):

  To undelete with key `1234`, run:

      $ {command} 1234

  To undelete with `1234` in project `myproject` using the fully qualified API
  key name, run:

      $ {command} projects/myproject/locations/global/keys/1234

  To undelete using a Key-string, run:

    $ {command} --key-string='my-key-string'
  c                 l    t        j                  |        t        j                  j	                  |        y )N)r	   add_key_undelete_argsr   
ASYNC_FLAGAddToParser)parsers    )lib/surface/services/api_keys/undelete.pyArgszUndelete.Args:   s$     &&v.OO'    c                 &   t        j                         }|j                  }|j                  d      r4|j                  j
                  j                         }|j                         }|j                  d      rC|j                  |j                        }|j                  j                  |      }|j                  }|j                        }|j                  j                  |      }	|	j                   s|j"                  rOt$        j'                  |	j                        }
t(        j*                  j-                  dj'                  |
             |	S t/        j0                  |	j                  t         j2                        }	t/        j4                  |	       |	S )zRun command.

    Args:
      args: an argparse namespace. All the arguments that were provided to this
        command invocation.

    Returns:
      None
    key
key_string)	keyString)namezcAsynchronous operation is in progress... Use the following command to wait for its completion:
 {0})r   GetClientInstanceMESSAGES_MODULEIsSpecifiedCONCEPTSr   ParseRelativeNameApikeysKeysLookupKeyRequestr   keys	LookupKeyr   +ApikeysProjectsLocationsKeysUndeleteRequestprojects_locations_keysr   doneasync_OP_WAIT_CMDformatr
   statusPrintr   WaitOperationGetOperationPrintOperationWithResponse)selfargsclientmessageskey_refkey_namelookup_requestresponserequestopcmds              r   RunzUndelete.Run@   sC    &&(F%%H!!'')g%%'h%;;OO < n &&~6hhBB C G 
	'	'	0	0	9B77	  )

 --3VC[	: 	&&rww0D0DEb,,R0Ir   N)__name__
__module____qualname____doc__staticmethodr   r9    r   r   r   r      s     . ( (
&r   r   N)r=   
__future__r   r   r   googlecloudsdk.api_lib.servicesr   r   googlecloudsdk.callioper   #googlecloudsdk.command_lib.servicesr	   googlecloudsdk.corer
   OP_BASE_CMDr'   ReleaseTracksReleaseTrackALPHABETAGARestoreCommandr   r?   r   r   <module>rL      s    * &  ' 3 9 ( < #+J& T..33T5F5F5I5IDt"" DDr   