o
    !dE                     @   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.

    NZsdbc                 C   s   |  dt d S )Nzbuilding-command-table.main)registermark_as_preview)events r   Ausr/lib/python3.10/site-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: %sTZPreviewCommand)Zcli_namesessionservice_name
is_enabledZevent_emitterzdoc-description.%s)_get_allowed_servicesPREVIEW_SERVICESloggerdebugtypePreviewModeCommandMixin	__class__nameZservice_modelr
   Zget_componentZregister_lastupdate_description_with_preview)Zcommand_tabler	   kwargsZallowed_servicesZpreview_servicer   Zoriginal_commandZ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styleZ
start_noteZboldr   HELP_SNIPPETstripwriteZevent_classsplitcodeZend_note)Z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)Zfull_configgetitemsappend)r	   allowedZ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)r&   _is_help_commandr'   r   __call___display_opt_in_message)r)   r*   Z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
)Zservice   )sysstderrr   r   ENABLE_DOCSformatZ_service_name)r)   r   r   r   r.      s   z/PreviewModeCommandMixin._display_opt_in_message)__name__
__module____qualname__textwrapdedentr5   r   r(   r-   r,   r.   __classcell__r   r   r+   r   r   q   s    
r   )__doc__loggingr3   r:   	getLoggerr7   r   r   r   r   r   r   objectr   r   r   r   r   <module>   s   
