HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //proc/1233/cwd/usr/lib/python3/dist-packages/docker/api/__pycache__/plugin.cpython-310.pyc
o

�2.a�"�@s"ddlmZmZGdd�d�ZdS)�)�auth�utilsc@seZdZe�d�e�d�dd���Ze�d�ddd��Ze�d�dd	��Ze�d�ddd��Z	e�d�d
d��Z
e�d�ddd��Ze�d�dd��Ze�d�dd��Z
e�d�e�d�dd���Ze�d�e�d�ddd���Ze�d�e�d�dd���ZdS) �PluginApiMixinz1.25�namecCsH|�d|�}|}t|t�rdd�|��D�}|j||d�}|�|�dS)aC
            Configure a plugin.

            Args:
                name (string): The name of the plugin. The ``:latest`` tag is
                    optional, and is the default if omitted.
                options (dict): A key-value mapping of options

            Returns:
                ``True`` if successful
        z/plugins/{0}/setcSsg|]\}}|�d|���qS)�=�)�.0�k�vrr�3/usr/lib/python3/dist-packages/docker/api/plugin.py�
<listcomp>sz3PluginApiMixin.configure_plugin.<locals>.<listcomp>)�dataT)�_url�
isinstance�dict�items�
_post_json�_raise_for_status)�selfr�options�urlr
�resrrr�configure_plugins

zPluginApiMixin.configure_pluginFcCsj|�d�}tj||ttj�|g��d��}|j|d|i|d�}Wd�n1s)wY|�|�dS)a*
            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:
                ``True`` if successful
        z/plugins/create)�root�gzip�filesr)�paramsr
NT)rr�create_archive�set�build�walk�_postr)rr�plugin_data_dirrr�archvrrrr�
create_plugins
��
zPluginApiMixin.create_plugincCs$|�d|�}|�|�}|�|�dS)a

            Disable an installed plugin.

            Args:
                name (string): The name of the plugin. The ``:latest`` tag is
                    optional, and is the default if omitted.

            Returns:
                ``True`` if successful
        z/plugins/{0}/disableT�rr!r)rrrrrrr�disable_plugin5s

zPluginApiMixin.disable_plugin�cCs0|�d|�}d|i}|j||d�}|�|�dS)aV
            Enable an installed plugin.

            Args:
                name (string): The name of the plugin. The ``:latest`` tag is
                    optional, and is the default if omitted.
                timeout (int): Operation timeout (in seconds). Default: 0

            Returns:
                ``True`` if successful
        z/plugins/{0}/enable�timeout�rTr%)rrr(rrrrrr�
enable_pluginFs


zPluginApiMixin.enable_plugincCs|�d|�}|�|�|�d�S)a
            Retrieve plugin metadata.

            Args:
                name (string): The name of the plugin. The ``:latest`` tag is
                    optional, and is the default if omitted.

            Returns:
                A dict containing plugin info
        z/plugins/{0}/jsonT�r�_result�_get)rrrrrr�inspect_pluginYszPluginApiMixin.inspect_pluginNcCst|�d�}d|i}|r||d<i}t�|�\}}t�||�}	|	r$|	|d<|j||||dd�}
|�|
�|j|
dd�S)a
            Pull and install a plugin. After the plugin is installed, it can be
            enabled using :py:meth:`~enable_plugin`.

            Args:
                remote (string): Remote reference for the plugin to install.
                    The ``:latest`` tag is optional, and is the default if
                    omitted.
                privileges (:py:class:`list`): A list of privileges the user
                    consents to grant to the plugin. Can be retrieved using
                    :py:meth:`~plugin_privileges`.
                name (string): Local name for the pulled plugin. The
                    ``:latest`` tag is optional, and is the default if omitted.

            Returns:
                An iterable object streaming the decoded API logs
        z
/plugins/pull�remoter�X-Registry-AuthT�r�headersr
�stream��decode�rr�resolve_repository_name�get_config_headerrr�_stream_helper)rr/�
privilegesrrrr2�registry�	repo_name�header�responserrr�pull_pluginhs 
��
zPluginApiMixin.pull_plugincCs|�d�}|�|�|�d�S)z�
            Retrieve a list of installed plugins.

            Returns:
                A list of dicts, one per plugin
        z/pluginsTr+)rrrrr�plugins�s
zPluginApiMixin.pluginscCsTd|i}i}t�|�\}}t�||�}|r||d<|�d�}|�|j|||d�d�S)al
            Retrieve list of privileges to be granted to a plugin.

            Args:
                name (string): Name of the remote plugin to examine. The
                    ``:latest`` tag is optional, and is the default if omitted.

            Returns:
                A list of dictionaries representing the plugin's
                permissions

        r/r0z/plugins/privileges)rr2T)rr7r8rr,r-)rrrr2r;r<r=rrrr�plugin_privileges�s�
�z PluginApiMixin.plugin_privilegescCs\|�d|�}i}t�|�\}}t�||�}|r||d<|j||d�}|�|�|j|dd�S)a
            Push a plugin to the registry.

            Args:
                name (string): Name of the plugin to upload. The ``:latest``
                    tag is optional, and is the default if omitted.

            Returns:
                ``True`` if successful
        z/plugins/{0}/pullr0)r2Tr4)rrr7r8r!rr9)rrrr2r;r<r=rrrr�push_plugin�s

zPluginApiMixin.push_plugincCs,|�d|�}|j|d|id�}|�|�dS)a�
            Remove an installed plugin.

            Args:
                name (string): Name of the plugin to remove. The ``:latest``
                    tag is optional, and is the default if omitted.
                force (bool): Disable the plugin before removing. This may
                    result in issues if the plugin is in use by a container.

            Returns:
                ``True`` if successful
        z/plugins/{0}�forcer)T)r�_deleter)rrrCrrrrr�
remove_plugin�s
zPluginApiMixin.remove_pluginz1.26cCsj|�d|�}d|i}i}t�|�\}}t�||�}	|	r|	|d<|j||||dd�}
|�|
�|j|
dd�S)a�
            Upgrade an installed plugin.

            Args:
                name (string): Name of the plugin to upgrade. The ``:latest``
                    tag is optional and is the default if omitted.
                remote (string): Remote reference to upgrade to. The
                    ``:latest`` tag is optional and is the default if omitted.
                privileges (:py:class:`list`): A list of privileges the user
                    consents to grant to the plugin. Can be retrieved using
                    :py:meth:`~plugin_privileges`.

            Returns:
                An iterable object streaming the decoded API logs
        z/plugins/{0}/upgrader/r0Tr1r4r6)rrr/r:rrr2r;r<r=r>rrr�upgrade_plugin�s��
zPluginApiMixin.upgrade_plugin)F)r')N)�__name__�
__module__�__qualname__r�minimum_version�check_resourcerr$r&r*r.r?r@rArBrErFrrrrrs6

%


rN)�rrrrrrr�<module>s