Ë
    ú}àid6  ã                   ó–   — d dl Z d dlmZmZ d dlmZmZmZmZ ddl	m
Z
mZ  G d„ de«      Z G d„ d	e
«      Zg d
¢Zg d¢Zg d¢Zg d¢Zd„ Zy)é    N)ÚInvalidArgumentÚcreate_unexpected_kwargs_error)ÚContainerSpecÚ	PlacementÚServiceModeÚTaskTemplateé   )Ú
CollectionÚModelc                   óZ   — e Zd ZdZdZed„ «       Zed„ «       Zd„ Zdd„Z	d„ Z
d	„ Zd
„ Zd„ Zy)ÚServicez
A service.ÚIDc                 ó&   — | j                   d   d   S )zThe service's name.ÚSpecÚName)Úattrs©Úselfs    ú]/home/factor_ks/STREAMA2026/tests/venv/lib/python3.12/site-packages/docker/models/services.pyÚnamezService.name   s   € ð �z‰z˜&Ñ! &Ñ)Ð)ó    c                 óV   — | j                   j                  d«      j                  d«      S )zÝ
        The version number of the service. If this is not the same as the
        server, the :py:meth:`update` function will not work and you will
        need to call :py:meth:`reload` before calling it again.
        ÚVersionÚIndex)r   Úgetr   s    r   ÚversionzService.version   s"   € ð �z‰z�~‰~˜iÓ(×,Ñ,¨WÓ5Ð5r   c                 ó`   — | j                   j                  j                  | j                  «      S )zž
        Stop and remove the service.

        Raises:
            :py:class:`docker.errors.APIError`
                If the server returns an error.
        )ÚclientÚapiÚremove_serviceÚidr   s    r   ÚremovezService.remove   s!   € ð �{‰{�‰×-Ñ-¨d¯g©gÓ6Ð6r   Nc                 ót   — |€i }| j                   |d<   | j                  j                  j                  |¬«      S )a³  
        List the tasks in this service.

        Args:
            filters (dict): A map of filters to process on the tasks list.
                Valid filters: ``id``, ``name``, ``node``,
                ``label``, and ``desired-state``.

        Returns:
            :py:class:`list`: List of task dictionaries.

        Raises:
            :py:class:`docker.errors.APIError`
                If the server returns an error.
        Úservice)Úfilters)r!   r   r   Útasks)r   r%   s     r   r&   zService.tasks%   s8   € ð  ˆ?ØˆGØ!ŸW™Wˆ�	ÑØ�{‰{�‰×$Ñ$¨WÐ$Ó5Ð5r   c                 ód  — d|vr| j                   d   d   d   }|d   |d<   |j                  d«      du r5| j                   d   d   }t        |j                  dd	«      «      }|d
z   |d<   t        d|«      } | j                  j
                  j                  | j                  | j                  fi |¤ŽS )a)  
        Update a service's configuration. Similar to the ``docker service
        update`` command.

        Takes the same parameters as :py:meth:`~ServiceCollection.create`.

        Raises:
            :py:class:`docker.errors.APIError`
                If the server returns an error.
        Úimager   r   r   ÚImageÚforce_updateTÚForceUpdater   r	   Úupdate)	r   r   ÚintÚ_get_create_service_kwargsr   r   Úupdate_servicer!   r   )r   ÚkwargsÚspecÚtask_templateÚcurrent_valueÚcreate_kwargss         r   r,   zService.update:   s¼   € ð ˜&Ñ Ø—:‘:˜fÑ% nÑ5°oÑFˆDØ" 7™mˆF�7‰Oà�:‰:�nÓ%¨Ñ-Ø ŸJ™J vÑ.¨~Ñ>ˆMÜ × 1Ñ 1°-ÀÓ CÓDˆMØ%2°QÑ%6ˆF�>Ñ"ä2°8¸VÓDˆà-ˆt�{‰{�‰×-Ñ-Ø�G‰GØ�L‰Lñ
ð ñ
ð 	
r   c                 ó²   — | j                   d   d   d   j                  dd«      } | j                  j                  j                  | j
                  fd|i|¤ŽS )aö  
        Get log stream for the service.
        Note: This method works only for services with the ``json-file``
        or ``journald`` logging drivers.

        Args:
            details (bool): Show extra details provided to logs.
                Default: ``False``
            follow (bool): Keep connection open to read logs as they are
                sent by the Engine. Default: ``False``
            stdout (bool): Return logs from ``stdout``. Default: ``False``
            stderr (bool): Return logs from ``stderr``. Default: ``False``
            since (int): UNIX timestamp for the logs staring point.
                Default: 0
            timestamps (bool): Add timestamps to every log line.
            tail (string or int): Number of log lines to be returned,
                counting from the current end of the logs. Specify an
                integer or ``'all'`` to output all log lines.
                Default: ``all``

        Returns:
            generator: Logs for the service.
        r   r   r   ÚTTYFÚis_tty)r   r   r   r   Úservice_logsr!   )r   r0   r7   s      r   ÚlogszService.logsW   sW   € ð0 —‘˜FÑ# NÑ3°OÑD×HÑHØ�5ó
ˆð ,ˆt�{‰{�‰×+Ñ+¨D¯G©GÑM¸FÐMÀfÑMÐMr   c                 óî   — d| j                   d   d   j                  «       v rt        d«      ‚t        d|«      }| j                  j
                  j                  | j                  | j                  |d¬«      S )zÂ
        Scale service container.

        Args:
            replicas (int): The number of containers that should be running.

        Returns:
            bool: ``True`` if successful.
        ÚGlobalr   ÚModezCannot scale a global containerÚ
replicatedT)ÚmodeÚfetch_current_spec)	r   Úkeysr   r   r   r   r/   r!   r   )r   ÚreplicasÚservice_modes      r   ÚscalezService.scalet   so   € ð �t—z‘z &Ñ)¨&Ñ1×6Ñ6Ó8Ñ8Ü!Ð"CÓDÐDä" <°Ó:ˆØ�{‰{�‰×-Ñ-¨d¯g©g°t·|±|Ø3?ØAEð .ó Gð 	Gr   c                 ó(   — | j                  dd¬«      S )z…
        Force update the service even if no changes require it.

        Returns:
            bool: ``True`` if successful.
        T)r*   r?   )r,   r   s    r   r*   zService.force_update‡   s   € ð �{‰{¨Àˆ{ÓFÐFr   ©N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úid_attributeÚpropertyr   r   r"   r&   r,   r9   rC   r*   © r   r   r   r   	   sQ   „ ÙØ€Làñ*ó ð*ð ñ6ó ð6ò7ó6ò*
ò:Nò:Gó&Gr   r   c                   ó*   — e Zd ZdZeZdd„Zdd„Zd„ Zy)ÚServiceCollectionzServices on the Docker server.Nc                 óœ   — ||d<   ||d<   t        d|«      } | j                  j                  j                  di |¤Ž}| j	                  |«      S )a™  
        Create a service. Similar to the ``docker service create`` command.

        Args:
            image (str): The image name to use for the containers.
            command (list of str or str): Command to run.
            args (list of str): Arguments to the command.
            constraints (list of str): :py:class:`~docker.types.Placement`
                constraints.
            preferences (list of tuple): :py:class:`~docker.types.Placement`
                preferences.
            maxreplicas (int): :py:class:`~docker.types.Placement` maxreplicas
                or (int) representing maximum number of replicas per node.
            platforms (list of tuple): A list of platform constraints
                expressed as ``(arch, os)`` tuples.
            container_labels (dict): Labels to apply to the container.
            endpoint_spec (EndpointSpec): Properties that can be configured to
                access and load balance a service. Default: ``None``.
            env (list of str): Environment variables, in the form
                ``KEY=val``.
            hostname (string): Hostname to set on the container.
            init (boolean): Run an init inside the container that forwards
                signals and reaps processes
            isolation (string): Isolation technology used by the service's
                containers. Only used for Windows containers.
            labels (dict): Labels to apply to the service.
            log_driver (str): Log driver to use for containers.
            log_driver_options (dict): Log driver options.
            mode (ServiceMode): Scheduling mode for the service.
                Default:``None``
            mounts (list of str): Mounts for the containers, in the form
                ``source:target:options``, where options is either
                ``ro`` or ``rw``.
            name (str): Name to give to the service.
            networks (:py:class:`list`): List of network names or IDs or
                :py:class:`~docker.types.NetworkAttachmentConfig` to attach the
                service to. Default: ``None``.
            resources (Resources): Resource limits and reservations.
            restart_policy (RestartPolicy): Restart policy for containers.
            secrets (list of :py:class:`~docker.types.SecretReference`): List
                of secrets accessible to containers for this service.
            stop_grace_period (int): Amount of time to wait for
                containers to terminate before forcefully killing them.
            update_config (UpdateConfig): Specification for the update strategy
                of the service. Default: ``None``
            rollback_config (RollbackConfig): Specification for the rollback
                strategy of the service. Default: ``None``
            user (str): User to run commands as.
            workdir (str): Working directory for commands to run.
            tty (boolean): Whether a pseudo-TTY should be allocated.
            groups (:py:class:`list`): A list of additional groups that the
                container process will run as.
            open_stdin (boolean): Open ``stdin``
            read_only (boolean): Mount the container's root filesystem as read
                only.
            stop_signal (string): Set signal to stop the service's containers
            healthcheck (Healthcheck): Healthcheck
                configuration for this service.
            hosts (:py:class:`dict`): A set of host to IP mappings to add to
                the container's `hosts` file.
            dns_config (DNSConfig): Specification for DNS
                related configurations in resolver configuration file.
            configs (:py:class:`list`): List of
                :py:class:`~docker.types.ConfigReference` that will be exposed
                to the service.
            privileges (Privileges): Security options for the service's
                containers.
            cap_add (:py:class:`list`): A list of kernel capabilities to add to
                the default set for the container.
            cap_drop (:py:class:`list`): A list of kernel capabilities to drop
                from the default set for the container.
            sysctls (:py:class:`dict`): A dict of sysctl values to add to the
                container

        Returns:
            :py:class:`Service`: The created service.

        Raises:
            :py:class:`docker.errors.APIError`
                If the server returns an error.
        r(   ÚcommandÚcreaterL   )r.   r   r   Úcreate_servicer   )r   r(   rP   r0   r4   Ú
service_ids         r   rQ   zServiceCollection.create–   sP   € ðd  ˆˆw‰Ø#ˆˆyÑÜ2°8¸VÓDˆØ3�T—[‘[—_‘_×3Ñ3ÑD°mÑDˆ
Ø�x‰x˜
Ó#Ð#r   c                 ól   — | j                  | j                  j                  j                  ||«      «      S )a}  
        Get a service.

        Args:
            service_id (str): The ID of the service.
            insert_defaults (boolean): If true, default values will be merged
                into the output.

        Returns:
            :py:class:`Service`: The service.

        Raises:
            :py:class:`docker.errors.NotFound`
                If the service does not exist.
            :py:class:`docker.errors.APIError`
                If the server returns an error.
            :py:class:`docker.errors.InvalidVersion`
                If one of the arguments is not supported with the current
                API version.
        )Úprepare_modelr   r   Úinspect_service)r   rS   Úinsert_defaultss      r   r   zServiceCollection.getî   s/   € ð* ×!Ñ!Ø�K‰K�O‰O×+Ñ+¨J¸ÓHó
ð 	
r   c                 ó’   —  | j                   j                  j                  di |¤ŽD �cg c]  }| j                  |«      ‘Œ c}S c c}w )a  
        List services.

        Args:
            filters (dict): Filters to process on the nodes list. Valid
                filters: ``id``, ``name`` , ``label`` and ``mode``.
                Default: ``None``.
            status (bool): Include the service task count of running and
                desired tasks. Default: ``None``.

        Returns:
            list of :py:class:`Service`: The services.

        Raises:
            :py:class:`docker.errors.APIError`
                If the server returns an error.
        rL   )r   r   ÚservicesrU   )r   r0   Úss      r   ÚlistzServiceCollection.list  sG   € ð( .�T—[‘[—_‘_×-Ñ-Ñ7°Ñ7ö
àð ×Ñ˜qÕ!ò
ð 	
ùò 
s   ©ArE   )	rF   rG   rH   rI   r   ÚmodelrQ   r   r[   rL   r   r   rN   rN   ’   s   „ Ù(Ø€EóV$óp
ó2
r   rN   )ÚargsÚcap_addÚcap_droprP   ÚconfigsÚ
dns_configÚenvÚgroupsÚhealthcheckÚhostnameÚhostsr(   ÚinitÚ	isolationÚlabelsÚmountsÚ
open_stdinÚ
privilegesÚ	read_onlyÚsecretsÚstop_grace_periodÚstop_signalÚttyÚuserÚworkdirÚsysctls)ÚnetworksÚ	resourcesÚrestart_policy)r   ri   r>   Úupdate_configÚrollback_configÚendpoint_spec)ÚconstraintsÚpreferencesÚ	platformsÚmaxreplicasc                 ó4  — i }t        j                   |«      D ]  }|t        v sŒ|j                  |«      ||<   Œ! i }t        j                   |«      D ]  }|t        v sŒ|j                  |«      ||<   Œ! i }t        j                   |«      D ]  }|t        v sŒ|j                  |«      ||<   Œ! d|v r|j                  d«      |d<   i }t        j                   |«      D ]  }|t
        v sŒ|j                  |«      ||<   Œ! t        di |¤Ž}||d<   d|v r'|j                  d«      |j                  di «      dœ|d<   | dk(  r/d|v r|j                  d«      |d<   |j                  d	d
«      }||d	<   |rt        | |«      ‚t        di |¤Ž}||d<   t        di |¤Ž|d<   |S )NÚcontainer_labelsri   Ú	placementÚ
log_driverÚlog_driver_options)r   ÚOptionsr,   r*   r?   TÚcontainer_specr2   rL   )
ÚcopyÚCREATE_SERVICE_KWARGSÚpopÚCONTAINER_SPEC_KWARGSÚTASK_TEMPLATE_KWARGSÚPLACEMENT_KWARGSr   r   r   r   )	Ú	func_namer0   r4   ÚkeyÚcontainer_spec_kwargsÚtask_template_kwargsr�   r?   r…   s	            r   r.   r.   V  sÜ  € à€MÜ�y‰y˜Ó ò 1ˆØÔ'Ò'Ø!'§¡¨C£ˆM˜#Òð1ð ÐÜ�y‰y˜Ó ò 9ˆØÔ'Ò'Ø)/¯©°C«Ð! #Ò&ð9ð ÐÜ�y‰y˜Ó ò 8ˆØÔ&Ò&Ø(.¯
©
°3«Ð  Ò%ð8ð ˜VÑ#Ø*0¯*©*Ð5GÓ*HÐ˜hÑ'à€IÜ�y‰y˜Ó ò -ˆØÔ"Ò"Ø#ŸZ™Z¨›_ˆI�cŠNð-ô Ñ&˜IÑ&€IØ(1Ð˜Ñ%à�vÑà—J‘J˜|Ó,Ø—z‘zÐ"6¸Ó;ñ.
Ð˜\Ñ*ð
 �HÒØ˜VÑ#Ø39·:±:¸nÓ3MÐ  Ñ0ð $ŸZ™ZÐ(<¸dÓCÐØ.@ˆÐ*Ñ+ñ Ü,¨Y¸Ó?Ð?ä"Ñ;Ð%:Ñ;€NØ-;ÐÐ)Ñ*Ü%1Ñ%IÐ4HÑ%I€M�/Ñ"ØÐr   )r†   Údocker.errorsr   r   Údocker.typesr   r   r   r   Úresourcer
   r   r   rN   r‰   rŠ   r‡   r‹   r.   rL   r   r   ú<module>r“      sY   ðÛ ç Iß LÓ Lç 'ôFGˆeô FGôRJ
˜
ô J
ò\Ð ò<Ð òÐ òÐ ó0r   