
    9Yf0                     J    d dl mZ d dlmZmZmZ d dlmZ  G d deee      Zy)    )ApiError)GetableAPIResourceCreateableAPIResourceSearchableAPIResource)	iteritemsc                   Z     e Zd ZdZdZ eddg      Zed fd	       Ze fd       Z	 xZ
S )Eventz*
    A wrapper around Event HTTP API.
    eventsstartendc                 t    |j                  d      r|d   dvrt        d      t        t        |   dd|i|S )a  
        Post an event.

        :param title: title for the new event
        :type title: string

        :param text: event message
        :type text: string

        :param aggregation_key: key by which to group events in event stream
        :type aggregation_key: string

        :param alert_type: "error", "warning", "info" or "success".
        :type alert_type: string

        :param date_happened: when the event occurred. if unset defaults to the current time.         (POSIX timestamp)
        :type date_happened: integer

        :param handle: user to post the event as. defaults to owner of the application key used         to submit.
        :type handle: string

        :param priority: priority to post the event as. ("normal" or "low", defaults to "normal")
        :type priority: string

        :param related_event_id: post event as a child of the given event
        :type related_event_id: id

        :param tags: tags to post the event with
        :type tags: list of strings

        :param host: host to post the event with
        :type host: string

        :param device_name: device_name to post the event with
        :type device_name: list of strings

        :returns: Dictionary representing the API's JSON response

        >>> title = "Something big happened!"
        >>> text = 'And let me tell you all about it here!'
        >>> tags = ['version:1', 'application:web']

        >>> api.Event.create(title=title, text=text, tags=tags)
        
alert_type)errorwarninginfosuccesszCParameter alert_type must be either error, warning, info or successattach_host_name )getr   superr	   create)clsr   params	__class__s      R/var/www/highfloat_scraper/venv/lib/python3.12/site-packages/datadog/api/events.pyr   zEvent.create   sG    ` ::l#l#+RRdeeUC'T9ITVTT    c                 r      fdt        fdt        |      D              }t        t           di |S )a  
        Get the events that occurred between the *start* and *end* POSIX timestamps,
        optional filtered by *priority* ("low" or "normal"), *sources* and
        *tags*.

        See the `event API documentation <http://docs.datadoghq.com/api/#events-get-all>`_ for the
        event data format.

        :returns: Dictionary representing the API's JSON response

        >>> api.Event.query(start=1313769783, end=1419436870, priority="normal",             tags=["application:web"])
        c                 :    | j                   v rt        |      S |S N)_timestamp_keysint)kvr   s     r   timestamp_to_integerz)Event.query.<locals>.timestamp_to_integerW   s    C'''1vr   c              3   :   K   | ]  \  }}| ||      f  y wr   r   ).0r"   r#   r$   s      r   	<genexpr>zEvent.query.<locals>.<genexpr>]   s"     T$!Qq.q!45Ts   r   )dictr   r   r	   _search)r   r   r$   r   s   ` @r   queryzEvent.queryG   s4     	 T)FBSTTUC(2622r   )T)__name__
__module____qualname____doc___resource_namesetr    classmethodr   r*   __classcell__)r   s   @r   r	   r	   	   sG     N7E*+O3U 3Uj 3 3r   r	   N)	datadog.api.exceptionsr   datadog.api.resourcesr   r   r   datadog.util.compatr   r	   r   r   r   <module>r6      s(    , b b )V3 57L V3r   