
    q_a
                     ,    d dl Z ddlmZ  G d d      Zy)    N   )utilsc                   $   e Zd Z ej                  d      dd       Z ej                  d       ej                  d      d               Z ej                  d       ej                  d      d               Z ej                  d      d	d       Z	y)
ConfigApiMixinz1.30Nc                    t        |t              s|j                  d      }t        j                  |      }|j                  d      }||||d}| j                  d      }| j                  | j                  ||      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)DataNameLabels
Templatingz/configs/create)dataT)	
isinstancebytesencodebase64	b64encodedecode_url_result
_post_json)selfnamer   labels
templatingbodyurls          3/usr/lib/python3/dist-packages/docker/api/config.pycreate_configzConfigApiMixin.create_config   s     $&;;w'D%{{7#$	
 ii)*||OOCdO+T
 	
    idc                 h    | j                  d|      }| j                  | j                  |      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   s      r   inspect_configzConfigApiMixin.inspect_config'   s-     ii+||DIIcND11r   c                 l    | j                  d|      }| j                  |      }| j                  |       y)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   _delete_raise_for_status)r   r    r   ress       r   remove_configzConfigApiMixin.remove_config9   s3     ii+ll3s#r   c                     | j                  d      }i }|rt        j                  |      |d<   | j                  | j	                  ||      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   convert_filtersr   r#   )r   r+   r   r,   s       r   configszConfigApiMixin.configsM   sM     ii
# % 5 5g >F9||DIIc&I94@@r   )NN)N)
__name__
__module____qualname__r   minimum_versionr   check_resourcer$   r)   r.    r   r   r   r      s    U6"
 #
> U6"U$2   #2  U6"U$   #$ U6"A #Ar   r   )r    r   r   r4   r   r   <module>r6      s     VA VAr   