
    ZTh                          d dl m Z  d dlmZ d dlmZmZmZmZ d dlZd dl	m
Z
mZ d dlmZ d dlmZ d dlmZ d	ee   d
ee   fdZded
ee   fdZ G d de      Zy)    )datetime)Path)AnyDictListcastN)NotRequired	TypedDict)YamlConfigError)ReportTemplateConfig)_handle_subdirpathsreturnc                     g dt         ffd}| D ]8  }|j                         rt        ||        |j                         s1 ||       : S )z
    Takes in a list of paths to YAML files which contains report templates and processes them into a list of
    `ReportTemplateConfig` objects. For more information on report templates see
    `sift_py.report_templates.config.ReportTemplateConfig`.
    pathc                 :    j                  t        |              y )N)extend_read_report_template_yaml)r   report_templatess    b/home/www/backend.miabetepe.com/venv/lib/python3.12/site-packages/sift_py/yaml/report_templates.pyupdate_report_templatesz6load_report_templates.<locals>.update_report_templates   s     :4 @A    )r   is_dirr   is_file)r   r   r   r   s      @r   load_report_templatesr      sW     46Bd B  *;;=4!89\\^#D)	*
 r   r   c                    g }t        | d      5 }t        t        t        t        f   t        j                  |j                                     }|j                  d      }t        |t              st        d|  d      |D ]  }	 t        di |}|j                  |       ! |cd d d        S # t        $ r}t        d| d      |d }~ww xY w# 1 sw Y   y xY w)Nrr   zCExpected 'report_templates' to be a list in report template yaml: ''zError parsing report template ' )openr   r   strr   yaml	safe_loadreadget
isinstancelistr   r   append	Exception)r   r   freport_templates_yamlreport_template_listreport_templatereport_template_configes           r   r   r       s    	dC  A $T#s(^T^^AFFH5M N4889KL.5!UVZU[[\]   4 	cOc)=)P)P& ''(>?	c  !     c%(GGXXY&Z[abbc   s0   A4CB- C-	C6CCCCc                   |    e Zd ZU dZeed<   eed<   ee   ed<   eee      ed<   ee   ed<   ee   ed<   ee   ed<   y	)
ReportTemplateYamlSpecaf  
    Formal spec for a report template.

    `name`: Name of the report template.
    `template_client_key`: Unique client key to identify the report template.
    `organization_id`: Organization ID that the report template belongs to.
    `tags`: Tags to associate with the report template.
    `description`: Description of the report template.
    `rule_client_keys`: List of rule client keys associated with the report template.
    `archived_date`: Date when the report template was archived. Setting this field
      will archive the report template, and unsetting it will unarchive the report template.
    nametemplate_client_keyorganization_idtagsdescriptionrule_client_keysarchived_dateN)	__name__
__module____qualname____doc__r!   __annotations__r	   r   r   r   r   r   r1   r1   5   sN     I %%
d3i
  S!!3ix((r   r1   )r   pathlibr   typingr   r   r   r   r"   typing_extensionsr	   r
   #sift_py.ingestion.config.yaml.errorr   sift_py.report_templates.configr   sift_py.yaml.utilsr   r   r   r1   r   r   r   <module>rD      sb      ( (  4 ? @ -d 5I0J & T  d3G.H  *)Y )r   