
    ]h#                        U d dl mZ d dlZd dlmZ d dlmZ d dlmZmZm	Z	m
Z
mZmZmZ ddlmZmZ ddlmZ dd	lmZ d
gZ e       Zded<    ed      Z G d d
ee         Zy)    )annotationsN)	b64decode)datetime)castUnionAnyOptionalDictTypeVarGeneric   )_convert_to_isoformatTZ_UTC)_get_json_content)NULL
CloudEventr   _UnsetDataTypec            	         e Zd ZU dZded<   	 ded<   	 dZded<   	 ded<   	 ded	<   	 d
ed<   	 ded<   	 ded<   	 ded<   	 ded<   	 ddedddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZddZe	dd       Z
e	dd       Zy)r   a  Properties of the CloudEvent 1.0 Schema.
    All required parameters must be populated in order to send to Azure.

    :param source: Required. Identifies the context in which an event happened. The combination of id and source must
     be unique for each distinct event. If publishing to a domain topic, source must be the domain topic name.
    :type source: str
    :param type: Required. Type of event related to the originating occurrence.
    :type type: str
    :keyword specversion: Optional. The version of the CloudEvent spec. Defaults to "1.0"
    :paramtype specversion: str
    :keyword data: Optional. Event data specific to the event type.
    :paramtype data: object
    :keyword time: Optional. The time (in UTC) the event was generated.
    :paramtype time: ~datetime.datetime
    :keyword dataschema: Optional. Identifies the schema that data adheres to.
    :paramtype dataschema: str
    :keyword datacontenttype: Optional. Content type of data value.
    :paramtype datacontenttype: str
    :keyword subject: Optional. This describes the subject of the event in the context of the event producer
     (identified by source).
    :paramtype subject: str
    :keyword id: Optional. An identifier for the event. The combination of id and source must be
     unique for each distinct event. If not provided, a random UUID will be generated and used.
    :paramtype id: Optional[str]
    :keyword extensions: Optional. A CloudEvent MAY include any number of additional context attributes
     with distinct names represented as key - value pairs. Each extension must be alphanumeric, lower cased
     and must not exceed the length of 20 characters.
    :paramtype extensions: Optional[dict]
    strsourcetypez1.0specversionidOptional[DataType]dataOptional[datetime]timeOptional[str]
dataschemadatacontenttypesubjectOptional[Dict[str, Any]]
extensionsN)r   r   r   r!   r    r"   r   r$   c               6   || _         || _        |r|| _        |r|nt        t	        j
                               | _        |  |t        u rt        j                  t              | _        n|| _        || _        || _        || _        |	| _        |
| _        | j                   rJ| j                   j#                         D ]-  }|j%                         r|j'                         r$t)        d       |r1dj+                  |j#                               }t)        d| ddz         y )Nz<Extension attributes should be lower cased and alphanumeric.z, zUnexpected keyword arguments z. zDAny extension attributes must be passed explicitly using extensions.)r   r   r   r   uuiduuid4r   r   r   nowr   r   r!   r    r"   r   r$   keysislowerisalnum
ValueErrorjoin)selfr   r   r   r   r   r!   r    r"   r   r$   kwargskey	remainings                 Z/var/www/core.comfia.cic-ware.com/crm/lib/python3.12/site-packages/azure/core/messaging.py__init__zCloudEvent.__init__[   s     "	$/DrS%66> V,DIDI.=)3&-(,	4>??++- e{{}CKKM$%cdde 		&++-0I/	{"=XY      c                    dj                  | j                  | j                  | j                  | j                  | j
                        d d S )Nz>CloudEvent(source={}, type={}, specversion={}, id={}, time={})i   )formatr   r   r   r   r   )r.   s    r2   __repr__zCloudEvent.__repr__   s@    OVVKKD$4$4dggtyy

4 	r4   c                   i }g d}dv rdv rt        d      dv rj                  d      }||nt        |d<   n<dv r8t        t	        t
        t        t        f   j                  d                  |d<   dD ]%  }|v sj                  |      }||nt        ||<   ' j                         D ci c]  \  }}||vs|| }	}}|	r|	|d<   	  | dj                  d      d	   d
   j                  d      t        j                  d            d|}
|
S c c}}w # t        $ r1}t        fddD              rt        d      |t        d      |d}~ww xY w)a  Returns the deserialized CloudEvent object when a dict is provided.

        :param event: The dict representation of the event which needs to be deserialized.
        :type event: dict
        :rtype: CloudEvent
        :return: The deserialized CloudEvent object.
        )
r   data_base64r   r   r   r   r   r    r!   r"   r   r9   z@Invalid input. Only one of data and data_base64 must be present.N)r!   r    r"   r$   r   r   r   r   r   )r   r   r   r   r   c              3  &   K   | ]  }|v  
 y w)N ).0r0   events     r2   	<genexpr>z'CloudEvent.from_dict.<locals>.<genexpr>   s      
 u
s   )r"   	eventTyper   dataVersionr   	eventTimezThe event you are trying to parse follows the Eventgrid Schema. You can parse EventGrid events using EventGridEvent.from_dict method in the azure-eventgrid library.zThe event does not conform to the cloud event spec https://github.com/cloudevents/spec. The `source` and `type` params are required.r;   )r,   getr   r   r   r   r   bytesitemsr   KeyErrorall)clsr=   r/   reserved_attrr   itemvalkvr$   	event_objerrs    `          r2   	from_dictzCloudEvent.from_dict   s    "$
 U?}5_``U?99V$D%)%5T4F6Ne#&tE#u*,=uyy?W'XYF6N@ 	@Du}iio&)os4t	@
 (-{{}Otq!8NadO
O#-F< 	 99T?X6]!IIm4*599V+<= I> I P  	  

 
 !p  B '	s%   7D D A
D& &	E /,EE c                B    t        |      }t        j                  |      S )a  Returns the deserialized CloudEvent object when a json payload is provided.

        :param event: The json string that should be converted into a CloudEvent. This can also be
         a storage QueueMessage, eventhub's EventData or ServiceBusMessage
        :type event: object
        :rtype: CloudEvent
        :return: The deserialized CloudEvent object.
        :raises ValueError: If the provided JSON is invalid.
        )r   r   rO   )rG   r=   
dict_events      r2   	from_jsonzCloudEvent.from_json   s     'u-
##J//r4   )r   r   r   r   r   r   r   r   r   r   r!   r   r    r   r"   r   r   r   r$   r#   r/   r   returnNone)rS   r   )r=   zDict[str, Any]rS   CloudEvent[DataType])r=   r   rS   rU   )__name__
__module____qualname____doc____annotations__r   r   r3   r7   classmethodrO   rR   r;   r4   r2   r   r      s:   < Kt I>K@Ge 0
45""%! )(; &* #))-$(!%#'/3,, ,
 #, , !, ', ", , !, -, , 
,\
 H HT 0 0r4   )
__future__r   r&   base64r   r   typingr   r   r   r	   r
   r   r   utils._utilsr   r   utils._messaging_sharedr   serializationr   __all__objectr   rZ   r   r   r;   r4   r2   <module>rd      sY    #    E E E 7 6  . h :L0" L0r4   