Ë
    9àiPF  ã                   ó¸   — d dl Z d dlZd dlZddlmZ ddlmZ ddlmZm	Z	m
Z
 ddlmZ ddlmZ dd	lmZmZ  G d
„ de«      Z G d„ de«      Z G d„ de«      Zd„ Zy)é    Né   )Ú	APIClient)ÚDEFAULT_DATA_CHUNK_SIZE)Ú
BuildErrorÚImageLoadErrorÚInvalidArgument)Úparse_repository_tag)Újson_streamé   )Ú
CollectionÚModelc                   óh   — e Zd ZdZd„ Zed„ «       Zed„ «       Zed„ «       Zd„ Z	dd„Z
edfd	„Zdd„Zy
)ÚImagez!
    An image on the server.
    c                 ór   — dj                  | j                  «      }d| j                  j                  › d|› d�S )Nz', 'ú<z: 'z'>)ÚjoinÚtagsÚ	__class__Ú__name__)ÚselfÚtag_strs     úU/home/factor_ks/STREAMA2026/venv/lib/python3.12/site-packages/docker/models/images.pyÚ__repr__zImage.__repr__   s4   € Ø—+‘+˜dŸi™iÓ(ˆØ�4—>‘>×*Ñ*Ð+¨3¨w¨i°rÐ:Ð:ó    c                 óJ   — | j                   d   j                  d«      }|xs i S )z7
        The labels of an image as dictionary.
        ÚConfigÚLabels©ÚattrsÚget)r   Úresults     r   ÚlabelszImage.labels   s'   € ð
 —‘˜HÑ%×)Ñ)¨(Ó3ˆØŠ|˜Ðr   c                 ót   — | j                   j                  d«      r| j                   dd S | j                   dd S )úf
        The ID of the image truncated to 12 characters, plus the ``sha256:``
        prefix.
        úsha256:Né   é   )ÚidÚ
startswith©r   s    r   Úshort_idzImage.short_id   s6   € ð �7‰7×Ñ˜iÔ(Ø—7‘7˜3˜B�<ÐØ�w‰w�s˜ˆ|Ðr   c                 óv   — | j                   j                  d«      }|€g }|D �cg c]
  }|dk7  sŒ	|‘Œ c}S c c}w )z#
        The image's tags.
        ÚRepoTagsz<none>:<none>r   )r   r   Útags      r   r   z
Image.tags'   s;   € ð
 �z‰z�~‰~˜jÓ)ˆØˆ<ØˆDØ#Ö>˜ s¨oÓ'=’Ò>Ð>ùÒ>s   ¤
6¯6c                 ó`   — | j                   j                  j                  | j                  «      S )zß
        Show the history of an image.

        Returns:
            (list): The history of the image.

        Raises:
            :py:class:`docker.errors.APIError`
                If the server returns an error.
        )ÚclientÚapiÚhistoryr(   r*   s    r   r2   zImage.history1   s!   € ð �{‰{�‰×&Ñ& t§w¡wÓ/Ð/r   Fc                 óf   — | j                   j                  j                  | j                  ||¬«      S )a  
        Remove this image.

        Args:
            force (bool): Force removal of the image
            noprune (bool): Do not delete untagged parents

        Raises:
            :py:class:`docker.errors.APIError`
                If the server returns an error.
        )ÚforceÚnoprune)r0   r1   Úremove_imager(   )r   r4   r5   s      r   ÚremovezImage.remove>   s1   € ð �{‰{�‰×+Ñ+Ø�G‰GØØð ,ó 
ð 	
r   c                 ó   — | j                   }|rK| j                  r| j                  d   n|}t        |t        «      r|| j                  vrt	        |› d�«      ‚|}| j
                  j                  j                  ||«      S )a™  
        Get a tarball of an image. Similar to the ``docker save`` command.

        Args:
            chunk_size (int): The generator will return up to that much data
                per iteration, but may return less. If ``None``, data will be
                streamed as it is received. Default: 2 MB
            named (str or bool): If ``False`` (default), the tarball will not
                retain repository and tag information for this image. If set
                to ``True``, the first tag in the :py:attr:`~tags` list will
                be used to identify the image. Alternatively, any element of
                the :py:attr:`~tags` list can be used as an argument to use
                that specific tag as the saved identifier.

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

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

        Example:

            >>> image = cli.images.get("busybox:latest")
            >>> f = open('/tmp/busybox-latest.tar', 'wb')
            >>> for chunk in image.save():
            >>>   f.write(chunk)
            >>> f.close()
        r   z" is not a valid tag for this image)r(   r   Ú
isinstanceÚstrr   r0   r1   Ú	get_image)r   Ú
chunk_sizeÚnamedÚimgs       r   Úsavez
Image.saveP   su   € ð< �g‰gˆÙØ"&§)¢)�$—)‘)˜A’,°ˆCÜ˜%¤Ô%Ø §	¡	Ñ)Ü)Ø ˜'Ð!CÐDóð ð �à�{‰{�‰×(Ñ(¨¨jÓ9Ð9r   Nc                 ój   —  | j                   j                  j                  | j                  |fd|i|¤ŽS )a¢  
        Tag this image into a repository. Similar to the ``docker tag``
        command.

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

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

        Returns:
            (bool): ``True`` if successful
        r.   )r0   r1   r.   r(   ©r   Ú
repositoryr.   Úkwargss       r   r.   z	Image.tagz   s/   € ð" #ˆt�{‰{�‰×"Ñ" 4§7¡7¨JÑJ¸CÐJÀ6ÑJÐJr   )FF©N)r   Ú
__module__Ú__qualname__Ú__doc__r   Úpropertyr"   r+   r   r2   r7   r   r?   r.   © r   r   r   r      se   „ ñò;ð ñó ðð ñó ðð ñ?ó ð?ò0ó
ð$ 6¸Uó (:ôTKr   r   c                   óŒ   ‡ — e Zd ZdZˆ fd„Zed„ «       Zed„ «       Zdd„Zd„ Z	d„ Z
ej                  j                  e
_        ˆ xZS )	ÚRegistryDatazO
    Image metadata stored on the registry, including available platforms.
    c                 ó2   •— t        ‰| �  |i |¤Ž || _        y rD   )ÚsuperÚ__init__Ú
image_name)r   rO   ÚargsrC   r   s       €r   rN   zRegistryData.__init__’   s   ø€ Ü‰Ñ˜$Ð) &Ò)Ø$ˆ�r   c                 ó&   — | j                   d   d   S )z'
        The ID of the object.
        Ú
DescriptorÚdigest)r   r*   s    r   r(   zRegistryData.id–   s   € ð
 �z‰z˜,Ñ'¨Ñ1Ð1r   c                 ó    — | j                   dd S )r$   Nr&   )r(   r*   s    r   r+   zRegistryData.short_id�   s   € ð �w‰w�s˜ˆ|Ðr   c                 ó‚   — t        | j                  «      \  }}| j                  j                  || j                  |¬«      S )zé
        Pull the image digest.

        Args:
            platform (str): The platform to pull the image for.
            Default: ``None``

        Returns:
            (:py:class:`Image`): A reference to the pulled image.
        )r.   Úplatform)r	   rO   Ú
collectionÚpullr(   )r   rV   rB   Ú_s       r   rX   zRegistryData.pull¥   s6   € ô -¨T¯_©_Ó=‰ˆ
�AØ�‰×#Ñ# J°D·G±GÀhÐ#ÓOÐOr   c                 ój  — |rt        |t        «      so|j                  d«      }t        |«      dkD  st        |«      dk  rt	        d|› d�«      ‚d|d   i}t        |«      dkD  r|d   |d	<   t        |«      dkD  r|d   |d
<   t        || j                  j                  «       «      | j                  d   v S )aú  
        Check whether the given platform identifier is available for this
        digest.

        Args:
            platform (str or dict): A string using the ``os[/arch[/variant]]``
                format, or a platform dictionary.

        Returns:
            (bool): ``True`` if the platform is recognized as available,
            ``False`` otherwise.

        Raises:
            :py:class:`docker.errors.InvalidArgument`
                If the platform argument is not a valid descriptor.
        ú/é   r   ú"z$" is not a valid platform descriptorÚosr   r   ÚvariantÚarchitectureÚ	Platforms)	r9   ÚdictÚsplitÚlenr   Únormalize_platformr0   Úversionr   )r   rV   Úpartss      r   Úhas_platformzRegistryData.has_platform³   s¿   € ñ" œJ x´Ô6Ø—N‘N 3Ó'ˆEÜ�5‹z˜AŠ~¤ U£¨a¢Ü%Ø˜�zÐ!EÐFóð ð ˜e A™hÐ'ˆHÜ�5‹z˜AŠ~Ø&+¨A¡h�˜Ñ#Ü�5‹z˜AŠ~Ø+0°©8�˜Ñ(Ü!Ø�d—k‘k×)Ñ)Ó+ó
à�Z‰Z˜Ñ$ð%ð 	%r   c                 ól   — | j                   j                  j                  | j                  «      | _        y rD   )r0   r1   Úinspect_distributionrO   r   r*   s    r   ÚreloadzRegistryData.reloadÓ   s    € Ø—[‘[—_‘_×9Ñ9¸$¿/¹/ÓJˆ�
r   rD   )r   rE   rF   rG   rN   rH   r(   r+   rX   rh   rk   r   Ú__classcell__)r   s   @r   rK   rK   Ž   s\   ø„ ñô%ð ñ2ó ð2ð ñó ðóPò%ò@Kð —\‘\×)Ñ)€F‡N€Nr   rK   c                   ój  — e Zd ZeZd„ Zd„ Zdd„Zdd„Zd„ Z	dd„Z
dd„Zej                  j                  e_        d	„ Zej                  j                  e_        d
„ Zej                   j                  e_        dd„Zej$                  j                  e_        d„ Zej&                  j                  e_        y)ÚImageCollectionc                 ó¼  —  | j                   j                  j                  di |¤Ž}t        |t        «      r| j                  |«      S d}d}t        j                  t        |«      «      \  }}|D ]G  }d|v rt        |d   |«      ‚d|v r,t        j                  d|d   «      }|r|j                  d«      }|}ŒI |r| j                  |«      |fS t        |xs d|«      ‚)a…  
        Build an image and return it. Similar to the ``docker build``
        command. Either ``path`` or ``fileobj`` must be set.

        If you already have a tar file for the Docker build context (including
        a Dockerfile), pass a readable file-like object to ``fileobj``
        and also pass ``custom_context=True``. If the stream is also
        compressed, set ``encoding`` to the correct value (e.g ``gzip``).

        If you want to get the raw output of the build, use the
        :py:meth:`~docker.api.build.BuildApiMixin.build` method in the
        low-level API.

        Args:
            path (str): Path to the directory containing the Dockerfile
            fileobj: A file object to use as the Dockerfile. (Or a file-like
                object)
            tag (str): A tag to add to the final image
            quiet (bool): Whether to return the status
            nocache (bool): Don't use the cache when set to ``True``
            rm (bool): Remove intermediate containers. The ``docker build``
                command now defaults to ``--rm=true``, but we have kept the old
                default of `False` to preserve backward compatibility
            timeout (int): HTTP timeout
            custom_context (bool): Optional if using ``fileobj``
            encoding (str): The encoding for a stream. Set to ``gzip`` for
                compressing
            pull (bool): Downloads any updates to the FROM image in Dockerfiles
            forcerm (bool): Always remove intermediate containers, even after
                unsuccessful builds
            dockerfile (str): path within the build context to the Dockerfile
            buildargs (dict): A dictionary of build arguments
            container_limits (dict): A dictionary of limits applied to each
                container created by the build process. Valid keys:

                - memory (int): set memory limit for build
                - memswap (int): Total memory (memory + swap), -1 to disable
                    swap
                - cpushares (int): CPU shares (relative weight)
                - cpusetcpus (str): CPUs in which to allow execution, e.g.,
                    ``"0-3"``, ``"0,1"``
            shmsize (int): Size of `/dev/shm` in bytes. The size must be
                greater than 0. If omitted the system uses 64MB
            labels (dict): A dictionary of labels to set on the image
            cache_from (list): A list of images used for build cache
                resolution
            target (str): Name of the build-stage to build in a multi-stage
                Dockerfile
            network_mode (str): networking mode for the run commands during
                build
            squash (bool): Squash the resulting images layers into a
                single layer.
            extra_hosts (dict): Extra hosts to add to /etc/hosts in building
                containers, as a mapping of hostname to IP address.
            platform (str): Platform in the format ``os[/arch[/variant]]``.
            isolation (str): Isolation technology used during build.
                Default: `None`.
            use_config_proxy (bool): If ``True``, and if the docker client
                configuration file (``~/.docker/config.json`` by default)
                contains a proxy configuration, the corresponding environment
                variables will be set in the container being built.

        Returns:
            (tuple): The first item is the :py:class:`Image` object for the
                image that was built. The second item is a generator of the
                build logs as JSON-decoded objects.

        Raises:
            :py:class:`docker.errors.BuildError`
                If there is an error during the build.
            :py:class:`docker.errors.APIError`
                If the server returns any other error.
            ``TypeError``
                If neither ``path`` nor ``fileobj`` is specified.
        NÚerrorÚstreamz*(^Successfully built |sha256:)([0-9a-f]+)$r   ÚUnknownrI   )r0   r1   Úbuildr9   r:   r    Ú	itertoolsÚteer
   r   ÚreÚsearchÚgroup)	r   rC   ÚrespÚ
last_eventÚimage_idÚresult_streamÚinternal_streamÚchunkÚmatchs	            r   rs   zImageCollection.buildÜ   sæ   € ðX %ˆt�{‰{�‰×$Ñ$Ñ. vÑ.ˆÜ�dœCÔ Ø—8‘8˜D“>Ð!Øˆ
ØˆÜ)2¯©´{À4Ó7HÓ)IÑ&ˆ�Ø$ò 
	ˆEØ˜%ÑÜ   w¡°Ó?Ð?Ø˜5Ñ ÜŸ	™	ØAØ˜(‘Oó�ñ Ø$Ÿ{™{¨1›~�HØ‰Jð
	ñ Ø—H‘H˜XÓ&¨Ð6Ð6Ü˜Ò0 y°-Ó@Ð@r   c                 ój   — | j                  | j                  j                  j                  |«      «      S )am  
        Gets an image.

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

        Returns:
            (:py:class:`Image`): The image.

        Raises:
            :py:class:`docker.errors.ImageNotFound`
                If the image does not exist.
            :py:class:`docker.errors.APIError`
                If the server returns an error.
        )Úprepare_modelr0   r1   Úinspect_image)r   Únames     r   r    zImageCollection.get=  s(   € ð  ×!Ñ! $§+¡+§/¡/×"?Ñ"?ÀÓ"EÓFÐFr   Nc                 ó|   — t        || j                  j                  j                  ||«      | j                  | ¬«      S )a  
        Gets the registry data for an image.

        Args:
            name (str): The name of the image.
            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:
            (:py:class:`RegistryData`): The data object.

        Raises:
            :py:class:`docker.errors.APIError`
                If the server returns an error.
        )rO   r   r0   rW   )rK   r0   r1   rj   )r   rƒ   Úauth_configs      r   Úget_registry_dataz!ImageCollection.get_registry_dataO  s6   € ô" ØØ—+‘+—/‘/×6Ñ6°t¸[ÓIØ—;‘;Øô	
ð 	
r   c                 ó    — | j                   j                  j                  |||¬«      }|D �cg c]  }| j                  |d   «      ‘Œ c}S c c}w )a²  
        List images on the server.

        Args:
            name (str): Only show images belonging to the repository ``name``
            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:
            (list of :py:class:`Image`): The images.

        Raises:
            :py:class:`docker.errors.APIError`
                If the server returns an error.
        )rƒ   ÚallÚfiltersÚId)r0   r1   Úimagesr    )r   rƒ   rˆ   r‰   ry   Úrs         r   ÚlistzImageCollection.listg  sD   € ð* �{‰{�‰×%Ñ%¨4°SÀ'Ð%ÓJˆØ+/Ö0 a�—‘˜˜4™Õ!Ò0Ð0ùÒ0s   ­Ac                 óL  — | j                   j                  j                  |«      }g }|D ]U  }d|v r=t        j                  d|d   «      }|r"|j                  d«      }|j                  |«       d|v sŒIt        |d   «      ‚ |D �cg c]  }| j                  |«      ‘Œ c}S c c}w )a§  
        Load an image that was previously saved using
        :py:meth:`~docker.models.images.Image.save` (or ``docker save``).
        Similar to ``docker load``.

        Args:
            data (binary): Image data to be loaded.

        Returns:
            (list of :py:class:`Image`): The images.

        Raises:
            :py:class:`docker.errors.APIError`
                If the server returns an error.
        rq   z)(^Loaded image ID: |^Loaded image: )(.+)$r   rp   )	r0   r1   Ú
load_imagerv   rw   rx   Úappendr   r    )r   Údatary   r‹   r~   r   r{   Úis           r   ÚloadzImageCollection.load  s£   € ð  �{‰{�‰×)Ñ)¨$Ó/ˆØˆØò 
	5ˆEØ˜5Ñ ÜŸ	™	Ø@Ø˜(‘Oó�ñ Ø$Ÿ{™{¨1›~�HØ—M‘M (Ô+Ø˜%ÒÜ$ U¨7¡^Ó4Ð4ð
	5ð &,Ö, �—‘˜•Ò,Ð,ùÒ,s   ÂB!c                 óP  — t        |«      \  }}|xs |xs d}d|v rt        j                  dd¬«       |d=  | j                  j                  j
                  |f|d|dœ|¤Ž}|D ]  }Œ |s,|j                  d«      rd	nd
}| j                  |› |› |› �«      S | j                  |«      S )aÝ  
        Pull an image of the given name and return it. Similar to the
        ``docker pull`` command.
        If ``tag`` is ``None`` or empty, it is set to ``latest``.
        If ``all_tags`` is set, the ``tag`` parameter is ignored and all image
        tags will be pulled.

        If you want to get the raw pull output, use the
        :py:meth:`~docker.api.image.ImageApiMixin.pull` method in the
        low-level API.

        Args:
            repository (str): The repository to pull
            tag (str): The tag to pull
            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.
            platform (str): Platform in the format ``os[/arch[/variant]]``
            all_tags (bool): Pull all image tags

        Returns:
            (:py:class:`Image` or list): The image that has been pulled.
                If ``all_tags`` is True, the method will return a list
                of :py:class:`Image` objects belonging to this repository.

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

        Example:

            >>> # Pull the image tagged `latest` in the busybox repo
            >>> image = client.images.pull('busybox')

            >>> # Pull all tags in the busybox repo
            >>> images = client.images.pull('busybox', all_tags=True)
        Úlatestrq   zH`stream` is not a valid parameter for this method and will be overriddenr   )Ú
stacklevelT)r.   rq   Úall_tagsr%   ú@ú:)	r	   ÚwarningsÚwarnr0   r1   rX   r)   r    r�   )	r   rB   r.   r—   rC   Ú	image_tagÚpull_logrY   Úseps	            r   rX   zImageCollection.pullŸ  sÒ   € ôL !5°ZÓ @Ñˆ
�IØÒ*�YÒ* (ˆà�vÑÜ�M‰Mð*àõð
 �xÐ à'�4—;‘;—?‘?×'Ñ'Øð
Ø¨°xñ
ØCIñ
ˆð ò 	ˆAð ð		ñ
 ØŸ™¨	Ô2‘#¸ˆCØ—8‘8˜z˜l¨3¨%°¨uÐ5Ó6Ð6Ø�y‰y˜Ó$Ð$r   c                 óT   —  | j                   j                  j                  |fd|i|¤ŽS )Nr.   )r0   r1   ÚpushrA   s       r   r    zImageCollection.pushÝ  s'   € Ø#ˆt�{‰{�‰×#Ñ# JÑB°CÐB¸6ÑBÐBr   c                 óP   —  | j                   j                  j                  |i |¤Ž y rD   )r0   r1   r6   ©r   rP   rC   s      r   r7   zImageCollection.removeá  s   € Ø$ˆ�‰�‰×$Ñ$ dÐ5¨fÓ5r   c                 óN   —  | j                   j                  j                  |i |¤ŽS rD   )r0   r1   rw   r¢   s      r   rw   zImageCollection.searchå  s"   € Ø%ˆt�{‰{�‰×%Ñ% tÐ6¨vÑ6Ð6r   c                 óN   — | j                   j                  j                  |¬«      S )N)r‰   )r0   r1   Úprune_images)r   r‰   s     r   ÚprunezImageCollection.pruneé  s   € Ø�{‰{�‰×+Ñ+°GÐ+Ó<Ð<r   c                 óN   —  | j                   j                  j                  |i |¤ŽS rD   )r0   r1   Úprune_buildsr¢   s      r   r¨   zImageCollection.prune_buildsí  s"   € Ø+ˆt�{‰{�‰×+Ñ+¨TÐ<°VÑ<Ð<r   rD   )NFN)NF)r   rE   rF   r   Úmodelrs   r    r†   r�   r“   rX   r    r   rG   r7   r6   rw   r¦   r¥   r¨   rI   r   r   rn   rn   Ù   s£   „ Ø€Eò_AòBGó$
ó01ò0-ó@<%ó|Cà—>‘>×)Ñ)€D„Lò6à×+Ñ+×3Ñ3€F„Nò7à×%Ñ%×-Ñ-€F„Nó=à×*Ñ*×2Ñ2€E„Mò=à$×1Ñ1×9Ñ9€LÕr   rn   c                 ó>   — | €i } d| vr|d   | d<   d| vr|d   | d<   | S )Nr^   ÚOsr`   ÚArchrI   )rV   Úengine_infos     r   re   re   ò  s?   € ØÐØˆØ�8ÑØ$ TÑ*ˆ�‰Ø˜XÑ%Ø#.¨vÑ#6ˆ�Ñ Ø€Or   )rt   rv   rš   r1   r   Ú	constantsr   Úerrorsr   r   r   Úutilsr	   Úutils.json_streamr
   Úresourcer   r   r   rK   rn   re   rI   r   r   ú<module>r³      sW   ðÛ Û 	Û å Ý /ß @Ñ @Ý (Ý +ß 'ô~KˆEô ~KôBH*�5ô H*ôVV:�jô V:órr   