
                             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  G d
 dej                        Zdddde_        y)zIImplements command to remove an SSH public key from the OS Login profile.    )absolute_import)division)unicode_literals)client)base)flags)oslogin_utils)
propertiesc                   8     e Zd ZdZ fdZed        Zd Z xZS )Remove2Remove an SSH public key from an OS Login profile.c                 ,    t        t        | 
  |i | y )N)superr   __init__)selfargskwargs	__class__s      /lib/surface/compute/os_login/ssh_keys/remove.pyr   zRemove.__init__    s    	&$ $1&1    c                 8    d}t        j                  | d|       y)z\Set up arguments for this command.

    Args:
      parser: An argparse.ArgumentParser.
    zL Key value can either be the SSH key or the OS Login fingerprint of the key.zremove from)additional_helpN)r   AddKeyFlags)parserr   s     r   ArgszRemove.Args#   s    :O	fm_Mr   c                    t        j                  |      }t        j                  | j	                               }t
        j                  j                  j                  j                         xs2 t
        j                  j                  j                  j                         }t        j                  ||      }t        j                  ||      }|r|j                  ||      S t        j                   d      )z$See ssh_utils.BaseSSHCLICommand.Run.zCannot find requested SSH key.)r   GetKeyFromArgsr   OsloginClientReleaseTrackr
   VALUESauthimpersonate_service_accountGetcoreaccountr	   GetKeyDictionaryFromProfileFindKeyInKeyListDeleteSshPublicKeyOsloginKeyNotFoundError)r   r   keyoslogin_client
user_emailkeysfingerprints          r   Runz
Remove.Run.   s    


t
$C))$*;*;*=>N##((DDHHJ :&&++33779  44ZPD00d;K..z;GG**+KLLr   )	__name__
__module____qualname____doc__r   staticmethodr   r/   __classcell__)r   s   @r   r   r      s'    :2 N NMr   r   r   a        *{command}* accepts either a string containing an SSH public
      key or a filename for an SSH public key and removes that key from the
      user's OS Login profile. The key value used can either be the
      full SSH key or the OS Login fingerprint for that key.
    aA  
      To remove the key that is stored in `/home/user/.ssh/id_rsa.pub`, run:

        $ {command} --key-file=/home/user/.ssh/id_rsa.pub

      To remove the key with fingerprint
      'e0d96d6fad35a61a0577f467940509b5aa08b6dea8d99456ec19a6e47126bc52', run:

        $ {command} --key='e0d96d6fad35a61a0577f467940509b5aa08b6dea8d99456ec19a6e47126bc52'

      To remove the SSH public key
      'AAAAB3NzaC1yc2EAAAADAQABAAAB...ZrPg+DZJIwPab2wPlveLh+ut1Lxs5QTR/9QfEa7', run:

        $ {command} --key='AAAAB3NzaC1yc2EAAAADAQABAAAB...ZrPg+DZJIwPab2wPlveLh+ut1Lxs5QTR/9QfEa7'
    )briefDESCRIPTIONEXAMPLESN)r3   
__future__r   r   r   googlecloudsdk.api_lib.osloginr   googlecloudsdk.callioper   "googlecloudsdk.command_lib.osloginr   r	   googlecloudsdk.corer
   Commandr   detailed_help r   r   <module>rA      sP     P &  ' 1 ( 4 < *MT\\ MB B r   