
    {
                         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)zHImplements the command to add an SSH public key to 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 )Addz$SSH into a virtual machine instance.c                 ,    t        t        | 
  |i | y )N)superr   __init__)selfargskwargs	__class__s      ,lib/surface/compute/os_login/ssh_keys/add.pyr   zAdd.__init__    s    	#tt.v.    c                 Z    t        j                  | d       t        j                  |        y)z\Set up arguments for this command.

    Args:
      parser: An argparse.ArgumentParser.
    zadd toN)r   AddKeyFlags
AddTtlFlag)parsers    r   ArgszAdd.Args#   s"     
fh'	Vr   c                    t        j                  |      }t        j                  | j	                               }t
        j                  j                  j                  j                         xs2 t
        j                  j                  j                  j                         }t        j                  |j                        }|j                  |||      S )z$See ssh_utils.BaseSSHCLICommand.Run.)expiration_time)r   GetKeyFromArgsr   OsloginClientReleaseTrackr
   VALUESauthimpersonate_service_accountGetcoreaccountr	   ConvertTtlArgToExpiryttlImportSshPublicKey)r   r   keyoslogin_client
user_emailexpirys         r   RunzAdd.Run-   s    


t
$C))$*;*;*=>N##((DDHHJ :&&++33779  00:F,,Z=C - E Er   )	__name__
__module____qualname____doc__r   staticmethodr   r-   __classcell__)r   s   @r   r   r      s%    ,/  
Er   r   z-Add an SSH public key to an OS Login profile.z      *{command}* accepts either a string containing an SSH public
      key or a filename for an SSH public key and adds that key to the
      user's OS Login profile.
    a  
      To add the key in `/home/user/.ssh/id_rsa.pub` to your OS Login profile,
      run:

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

      To add the same key, but with a one year expiration time, run:

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

      To add a key not stored in a file, run:

        $ {command} --key='ssh-rsa AAAAB3NzaC1yc2EAAA...MTg+InRG47+/O4/uWEOy6gIQEF user@example.com'
    )briefDESCRIPTIONEXAMPLESN)r1   
__future__r   r   r   googlecloudsdk.api_lib.osloginr   googlecloudsdk.callioper   "googlecloudsdk.command_lib.osloginr   r	   googlecloudsdk.corer
   Commandr   detailed_help r   r   <module>r?      sN     O &  ' 1 ( 4 < *E$,, E< =
 r   