o
    h_p                     @   s4   d dl mZmZ G dd deZG dd deZdS )   )Model
Collectionc                   @   s2   e Zd ZdZdZedd Zdd Zddd	Zd
S )NodezA node in a swarm.ZIDc                 C   s   | j d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.
        ZVersionZIndex)Zattrsgetself r   5/usr/lib/python3/dist-packages/docker/models/nodes.pyversion   s   zNode.versionc                 C   s   | j j| j| j|S )a  
        Update the node's configuration.

        Args:
            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'}
                            }
            >>> node.update(node_spec)

        )clientapiZupdate_nodeidr
   )r   Z	node_specr   r   r	   update   s   zNode.updateFc                 C   s   | j jj| j|dS )a  
        Remove this node from the swarm.

        Args:
            force (bool): Force remove an active node. Default: `False`

        Returns:
            `True` if the request was successful.

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

            :py:class:`docker.errors.APIError`
                If the server returns an error.
        )force)r   r   Zremove_noder   )r   r   r   r   r	   remove,   s   zNode.removeN)F)	__name__
__module____qualname____doc__Zid_attributepropertyr
   r   r   r   r   r   r	   r      s    
r   c                   @   s$   e Zd ZdZeZdd Zdd ZdS )NodeCollectionzNodes on the Docker server.c                 C   s   |  | jj|S )a  
        Get a node.

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

        Returns:
            A :py:class:`Node` object.

        Raises:
            :py:class:`docker.errors.APIError`
                If the server returns an error.
        )prepare_modelr   r   Zinspect_node)r   Znode_idr   r   r	   r   D   s   zNodeCollection.getc                    s"    fdd j jj|i |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 :py:class:`Node` objects.

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

        Example:

            >>> client.nodes.list(filters={'role': 'manager'})
        c                    s   g | ]}  |qS r   )r   ).0nr   r   r	   
<listcomp>h   s    z'NodeCollection.list.<locals>.<listcomp>)r   r   Znodes)r   argskwargsr   r   r	   listT   s   
zNodeCollection.listN)r   r   r   r   r   Zmodelr   r   r   r   r   r	   r   @   s
    r   N)Zresourcer   r   r   r   r   r   r   r	   <module>   s    <