o
    i0                     @   sD   d dl mZ d dlmZmZmZ d dlmZ G dd deeeZdS )    )ApiError)GetableAPIResourceCreateableAPIResourceSearchableAPIResource)	iteritemsc                       sF   e Zd ZdZdZeddgZed
 fdd	Ze fdd	Z	  Z
S )Eventz*
    A wrapper around Event HTTP API.
    eventsstartendTc                    s8   | dr|d dvrtdtt| j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_nameN )getr   superr   create)clsr   params	__class__r   F/home/ubuntu/.local/lib/python3.10/site-packages/datadog/api/events.pyr      s   
0zEvent.createc                    s<    fddt fddt|D }tt j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                    s   |  j v r	t|S |S N)_timestamp_keysint)kv)r   r   r   timestamp_to_integerW   s   
z)Event.query.<locals>.timestamp_to_integerc                 3   s"    | ]\}}| ||fV  qd S r   r   ).0r   r   )r   r   r   	<genexpr>]   s     zEvent.query.<locals>.<genexpr>Nr   )dictr   r   r   _search)r   r   r   )r   r   r   queryG   s   zEvent.query)T)__name__
__module____qualname____doc___resource_namesetr   classmethodr   r$   __classcell__r   r   r   r   r   	   s    5r   N)	datadog.api.exceptionsr   datadog.api.resourcesr   r   r   datadog.util.compatr   r   r   r   r   r   <module>   s   