o
    q_a
  ć                   @   s&   d dl Z ddlmZ G dd dZdS )é    Né   )Śutilsc                   @   sl   e Zd Ze d”dddZe d”e d”dd Ze d”e d”dd	 Ze d”dd
dZ	dS )ŚConfigApiMixinz1.30Nc                 C   sV   t |ts
| d”}t |”}| d”}||||d}|  d”}|  | j||dd”S )a  
            Create a config

            Args:
                name (string): Name of the config
                data (bytes): Config data to be stored
                labels (dict): A mapping of labels to assign to the config
                templating (dict): dictionary containing the name of the
                                   templating driver to be used expressed as
                                   { name: <templating_driver_name>}

            Returns (dict): ID of the newly created config
        zutf-8Śascii)ZDataŚNameZLabelsZ
Templatingz/configs/create)ŚdataT)	Ś
isinstanceŚbytesŚencodeŚbase64Z	b64encodeŚdecodeŚ_urlŚ_resultZ
_post_json)ŚselfŚnamer   ŚlabelsZ
templatingŚbodyŚurl© r   ś3/usr/lib/python3/dist-packages/docker/api/config.pyŚcreate_config   s   



ü
’zConfigApiMixin.create_configŚidc                 C   s   |   d|”}|  |  |”d”S )a2  
            Retrieve config metadata

            Args:
                id (string): Full ID of the config to inspect

            Returns (dict): A dictionary of metadata

            Raises:
                :py:class:`docker.errors.NotFound`
                    if no config with that ID exists
        ś/configs/{0}T)r   r   Ś_get)r   r   r   r   r   r   Śinspect_config'   s   zConfigApiMixin.inspect_configc                 C   s$   |   d|”}|  |”}|  |” dS )a%  
            Remove a config

            Args:
                id (string): Full ID of the config to remove

            Returns (boolean): True if successful

            Raises:
                :py:class:`docker.errors.NotFound`
                    if no config with that ID exists
        r   T)r   Z_deleteZ_raise_for_status)r   r   r   Śresr   r   r   Śremove_config9   s   

zConfigApiMixin.remove_configc                 C   s6   |   d”}i }|rt |”|d< |  | j||dd”S )zā
            List configs

            Args:
                filters (dict): A map of filters to process on the configs
                list. Available filters: ``names``

            Returns (list): A list of configs
        z/configsŚfilters)ŚparamsT)r   r   Zconvert_filtersr   r   )r   r   r   r   r   r   r   ŚconfigsM   s
   
zConfigApiMixin.configs)NN)N)
Ś__name__Ś
__module__Ś__qualname__r   Zminimum_versionr   Zcheck_resourcer   r   r   r   r   r   r   r      s    r   )r   Ś r   r   r   r   r   r   Ś<module>   s    