Ë
    ú}ài O  ã                   ó~   — d dl Z d dlZddlmZmZmZ ddlmZ  e j                  e	«      Z
 G d„ d«      Zd„ Z	 	 d	d„Zy)
é    Né   )ÚauthÚerrorsÚutils)ÚDEFAULT_DATA_CHUNK_SIZEc                   ó
  — e Zd Z ej                  d«      efd„«       Z ej                  d«      d„ «       Zdd„Z	 	 dd„Z		 	 dd„Z
	 	 dd„Z	 	 dd	„Z	 	 dd
„Z	 	 dd„Z ej                  d«      d„ «       Z ej                   d«       ej                  d«      dd„«       «       Zdd„Z ej                   d«      dd„«       Z	 	 dd„Z	 	 dd„Z ej                  d«      dd„«       Zdd„Z ej                  d«      dd„«       Zy)ÚImageApiMixinÚimagec                 ón   — | j                  | j                  d|«      d¬«      }| j                  ||d«      S )aõ  
        Get a tarball of an image. Similar to the ``docker save`` command.

        Args:
            image (str): Image name to get
            chunk_size (int): The number of bytes returned by each iteration
                of the generator. If ``None``, data will be streamed as it is
                received. Default: 2 MB

        Returns:
            (generator): A stream of raw archive data.

        Raises:
            :py:class:`docker.errors.APIError`
                If the server returns an error.

        Example:

            >>> image = client.api.get_image("busybox:latest")
            >>> f = open('/tmp/busybox-latest.tar', 'wb')
            >>> for chunk in image:
            >>>   f.write(chunk)
            >>> f.close()
        z/images/{0}/getT)ÚstreamF)Ú_getÚ_urlÚ_stream_raw_result)Úselfr
   Ú
chunk_sizeÚress       úW/home/factor_ks/STREAMA2026/tests/venv/lib/python3.12/site-packages/docker/api/image.pyÚ	get_imagezImageApiMixin.get_image   s7   € ð4 �i‰i˜Ÿ	™	Ð"3°UÓ;ÀDˆiÓIˆØ×&Ñ& s¨J¸Ó>Ð>ó    c                 óh   — | j                  | j                  d|«      «      }| j                  |d«      S )a$  
        Show the history of an image.

        Args:
            image (str): The image to show history for

        Returns:
            (list): The history of the image

        Raises:
            :py:class:`docker.errors.APIError`
                If the server returns an error.
        z/images/{0}/historyT)r   r   Ú_result)r   r
   r   s      r   ÚhistoryzImageApiMixin.history)   s/   € ð �i‰i˜Ÿ	™	Ð"7¸Ó?Ó@ˆØ�|‰|˜C Ó&Ð&r   Nc                 óT  — |rdnd|rdnddœ}|r2t        j                  | j                  d«      r||d<   n|r||d<   nd|i}|rt        j                  |«      |d<   | j	                  | j                  | j                  d«      |¬	«      d
«      }|r|D �cg c]  }|d   ‘Œ	 c}S |S c c}w )a  
        List images. Similar to the ``docker images`` command.

        Args:
            name (str): Only show images belonging to the repository ``name``
            quiet (bool): Only return numeric IDs as a list.
            all (bool): Show intermediate image layers. By default, these are
                filtered out.
            filters (dict): Filters to be processed on the image list.
                Available filters:
                - ``dangling`` (bool)
                - `label` (str|list): format either ``"key"``, ``"key=value"``
                    or a list of such.

        Returns:
            (dict or list): A list if ``quiet=True``, otherwise a dict.

        Raises:
            :py:class:`docker.errors.APIError`
                If the server returns an error.
        é   r   )Úonly_idsÚallú1.25ÚfilterÚ	referenceÚfiltersz/images/json©ÚparamsTÚId)r   Ú
version_ltÚ_versionÚconvert_filtersr   r   r   )r   ÚnameÚquietr   r    r"   r   Úxs           r   ÚimageszImageApiMixin.images;   s¶   € ñ. #™¨Ù‘1 ñ
ˆñ Ü×Ñ §¡¨vÔ6à#'��xÒ áØ+/�G˜KÒ(à*¨DÐ1�GÙÜ %× 5Ñ 5°gÓ >ˆF�9ÑØ�l‰l˜4Ÿ9™9 T§Y¡Y¨~Ó%>Àv˜9ÓNØó!ˆáØ%(Ö) �A�d“GÒ)Ð)Øˆ
ùò *s   ÂB%c           
      ó  — |s|st        j                  d«      ‚| j                  d«      }t        |||t	        |t
        «      r|nd|¬«      }ddi}	|s|j                  d«      dk7  r#| j                  | j                  |d|¬	«      «      S t	        |t
        «      r;t        |d
«      5 }
| j                  | j                  ||
||	d¬«      «      cddd«       S |rd|	d<   | j                  | j                  ||||	¬«      «      S # 1 sw Y   yxY w)ad  
        Import an image. Similar to the ``docker import`` command.

        If ``src`` is a string or unicode string, it will first be treated as a
        path to a tarball on the local system. If there is an error reading
        from that file, ``src`` will be treated as a URL instead to fetch the
        image from. You can also pass an open file handle as ``src``, in which
        case the data will be read from that file.

        If ``src`` is unset but ``image`` is set, the ``image`` parameter will
        be taken as the name of an existing image to import from.

        Args:
            src (str or file): Path to tarfile, URL, or file-like object
            repository (str): The repository to create
            tag (str): The tag to apply
            image (str): Use another image like the ``FROM`` Dockerfile
                parameter
        z(Must specify src or image to import fromú/images/createN©ÚsrcÚchangesúContent-Typeúapplication/tarÚfromSrcú-)Údatar"   Úrb©r4   r"   ÚheadersÚtimeoutÚchunkedzTransfer-Encoding)r4   r"   r7   )
r   ÚDockerExceptionr   Ú_import_image_paramsÚ
isinstanceÚstrÚgetr   Ú_postÚopen)r   r.   Ú
repositoryÚtagr
   r/   Ú
stream_srcÚur"   r7   Úfs              r   Úimport_imagezImageApiMixin.import_imagef   s#  € ñ* ‘uÜ×(Ñ(Ø:óð ð �I‰IÐ&Ó'ˆä%Ø˜˜UÜ" 3¬Ô,‘°$Øô
ˆð
 "Ð#4Ð5ˆá�F—J‘J˜yÓ)¨SÒ0Ø—<‘<Ø—
‘
˜1 4°�
Ó7óð ô ˜œSÔ!Ü�c˜4“ð  AØ—|‘|Ø—J‘JØ ¨&¸'È4ð ó ó÷ñ ñ Ø/8�Ð+Ñ,Ø—<‘<Ø—
‘
˜1 3¨v¸w�
ÓGóð ÷ð ús   Â&%D Ä D	c           	      ó”   — | j                  d«      }t        ||d|¬«      }ddi}| j                  | j                  ||||d¬«      «      S )a@  
        Like :py:meth:`~docker.api.image.ImageApiMixin.import_image`, but
        allows importing in-memory bytes data.

        Args:
            data (bytes collection): Bytes collection containing valid tar data
            repository (str): The repository to create
            tag (str): The tag to apply
        r,   r3   r-   r0   r1   Nr6   )r   r;   r   r?   )r   r4   rA   rB   r/   rD   r"   r7   s           r   Úimport_image_from_dataz$ImageApiMixin.import_image_from_dataš   s`   € ð �I‰IÐ&Ó'ˆÜ%Ø˜ ¨gô
ˆð "Ð#4Ð5ˆØ�|‰|Ø�J‰JØ˜ V°WÀdð ó ó
ð 	
r   c                 ó,   — | j                  ||||¬«      S )aj  
        Like :py:meth:`~docker.api.image.ImageApiMixin.import_image`, but only
        supports importing from a tar file on disk.

        Args:
            filename (str): Full path to a tar file.
            repository (str): The repository to create
            tag (str): The tag to apply

        Raises:
            IOError: File does not exist.
        ©r.   rA   rB   r/   ©rF   )r   ÚfilenamerA   rB   r/   s        r   Úimport_image_from_filez$ImageApiMixin.import_image_from_file±   s%   € ð × Ñ Ø Z°SÀ'ð !ó 
ð 	
r   c                 ó.   — | j                  |d|||¬«      S )NT)r.   rC   rA   rB   r/   rK   )r   r   rA   rB   r/   s        r   Úimport_image_from_streamz&ImageApiMixin.import_image_from_streamÄ   s&   € à× Ñ Ø 4°JÀCØð !ó 
ð 	
r   c                 ó,   — | j                  ||||¬«      S )a"  
        Like :py:meth:`~docker.api.image.ImageApiMixin.import_image`, but only
        supports importing from a URL.

        Args:
            url (str): A URL pointing to a tar file.
            repository (str): The repository to create
            tag (str): The tag to apply
        rJ   rK   )r   ÚurlrA   rB   r/   s        r   Úimport_image_from_urlz#ImageApiMixin.import_image_from_urlË   s%   € ð × Ñ Ø 
°¸Wð !ó 
ð 	
r   c                 ó,   — | j                  ||||¬«      S )aX  
        Like :py:meth:`~docker.api.image.ImageApiMixin.import_image`, but only
        supports importing from another image, like the ``FROM`` Dockerfile
        parameter.

        Args:
            image (str): Image name to import from
            repository (str): The repository to create
            tag (str): The tag to apply
        )r
   rA   rB   r/   rK   )r   r
   rA   rB   r/   s        r   Úimport_image_from_imagez%ImageApiMixin.import_image_from_imageÚ   s%   € ð × Ñ Ø J°CÀð !ó 
ð 	
r   c                 ód   — | j                  | j                  | j                  d|«      «      d«      S )aŸ  
        Get detailed information about an image. Similar to the ``docker
        inspect`` command, but only for images.

        Args:
            image (str): The image to inspect

        Returns:
            (dict): Similar to the output of ``docker inspect``, but as a
        single dict

        Raises:
            :py:class:`docker.errors.APIError`
                If the server returns an error.
        z/images/{0}/jsonT©r   r   r   )r   r
   s     r   Úinspect_imagezImageApiMixin.inspect_imageê   s/   € ð" �|‰|Ø�I‰I�d—i‘iÐ 2°EÓ:Ó;¸Tó
ð 	
r   z1.30c                 ó:  — t        j                  |«      \  }}i }|€t        j                  | |«      }|r3||d<   n-t        j	                  d«       t        j
                  |«      |d<   | j                  d|«      }| j                  | j                  ||¬«      d«      S )a/  
        Get image digest and platform information by contacting the registry.

        Args:
            image (str): The image name to inspect
            auth_config (dict): Override the credentials that are found in the
                config for this request.  ``auth_config`` should contain the
                ``username`` and ``password`` keys to be valid.

        Returns:
            (dict): A dict containing distribution data

        Raises:
            :py:class:`docker.errors.APIError`
                If the server returns an error.
        úX-Registry-AuthúSending supplied auth configz/distribution/{0}/json)r7   T)	r   Úresolve_repository_nameÚget_config_headerÚlogÚdebugÚencode_headerr   r   r   )r   r
   Úauth_configÚregistryÚ_r7   ÚheaderrQ   s           r   Úinspect_distributionz"ImageApiMixin.inspect_distributionÿ   sš   € ô& ×2Ñ2°5Ó9‰ˆ�!àˆØÐÜ×+Ñ+¨D°(Ó;ˆFÙØ-3�Ð)Ò*ä�I‰IÐ4Ô5Ü)-×);Ñ);¸KÓ)HˆGÐ%Ñ&à�i‰iÐ0°%Ó8ˆà�|‰|Ø�I‰I�c 7ˆIÓ+¨Tó
ð 	
r   c                 óP  — i }|�:t        j                  | j                  d«      rt        j                  d«      ‚||d<   | j                  | j                  d«      ||d¬«      }t        j                  | j                  d«      r| j                  |d¬«      S | j                  |«       y)	a9  
        Load an image that was previously saved using
        :py:meth:`~docker.api.image.ImageApiMixin.get_image` (or ``docker
        save``). Similar to ``docker load``.

        Args:
            data (binary): Image data to be loaded.
            quiet (boolean): Suppress progress details in response.

        Returns:
            (generator): Progress output as JSON objects. Only available for
                         API version >= 1.23

        Raises:
            :py:class:`docker.errors.APIError`
                If the server returns an error.
        Nz1.23z,quiet is not supported in API version < 1.23r(   z/images/loadT)r4   r"   r   ©Údecode)
r   r$   r%   r   ÚInvalidVersionr?   r   Úversion_gteÚ_stream_helperÚ_raise_for_status)r   r4   r(   r"   r   s        r   Ú
load_imagezImageApiMixin.load_image#  s£   € ð$ ˆàÐÜ×Ñ §¡¨vÔ6Ü×+Ñ+ØBóð ð $ˆF�7‰Oà�j‰jØ�I‰I�nÓ%¨D¸Èð ó 
ˆô ×Ñ˜TŸ]™]¨FÔ3Ø×&Ñ& s°4Ð&Ó8Ð8à×Ñ˜sÕ#r   r   c                 ó¢   — | j                  d«      }i }|�t        j                  |«      |d<   | j                  | j	                  ||¬«      d«      S )a  
        Delete unused images

        Args:
            filters (dict): Filters to process on the prune list.
                Available filters:
                - dangling (bool):  When set to true (or 1), prune only
                unused and untagged images.

        Returns:
            (dict): A dict containing a list of deleted image IDs and
                the amount of disk space reclaimed in bytes.

        Raises:
            :py:class:`docker.errors.APIError`
                If the server returns an error.
        z/images/pruner    r!   T)r   r   r&   r   r?   )r   r    rQ   r"   s       r   Úprune_imageszImageApiMixin.prune_imagesF  sP   € ð& �i‰i˜Ó(ˆØˆØÐÜ %× 5Ñ 5°gÓ >ˆF�9ÑØ�|‰|˜DŸJ™J s°6˜JÓ:¸DÓAÐAr   c                 óV  — t        j                  |«      \  }}|xs |xs d}|rd}t        j                  |«      \  }	}
||dœ}i }|€t        j                  | |	«      }|r3||d<   n-t
        j                  d«       t        j                  |«      |d<   |�:t        j                  | j                  d«      rt        j                  d«      ‚||d<   | j                  | j                  d	«      |||d¬
«      }| j                  |«       |r| j                  ||¬«      S | j!                  |«      S )aa  
        Pulls an image. Similar to the ``docker pull`` command.

        Args:
            repository (str): The repository to pull
            tag (str): The tag to pull. If ``tag`` is ``None`` or empty, it
                is set to ``latest``.
            stream (bool): Stream the output as a generator. Make sure to
                consume the generator, otherwise pull might get cancelled.
            auth_config (dict): Override the credentials that are found in the
                config for this request.  ``auth_config`` should contain the
                ``username`` and ``password`` keys to be valid.
            decode (bool): Decode the JSON data from the server into dicts.
                Only applies with ``stream=True``
            platform (str): Platform in the format ``os[/arch[/variant]]``
            all_tags (bool): Pull all image tags, the ``tag`` parameter is
                ignored.

        Returns:
            (generator or str): The output

        Raises:
            :py:class:`docker.errors.APIError`
                If the server returns an error.

        Example:

            >>> resp = client.api.pull('busybox', stream=True, decode=True)
            ... for line in resp:
            ...     print(json.dumps(line, indent=4))
            {
                "status": "Pulling image (latest) from busybox",
                "progressDetail": {},
                "id": "e72ac664f4f0"
            }
            {
                "status": "Pulling image (latest) from busybox, endpoint: ...",
                "progressDetail": {},
                "id": "e72ac664f4f0"
            }

        ÚlatestN)rB   Ú	fromImagerY   rZ   z1.32z0platform was only introduced in API version 1.32Úplatformr,   )r"   r7   r   r8   rf   )r   Úparse_repository_tagr   r[   r\   r]   r^   r_   r$   r%   r   rh   r?   r   rk   rj   r   )r   rA   rB   r   r`   rg   rr   Úall_tagsÚ	image_tagra   Ú	repo_namer"   r7   rc   Úresponses                  r   ÚpullzImageApiMixin.pull_  sB  € ôX !&× :Ñ :¸:Ó FÑˆ
�IØÒ*�YÒ* (ˆáØˆCä"×:Ñ:¸:ÓFÑˆ�)ð Ø#ñ
ˆð ˆàÐÜ×+Ñ+¨D°(Ó;ˆFÙØ-3�Ð)Ò*ä�I‰IÐ4Ô5Ü)-×);Ñ);¸KÓ)HˆGÐ%Ñ&àÐÜ×Ñ §¡¨vÔ6Ü×+Ñ+ØFóð ð "*ˆF�:Ñà—:‘:Ø�I‰IÐ&Ó'°ÀØ 4ð ó 
ˆð
 	×Ñ˜xÔ(áØ×&Ñ& x¸Ð&Ó?Ð?à�|‰|˜HÓ%Ð%r   c                 óÊ  — |st        j                  |«      \  }}t        j                  |«      \  }}| j	                  d|«      }d|i}	i }
|€t        j
                  | |«      }|r3||
d<   n-t        j                  d«       t        j                  |«      |
d<   | j                  |d|
||	¬«      }| j                  |«       |r| j                  ||¬«      S | j                  |«      S )aG  
        Push an image or a repository to the registry. Similar to the ``docker
        push`` command.

        Args:
            repository (str): The repository to push to
            tag (str): An optional tag to push
            stream (bool): Stream the output as a blocking generator
            auth_config (dict): Override the credentials that are found in the
                config for this request.  ``auth_config`` should contain the
                ``username`` and ``password`` keys to be valid.
            decode (bool): Decode the JSON data from the server into dicts.
                Only applies with ``stream=True``

        Returns:
            (generator or str): The output from the server.

        Raises:
            :py:class:`docker.errors.APIError`
                If the server returns an error.

        Example:
            >>> resp = client.api.push(
            ...     'yourname/app',
            ...     stream=True,
            ...     decode=True,
            ... )
            ... for line in resp:
            ...   print(line)
            {'status': 'Pushing repository yourname/app (1 tags)'}
            {'status': 'Pushing','progressDetail': {}, 'id': '511136ea3c5a'}
            {'status': 'Image already pushed, skipping', 'progressDetail':{},
             'id': '511136ea3c5a'}
            ...

        z/images/{0}/pushrB   NrY   rZ   )r7   r   r"   rf   )r   rs   r   r[   r   r\   r]   r^   r_   Ú
_post_jsonrk   rj   r   )r   rA   rB   r   r`   rg   ra   rv   rD   r"   r7   rc   rw   s                r   ÚpushzImageApiMixin.push´  sô   € ñL Ü#×8Ñ8¸ÓD‰OˆJ˜Ü"×:Ñ:¸:ÓFÑˆ�)Ø�I‰IÐ(¨*Ó5ˆà�3ð
ˆð ˆàÐÜ×+Ñ+¨D°(Ó;ˆFÙØ-3�Ð)Ò*ä�I‰IÐ4Ô5Ü)-×);Ñ);¸KÓ)HˆGÐ%Ñ&à—?‘?Øˆt˜W¨V¸Fð #ó 
ˆð 	×Ñ˜xÔ(áØ×&Ñ& x¸Ð&Ó?Ð?à�|‰|˜HÓ%Ð%r   c                 óv   — ||dœ}| j                  | j                  d|«      |¬«      }| j                  |d«      S )zõ
        Remove an image. Similar to the ``docker rmi`` command.

        Args:
            image (str): The image to remove
            force (bool): Force removal of the image
            noprune (bool): Do not delete untagged parents
        )ÚforceÚnoprunez/images/{0}r!   T)Ú_deleter   r   )r   r
   r}   r~   r"   r   s         r   Úremove_imagezImageApiMixin.remove_imageö  s<   € ð !¨WÑ5ˆØ�l‰l˜4Ÿ9™9 ]°EÓ:À6ˆlÓJˆØ�|‰|˜C Ó&Ð&r   c                 ó|   — d|i}|�||d<   | j                  | j                  | j                  d«      |¬«      d«      S )až  
        Search for images on Docker Hub. Similar to the ``docker search``
        command.

        Args:
            term (str): A term to search for.
            limit (int): The maximum number of results to return.

        Returns:
            (list of dicts): The response of the search.

        Raises:
            :py:class:`docker.errors.APIError`
                If the server returns an error.
        ÚtermÚlimitz/images/searchr!   TrV   )r   r‚   rƒ   r"   s       r   ÚsearchzImageApiMixin.search  sJ   € ð  ˜$�ˆØÐØ#ˆF�7‰Oà�|‰|Ø�I‰I�d—i‘iÐ 0Ó1¸&ˆIÓAØó
ð 	
r   c                 ó    — |||rdnddœ}| j                  d|«      }| j                  ||¬«      }| j                  |«       |j                  dk(  S )aH  
        Tag an image into a repository. Similar to the ``docker tag`` command.

        Args:
            image (str): The image to tag
            repository (str): The repository to set for the tag
            tag (str): The tag name
            force (bool): Force

        Returns:
            (bool): ``True`` if successful

        Raises:
            :py:class:`docker.errors.APIError`
                If the server returns an error.

        Example:

            >>> client.api.tag('ubuntu', 'localhost:5000/ubuntu', 'latest',
                           force=True)
        r   r   )rB   Úrepor}   z/images/{0}/tagr!   éÉ   )r   r?   rk   Ústatus_code)r   r
   rA   rB   r}   r"   rQ   r   s           r   rB   zImageApiMixin.tag  sZ   € ð0 ØÙ‘Q Qñ
ˆð
 �i‰iÐ)¨5Ó1ˆØ�j‰j˜ VˆjÓ,ˆØ×Ñ˜sÔ#Ø�‰ #Ñ%Ð%r   )NFFN)NNNNNF©NNN)N)NFNFNF)NFNF)FF©NF)Ú__name__Ú
__module__Ú__qualname__r   Úcheck_resourcer   r   r   r*   rF   rH   rM   rO   rR   rT   rW   Úminimum_versionrd   rl   rn   rx   r{   r€   r„   rB   © r   r   r	   r	   
   s�  „ à€U×Ñ˜'Ó"Ø*Aò ?ó #ð?ð8 €U×Ñ˜'Ó"ñ'ó #ð'ó")ðV GKØ.3ó2ðh AEØ'+ó
ð. EIØ'+ó
ð& EIØ)-ó
ð ?CØ&*ó
ð CGØ(,ó
ð  €U×Ñ˜'Ó"ñ
ó #ð
ð( €U×Ñ˜6Ó"Ø€U×Ñ˜'Ó"ò 
ó #ó #ð 
óD!$ðF €U×Ñ˜6Ó"òBó #ðBð0 DHØ38óS&ðj DHØó@&ðD €U×Ñ˜'Ó"ò'ó #ð'ó
ð2 €U×Ñ˜'Ó"ò&ó #ñ&r   r	   c                 ó„   — 	 t        | t        «      xr t        j                  j	                  | «      S # t
        $ r Y yw xY wrŠ   )r<   r=   ÚosÚpathÚisfileÚ	TypeError)r.   s    r   Úis_filer–   ?  s?   € ðä�sœCÓ ò  Ü�G‰G�N‰N˜3Óð	
øô ò Ùðús   ‚03 ³	?¾?c                 ó^   — | |dœ}|r||d<   n|rt        |«      s||d<   nd|d<   |r||d<   |S )N)r†   rB   rq   r2   r3   r/   )r–   )r†   rB   r
   r.   r/   r"   s         r   r;   r;   I  sO   € ð Øñ€Fñ Ø#ˆˆ{ÒÙ	”W˜S”\ØˆˆyÒàˆˆyÑáØ#ˆˆyÑà€Mr   r‰   )Úloggingr’   Ú r   r   r   Ú	constantsr   Ú	getLoggerr‹   r]   r	   r–   r;   r�   r   r   ú<module>rœ      sE   ðÛ Û 	ç "Ñ "Ý /à€g×Ñ˜Ó!€÷r&ñ r&òjð 59Ø!%ôr   