a
   .}"CX                   @   s0   d dl Z d dlZddlmZ G dd de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   sZ   t |ts|d}t|}tjr.|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

            Returns (dict): ID of the newly created config
        zutf-8ascii)ZDataNameZLabelsz/configs/create)dataT)
isinstancebytesencodebase64Z	b64encodesixZPY3decode_url_resultZ
_post_json)selfnamer   labelsbodyurl r   5/usr/lib/python3.9/site-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   _deleteZ_raise_for_status)r   r   r   resr   r   r   remove_config8   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   configsL   s
    
zConfigApiMixin.configs)N)N)
__name__
__module____qualname__r   Zminimum_versionr   Zcheck_resourcer   r   r!   r   r   r   r   r      s   r   )r   r    r   objectr   r   r   r   r   <module>   s   