o
    NrfS                     @   s@   d dl mZ ddlmZmZ G dd deZG dd deZdS )	   )errors   )
CollectionModelc                   @   st   e Zd ZdZdd Zedd Zedd Zedd	 Zd
d Z	dddZ
dddZdd ZdddZdddZdS )Pluginz!
    A plugin on the server.
    c                 C   s   d| j j d| j dS )N<z: 'z'>)	__class____name__nameself r   ^/var/www/html/software/conda/envs/catlas/lib/python3.10/site-packages/docker/models/plugins.py__repr__	   s   zPlugin.__repr__c                 C      | j dS )z$
        The plugin's name.
        Nameattrsgetr   r   r   r   r
         zPlugin.namec                 C   r   )z0
        Whether the plugin is enabled.
        ZEnabledr   r   r   r   r   enabled   r   zPlugin.enabledc                 C   r   )zG
        A dictionary representing the plugin's configuration.
        ZSettingsr   r   r   r   r   settings   r   zPlugin.settingsc                 C      | j j| j| |   dS )a  
            Update the plugin's settings.

            Args:
                options (dict): A key-value mapping of options.

            Raises:
                :py:class:`docker.errors.APIError`
                    If the server returns an error.
        N)clientapiZconfigure_pluginr
   reload)r   optionsr   r   r   	configure!      zPlugin.configureFc                 C   r   )z
            Disable the plugin.

            Args:
                force (bool): Force disable. Default: False

            Raises:
                :py:class:`docker.errors.APIError`
                    If the server returns an error.
        N)r   r   Zdisable_pluginr
   r   r   forcer   r   r   disable/   s   zPlugin.disable    c                 C   r   )z
            Enable the plugin.

            Args:
                timeout (int): Timeout in seconds. Default: 0

            Raises:
                :py:class:`docker.errors.APIError`
                    If the server returns an error.
        N)r   r   Zenable_pluginr
   r   )r   timeoutr   r   r   enable>   r   zPlugin.enablec                 C   s   | j j| jS )a  
            Push the plugin to a remote registry.

            Returns:
                A dict iterator streaming the status of the upload.

            Raises:
                :py:class:`docker.errors.APIError`
                    If the server returns an error.
        )r   r   Zpush_pluginr
   r   r   r   r   pushL   s   zPlugin.pushc                 C   s   | j jj| j|dS )a.  
            Remove the plugin from the server.

            Args:
                force (bool): Remove even if the plugin is enabled.
                    Default: False

            Raises:
                :py:class:`docker.errors.APIError`
                    If the server returns an error.
        )r    )r   r   Zremove_pluginr
   r   r   r   r   removeY   s   zPlugin.removeNc                 c   sT    | j r	td|du r| j}| jj|}| jj| j||E dH  |   dS )aR  
            Upgrade the plugin.

            Args:
                remote (string): Remote reference to upgrade to. The
                    ``:latest`` tag is optional and is the default if omitted.
                    Default: this plugin's name.

            Returns:
                A generator streaming the decoded API logs
        z)Plugin must be disabled before upgrading.N)	r   r   ZDockerErrorr
   r   r   plugin_privilegesZupgrade_pluginr   )r   remote
privilegesr   r   r   upgradeg   s   
zPlugin.upgradeF)r"   N)r	   
__module____qualname____doc__r   propertyr
   r   r   r   r!   r$   r%   r&   r*   r   r   r   r   r      s    





r   c                   @   s4   e Zd ZeZdddZdd ZdddZd	d
 ZdS )PluginCollectionFc                 C   s   | j j||| | |S )aC  
            Create a new plugin.

            Args:
                name (string): The name of the plugin. The ``:latest`` tag is
                    optional, and is the default if omitted.
                plugin_data_dir (string): Path to the plugin data directory.
                    Plugin data directory must contain the ``config.json``
                    manifest file and the ``rootfs`` directory.
                gzip (bool): Compress the context using gzip. Default: False

            Returns:
                (:py:class:`Plugin`): The newly created plugin.
        )r   r   Zcreate_pluginr   )r   r
   Zplugin_data_dirgzipr   r   r   create   s   
zPluginCollection.createc                 C   s   |  | jj|S )ah  
        Gets a plugin.

        Args:
            name (str): The name of the plugin.

        Returns:
            (:py:class:`Plugin`): The plugin.

        Raises:
            :py:class:`docker.errors.NotFound` If the plugin does not
            exist.
            :py:class:`docker.errors.APIError`
                If the server returns an error.
        )prepare_modelr   r   Zinspect_plugin)r   r
   r   r   r   r      s   zPluginCollection.getNc                 C   s8   | j j|}| j j|||}|D ]}q| |p|S )a  
            Pull and install a plugin.

            Args:
                remote_name (string): Remote reference for the plugin to
                    install. The ``:latest`` tag is optional, and is the
                    default if omitted.
                local_name (string): Local name for the pulled plugin.
                    The ``:latest`` tag is optional, and is the default if
                    omitted. Optional.

            Returns:
                (:py:class:`Plugin`): The installed plugin
            Raises:
                :py:class:`docker.errors.APIError`
                    If the server returns an error.
        )r   r   r'   Zpull_pluginr   )r   Zremote_nameZ
local_namer)   it_datar   r   r   install   s
   zPluginCollection.installc                    s    j j } fdd|D S )z
        List plugins installed on the server.

        Returns:
            (list of :py:class:`Plugin`): The plugins.

        Raises:
            :py:class:`docker.errors.APIError`
                If the server returns an error.
        c                    s   g | ]}  |qS r   )r4   ).0rr   r   r   
<listcomp>   s    z)PluginCollection.list.<locals>.<listcomp>)r   r   plugins)r   respr   r   r   list   s   zPluginCollection.listr+   r,   )	r	   r-   r.   r   modelr3   r   r7   r=   r   r   r   r   r1      s    

r1   N) r   resourcer   r   r   r1   r   r   r   r   <module>   s    ~