Ë
    9ài©F  ã                   ót   — d dl mZ d dlZddlmZmZmZ ddlm	Z	m
Z
  ej                  e«      Z G d„ d«      Zy)é    Né   )ÚerrorsÚtypesÚutils)ÚDEFAULT_SWARM_ADDR_POOLÚDEFAULT_SWARM_SUBNET_SIZEc                   ó˜  — e Zd Zd„ Z ej
                  d«      d„ «       Z ej
                  d«      	 	 	 	 dd„«       Z ej
                  d«      d„ «       Z ej                  d«       ej
                  d«      d„ «       «       Z
 ej
                  d«      	 	 dd	„«       Z ej
                  d«      dd
„«       Z ej
                  d«      dd„«       Z ej                  d«       ej
                  d«      dd„«       «       Z ej
                  d«      d„ «       Z ej
                  d«      dd„«       Z ej
                  d«      	 	 	 	 dd„«       Zy)ÚSwarmApiMixinc                 ó|   — |j                  dd«      }|r|g|d<   t        j                  | j                  g|¢­i |¤ŽS )a^
  
        Create a :py:class:`docker.types.SwarmSpec` instance that can be used
        as the ``swarm_spec`` argument in
        :py:meth:`~docker.api.swarm.SwarmApiMixin.init_swarm`.

        Args:
            task_history_retention_limit (int): Maximum number of tasks
                history stored.
            snapshot_interval (int): Number of logs entries between snapshot.
            keep_old_snapshots (int): Number of snapshots to keep beyond the
                current snapshot.
            log_entries_for_slow_followers (int): Number of log entries to
                keep around to sync up slow followers after a snapshot is
                created.
            heartbeat_tick (int): Amount of ticks (in seconds) between each
                heartbeat.
            election_tick (int): Amount of ticks (in seconds) needed without a
                leader to trigger a new election.
            dispatcher_heartbeat_period (int):  The delay for an agent to send
                a heartbeat to the dispatcher.
            node_cert_expiry (int): Automatic expiry for nodes certificates.
            external_cas (:py:class:`list`): Configuration for forwarding
                signing requests to an external certificate authority. Use
                a list of :py:class:`docker.types.SwarmExternalCA`.
            name (string): Swarm's name
            labels (dict): User-defined key/value metadata.
            signing_ca_cert (str): The desired signing CA certificate for all
                swarm node TLS leaf certificates, in PEM format.
            signing_ca_key (str): The desired signing CA key for all swarm
                node TLS leaf certificates, in PEM format.
            ca_force_rotate (int): An integer whose purpose is to force swarm
                to generate a new signing CA certificate and key, if none have
                been specified.
            autolock_managers (boolean): If set, generate a key and use it to
                lock data stored on the managers.
            log_driver (DriverConfig): The default log driver to use for tasks
                created in the orchestrator.

        Returns:
            :py:class:`docker.types.SwarmSpec`

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

        Example:

            >>> spec = client.api.create_swarm_spec(
              snapshot_interval=5000, log_entries_for_slow_followers=1200
            )
            >>> client.api.init_swarm(
              advertise_addr='eth0', listen_addr='0.0.0.0:5000',
              force_new_cluster=False, swarm_spec=spec
            )
        Úexternal_caNÚexternal_cas)Úpopr   Ú	SwarmSpecÚ_version)ÚselfÚargsÚkwargsÚext_cas       úQ/home/factor_ks/STREAMA2026/venv/lib/python3.12/site-packages/docker/api/swarm.pyÚcreate_swarm_speczSwarmApiMixin.create_swarm_spec   sA   € ðp —‘˜M¨4Ó0ˆÙØ&, XˆF�>Ñ"Ü�‰˜tŸ}™}Ð>¨tÒ>°vÑ>Ð>ó    z1.24c                 ób   — | j                  | j                  | j                  d«      «      d«      S )z”
            Get the unlock key for this Swarm manager.

            Returns:
                A ``dict`` containing an ``UnlockKey`` member
        z/swarm/unlockkeyT)Ú_resultÚ_getÚ_url)r   s    r   Úget_unlock_keyzSwarmApiMixin.get_unlock_keyI   s(   € ð �|‰|˜DŸI™I d§i¡iÐ0BÓ&CÓDÀdÓKÐKr   Nc	                 ó¨  — | j                  d«      }	|�t        |t        «      st        d«      ‚|�=t	        j
                  | j                  d«      rt        j                  d«      ‚|€t        }|�=t	        j
                  | j                  d«      rt        j                  d«      ‚|€t        }||||||dœ}
|�:t	        j
                  | j                  d«      rt        j                  d«      ‚||
d	<   |�:t	        j
                  | j                  d
«      rt        j                  d«      ‚||
d<   | j                  |	|
¬«      }| j                  |d¬«      S )a}	  
        Initialize a new Swarm using the current connected engine as the first
        node.

        Args:
            advertise_addr (string): Externally reachable address advertised
                to other nodes. This can either be an address/port combination
                in the form ``192.168.1.1:4567``, or an interface followed by a
                port number, like ``eth0:4567``. If the port number is omitted,
                the port number from the listen address is used. If
                ``advertise_addr`` is not specified, it will be automatically
                detected when possible. Default: None
            listen_addr (string): Listen address used for inter-manager
                communication, as well as determining the networking interface
                used for the VXLAN Tunnel Endpoint (VTEP). This can either be
                an address/port combination in the form ``192.168.1.1:4567``,
                or an interface followed by a port number, like ``eth0:4567``.
                If the port number is omitted, the default swarm listening port
                is used. Default: '0.0.0.0:2377'
            force_new_cluster (bool): Force creating a new Swarm, even if
                already part of one. Default: False
            swarm_spec (dict): Configuration settings of the new Swarm. Use
                ``APIClient.create_swarm_spec`` to generate a valid
                configuration. Default: None
            default_addr_pool (list of strings): Default Address Pool specifies
                default subnet pools for global scope networks. Each pool
                should be specified as a CIDR block, like '10.0.0.0/8'.
                Default: None
            subnet_size (int): SubnetSize specifies the subnet size of the
                networks created from the default subnet pool. Default: None
            data_path_addr (string): Address or interface to use for data path
                traffic. For example, 192.168.1.1, or an interface, like eth0.
            data_path_port (int): Port number to use for data path traffic.
                Acceptable port range is 1024 to 49151. If set to ``None`` or
                0, the default port 4789 will be used. Default: None

        Returns:
            (str): The ID of the created node.

        Raises:
            :py:class:`docker.errors.APIError`
                If the server returns an error.
        z/swarm/initzswarm_spec must be a dictionaryz1.39z6Address pool is only available for API version >= 1.39z5Subnet size is only available for API version >= 1.39)ÚAdvertiseAddrÚ
ListenAddrÚDefaultAddrPoolÚ
SubnetSizeÚForceNewClusterÚSpecú1.30ú;Data address path is only available for API version >= 1.30ÚDataPathAddrz1.40z8Data path port is only available for API version >= 1.40ÚDataPathPort©ÚdataT)Újson)r   Ú
isinstanceÚdictÚ	TypeErrorr   Ú
version_ltr   r   ÚInvalidVersionr   r   Ú
_post_jsonr   )r   Úadvertise_addrÚlisten_addrÚforce_new_clusterÚ
swarm_specÚdefault_addr_poolÚsubnet_sizeÚdata_path_addrÚdata_path_portÚurlr)   Úresponses               r   Ú
init_swarmzSwarmApiMixin.init_swarmS   sg  € ðb �i‰i˜Ó&ˆØÐ!¬*°ZÄÔ*FÜÐ=Ó>Ð>àÐ(Ü×Ñ §¡¨vÔ6Ü×+Ñ+ØLóð ð Ð"Ü7�àÐ"Ü×Ñ §¡¨vÔ6Ü×+Ñ+ØKóð ð !Ð(Ü$;Ð!ð ,Ø%Ø0Ø%Ø0Øñ
ˆð Ð%Ü×Ñ §¡¨vÔ6Ü×+Ñ+ð*óð ð $2ˆD�Ñ àÐ%Ü×Ñ §¡¨vÔ6Ü×+Ñ+ð*óð ð $2ˆD�Ñ à—?‘? 3¨T�?Ó2ˆØ�|‰|˜H¨4ˆ|Ó0Ð0r   c                 óf   — | j                  d«      }| j                  | j                  |«      d«      S )a  
        Retrieve low-level information about the current swarm.

        Returns:
            A dictionary containing data about the swarm.

        Raises:
            :py:class:`docker.errors.APIError`
                If the server returns an error.
        z/swarmT©r   r   r   )r   r9   s     r   Úinspect_swarmzSwarmApiMixin.inspect_swarm¶   s+   € ð �i‰i˜Ó!ˆØ�|‰|˜DŸI™I c›N¨DÓ1Ð1r   Únode_idc                 óh   — | j                  d|«      }| j                  | j                  |«      d«      S )aL  
        Retrieve low-level information about a swarm node

        Args:
            node_id (string): ID of the node to be inspected.

        Returns:
            A dictionary containing data about this node.

        Raises:
            :py:class:`docker.errors.APIError`
                If the server returns an error.
        ú
/nodes/{0}Tr=   )r   r?   r9   s      r   Úinspect_nodezSwarmApiMixin.inspect_nodeÅ   s-   € ð  �i‰i˜ gÓ.ˆØ�|‰|˜DŸI™I c›N¨DÓ1Ð1r   c                 óô   — ||||dœ}|�:t        j                  | j                  d«      rt        j                  d«      ‚||d<   | j                  d«      }| j                  ||¬«      }| j                  |«       y)aª  
        Make this Engine join a swarm that has already been created.

        Args:
            remote_addrs (:py:class:`list`): Addresses of one or more manager
                nodes already participating in the Swarm to join.
            join_token (string): Secret token for joining this Swarm.
            listen_addr (string): Listen address used for inter-manager
                communication if the node gets promoted to manager, as well as
                determining the networking interface used for the VXLAN Tunnel
                Endpoint (VTEP). Default: ``'0.0.0.0:2377``
            advertise_addr (string): Externally reachable address advertised
                to other nodes. This can either be an address/port combination
                in the form ``192.168.1.1:4567``, or an interface followed by a
                port number, like ``eth0:4567``. If the port number is omitted,
                the port number from the listen address is used. If
                AdvertiseAddr is not specified, it will be automatically
                detected when possible. Default: ``None``
            data_path_addr (string): Address or interface to use for data path
                traffic. For example, 192.168.1.1, or an interface, like eth0.

        Returns:
            ``True`` if the request went through.

        Raises:
            :py:class:`docker.errors.APIError`
                If the server returns an error.
        )ÚRemoteAddrsr   Ú	JoinTokenr   r$   r%   r&   z/swarm/joinr(   T)r   r.   r   r   r/   r   r0   Ú_raise_for_status)	r   Úremote_addrsÚ
join_tokenr2   r1   r7   r)   r9   r:   s	            r   Ú
join_swarmzSwarmApiMixin.join_swarmØ   s‰   € ð@ (Ø%Ø#Ø+ñ	
ˆð Ð%Ü×Ñ §¡¨vÔ6Ü×+Ñ+ð*óð ð $2ˆD�Ñ à�i‰i˜Ó&ˆØ—?‘? 3¨T�?Ó2ˆØ×Ñ˜xÔ(Ør   c                 óò   — | j                  d«      }| j                  |d|i¬«      }|r|j                  t        j                  k(  ry|r|j                  t        j
                  k(  ry| j                  |«       y)aP  
        Leave a swarm.

        Args:
            force (bool): Leave the swarm even if this node is a manager.
                Default: ``False``

        Returns:
            ``True`` if the request went through.

        Raises:
            :py:class:`docker.errors.APIError`
                If the server returns an error.
        z/swarm/leaveÚforce©ÚparamsT)r   Ú_postÚstatus_codeÚhttp_clientÚNOT_ACCEPTABLEÚSERVICE_UNAVAILABLErF   )r   rK   r9   r:   s       r   Úleave_swarmzSwarmApiMixin.leave_swarm  sn   € ð  �i‰i˜Ó'ˆØ—:‘:˜c¨7°EÐ*:�:Ó;ˆá�X×)Ñ)¬[×-GÑ-GÒGØñ �X×)Ñ)¬[×-LÑ-LÒLØØ×Ñ˜xÔ(Ør   c                 ó¢   — | j                  d«      }i }|rt        j                  |«      |d<   | j                  | j	                  ||¬«      d«      S )a°  
        List swarm nodes.

        Args:
            filters (dict): Filters to process on the nodes list. Valid
                filters: ``id``, ``name``, ``membership`` and ``role``.
                Default: ``None``

        Returns:
            A list of dictionaries containing data about each swarm node.

        Raises:
            :py:class:`docker.errors.APIError`
                If the server returns an error.
        z/nodesÚfiltersrL   T)r   r   Úconvert_filtersr   r   )r   rU   r9   rM   s       r   ÚnodeszSwarmApiMixin.nodes'  sM   € ð" �i‰i˜Ó!ˆØˆÙÜ %× 5Ñ 5°gÓ >ˆF�9Ñà�|‰|˜DŸI™I c°&˜IÓ9¸4Ó@Ð@r   c                 óx   — | j                  d|«      }d|i}| j                  ||¬«      }| j                  |«       y)aè  
        Remove a node from the swarm.

        Args:
            node_id (string): ID of the node to be removed.
            force (bool): Force remove an active node. Default: `False`

        Raises:
            :py:class:`docker.errors.NotFound`
                If the node referenced doesn't exist in the swarm.

            :py:class:`docker.errors.APIError`
                If the server returns an error.
        Returns:
            `True` if the request was successful.
        rA   rK   rL   T)r   Ú_deleterF   )r   r?   rK   r9   rM   Úress         r   Úremove_nodezSwarmApiMixin.remove_node?  sE   € ð& �i‰i˜ gÓ.ˆà�Uð
ˆð �l‰l˜3 vˆlÓ.ˆØ×Ñ˜sÔ#Ør   c                 óÈ   — t        |t        «      rd|vrt        j                  d«      ‚d|i}| j	                  d«      }| j                  ||¬«      }| j                  |«       y)al  
            Unlock a locked swarm.

            Args:
                key (string): The unlock key as provided by
                    :py:meth:`get_unlock_key`

            Raises:
                :py:class:`docker.errors.InvalidArgument`
                    If the key argument is in an incompatible format

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

            Returns:
                `True` if the request was successful.

            Example:

                >>> key = client.api.get_unlock_key()
                >>> client.unlock_swarm(key)

        Ú	UnlockKeyzInvalid unlock key formatz/swarm/unlockr(   T)r+   r,   r   ÚInvalidArgumentr   r0   rF   )r   Úkeyr9   rZ   s       r   Úunlock_swarmzSwarmApiMixin.unlock_swarmZ  sc   € ô2 �cœ4Ô Ø #Ñ%Ü×,Ñ,Ð-HÓIÐIà Ð$ˆCà�i‰i˜Ó(ˆØ�o‰o˜c¨ˆoÓ,ˆØ×Ñ˜sÔ#Ør   c                 ó„   — | j                  d|t        |«      «      }| j                  ||¬«      }| j                  |«       y)a©  
        Update the node's configuration

        Args:

            node_id (string): ID of the node to be updated.
            version (int): The version number of the node object being
                updated. This is required to avoid conflicting writes.
            node_spec (dict): Configuration settings to update. Any values
                not provided will be removed. Default: ``None``

        Returns:
            `True` if the request went through.

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

        Example:

            >>> node_spec = {'Availability': 'active',
                         'Name': 'node-name',
                         'Role': 'manager',
                         'Labels': {'foo': 'bar'}
                        }
            >>> client.api.update_node(node_id='24ifsmvkjbyhk', version=8,
                node_spec=node_spec)

        z/nodes/{0}/update?version={1}r(   T)r   Ústrr0   rF   )r   r?   ÚversionÚ	node_specr9   rZ   s         r   Úupdate_nodezSwarmApiMixin.update_node~  s>   € ð> �i‰iÐ7¸Ä#ÀgÃ,ÓOˆØ�o‰o˜c¨	ˆoÓ2ˆØ×Ñ˜sÔ#Ør   c                 óô   — | j                  d«      }|||dœ}|r:t        j                  | j                  d«      rt	        j
                  d«      ‚||d<   | j                  |||¬«      }| j                  |«       y)a£  
        Update the Swarm's configuration

        Args:
            version (int): The version number of the swarm object being
                updated. This is required to avoid conflicting writes.
            swarm_spec (dict): Configuration settings to update. Use
                :py:meth:`~docker.api.swarm.SwarmApiMixin.create_swarm_spec` to
                generate a valid configuration. Default: ``None``.
            rotate_worker_token (bool): Rotate the worker join token. Default:
                ``False``.
            rotate_manager_token (bool): Rotate the manager join token.
                Default: ``False``.
            rotate_manager_unlock_key (bool): Rotate the manager unlock key.
                Default: ``False``.

        Returns:
            ``True`` if the request went through.

        Raises:
            :py:class:`docker.errors.APIError`
                If the server returns an error.
        z/swarm/update)ÚrotateWorkerTokenÚrotateManagerTokenrc   z1.25zCRotate manager unlock key is only available for API version >= 1.25ÚrotateManagerUnlockKey)r)   rM   T)r   r   r.   r   r   r/   r0   rF   )	r   rc   r4   Úrotate_worker_tokenÚrotate_manager_tokenÚrotate_manager_unlock_keyr9   rM   r:   s	            r   Úupdate_swarmzSwarmApiMixin.update_swarm¢  s‡   € ð8 �i‰i˜Ó(ˆà!4Ø"6Øñ
ˆñ
 %Ü×Ñ §¡¨vÔ6Ü×+Ñ+ð@óð ð 0IˆFÐ+Ñ,à—?‘? 3¨ZÀ�?ÓGˆØ×Ñ˜xÔ(Ør   )Nú0.0.0.0:2377FNNNNN)rn   NN)F)N)NFFF)Ú__name__Ú
__module__Ú__qualname__r   r   Úminimum_versionr   r;   r>   Úcheck_resourcerB   rI   rS   rW   r[   r`   re   rm   © r   r   r
   r
   
   sÅ  „ ò;?ðz €U×Ñ˜6Ó"ñLó #ðLð €U×Ñ˜6Ó"Ø:HØ7;Ø7;Ø7;ò`1ó #ð`1ðD €U×Ñ˜6Ó"ñ2ó #ð2ð €U×Ñ˜)Ó$Ø€U×Ñ˜6Ó"ñ2ó #ó %ð2ð" €U×Ñ˜6Ó"Ø?MØ7;ò0ó #ð0ðd €U×Ñ˜6Ó"òó #ðð6 €U×Ñ˜6Ó"òAó #ðAð. €U×Ñ˜)Ó$Ø€U×Ñ˜6Ó"òó #ó %ðð2 €U×Ñ˜6Ó"ñ!ó #ð!ðF €U×Ñ˜6Ó"ò!ó #ð!ðF €U×Ñ˜6Ó"Ø/3Ø).Ø*/Ø/4ò+ó #ñ+r   r
   )Úhttp.clientÚclientrP   ÚloggingÚ r   r   r   Ú	constantsr   r   Ú	getLoggerro   Úlogr
   rt   r   r   ú<module>r|      s2   ðÝ !Û ç #Ñ #ß Jà€g×Ñ˜Ó!€÷Dò Dr   