
    #                     (    S SK JrJr   " S S5      rg)   )authutilsc                      \ rS rSr\R
                  " S5      \R                  " S5      S 5       5       r\R
                  " S5      SS j5       r\R
                  " S5      SS j5       r	\R
                  " S5      SS j5       r
\R
                  " S5      S 5       r\R
                  " S5      SS
 j5       r\R
                  " S5      S 5       r\R
                  " S5      S 5       r\R
                  " S5      \R                  " S5      S 5       5       r\R
                  " S5      \R                  " S5      SS j5       5       r\R
                  " S5      \R                  " S5      S 5       5       rSrg	)PluginApiMixin   z1.25namec                     U R                  SU5      nUn[        U[        5      (       a)  UR                  5        VVs/ s H  u  pVU SU 3PM     nnnU R	                  X4S9nU R                  U5        gs  snnf )z
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}/set=)dataT)_url
isinstancedictitems
_post_json_raise_for_status)selfr   optionsurlr   kvress           $lib/third_party/docker/api/plugin.pyconfigure_pluginPluginApiMixin.configure_plugin   ss     ii*D1dD!!+/::<8<41qc1#J<D8ooco-s# 9s   A4c           
         U R                  S5      n[        R                  " X#[        [        R                  R                  U/ 5      5      S9 nU R                  USU0US9nSSS5        U R                  W5        g! , (       d  f       N = f)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)r   r   create_archivesetbuildwalk_postr   )r   r   plugin_data_dirr   r   archvr   s          r   create_pluginPluginApiMixin.create_plugin   s}      ii)*!! ekk&&;<
 **S&$e*DC	

 	s#
 
s   A<<
B
c                 n    U R                  SU5      nU R                  USU0S9nU R                  U5        g)z
Disable an installed plugin.

Args:
    name (string): The name of the plugin. The ``:latest`` tag is
        optional, and is the default if omitted.
    force (bool): To enable the force query parameter.

Returns:
    ``True`` if successful
z/plugins/{0}/disableforcer   Tr   r$   r   r   r   r*   r   r   s        r   disable_pluginPluginApiMixin.disable_plugin5   s=     ii.5jjgu%5j6s#    c                 p    U R                  SU5      nSU0nU R                  X4S9nU R                  U5        g)z
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timeoutr+   Tr,   )r   r   r2   r   r   r   s         r   enable_pluginPluginApiMixin.enable_pluginG   s@     ii-t4W%jjj,s#r0   c                 h    U R                  SU5      nU R                  U R                  U5      S5      $ )z
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)r   r   r   s      r   inspect_pluginPluginApiMixin.inspect_pluginZ   s.     ii+T2||DIIcND11r0   Nc                    U R                  S5      nSU0nU(       a  X5S'   0 n[        R                  " U5      u  px[        R                  " X5      n	U	(       a  XS'   U R	                  XEXbSS9n
U R                  U
5        U R                  U
SS9$ )ak  
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r   r   resolve_repository_nameget_config_headerr   r   _stream_helper)r   r<   
privilegesr   r   r   r?   registry	repo_nameheaderresponses              r   pull_pluginPluginApiMixin.pull_plugini   s    & ii(f
 !6N"::6B''7)/%&?? # 
 	x(""8D"99r0   c                 f    U R                  S5      nU R                  U R                  U5      S5      $ )zU
Retrieve a list of installed plugins.

Returns:
    A list of dicts, one per plugin
z/pluginsTr6   )r   r   s     r   pluginsPluginApiMixin.plugins   s+     ii
#||DIIcND11r0   c                     SU0n0 n[         R                  " U5      u  pE[         R                  " X5      nU(       a  XcS'   U R                  S5      nU R	                  U R                  XrUS9S5      $ )a  
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<   r=   z/plugins/privileges)r   r?   T)r   rD   rE   r   r7   r8   )r   r   r   r?   rH   rI   rJ   r   s           r   plugin_privileges PluginApiMixin.plugin_privileges   sx     d
 "::4@''7)/%&ii-.||IIc'I:D
 	
r0   c                     U R                  SU5      n0 n[        R                  " U5      u  pE[        R                  " X5      nU(       a  XcS'   U R	                  X#S9nU R                  U5        U R                  USS9$ )z
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}/pullr=   )r?   TrA   )r   r   rD   rE   r$   r   rF   )r   r   r   r?   rH   rI   rJ   r   s           r   push_pluginPluginApiMixin.push_plugin   s}     ii+T2"::4@''7)/%&jjj.s#""3t"44r0   c                 n    U R                  SU5      nU R                  USU0S9nU R                  U5        g)aB  
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}r*   r+   T)r   _deleter   r-   s        r   remove_pluginPluginApiMixin.remove_plugin   s<     ii-ll3'7l8s#r0   z1.26c                    U R                  SU5      nSU0n0 n[        R                  " U5      u  px[        R                  " X5      n	U	(       a  XS'   U R	                  XEXcSS9n
U R                  U
5        U R                  U
SS9$ )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<   r=   Tr>   rA   rC   )r   r   r<   rG   r   r   r?   rH   rI   rJ   rK   s              r   upgrade_pluginPluginApiMixin.upgrade_plugin   s    & ii.5f
 "::6B''7)/%&?? # 
 	x(""8D"99r0    )F)    )N)__name__
__module____qualname____firstlineno__r   minimum_versioncheck_resourcer   r'   r.   r3   r9   rL   rO   rR   rU   rY   r\   __static_attributes__r^   r0   r   r   r      s   
6"
&! " #( 6" #2 6" #" 6" #$ 6"2 #2 6"#: ##:J 6"2 #2 6"
 #
8 6"
&!5 " #5, 6"
&! " #$ 6"
&! : " # :r0   r   N) r   r   r   r^   r0   r   <module>rh      s    A: A:r0   