o
    .&ßaE  ã                   @   s`   d Z ddlZddlZddlZe e¡ZdgZdd„ Zdd„ Z	dd	„ Z
d
d„ ZG dd„ deƒZdS )a:  This module enables the preview-mode customization.

If a service is marked as being in preview mode, then any attempts
to call operations on that service will print a message pointing
the user to alternate solutions.  A user can still access this
service by enabling the service in their config file via:

    [preview]
    servicename=true

or by running:

    aws configure set preview.servicename true

Also any service that is marked as being in preview will *not*
be listed in the help docs, unless the service has been enabled
in the config file as shown above.

é    NÚsdbc                 C   s   |   dt¡ d S )Nzbuilding-command-table.main)ÚregisterÚmark_as_preview)Úevents© r   ú?/usr/lib/python3/dist-packages/awscli/customizations/preview.pyÚregister_preview_commands-   ó   r   c                 K   s|   t |ƒ}tD ]5}d}||v rt d|¡ d}| | }tdt|jfi ƒ}||j||jj	|d�| |< | 
d¡ d| t¡ qd S )NFz/Preview service enabled through config file: %sTÚPreviewCommand)Úcli_nameÚsessionÚservice_nameÚ
is_enabledÚevent_emitterzdoc-description.%s)Ú_get_allowed_servicesÚPREVIEW_SERVICESÚloggerÚdebugÚtypeÚPreviewModeCommandMixinÚ	__class__ÚnameÚservice_modelr   Úget_componentÚregister_lastÚupdate_description_with_preview)Úcommand_tabler   ÚkwargsÚallowed_servicesÚpreview_servicer   Úoriginal_commandÚpreview_clsr   r   r   r   1   s0   ÿ
þ
ü
þìr   c                 K   sV   | j j}| ¡  | tj ¡ ¡ |j  d¡ | j 	d¡d }| 
d| ¡ | ¡  d S )Nz(You can enable this service by running: Ú.r   z!aws configure set preview.%s true)ÚdocÚstyleÚ
start_noteÚboldr   ÚHELP_SNIPPETÚstripÚwriteÚevent_classÚsplitÚcodeÚend_note)Úhelp_commandr   r$   r   r   r   r   r   N   s   r   c                 C   s:   g }| j  di ¡}| ¡ D ]\}}|dkr| |¡ q|S )NÚpreviewÚtrue)Úfull_configÚgetÚitemsÚappend)r   ÚallowedÚpreview_servicesr/   Úvaluer   r   r   r   e   s   
€r   c                       sF   e Zd Ze d¡ZdZ‡ fdd„Z‡ fdd„Zdd„ Z	d	d
„ Z
‡  ZS )r   a      However, if you'd like to use the "aws {service}" commands with the
    AWS CLI, you can enable this service by adding the following to your CLI
    config file:

        [preview]
        {service}=true

    or by running:

        aws configure set preview.{service} true

    zGAWS CLI support for this service is only available in a preview stage.
c                    s&   |  d¡| _tt| ƒj|i |¤Ž d S )Nr   )ÚpopÚ_is_enabledÚsuperr   Ú__init__)ÚselfÚargsr   ©r   r   r   r;   ‚   s   z PreviewModeCommandMixin.__init__c                    s*   | j s|  |¡rtt| ƒ ||¡S |  ¡ S )N)r9   Ú_is_help_commandr:   r   Ú__call__Ú_display_opt_in_message)r<   r=   Úparsed_globalsr>   r   r   r@   †   s
   
ÿz PreviewModeCommandMixin.__call__c                 C   s   |o|d dkS )NéÿÿÿÿÚhelpr   )r<   r=   r   r   r   r?   �   r	   z(PreviewModeCommandMixin._is_help_commandc                 C   s6   t j | j¡ t j d¡ t j | jj| jd�¡ dS )NÚ
)Úserviceé   )ÚsysÚstderrr)   r'   ÚENABLE_DOCSÚformatÚ_service_name)r<   r   r   r   rA   �   s   z/PreviewModeCommandMixin._display_opt_in_message)Ú__name__Ú
__module__Ú__qualname__ÚtextwrapÚdedentrJ   r'   r;   r@   r?   rA   Ú__classcell__r   r   r>   r   r   q   s    
r   )Ú__doc__ÚloggingrH   rP   Ú	getLoggerrM   r   r   r   r   r   r   Úobjectr   r   r   r   r   Ú<module>   s   
ÿ