@@ -58,11 +58,11 @@ def createconfig(declaration: ConfigDeclaration, apiversion: str, runfromautosyn
5858
5959 try :
6060 # Pydantic JSON validation
61- ConfigDeclaration (** declaration .dict ())
61+ ConfigDeclaration (** declaration .model_dump ())
6262 except ValidationError as e :
6363 print (f'Invalid declaration { e } ' )
6464
65- d = declaration .dict ()
65+ d = declaration .model_dump ()
6666 decltype = d ['output' ]['type' ]
6767
6868 if 'http' in d ['declaration' ]:
@@ -172,7 +172,7 @@ def createconfig(declaration: ConfigDeclaration, apiversion: str, runfromautosyn
172172 httpConf = j2_env .get_template (NcgConfig .config ['templates' ]['httpconf' ]).render (
173173 declaration = d ['declaration' ]['http' ], ncgconfig = NcgConfig .config ) if 'http' in d ['declaration' ] else ''
174174 streamConf = j2_env .get_template (NcgConfig .config ['templates' ]['streamconf' ]).render (
175- declaration = d ['declaration' ]['layer4' ], ncgconfig = NcgConfig .config ) if 'layer ' in d ['declaration' ] else ''
175+ declaration = d ['declaration' ]['layer4' ], ncgconfig = NcgConfig .config ) if 'layer4 ' in d ['declaration' ] else ''
176176
177177 b64HttpConf = str (base64 .urlsafe_b64encode (httpConf .encode ("utf-8" )), "utf-8" )
178178 b64StreamConf = str (base64 .urlsafe_b64encode (streamConf .encode ("utf-8" )), "utf-8" )
@@ -557,7 +557,7 @@ def patch_config(declaration: ConfigDeclaration, configUid: str, apiversion: str
557557 )
558558
559559 # The declaration sections to be patched
560- declarationToPatch = declaration .dict ()
560+ declarationToPatch = declaration .model_dump ()
561561
562562 # The currently applied declaration
563563 status_code , currentDeclaration = get_declaration (configUid = configUid )
@@ -582,40 +582,40 @@ def patch_config(declaration: ConfigDeclaration, configUid: str, apiversion: str
582582 if 'declaration' in declarationToPatch :
583583 # HTTP
584584 d_upstreams = Contrib .MiscUtils .getDictKey (declarationToPatch , 'declaration.http.upstreams' )
585- if d_upstreams is not None :
585+ if d_upstreams :
586586 # HTTP upstream patch
587587 for u in d_upstreams :
588- # print(f"Patching HTTP upstream [{u['name']}]")
588+ #print(f"Patching HTTP upstream [{u['name']}]")
589589 currentDeclaration = Contrib .DeclarationPatcher .patchHttpUpstream (
590590 sourceDeclaration = currentDeclaration , patchedHttpUpstream = u )
591591
592592 d_servers = Contrib .MiscUtils .getDictKey (declarationToPatch , 'declaration.http.servers' )
593- if d_servers is not None :
593+ if d_servers :
594594 # HTTP servers patch
595595 for s in d_servers :
596- # print(f"Patching HTTP server [{s['name']}]")
596+ #print(f"Patching HTTP server [{s['name']}]")
597597 currentDeclaration = Contrib .DeclarationPatcher .patchHttpServer (
598598 sourceDeclaration = currentDeclaration , patchedHttpServer = s )
599599
600600 # Stream / Layer4
601601 d_upstreams = Contrib .MiscUtils .getDictKey (declarationToPatch , 'declaration.layer4.upstreams' )
602- if d_upstreams is not None :
602+ if d_upstreams :
603603 # Stream upstream patch
604604 for u in d_upstreams :
605- # print(f"Patching Stream upstream [{u['name']}]")
605+ #print(f"Patching Stream upstream [{u['name']}]")
606606 currentDeclaration = Contrib .DeclarationPatcher .patchStreamUpstream (
607607 sourceDeclaration = currentDeclaration , patchedStreamUpstream = u )
608608
609609 d_servers = Contrib .MiscUtils .getDictKey (declarationToPatch , 'declaration.layer4.servers' )
610- if d_servers is not None :
610+ if d_servers :
611611 # Stream servers patch
612612 for s in d_servers :
613- # print(f"Patching Stream server [{s['name']}]")
613+ #print(f"Patching Stream server [{s['name']}]")
614614 currentDeclaration = Contrib .DeclarationPatcher .patchStreamServer (
615615 sourceDeclaration = currentDeclaration , patchedStreamServer = s )
616616
617617 # Apply the updated declaration
618- configDeclaration = ConfigDeclaration .parse_raw (json .dumps (currentDeclaration ))
618+ configDeclaration = ConfigDeclaration .model_validate_json (json .dumps (currentDeclaration ))
619619
620620 r = createconfig (declaration = configDeclaration , apiversion = apiversion ,
621621 runfromautosync = True , configUid = configUid )
0 commit comments