o
    ¶žâcò  ã                   @   s0   d dl mZmZmZmZmZ G dd„ deƒZdS )é    )ÚKeyDictÚFloatÚBytesÚConstantÚAnyc                       s.   e Zd ZdZd‡ fdd„	Z‡ fdd„Z‡  ZS )ÚMessagea
  
    Like L{KeyDict}, but with three predefined keys: C{type}, C{api},
    and C{timestamp}. Of these, C{api} and C{timestamp} are optional.


    @param type: The type of the message. The C{type} key will need to
        match this as a constant.
    @param schema: A dict of additional schema in a format L{KeyDict}
        will accept.
    @param optional: An optional list of keys that should be optional.
    @param api: The server API version needed to send this message,
        if C{None} any version is fine.
    Nc                    sn   || _ || _tƒ |d< ttƒ td ƒƒ|d< t|ƒ|d< |d ur'| ddg¡ nddg}tt| ƒj	||d� d S )NÚ	timestampÚapiÚtype)Úoptional)
r
   r	   r   r   r   r   ÚextendÚsuperr   Ú__init__)Úselfr
   Úschemar   r	   ©Ú	__class__© úC/usr/lib/python3/dist-packages/landscape/message_schemas/message.pyr      s   
zMessage.__init__c                    s6   t | ¡ ƒD ]}|| jvr| |¡ qtt| ƒ |¡S )N)ÚlistÚkeysr   Úpopr   r   Úcoerce)r   ÚvalueÚkr   r   r   r      s
   

€zMessage.coerce)NN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   Ú__classcell__r   r   r   r   r      s    r   N)Úlandscape.lib.schemar   r   r   r   r   r   r   r   r   r   Ú<module>   s   