
    j                         d dl Z d dlZd dlZd dlmZ d dlmZ d dlm	Z	m
Z
 e	j        j        e
j        j        dZ G d dej                  ZdS )    N)abstract)v1v03)1.0z0.3c                   :   e Zd ZdZedej        eej        f         dej	        ej                 dd fd            Z
ddej        eef         dej        fdZdej        eej        f         fdZdej	        ej                 fd	Zd
edej        ddfdZd
eddfdZdS )
CloudEventzx
    Python-friendly cloudevent class supporting v1 events
    Supports both binary and structured mode CloudEvents
    
attributesdatareturnc                      | ||          S N )clsr	   r
   s      a/DATA/AppData/hermes/projects/honcho/.venv/lib/python3.11/site-packages/cloudevents/http/event.pycreatezCloudEvent.create#   s     s:t$$$    Nc                    d |                                 D             | _        || _        d| j        vr
d| j        d<   d| j        vr(t          t	          j                              | j        d<   d| j        vrHt          j                            t          j        j	                  
                                | j        d<   | j        d         t          vr"t          j        d| j        d                    t          | j        d                  }|| j                                        k    s1t          j        d|| j                                        z
             dS )	a  
        Event Constructor
        :param attributes: a dict with cloudevent attributes. Minimally
            expects the attributes 'type' and 'source'. If not given the
            attributes 'specversion', 'id' or 'time', this will create
            those attributes with default values.
            e.g. {
                "specversion": "1.0",
                "type": "com.github.pull_request.opened",
                "source": "https://github.com/cloudevents/spec/pull",
                "id": "A234-1234-1234",
                "time": "2018-04-05T17:31:00Z",
            }
        :type attributes: typing.Dict[str, str]
        :param data: The payload of the event, as a python object
        :type data: typing.Any
        c                 >    i | ]\  }}|                                 |S r   )lower).0kvs      r   
<dictcomp>z'CloudEvent.__init__.<locals>.<dictcomp>=   s&    HHHTQAGGIIqHHHr   specversionr   idtimezInvalid specversion: zMissing required keys: N)items_attributesr
   struuiduuid4datetimenowtimezoneutc	isoformat_required_by_versioncloud_exceptionsMissingRequiredFieldskeys)selfr	   r
   required_sets       r   __init__zCloudEvent.__init__+   s]   $ IHZ5E5E5G5GHHH	 000.3D]+t'''%(%6%6DT")))'/'8'<'<!%( (ikk V$ M*2FFF"8I(8(GII  
 ,D,<],KLt/446666"8R,9I9N9N9P9P*PRR   76r   c                     | j         S r   r   r+   s    r   _get_attributeszCloudEvent._get_attributesT   s    r   c                     | j         S r   )r
   r0   s    r   get_datazCloudEvent.get_dataW   s
    yr   keyvaluec                     || j         |<   d S r   r/   )r+   r4   r5   s      r   __setitem__zCloudEvent.__setitem__Z   s     %r   c                     | j         |= d S r   r/   )r+   r4   s     r   __delitem__zCloudEvent.__delitem__]   s    S!!!r   r   )__name__
__module____qualname____doc__classmethodtypingMappingr   AnyOptionalr   r-   Dictr1   r3   r7   r9   r   r   r   r   r      s>        
 %N3
?3% ofj)% 
	% % % [%' '6>#s(#; '6: ' ' ' 'R S&*_!=        &/&*5    &s &6: &$ & & & &"s "t " " " " " "r   r   )r"   r?   r    cloudevents.exceptions
exceptionsr(   cloudeventsr   cloudevents.sdk.eventr   r   Event_ce_required_fieldsr'   r   r   r   r   <module>rJ      s       1 1 1 1 1 1             ) ) ) ) ) ) ) ) 8'9(  A" A" A" A" A"$ A" A" A" A" A"r   