
    $                         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 describe an SSH Public Key in 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 )Describe4Describe an SSH Public Key from an OS Login Profile.c                 ,    t        t        | 
  |i | y )N)superr   __init__)selfargskwargs	__class__s      1lib/surface/compute/os_login/ssh_keys/describe.pyr   zDescribe.__init__    s    	(D"D3F3    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describe from)additional_helpN)r   AddKeyFlags)parserr   s     r   ArgszDescribe.Args#   s    :O	foOr   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GetSshPublicKeyOsloginKeyNotFoundError)r   r   keyoslogin_client
user_emailkeysfingerprints          r   RunzDescribe.Run.   s    


t
$C))$*;*;*=>N##((DDHHJ :&&++33779  44ZPD00d;K++JDD**+KLLr   )	__name__
__module____qualname____doc__r   staticmethodr   r/   __classcell__)r   s   @r   r   r      s'    <4 P PMr   r   r   a        *{command}* accepts either a string containing an SSH Public
      Key or a filename for an SSH Public key and displays 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.
    a  
      To show all of the information for the key stored in your OS Login
      profile that matches the key in `/home/user/.ssh/id_rsa.pub`, run:

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

      To show all of the information about the key with a fingerprint of
      'e0d96d6fad35a61a0577f467940509b5aa08b6dea8d99456ec19a6e47126bc52', run:

        $ {command} --key='e0d96d6fad35a61a0577f467940509b5aa08b6dea8d99456ec19a6e47126bc52'
    )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 D
 r   