o
    !d                     @   s   d dl Z d dlZd dlZd dlmZ d dlmZ d dlmZm	Z	 e 
eZdZdd Zdd	 ZG d
d deZG dd de	ZdS )    N)
check_call)ignore_user_entered_signals)ServiceOperationCLIOperationCaller)z#SessionManagerPlugin is not found. z3Please refer to SessionManager Documentation here: z3http://docs.aws.amazon.com/console/systems-manager/z session-manager-plugin-not-foundc                 C   s   |  dt d S )Nzbuilding-command-table.ssm)registeradd_custom_start_session)Zevent_handlers r   Husr/lib/python3.10/site-packages/awscli/customizations/sessionmanager.pyregister_ssm_session   s   r
   c                 K   s*   t dd| | ddt| d|d< d S )Nzstart-sessionZssmStartSession)nameparent_namesessionoperation_modelZoperation_caller)StartSessionCommandZget_service_modelr   StartSessionCaller)r   Zcommand_tablekwargsr   r   r	   r   $   s   r   c                       s   e Zd Z fddZ  ZS )r   c                    s   t t|  }d | j_|S )N)superr   create_help_commandZ_operation_modelZoutput_shape)selfZhelp_command	__class__r   r	   r   1   s   z'StartSessionCommand.create_help_command)__name__
__module____qualname__r   __classcell__r   r   r   r	   r   /   s    r   c                   @   s   e Zd Zdd ZdS )r   c              
   C   s  | j j||j|j|jd}|jdi |}|d }|jj}| j jd ur'| j jnd}	|jj}
z)t	  t
dt||d|	t||
g W d    W dS 1 sOw   Y  W dS  ty } z!|jtjkrxtjddd	 |j|d
 tdtW Y d }~d S d }~ww )N)region_nameendpoint_urlZverify	SessionId zsession-manager-pluginr   r   z#SessionManagerPlugin is not presentT)exc_info)r   r   )Z_sessionZcreate_clientZregionr   Z
verify_sslZstart_sessionmetar   Zprofiler   r   jsondumpsOSErrorerrnoENOENTloggerdebugZterminate_session
ValueErrorjoinERROR_MESSAGE)r   Zservice_nameZoperation_name
parametersZparsed_globalsZclientresponseZ
session_idr   Zprofile_namer   exr   r   r	   invoke:   sJ   
		zStartSessionCaller.invokeN)r   r   r   r/   r   r   r   r	   r   9   s    r   )loggingr"   r%   
subprocessr   Zawscli.compatr   Zawscli.clidriverr   r   	getLoggerr   r'   r+   r
   r   r   r   r   r   r   r	   <module>   s   

