
    rbi                          d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ  G d de          Z G d	 d
e          Z G d de          Z	 G d d          Z
 G d d          ZdS )u   Weather alert bulletin Python model for the Météo-France REST API.

For getting weather alerts in metropolitan France and Andorre.
    )Any)Dict)List)Optional)	TypedDictc                   (    e Zd ZU dZeed<   eed<   dS )PhenomenonMaxColora  Describing a meteorological phenomenon and its maximum color code.

    Attributes:
        phenomenon_id (str): A unique identifier for the meteorological phenomenon.
                             This is kept as a string to match the format provided by
                             the API and could represent various types of weather
                             phenomena (e.g., storms, heavy rain, etc.).

        phenomenon_max_color_id (int): An integer representing the maximum alert color
                                       code associated with the phenomenon. The color
                                       codes typically indicate the severity or urgency
                                       of the weather-related alerts or warnings, with
                                       each color corresponding to a specific level of
                                       alert.
    phenomenon_idphenomenon_max_color_idN)__name__
__module____qualname____doc__str__annotations__int     m/var/www/html/mdtn/previsions/meteo_cartes/venv/lib/python3.11/site-packages/meteofrance_api/model/warning.pyr	   r	      s6                  r   r	   c                   H    e Zd ZU dZeed<   eed<   eed<   ee         ed<   dS )WarningCurrentPhenomenonsDatazMDescribing the data structure of CurrentPhenomenons object from the REST API.update_timeend_validity_time	domain_idphenomenons_max_colorsN)	r   r   r   r   r   r   r   r   r	   r   r   r   r   r   #   sK         WWNNN !3444444r   r   c                   0   e Zd ZU dZeed<   eed<   eed<   eed<   eeee	f                  ed<   ee
         ed<   eeeee	f                           ed<   eeeee	f                           ed	<   e	ed
<   eee	f         ed<   eeee	f                  ed<   e	ed<   dS )WarningFullDataz?Describing the data structure of full object from the REST API.r   r   r   	color_maxtimelapsphenomenons_itemsadvicesconsequencesmax_count_itemscommentstexttext_avalancheN)r   r   r   r   r   r   r   r   r   r   r	   r   r   r   r   r   r   ,   s         IINNNNNN4S>"""".////d4S>*++++4S#X/000038n
4S>
""""r   r   c                       e Zd ZdZdeddfdZedefd            Zedefd            Z	ede
fd            Zedee         fd	            Z	 	 	 	 ddZdefdZdS )CurrentPhenomenonsa  Class to access the results of a `warning/currentPhenomenons` REST API request.

    For coastal department two bulletins are available corresponding to two different
    domains.

    Attributes:
        update_time: A timestamp (as integer) corresponding to the latest update of the
            phenomenons.
        end_validity_time: A timestamp (as integer) corresponding to expiration date of
            the phenomenons.
        domain_id: A string corresponding do the domain ID of the bulletin. Value is
            'France' or a department number.
        phenomenons_max_colors: A list of dictionaries with type of phenomenons and the
            current alert level.
    raw_datareturnNc                     || _         dS )a  Initialize a CurrentPhenomenons object.

        Args:
            raw_data: A dictionary representing the JSON response from
                'warning/currentPhenomenons' REST API request. The structure is
                described by the WarningCurrentPhenomenonsData class.
        Nr)   selfr)   s     r   __init__zCurrentPhenomenons.__init__N        !r   c                     | j         d         S )z*Return the update time of the phenomenons.r   r,   r.   s    r   r   zCurrentPhenomenons.update_timeX        }]++r   c                     | j         d         S )z3Return the end of validity time of the phenomenons.r   r,   r2   s    r   r   z$CurrentPhenomenons.end_validity_time]        }011r   c                     | j         d         S )z(Return the domain ID of the phenomenons.r   r,   r2   s    r   r   zCurrentPhenomenons.domain_idb        }[))r   c                     | j         d         S )z.Return the list and colors of the phenomenons.r   r,   r2   s    r   r   z)CurrentPhenomenons.phenomenons_max_colorsg   s     }566r   coastal_phenomenonsc                 P    | j         d                             |j                   dS )aM  Merge the classical phenomenons bulleting with the coastal one.

        Extend the phenomenons_max_colors property with the content of the coastal
        weather alert bulletin.

        Args:
            coastal_phenomenons: CurrentPhenomenons instance corresponding to the
                coastal weather alert bulletin.
        r   N)r)   extendr   r.   r9   s     r   merge_with_coastal_phenomenonsz1CurrentPhenomenons.merge_with_coastal_phenomenonsl   s4     	./666	
 	
 	
 	
 	
r   c                 B    t          d | j        D                       }|S )zGet the maximum level of alert of a given domain (class helper).

        Returns:
            An integer corresponding to the status code representing the maximum alert.
        c              3   &   K   | ]}|d          V  dS )r   Nr   ).0xs     r   	<genexpr>z:CurrentPhenomenons.get_domain_max_color.<locals>.<genexpr>   s9       
 
-.A'(
 
 
 
 
 
r   )maxr   )r.   max_int_colors     r   get_domain_max_colorz'CurrentPhenomenons.get_domain_max_color}   s:      
 
262M
 
 
 
 
 r   )r9   r(   r*   N)r   r   r   r   r   r/   propertyr   r   r   r   r   r   r	   r   r=   rE   r   r   r   r(   r(   =   s"         !!> !4 ! ! ! ! ,S , , , X, 23 2 2 2 X2 *3 * * * X* 7-?(@ 7 7 7 X7
#7
	
 
 
 
"	c 	 	 	 	 	 	r   r(   c                       e Zd ZdZdeddfdZedefd            Zedefd            Z	ede
fd            Zedefd	            Zedeee
ef                  fd
            Zedee         fd            ZddZdS )Fulla  This class allows to access the results of a `warning/full` API command.

    For a given domain we can access the maximum alert, a timelaps of the alert
    evolution for the next 24 hours, and a list of alerts.

    For coastal department two bulletins are available corresponding to two different
    domains.

    Attributes:
        update_time: A timestamp (as integer) corresponding to the latest update of the
            phenomenons.
        end_validity_time: A timestamp (as integer) corresponding to expiration date of
            the phenomenons.
        domain_id: A string corresponding do the domain ID of the bulletin. Value is
            'France' or a department number.
        color_max: An integer representing the maximum alert level in the domain.
        timelaps: A list of dictionaries corresponding to the schedule of each
            phenomenons in the next 24 hours.
        phenomenons_items: list of dictionaries corresponding the alert level for each
            phenomenons type.
    r)   r*   Nc                     || _         dS )zInitialize a Full object.

        Args:
            raw_data: A dictionary representing the JSON response from'warning/full'
                REST API request. The structure is described by the WarningFullData
                class.
        Nr,   r-   s     r   r/   zFull.__init__   r0   r   c                     | j         d         S )z,Return the update time of the full bulletin.r   r,   r2   s    r   r   zFull.update_time   r3   r   c                     | j         d         S )z5Return the end of validity time of the full bulletin.r   r,   r2   s    r   r   zFull.end_validity_time   r5   r   c                     | j         d         S )z.Return the domain ID of the the full bulletin.r   r,   r2   s    r   r   zFull.domain_id   r7   r   c                     | j         d         S )z#Return the color max of the domain.r   r,   r2   s    r   r   zFull.color_max   r7   r   c                     | j         d         S )z6Return the timelaps of each phenomenon for the domain.r   r,   r2   s    r   r   zFull.timelaps   s     }Z((r   c                     | j         d         S )z)Return the phenomenon list of the domain.r    r,   r2   s    r   r    zFull.phenomenons_items   r5   r   r9   c                     t          | j        |j                  | j        d<   | j        d                             |j                   | j        d                             |j                   dS )aV  Merge the classical phenomenon bulletin with the coastal one.

        Extend the color_max, timelaps and phenomenons_items properties with the content
            of the coastal weather alert bulletin.

        Args:
            coastal_phenomenons: Full instance corresponding to the coastal weather
                alert bulletin.
        r   r   r    N)rC   r   r)   r;   r   r    r<   s     r   r=   z#Full.merge_with_coastal_phenomenons   si     &)9L9V%W%Wk" 	j!(()<)EFFF 	)*112E2WXXXXXr   )r9   rH   r*   N)r   r   r   r   r   r/   rF   r   r   r   r   r   r   r   r   r   r   r	   r    r=   r   r   r   rH   rH      sW        ,! !T ! ! ! ! ,S , , , X, 23 2 2 2 X2 *3 * * * X* *3 * * * X* )$tCH~. ) ) ) X) 24(:#; 2 2 2 X2Y Y Y Y Y Yr   rH   N)r   typingr   r   r   r   r   r	   r   r   r(   rH   r   r   r   <module>rR      s`   
                              ! ! ! ! ! ! ! !*5 5 5 5 5I 5 5 5    i   "I I I I I I I IXSY SY SY SY SY SY SY SY SY SYr   