
    >Tf%                        d dl 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 d dlT d dlT d dlmZ d d	lmZ d d
lmZ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Z G d de          Z  G d de          Z! G d de          Z" G d de          Z# G d de          Z$ G d de          Z% G d de          Z& G d de          Z' G d de          Z( G d  d!e          Z) G d" d#e          Z*dS )$    N)forms)SimpleArrayField)ObjectDoesNotExist)gettext_lazy)
ObjectType)*)get_event_type_choices)NetBoxModelImportForm)GroupUser)CSVModelForm)CSVChoiceFieldCSVContentTypeFieldCSVModelChoiceFieldCSVModelMultipleChoiceFieldCSVMultipleChoiceFieldCSVMultipleContentTypeField	SlugField)ConfigTemplateImportFormCustomFieldChoiceSetImportFormCustomFieldImportFormCustomLinkImportFormEventRuleImportFormExportTemplateImportFormJournalEntryImportFormNotificationGroupImportFormSavedFilterImportFormTagImportFormWebhookImportFormc            	       >   e Zd Z e ed          ej                            d           ed                    Z e	 ed          e
 ed                    Z e ed          ej                                        d	 ed
                    Z e ed          ej                                        dd	 ed                    Z e	 ed          ed	 ed                    Z e	 ed          ed	 ed                    Z G d d          ZdS )r   Object typescustom_fields!One or more assigned object typeslabelqueryset	help_textTypez*Field data type (e.g. text, integer, etc.)r%   choicesr'   zObject typeFz/Object type (for object or multi-object fields))r%   r&   requiredr'   z
Choice setnamez!Choice set (for selection fields))r%   r&   to_field_namer+   r'   z
UI visiblez/Whether the custom field is displayed in the UI)r%   r*   r+   r'   zUI editablez.Whether the custom field is editable in the UIc                       e Zd ZeZdZdS )CustomFieldImportForm.Meta)r,   r%   
group_nametypeobject_typesrelated_object_typer+   uniquedescriptionsearch_weightfilter_logicdefault
choice_setweightvalidation_minimumvalidation_maximumvalidation_regex
ui_visibleui_editableis_cloneablecommentsN)__name__
__module____qualname__CustomFieldmodelfields     =/var/www/html/netbox-4.1.3/netbox/extras/forms/bulk_import.pyMetar/   H   s        
rI   rK   N)rB   rC   rD   r   _r   objectswith_featurer2   r   CustomFieldTypeChoicesr1   r   publicr3   r   CustomFieldChoiceSetallr9   CustomFieldUIVisibleChoicesr>   CustomFieldUIEditableChoicesr?   rK   rH   rI   rJ   r   r   #   s       ..a#00AA!788  L
 >aii&!@AA  D
 .-a#**,,!EFF	   %$aoo%-1133!788  J  aoo+!EFF	  J !.a,!DEE	  K
 
 
 
 
 
 
 
 
 
rI   r   c                       e Zd Z eed ed                    Z e ej	                    d ed                    Z
 G d d          Zd Zd	S )
r   Fz2The base set of predefined choices to use (if any))r*   r+   r'   zQuoted string of comma-separated field choices with optional labels separated by colon: "choice1:First Choice,choice2:Second Choice")
base_fieldr+   r'   c                       e Zd ZeZdZdS )#CustomFieldChoiceSetImportForm.Meta)r,   r5   extra_choicesorder_alphabeticallyN)rB   rC   rD   rQ   rF   rG   rH   rI   rJ   rK   rX   `   s        $
rI   rK   c                 T   t          | j        d         t                    rg }| j        d         D ]u}	 t          j        d|d          \  }}|                    dd          }|                    dd          }n# t          $ r ||}}Y nw xY w|                    ||f           v|S d S )NrY   z(?<!\\):   )maxsplitz\::)
isinstancecleaned_datalistresplitreplace
ValueErrorappend)selfdatalinevaluer%   s        rJ   clean_extra_choicesz2CustomFieldChoiceSetImportForm.clean_extra_choicesf   s    d'8$?? 
	D)/: , ,.#%8K#J#J#JLE5!MM%55E!MM%55EE! . . .#'5EEE.UEN++++K
	 
	s   AA::B
BN)rB   rC   rD   r   CustomFieldChoiceSetBaseChoicesrL   base_choicesr   r   	CharFieldrY   rK   rk   rH   rI   rJ   r   r   Q   s        !>/!HII  L
 %$"5?$$!;
 
  M
 
 
 
 
 
 
 
    rI   r   c                       e Zd Z e ed          ej                            d           ed                    Z e	 ed          de
 ed                    Z G d	 d
          ZdS )r   r!   custom_linksr#   r$   zbutton classFzKThe class of the first link in a group will be used for the dropdown button)r%   r+   r*   r'   c                       e Zd ZeZdZdS )CustomLinkImportForm.Meta)	r,   r2   enabledr:   r0   button_class
new_window	link_textlink_urlN)rB   rC   rD   
CustomLinkrF   rG   rH   rI   rJ   rK   rr      s        
rI   rK   N)rB   rC   rD   r   rL   r   rM   rN   r2   r   CustomLinkButtonClassChoicesrt   rK   rH   rI   rJ   r   r   t   s        ..a#00@@!788  L
 ">a,!abb	  L
 
 
 
 
 
 
 
 
 
rI   r   c                       e Zd Z e ed          ej                            d           ed                    Z G d d          Z	dS )r   r!   export_templatesr#   r$   c                       e Zd ZeZdZdS )ExportTemplateImportForm.Meta)r,   r2   r5   	mime_typefile_extensionas_attachmenttemplate_codeN)rB   rC   rD   ExportTemplaterF   rG   rH   rI   rJ   rK   r}              
rI   rK   N)
rB   rC   rD   r   rL   r   rM   rN   r2   rK   rH   rI   rJ   r   r      s        ..a#001CDD!788  L
 
 
 
 
 
 
 
 
 
rI   r   c                   (    e Zd Z G d d          ZdS )r   c                       e Zd ZeZdZdS )ConfigTemplateImportForm.Meta)r,   r5   environment_paramsr   tagsN)rB   rC   rD   ConfigTemplaterF   rG   rH   rI   rJ   rK   r      r   rI   rK   NrB   rC   rD   rK   rH   rI   rJ   r   r      s<        
 
 
 
 
 
 
 
 
 
rI   r   c                       e Zd Z e ed          ej                                         ed                    Z G d d          Z	dS )r   r!   r#   r$   c                       e Zd ZeZdZdS )SavedFilterImportForm.Meta)r,   slugr2   r5   r:   rs   shared
parametersN)rB   rC   rD   SavedFilterrF   rG   rH   rI   rJ   rK   r      s        
rI   rK   N)
rB   rC   rD   r   rL   r   rM   rR   r2   rK   rH   rI   rJ   r   r      s        ..a#''))!788  L
 
 
 
 
 
 
 
 
 
rI   r   c                   (    e Zd Z G d d          ZdS )r   c                       e Zd ZeZdZdS )WebhookImportForm.Meta)r,   payload_urlhttp_methodhttp_content_typeadditional_headersbody_templatesecretssl_verificationca_file_pathr5   r   N)rB   rC   rD   WebhookrF   rG   rH   rI   rJ   rK   r      s        
rI   rK   Nr   rH   rI   rJ   r   r      s<        
 
 
 
 
 
 
 
 
 
rI   r   c                   B    e Zd Z e ed          ej                            d           ed                    Z e	 e
             ed           ed                    Z ej         ed          d	 ed
                    Z G d d          Z fdZ xZS )r   r!   event_rulesr#   r$   zEvent typesz.The event type(s) which will trigger this rule)r*   r%   r'   zAction objectTz2Webhook name or script as dotted path module.Class)r%   r+   r'   c                       e Zd ZeZdZdS )EventRuleImportForm.Meta)
r,   r5   rs   
conditionsr2   event_typesaction_typeaction_objectrA   r   N)rB   rC   rD   	EventRulerF   rG   rH   rI   rJ   rK   r      s        
rI   rK   c                 L   t                                                       | j                            d          }| j                            d          }|rG|rF|t          j        k    rx	 t          j                            |          }nH# t          j        $ r6 t          j
        t          d                              |                    w xY w|| j        _        d S |t          j        k    rddlm} |                    dd          \  }}	  |||          \  }}nC# t&          $ r6 t          j
        t          d	                              |                    w xY w|| j        _        t(          j                            |d
          | j        _        d S d S d S d S )Nr   r   )r,   zWebhook {name} not foundr   )get_module_and_script.r\   zScript {name} not foundF)for_concrete_model)supercleanr`   getEventRuleActionChoicesWEBHOOKr   rM   DoesNotExistr   ValidationErrorrL   formatinstancer   SCRIPTextras.scriptsr   rc   r   r   get_for_modelaction_object_type)
rg   r   r   webhookr   module_namescript_namemodulescript	__class__s
            rJ   r   zEventRuleImportForm.clean   s   )--o>>'++M:: 	v[ 	v4<<<j%o11}1EEGG+ j j j/2L0M0M0T0TZg0T0h0hiiij.5+++ 6 ===@@@@@@+8+>+>sA+F+F([i%:%:;%T%TNFFF) i i i/2K0L0L0S0SYf0S0g0ghhhi.4+3=3E3S3STZot3S3u3u000#	v 	v 	v 	v >=s   - B ACD$ $A E$)rB   rC   rD   r   rL   r   rM   rN   r2   r   r	   r   r   rn   r   rK   r   __classcell__)r   s   @rJ   r   r      s'       ..a#00??!788  L
 )(&&((a!DEE  K
 $EOa  !HII  M
 
 
 
 
 
 
 
v v v v v v v v vrI   r   c                   <    e Zd Z e            Z G d d          ZdS )r   c                       e Zd ZeZdZdS )TagImportForm.Meta)r,   r   colorr5   N)rB   rC   rD   TagrF   rG   rH   rI   rJ   rK   r      s        9rI   rK   N)rB   rC   rD   r   r   rK   rH   rI   rJ   r   r      sG        9;;D: : : : : : : : : :rI   r   c                       e Zd Z eej                                         ed                    Z e	 ed          e
 ed                    Z G d d          ZdS )	r   zAssigned object type)r&   r%   KindzThe classification of entryr)   c                       e Zd ZeZdZdS )JournalEntryImportForm.Meta)assigned_object_typeassigned_object_id
created_bykindrA   r   N)rB   rC   rD   JournalEntryrF   rG   rH   rI   rJ   rK   r      s        
rI   rK   N)rB   rC   rD   r   r   rM   rR   rL   r   r   JournalEntryKindChoicesr   rK   rH   rI   rJ   r   r      s        ..#''))a&''   >aii'!122  D
 
 
 
 
 
 
 
 
 
rI   r   c            	          e Zd Z e ed          ej                                        dd ed                    Z e ed          e	j                                        dd ed                    Z
 G d	 d
          ZdS )r   UsersFusernamez:User names separated by commas, encased with double quotes)r%   r&   r+   r-   r'   Groupsr,   z;Group names separated by commas, encased with double quotesc                       e Zd ZeZdZdS ) NotificationGroupImportForm.Meta)r,   r5   usersgroupsN)rB   rC   rD   NotificationGrouprF   rG   rH   rI   rJ   rK   r     s        !;rI   rK   N)rB   rC   rD   r   rL   r   rM   rR   r   r   r   rK   rH   rI   rJ   r   r     s        ''ajj!!## !PQQ  E )(akk""$$!QRR  F< < < < < < < < < <rI   r   )+rb   djangor   django.contrib.postgres.formsr   django.core.exceptionsr   django.utils.translationr   rL   core.modelsr   extras.choicesextras.modelsnetbox.eventsr	   netbox.formsr
   users.modelsr   r   utilities.formsr   utilities.forms.fieldsr   r   r   r   r   r   r   __all__r   r   r   r   r   r   r   r   r   r   r   rH   rI   rJ   <module>r      s   				       : : : : : : 5 5 5 5 5 5 6 6 6 6 6 6 " " " " " "         0 0 0 0 0 0 . . . . . . $ $ $ $ $ $ $ $ ( ( ( ( ( (                 
+
 +
 +
 +
 +
L +
 +
 +
\         \      F
 
 
 
 
< 
 
 
*
 
 
 
 
| 
 
 

 
 
 
 
| 
 
 

 
 
 
 
L 
 
 

 
 
 
 
- 
 
 
.v .v .v .v .v/ .v .v .vb: : : : :L : : :
 
 
 
 
2 
 
 
$< < < < <, < < < < <rI   