U
    ð¤ùdè  ã                   @  s’   d Z ddlmZ ddlmZmZmZmZmZm	Z	m
Z
 erpddlmZ ddlmZmZ ddlmZ ddlmZmZ G dd	„ d	ƒZG d
d„ deƒZdS )z%Represent a response from the server.é    )Úannotations)ÚTYPE_CHECKINGÚAnyÚListÚMappingÚOptionalÚSequenceÚUnion)Ú	timedelta)Ú_OpMsgÚ_OpReply)Ú
Connection)Ú_AddressÚ_DocumentOutc                   @  s”   e Zd ZdZdddddddœd	d
„Zeddœdd„ƒZeddœdd„ƒZeddœdd„ƒZeddœdd„ƒZ	eddœdd„ƒZ
eddœdd„ƒZdS )ÚResponse©Ú_dataÚ_addressÚ_request_idÚ	_durationÚ_from_commandÚ_docsúUnion[_OpMsg, _OpReply]r   ÚintúOptional[timedelta]ÚboolzSequence[Mapping[str, Any]])ÚdataÚaddressÚ
request_idÚdurationÚfrom_commandÚdocsc                 C  s(   || _ || _|| _|| _|| _|| _dS )al  Represent a response from the server.

        :Parameters:
          - `data`: A network response message.
          - `address`: (host, port) of the source server.
          - `request_id`: The request id of this operation.
          - `duration`: The duration of the operation.
          - `from_command`: if the response is the result of a db command.
        Nr   )Úselfr   r   r   r   r    r!   © r#   ú4/tmp/pip-unpacked-wheel-oblwsawz/pymongo/response.pyÚ__init__   s    zResponse.__init__©Úreturnc                 C  s   | j S )z!Server response's raw BSON bytes.)r   ©r"   r#   r#   r$   r   8   s    zResponse.datac                 C  s   | j S )z"(host, port) of the source server.)r   r(   r#   r#   r$   r   =   s    zResponse.addressc                 C  s   | j S )z!The request id of this operation.)r   r(   r#   r#   r$   r   B   s    zResponse.request_idc                 C  s   | j S )zThe duration of the operation.)r   r(   r#   r#   r$   r   G   s    zResponse.durationc                 C  s   | j S )z.If the response is a result from a db command.)r   r(   r#   r#   r$   r    L   s    zResponse.from_commandc                 C  s   | j S )zThe decoded document(s).)r   r(   r#   r#   r$   r!   Q   s    zResponse.docsN)Ú__name__Ú
__module__Ú__qualname__Ú	__slots__r%   Úpropertyr   r   r   r   r    r!   r#   r#   r#   r$   r      s   r   c                	      sX   e Zd ZdZddddddddd	œ‡ fd
d„Zeddœdd„ƒZeddœdd„ƒZ‡  ZS )ÚPinnedResponse)Ú_connÚ_more_to_comer   r   r   r   r   r   zList[_DocumentOut])r   r   Úconnr   r   r    r!   Úmore_to_comec	           	        s&   t ƒ  ||||||¡ || _|| _dS )aI  Represent a response to an exhaust cursor's initial query.

        :Parameters:
          - `data`:  A network response message.
          - `address`: (host, port) of the source server.
          - `conn`: The Connection used for the initial query.
          - `request_id`: The request id of this operation.
          - `duration`: The duration of the operation.
          - `from_command`: If the response is the result of a db command.
          - `docs`: List of documents.
          - `more_to_come`: Bool indicating whether cursor is ready to be
            exhausted.
        N)Úsuperr%   r/   r0   )	r"   r   r   r1   r   r   r    r!   r2   ©Ú	__class__r#   r$   r%   Z   s    zPinnedResponse.__init__r&   c                 C  s   | j S )zßThe Connection used for the initial query.

        The server will send batches on this socket, without waiting for
        getMores from the client, until the result set is exhausted or there
        is an error.
        )r/   r(   r#   r#   r$   r1   v   s    zPinnedResponse.connc                 C  s   | j S )zIf true, server is ready to send batches on the socket until the
        result set is exhausted or there is an error.
        )r0   r(   r#   r#   r$   r2   €   s    zPinnedResponse.more_to_come)	r)   r*   r+   r,   r%   r-   r1   r2   Ú__classcell__r#   r#   r4   r$   r.   W   s    	r.   N)Ú__doc__Ú
__future__r   Útypingr   r   r   r   r   r   r	   Údatetimer
   Zpymongo.messager   r   Zpymongo.poolr   Zpymongo.typingsr   r   r   r.   r#   r#   r#   r$   Ú<module>   s   $;