o
    !d                     @   sd   d Z ddlZddlmZ ddlmZ ddlmZ dZdZde ZG d	d
 d
eZ	G dd de
ZdS )a\  
This customization makes it easier to deal with the bootstrapping
data returned by the ``iam create-virtual-mfa-device`` command.
You can choose to bootstrap via a QRCode or via a Base32String.
You specify your choice via the ``--bootstrap-method`` option
which should be either "QRCodePNG" or "Base32StringSeed".  You
then specify the path to where you would like your bootstrapping
data saved using the ``--outfile`` option.  The command will
pull the appropriate data field out of the response and write it
to the specified file.  It will also remove the two bootstrap data
fields from the response.
    N)StatefulArgument)resolve_given_outfile_path)is_parsed_result_successful)Z	QRCodePNGZBase32StringSeedzMThe output path and file name where the bootstrap information will be stored.zAMethod to use to seed the virtual MFA.  Valid values are: %s | %sc                       s   e Zd Z fddZ  ZS )FileArgumentc                    s   t |}tt| || d S )N)r   superr   add_to_params)self
parametersvalue	__class__ Dusr/lib/python3.10/site-packages/awscli/customizations/iamvirtmfa.pyr   )   s   zFileArgument.add_to_params)__name__
__module____qualname__r   __classcell__r   r   r   r   r   '   s    r   c                   @   s$   e Zd Zdd Zdd Zdd ZdS )IAMVMFAWrapperc                 C   sL   || _ tdtdd| _tdttdd| _| j d| j	 | j d| j
 d S )NoutfileT)	help_textrequiredbootstrap-method)r   choicesr   z5building-argument-table.iam.create-virtual-mfa-devicez%after-call.iam.CreateVirtualMFADevice)Z_event_handlerr   OUTPUT_HELP_outfiler   BOOTSTRAP_HELPCHOICES_methodregister_add_options
_save_file)r   Zevent_handlerr   r   r   __init__2   s   zIAMVMFAWrapper.__init__c                 K   s   | j |d< | j|d< d S )Nr   r   )r   r   )r   Zargument_tablekwargsr   r   r   r   ?   s   
zIAMVMFAWrapper._add_optionsc                 K   s   t |sd S | jj}| jj}||d v rG|d | }t|d}|t| W d    n1 s2w   Y  tD ]}||d v rF|d |= q9d S d S )NZVirtualMFADevicewb)	r   r   r
   r   openwritebase64	b64decoder   )r   parsedr"   methodr   bodyfpchoicer   r   r   r    C   s   
zIAMVMFAWrapper._save_fileN)r   r   r   r!   r   r    r   r   r   r   r   0   s    r   )__doc__r&   Zawscli.customizations.argumentsr   r   r   r   r   r   r   objectr   r   r   r   r   <module>   s   	