§
    ÎÑßjË  ã                   óˆ   — d dl mZ d dlmZmZ d dlmZ ddgZ G d„ de¦  «        Z G d„ d¦  «        Z	 G d	„ de	¦  «        Z
d
S )é    )Ú	b64encode)Ú
ConnectionÚJsonResponse)ÚContainerImageÚRegistryClientÚ	HubClientc                   ó<   ‡ — e Zd ZeZ	 	 	 	 	 	 	 	 	 dˆ fd„	Zd„ Zˆ xZS )ÚDockerHubConnectionNTc           
      óv   •— t          ¦   «                              |||||||	|
¬¦  «         || _        || _        d S )N)ÚsecureÚhostÚportÚurlÚtimeoutÚ	proxy_urlÚbackoffÚretry_delay)ÚsuperÚ__init__ÚusernameÚpassword)Úselfr   r   r   r   r   r   r   r   r   r   Ú	__class__s              €úS/opt/saltstack/salt/lib/python3.11/site-packages/libcloud/container/utils/docker.pyr   zDockerHubConnection.__init__   sR   ø€ õ 	‰Œ×ÒØØØØØØØØ#ð 	ñ 		
ô 		
ð 		
ð !ˆŒØ ˆŒˆˆó    c           	      óì   — d|d<   | j         �gdt          t          d                     | j         | j        ¦  «                             d¦  «        ¦  «                             ¦   «         ¦  «        z   }||d<   |S )Nzapplication/jsonzContent-TypezBasic z{}:{}Úlatin1ÚAuthorization)r   Ústrr   Úformatr   ÚencodeÚstrip)r   ÚheadersÚauthstrs      r   Úadd_default_headersz'DockerHubConnection.add_default_headers6   ss   € Ø"4ˆ�ÑØŒ=Ð$Ø¥Ý˜7Ÿ>š>¨$¬-¸¼ÑGÔG×OÒOÐPXÑYÔYÑZÔZ×`Ò`ÑbÔbñ"ô "ñ ˆGð (/ˆG�OÑ$Øˆr   )	NNTNNNNNN)Ú__name__Ú
__module__Ú__qualname__r   ÚresponseClsr   r%   Ú__classcell__©r   s   @r   r
   r
      sn   ø€ € € € € Ø€Kð
 ØØØØØØØØð!ð !ð !ð !ð !ð !ð4ð ð ð ð ð ð r   r
   c                   ó<   — e Zd ZdZeZdd„Zdd„Zdd„Zdd	„Z	d
„ Z
dS )r   z1
    A client for the Docker v2 registry API
    Nc                 ó0   —  | j         |||fi |¤Ž| _        dS )ah  
        Construct a Docker registry client

        :param host: Your registry endpoint, e.g. 'registry.hub.docker.com'
        :type  host: ``str``

        :param username: (optional) Your registry account username
        :type  username: ``str``

        :param password: (optional) Your registry account password
        :type  password: ``str``
        N)ÚconnectionClsÚ
connection)r   r   r   r   Úkwargss        r   r   zRegistryClient.__init__G   s(   € ð -˜$Ô,¨T°8¸XÐPÐPÈÐPÐPˆŒˆˆr   Úlibraryéd   c                 óÞ   — d                      |||¦  «        }| j                             |¦  «        }g }|j        d         D ]+}|                     |                      ||¦  «        ¦  «         Œ,|S )aã  
        List the tags (versions) in a repository

        :param  repository_name: The name of the repository e.g. 'ubuntu'
        :type   repository_name: ``str``

        :param  namespace: (optional) The docker namespace
        :type   namespace: ``str``

        :param  max_count: The maximum number of records to return
        :type   max_count: ``int``

        :return: A list of images
        :rtype: ``list`` of :class:`libcloud.container.base.ContainerImage`
        z0/v2/repositories/{}/{}/tags/?page=1&page_size={}Úresults)r    r/   ÚrequestÚobjectÚappendÚ	_to_image)r   Úrepository_nameÚ	namespaceÚ	max_countÚpathÚresponseÚimagesÚimages           r   Úlist_imageszRegistryClient.list_imagesV   s   € ð  B×HÒHØØØñ
ô 
ˆð
 ”?×*Ò*¨4Ñ0Ô0ˆØˆØ”_ YÔ/ð 	Bð 	BˆEØ�MŠM˜$Ÿ.š.¨¸%Ñ@Ô@ÑAÔAÐAÐAØˆr   c                 óp   — d                      ||¦  «        }| j                             |¦  «        }|j        S )a_  
        Get the information about a specific repository

        :param  repository_name: The name of the repository e.g. 'ubuntu'
        :type   repository_name: ``str``

        :param  namespace: (optional) The docker namespace
        :type   namespace: ``str``

        :return: The details of the repository
        :rtype: ``object``
        z/v2/repositories/{}/{}/)r    r/   r5   r6   )r   r9   r:   r<   r=   s        r   Úget_repositoryzRegistryClient.get_repositoryq   s6   € ð )×/Ò/°	¸?ÑKÔKˆØ”?×*Ò*¨4Ñ0Ô0ˆØŒÐr   Úlatestc                 óš   — d                      |||¦  «        }| j                             |¦  «        }|                      ||j        ¦  «        S )aÙ  
        Get an image from a repository with a specific tag

        :param repository_name: The name of the repository, e.g. ubuntu
        :type  repository_name: ``str``

        :param  tag: (optional) The image tag (defaults to latest)
        :type   tag: ``str``

        :param  namespace: (optional) The docker namespace
        :type   namespace: ``str``

        :return: A container image
        :rtype: :class:`libcloud.container.base.ContainerImage`
        z/v2/repositories/{}/{}/tags/{}/)r    r/   r5   r8   r6   )r   r9   Útagr:   r<   r=   s         r   Ú	get_imagezRegistryClient.get_image‚   sG   € ð  1×7Ò7¸	À?ÐTWÑXÔXˆØ”?×*Ò*¨4Ñ0Ô0ˆØ�~Š~˜o¨x¬Ñ?Ô?Ð?r   c           	      ó¢   — d                      | j        j        ||d         ¦  «        }t          |d         |||d         d|d         id ¬¦  «        S )Nz{}/{}:{}ÚnameÚidÚ	full_size)rI   r<   rH   ÚversionÚextraÚdriver)r    r/   r   r   )r   r9   Úobjr<   s       r   r8   zRegistryClient._to_image–   s]   € Ø× Ò  ¤Ô!5°ÈÈFÌÑTÔTˆÝØ�4ŒyØØØ˜”KØ  KÔ 0Ð1Øð
ñ 
ô 
ð 	
r   ©NN)r1   r2   )r1   )rC   r1   )r&   r'   r(   Ú__doc__r
   r.   r   r@   rB   rF   r8   © r   r   r   r   @   sŒ   € € € € € ðð ð (€MðQð Qð Qð Qðð ð ð ð6ð ð ð ð"@ð @ð @ð @ð(	
ð 	
ð 	
ð 	
ð 	
r   c                   ó(   ‡ — e Zd ZdZdZdˆ fd„	Zˆ xZS )r   zV
    A client for the Docker Hub API

    The hub is based on the v2 registry API
    zregistry.hub.docker.comNc                 óJ   •—  t          ¦   «         j        | j        ||fi |¤Ž dS )zï
        Construct a Docker hub client

        :param username: (optional) Your Hub account username
        :type  username: ``str``

        :param password: (optional) Your hub account password
        :type  password: ``str``
        N)r   r   r   )r   r   r   r0   r   s       €r   r   zHubClient.__init__«   s0   ø€ ð 	�‰ŒÔ˜œ H¨hÐAÐA¸&ÐAÐAÐAÐAÐAr   rO   )r&   r'   r(   rP   r   r   r*   r+   s   @r   r   r   ¢   sX   ø€ € € € € ðð ð %€Dð
Bð 
Bð 
Bð 
Bð 
Bð 
Bð 
Bð 
Bð 
Bð 
Br   N)Úbase64r   Úlibcloud.common.baser   r   Úlibcloud.container.baser   Ú__all__r
   r   r   rQ   r   r   ú<module>rX      sç   ðð" Ð Ð Ð Ð Ð à 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9Ø 2Ð 2Ð 2Ð 2Ð 2Ð 2à˜[Ð
)€ð$ð $ð $ð $ð $˜*ñ $ô $ð $ðN_
ð _
ð _
ð _
ð _
ñ _
ô _
ð _
ðDBð Bð Bð Bð B�ñ Bô Bð Bð Bð Br   