HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: xnsbb3110 (1041)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/local/CyberPanel/lib/python3.10/site-packages/docker/api/__pycache__/service.cpython-310.pyc
o

��hK�@sBddlmZmZmZddlmZdd�Zdd�ZGdd�d�Zd	S)
�)�auth�errors�utils)�ServiceModecCsDdd�}|durAt�|d�r d|vr|dd�d|vr |dd�t�|d�r2|�d	�d
kr2|dd�t�|d�rAd
|vrA|dd�|dur_t�|d�rP|dd�t�|d�r_d
|vr_|dd�|dur}t�|d�r}d|vr}tdd�|dD��r}|dd�|du�r�d|vr�t�|d�r�|dd�|�d�r�t�|d�r�|d�d�r�|dd�t�|d�r�|d�d�r�|dd�|�d��r~|�d�}t�|d��r|�d �r�|d!d�|�d"�dur�|d#d�|�d$�dur�|d%d�|�d&�dur�|d'd�|�d(�du�r|d)d�|�d*�du�r|d+d�t�|d��r5|�d,�du�r(|d)d�|�d-�du�r5|d.d�t�|d��rV|�d/�du�rI|d0d�|�d1�du�rV|d2d�t�|d3��rj|�d4�du�rj|d5d3�t�|d6��r~|�d7�du�r~|d8d6�|�d9��r�t�|d��r�|d9�d:��r�|d;d�dSdSdSdSdS)<NcSst�|�d|����)Nz# is not supported in API version < )r�InvalidVersion)�param�min_version�r	�H/usr/local/CyberPanel/lib/python3.10/site-packages/docker/api/service.py�raise_version_errors�z0_check_api_features.<locals>.raise_version_error�1.25�MaxFailureRatiozUpdateConfig.max_failure_ratio�MonitorzUpdateConfig.monitorz1.28�
FailureAction�rollbackz$UpdateConfig.failure_action rollback�1.29�OrderzUpdateConfig.order�rollback_configzRollbackConfig.orderz1.32�Portscss�|]}|�d�VqdS)�PublishModeN)�get)�.0�pr	r	r
�	<genexpr>(s�z&_check_api_features.<locals>.<genexpr>zEndpointSpec.Ports[].mode�ForceUpdate�force_update�	Placementz1.30�	PlatformszPlacement.platformsz1.27�PreferenceszPlacement.preferences�
ContainerSpec�TTYzContainerSpec.tty�HostnamezContainerSpec.hostname�HostszContainerSpec.hosts�GroupszContainerSpec.groups�	DNSConfigzContainerSpec.dns_config�HealthcheckzContainerSpec.healthcheck�ReadOnly�
StopSignalzContainerSpec.stop_signal�ConfigszContainerSpec.configs�
PrivilegeszContainerSpec.privilegesz1.35�	IsolationzContainerSpec.isolationz1.38�InitzContainerSpec.init�	Resources�GenericResourceszResources.generic_resources)r�
version_ltr�any)�version�
task_template�
update_config�
endpoint_specrr�container_specr	r	r
�_check_api_featuress�

�




�

















�2r5cCsz|��}|dur;|��D].\}}|dkr2d|vri|d<|d��D]\}}|dur0||d|<q"q|dur:|||<q|S)Nr)�copy�items)�current�override�merged�ts_key�ts_value�cs_key�cs_valuer	r	r
�_merge_task_templatecs���r?c@s�eZdZe�d�			ddd��Ze�d�e�d�ddd���Ze�d�e�d�d	d
���Ze�d�e�d�dd���Z	e�d�dd
d��Z
e�d�e�d�			ddd���Ze�d�ddd��Ze�d�e�d�					ddd���Z
dS)�ServiceApiMixinz1.24Nc
Cs�t|j||||	�|�d�}
i}|�di��dd�}|dur#t�d��|r.t|t�s.t|�}t	�
|�\}
}t	�||
�}|rA||d<t�
|jd�rP|pO|�dd�}||||t�|�|d	�}|durd||d
<|	durl|	|d<|�|j|
||d�d
�S)a
        Create a service.

        Args:
            task_template (TaskTemplate): Specification of the task to start as
                part of the new service.
            name (string): User-defined name for the service. Optional.
            labels (dict): A map of labels to associate with the service.
                Optional.
            mode (ServiceMode): Scheduling mode for the service (replicated
                or global). Defaults to replicated.
            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``
            networks (:py:class:`list`): List of network names or IDs or
                :py:class:`~docker.types.NetworkAttachmentConfig` to attach the
                service to. Default: ``None``.
            endpoint_spec (EndpointSpec): Properties that can be configured to
                access and load balance a service. Default: ``None``.

        Returns:
            A dictionary containing an ``ID`` key for the newly created
            service.

        Raises:
            :py:class:`docker.errors.APIError`
                If the server returns an error.
        z/services/creater�ImageNz,Missing mandatory Image key in ContainerSpec�X-Registry-Authr�Networks)�Name�Labels�TaskTemplate�ModerC�EndpointSpec�UpdateConfig�RollbackConfig)�data�headersT)r5�_version�_urlrr�DockerException�
isinstance�dictrr�resolve_repository_name�get_config_headerrr.�pop�convert_service_networks�_result�
_post_json)�selfr1�name�labels�moder2�networks�endpoint_configr3r�urlrL�image�registry�	repo_name�auth_headerrKr	r	r
�create_servicessB$
�
��	�zServiceApiMixin.create_service�servicecCsN|�d|�}i}|durt�|jd�rt�d��||d<|�|j||d�d�S)a�
        Return information about a service.

        Args:
            service (str): Service name or ID.
            insert_defaults (boolean): If true, default values will be merged
                into the service inspect output.

        Returns:
            (dict): A dictionary of the server-side representation of the
                service, including all relevant properties.

        Raises:
            :py:class:`docker.errors.APIError`
                If the server returns an error.
        �
/services/{0}Nrz6insert_defaults is not supported in API version < 1.29�insertDefaults��paramsT)rNrr.rMrrrV�_get)rXrd�insert_defaultsr^rhr	r	r
�inspect_service�s�zServiceApiMixin.inspect_service�taskcCs|�d|�}|�|�|�d�S)a
        Retrieve information about a task.

        Args:
            task (str): Task ID

        Returns:
            (dict): Information about the task.

        Raises:
            :py:class:`docker.errors.APIError`
                If the server returns an error.
        z
/tasks/{0}T)rNrVri)rXrlr^r	r	r
�inspect_task�szServiceApiMixin.inspect_taskcCs$|�d|�}|�|�}|�|�dS)a
        Stop and remove a service.

        Args:
            service (str): Service name or ID

        Returns:
            ``True`` if successful.

        Raises:
            :py:class:`docker.errors.APIError`
                If the server returns an error.
        reT)rN�_delete�_raise_for_status)rXrdr^�respr	r	r
�remove_service�s

zServiceApiMixin.remove_servicecCs^d|rt�|�ndi}|durt�|jd�rt�d��||d<|�d�}|�|j||d�d�S)	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:
            A list of dictionaries containing data about each service.

        Raises:
            :py:class:`docker.errors.APIError`
                If the server returns an error.
        �filtersNz1.41z-status is not supported in API version < 1.41�statusz	/servicesrgT)	r�convert_filtersr.rMrrrNrVri)rXrrrsrhr^r	r	r
�servicess��
zServiceApiMixin.servicesrF��allc

Csd|||||||d�}
|�d|�}|j||
dd�}|	dur+|�|�ddd�d	d
�}	|�d||	�S)ar
            Get log stream for a service.
            Note: This endpoint works only for services with the ``json-file``
            or ``journald`` logging drivers.

            Args:
                service (str): ID or name of the service
                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``
                is_tty (bool): Whether the service's :py:class:`ContainerSpec`
                    enables the TTY option. If omitted, the method will query
                    the Engine for the information, causing an additional
                    roundtrip.

            Returns (generator): Logs for the service.
        )�details�follow�stdout�stderr�since�
timestamps�tailz/services/{0}/logsT)rh�streamN�SpecrFrr F)rNrirkr�_get_result_tty)
rXrdrxryrzr{r|r}r~�is_ttyrhr^�resr	r	r
�service_logs%s.!�
�����zServiceApiMixin.service_logscCs6d|rt�|�ndi}|�d�}|�|j||d�d�S)a�
        Retrieve a list of tasks.

        Args:
            filters (dict): A map of filters to process on the tasks list.
                Valid filters: ``id``, ``name``, ``service``, ``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.
        rrNz/tasksrgT)rrtrNrVri)rXrrrhr^r	r	r
�tasksWs�
zServiceApiMixin.tasksc
CsLt|j|||
|�|r d}
t�|jd�rd}
|j||
d�d}ni}|�d|�}i}i}|dur5|�d�n||d<|durB|�d�n||d<|durXt|t�sSt	|�}||d	<n|�d	�|d	<t
|�d
i�|�|d
<|d
�di�}|�dd�}|dur�t�|�\}}t�
||�}|r�||d
<|dur�||d<n|�d�|d<|dur�||d<n|�d�|d<|dur�t�|�}t�|jd�r�||d<n?||d
d<n8t�|jd�r�|�d�|d<n)|d
�d�du�r|�d
i�}|�d�}|dur�|�d�}|du�r||d
d<|
du�r
|
|d<n|�d�|d<|j||d|i|d�}|j|dd�S)a�
        Update a service.

        Args:
            service (string): A service identifier (either its name or service
                ID).
            version (int): The version number of the service object being
                updated. This is required to avoid conflicting writes.
            task_template (TaskTemplate): Specification of the updated task to
                start as part of the service.
            name (string): New name for the service. Optional.
            labels (dict): A map of labels to associate with the service.
                Optional.
            mode (ServiceMode): Scheduling mode for the service (replicated
                or global). Defaults to replicated.
            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``
            networks (:py:class:`list`): List of network names or IDs or
                :py:class:`~docker.types.NetworkAttachmentConfig` to attach the
                service to. Default: ``None``.
            endpoint_spec (EndpointSpec): Properties that can be configured to
                access and load balance a service. Default: ``None``.
            fetch_current_spec (boolean): Use the undefined settings from the
                current specification of the service. Default: ``False``

        Returns:
            A dictionary containing a ``Warnings`` key.

        Raises:
            :py:class:`docker.errors.APIError`
                If the server returns an error.
        TrN)rjr�z/services/{0}/updaterDrErGrFrrArBrIrJrrCrHr0)rKrhrL)�json)r5rMrr.rkrNrrPrQrr?rrRrSrUrWrV)rXrdr0r1rYrZr[r2r\r]r3�fetch_current_specr�inspect_defaultsr8r^rKrLr4r_r`rarb�converted_networks�current_task_template�current_networksrpr	r	r
�update_serviceosz*
���

�








�zServiceApiMixin.update_service)NNNNNNNN)N)NN)FFFFrvFrwN)
NNNNNNNNFN)�__name__�
__module__�__qualname__r�minimum_versionrc�check_resourcerkrmrqrur�r�r�r	r	r	r
r@rsB�K�0�r@N)	�rrr�typesrr5r?r@r	r	r	r
�<module>s
^