U
    /e                     @  s   d dl mZ d dlZeeZd dlmZmZ d dl	m
Z
 ddlmZ ddlmZ dd	lmZ errdd
lmZmZ dZG dd de
ZG dd dee ZdS )    )annotationsN)TYPE_CHECKINGAny)	TypedDict   )ID   )ProtocolError)Message)DocJsonDocument)pull_doc_replyc                   @  s   e Zd ZU ded< dS )PullDocr   docN)__name__
__module____qualname____annotations__ r   r   J/tmp/pip-unpacked-wheel-f5fndrjf/bokeh/protocol/messages/pull_doc_reply.pyr   2   s   
r   c                   @  s<   e Zd ZdZdZedddd dddZdd	d
ddZdS )r   z Define the ``PULL-DOC-REPLY`` message for replying to Document pull
    requests from clients

    The ``content`` fragment of for this message is has the form:

    .. code-block:: python

        {
            'doc' : <Document JSON>
        }

    zPULL-DOC-REPLYr   r   r   )
request_iddocumentmetadatareturnc                 K  s*   | j |d}t| d}| |||}|S )ac   Create an ``PULL-DOC-REPLY`` message

        Args:
            request_id (str) :
                The message ID for the message that issues the pull request

            document (Document) :
                The Document to reply with

        Any additional keyword arguments will be put into the message
        ``metadata`` fragment as-is.

        )r   )r   )Zcreate_headerr   Zto_json)clsr   r   r   headercontentmsgr   r   r   createE   s    zpull_doc_reply.createNone)r   r   c                 C  s&   d| j krtd|| j d  d S )Nr   zNo doc in PULL-DOC-REPLY)r   r	   Zreplace_with_json)selfr   r   r   r   push_to_documentZ   s    
zpull_doc_reply.push_to_documentN)r   r   r   __doc__Zmsgtypeclassmethodr   r!   r   r   r   r   r   5   s
   r   )
__future__r   logging	getLoggerr   logtypingr   r   Ztyping_extensionsr   Z
core.typesr   
exceptionsr	   messager
   Zdocument.documentr   r   __all__r   r   r   r   r   r   <module>   s   
