U
    ];                     @   s   d dl mZ d dlmZ d dlmZ d dlmZ d dlm	Z	 d dl
mZ d dlmZ d dlmZ d d	lmZ d d
lmZ d dlmZ d dlmZ d dlmZ G dd deZejZdS )   )	APIClient)DEFAULT_TIMEOUT_SECONDSConfigCollectionContainerCollectionImageCollectionNetworkCollectionNodeCollectionPluginCollectionSecretCollectionServiceCollectionSwarmVolumeCollection)kwargs_from_envc                   @   s"  e Zd ZdZdd Zedd Zedd Zedd	 Z	ed
d Z
edd Zedd Zedd Zedd Zedd Zedd Zedd Zdd Zejje_dd Zejje_dd Zejje_d d! Zejje_d"d# Zejje_d$d% Zejje_d&d' Zejje_d(d) Zd*S )+DockerClienta  
    A client for communicating with a Docker server.

    Example:

        >>> import docker
        >>> client = docker.DockerClient(base_url='unix://var/run/docker.sock')

    Args:
        base_url (str): URL to the Docker server. For example,
            ``unix:///var/run/docker.sock`` or ``tcp://127.0.0.1:1234``.
        version (str): The version of the API to use. Set to ``auto`` to
            automatically detect the server's version. Default: ``1.35``
        timeout (int): Default timeout for API calls, in seconds.
        tls (bool or :py:class:`~docker.tls.TLSConfig`): Enable TLS. Pass
            ``True`` to enable it with default options, or pass a
            :py:class:`~docker.tls.TLSConfig` object to use custom
            configuration.
        user_agent (str): Set a custom user agent for requests to the server.
        credstore_env (dict): Override environment variables when calling the
            credential store process.
    c                 O   s   t ||| _d S N)r   apiselfargskwargs r    //usr/lib/python3/dist-packages/docker/client.py__init__'   s    zDockerClient.__init__c                 K   s2   | dt}| dd}| f ||dtf |S )a:  
        Return a client configured from environment variables.

        The environment variables used are the same as those used by the
        Docker command-line client. They are:

        .. envvar:: DOCKER_HOST

            The URL to the Docker host.

        .. envvar:: DOCKER_TLS_VERIFY

            Verify the host against a CA certificate.

        .. envvar:: DOCKER_CERT_PATH

            A path to a directory containing TLS certificates to use when
            connecting to the Docker host.

        Args:
            version (str): The version of the API to use. Set to ``auto`` to
                automatically detect the server's version. Default: ``1.35``
            timeout (int): Default timeout for API calls, in seconds.
            ssl_version (int): A valid `SSL version`_.
            assert_hostname (bool): Verify the hostname of the server.
            environment (dict): The environment to read environment variables
                from. Default: the value of ``os.environ``
            credstore_env (dict): Override environment variables when calling
                the credential store process.

        Example:

            >>> import docker
            >>> client = docker.from_env()

        .. _`SSL version`:
            https://docs.python.org/3.5/library/ssl.html#ssl.PROTOCOL_TLSv1
        timeoutversionN)r#   r$   )popr   r   )clsr   r#   r$   r    r    r!   from_env*   s    ( zDockerClient.from_envc                 C   s
   t | dS )z
        An object for managing configs on the server. See the
        :doc:`configs documentation <configs>` for full details.
        Zclientr   r   r    r    r!   configsY   s    zDockerClient.configsc                 C   s
   t | dS )z
        An object for managing containers on the server. See the
        :doc:`containers documentation <containers>` for full details.
        r(   r   r)   r    r    r!   
containersa   s    zDockerClient.containersc                 C   s
   t | dS )z
        An object for managing images on the server. See the
        :doc:`images documentation <images>` for full details.
        r(   r   r)   r    r    r!   imagesi   s    zDockerClient.imagesc                 C   s
   t | dS )z
        An object for managing networks on the server. See the
        :doc:`networks documentation <networks>` for full details.
        r(   r
   r)   r    r    r!   networksq   s    zDockerClient.networksc                 C   s
   t | dS )z
        An object for managing nodes on the server. See the
        :doc:`nodes documentation <nodes>` for full details.
        r(   r   r)   r    r    r!   nodesy   s    zDockerClient.nodesc                 C   s
   t | dS )z
        An object for managing plugins on the server. See the
        :doc:`plugins documentation <plugins>` for full details.
        r(   r   r)   r    r    r!   plugins   s    zDockerClient.pluginsc                 C   s
   t | dS )z
        An object for managing secrets on the server. See the
        :doc:`secrets documentation <secrets>` for full details.
        r(   r   r)   r    r    r!   secrets   s    zDockerClient.secretsc                 C   s
   t | dS )z
        An object for managing services on the server. See the
        :doc:`services documentation <services>` for full details.
        r(   r   r)   r    r    r!   services   s    zDockerClient.servicesc                 C   s
   t | dS )z
        An object for managing a swarm on the server. See the
        :doc:`swarm documentation <swarm>` for full details.
        r(   r   r)   r    r    r!   swarm   s    zDockerClient.swarmc                 C   s
   t | dS )z
        An object for managing volumes on the server. See the
        :doc:`volumes documentation <volumes>` for full details.
        r(   r   r)   r    r    r!   volumes   s    zDockerClient.volumesc                 O   s   | j j||S r   )r   eventsr   r    r    r!   r4      s    zDockerClient.eventsc                 C   s
   | j  S r   )r   dfr)   r    r    r!   r5      s    zDockerClient.dfc                 O   s   | j j||S r   )r   infor   r    r    r!   r6      s    zDockerClient.infoc                 O   s   | j j||S r   )r   loginr   r    r    r!   r7      s    zDockerClient.loginc                 O   s   | j j||S r   )r   pingr   r    r    r!   r8      s    zDockerClient.pingc                 O   s   | j j||S r   )r   r$   r   r    r    r!   r$      s    zDockerClient.versionc                 C   s
   | j  S r   )r   closer)   r    r    r!   r9      s    zDockerClient.closec                 C   s2   d |g}tt|r |d td|d S )Nz+'DockerClient' object has no attribute '{}'zIn Docker SDK for Python 2.0, this method is now on the object APIClient. See the low-level API section of the documentation for more details. )formathasattrr   appendAttributeErrorjoin)r   namesr    r    r!   __getattr__   s    

zDockerClient.__getattr__N)__name__
__module____qualname____doc__r"   classmethodr'   propertyr*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r   r5   r6   r7   r8   r$   r9   rB   r    r    r    r!   r      sN   
.
















r   N)Z
api.clientr   Z	constantsr   Zmodels.configsr   Zmodels.containersr   Zmodels.imagesr	   Zmodels.networksr   Zmodels.nodesr   Zmodels.pluginsr   Zmodels.secretsr   Zmodels.servicesr   Zmodels.swarmr   Zmodels.volumesr   Zutilsr   objectr   r'   r    r    r    r!   <module>   s    A