@@ -156,6 +156,10 @@ func StartInternalServer(port uint) {
156156}
157157
158158func createAPIYaml (apiCPEvent * APICPEvent ) (string , string , string ) {
159+
160+ logger .LoggerMgtServer .Infof ("Creating API YAML for API: %+v" , apiCPEvent .API )
161+
162+
159163 config , err := config .ReadConfigs ()
160164 provider := "admin"
161165 if err == nil {
@@ -171,6 +175,7 @@ func createAPIYaml(apiCPEvent *APICPEvent) (string, string, string) {
171175 primarySandboxEndpointID := ""
172176 primaryProdcutionURL := ""
173177 primarySandboxURL := ""
178+ logger .LoggerMgtServer .Infof ("Production Multi-endpoint configs: %d" , len (multiEndpoints .ProdEndpoints ))
174179 for _ , endpoint := range multiEndpoints .ProdEndpoints {
175180 prodCount ++
176181 var endpointName string
@@ -214,6 +219,7 @@ func createAPIYaml(apiCPEvent *APICPEvent) (string, string, string) {
214219 },
215220 })
216221 }
222+ logger .LoggerMgtServer .Infof ("Sandbox Multi-endpoint configs: %d" , len (multiEndpoints .SandEndpoints ))
217223 for _ , endpoint := range multiEndpoints .SandEndpoints {
218224 sandCount ++
219225 var endpointName string
@@ -264,11 +270,12 @@ func createAPIYaml(apiCPEvent *APICPEvent) (string, string, string) {
264270 logger .LoggerMgtServer .Errorf ("Error occured while extracting operations from open API: %s, \n Error: %+v" , apiCPEvent .API .Definition , operationsErr )
265271 operations = []APIOperation {}
266272 }
267- sandEndpoint := ""
273+ sandEndpoint := apiCPEvent . API . SandEndpoint
268274 if apiCPEvent .API .SandEndpoint != "" {
269275 sandEndpoint = fmt .Sprintf ("%s://%s" , apiCPEvent .API .EndpointProtocol , apiCPEvent .API .SandEndpoint )
270276 }
271- prodEndpoint := ""
277+ prodEndpoint := apiCPEvent .API .ProdEndpoint
278+ logger .LoggerMgtServer .Infof ("Sandbox Endpoint: %s, Production Endpoint: %s" , sandEndpoint , prodEndpoint )
272279 if apiCPEvent .API .ProdEndpoint != "" {
273280 prodEndpoint = fmt .Sprintf ("%s://%s" , apiCPEvent .API .EndpointProtocol , apiCPEvent .API .ProdEndpoint )
274281 }
@@ -289,7 +296,14 @@ func createAPIYaml(apiCPEvent *APICPEvent) (string, string, string) {
289296 apiCPEvent .API .AIConfiguration .LLMProviderID + "\" }"
290297 }
291298 logger .LoggerMgtServer .Debugf ("Subtype Configuration: %+v" , subTypeConfiguration )
292-
299+ sandboxSecType := apiCPEvent .API .SandEndpointSecurity .SecurityType
300+ if sandboxSecType == "" {
301+ sandboxSecType = "NONE"
302+ }
303+ prodSecType := apiCPEvent .API .ProdEndpointSecurity .SecurityType
304+ if prodSecType == "" {
305+ prodSecType = "NONE"
306+ }
293307 data := map [string ]interface {}{
294308 "type" : "api" ,
295309 "version" : "v4.6.0" ,
@@ -322,7 +336,7 @@ func createAPIYaml(apiCPEvent *APICPEvent) (string, string, string) {
322336 "apiKeyValue" : apiCPEvent .API .SandEndpointSecurity .APIKeyValue ,
323337 "apiKeyIdentifier" : apiCPEvent .API .SandEndpointSecurity .APIKeyName ,
324338 "apiKeyIdentifierType" : "HEADER" ,
325- "type" : apiCPEvent . API . SandEndpointSecurity . SecurityType ,
339+ "type" : sandboxSecType ,
326340 "username" : apiCPEvent .API .SandEndpointSecurity .BasicUsername ,
327341 "password" : apiCPEvent .API .SandEndpointSecurity .BasicPassword ,
328342 "enabled" : apiCPEvent .API .SandEndpointSecurity .Enabled ,
@@ -336,7 +350,7 @@ func createAPIYaml(apiCPEvent *APICPEvent) (string, string, string) {
336350 "apiKeyValue" : apiCPEvent .API .ProdEndpointSecurity .APIKeyValue ,
337351 "apiKeyIdentifier" : apiCPEvent .API .ProdEndpointSecurity .APIKeyName ,
338352 "apiKeyIdentifierType" : "HEADER" ,
339- "type" : apiCPEvent . API . ProdEndpointSecurity . SecurityType ,
353+ "type" : prodSecType ,
340354 "username" : apiCPEvent .API .ProdEndpointSecurity .BasicUsername ,
341355 "password" : apiCPEvent .API .ProdEndpointSecurity .BasicPassword ,
342356 "enabled" : apiCPEvent .API .ProdEndpointSecurity .Enabled ,
@@ -364,10 +378,12 @@ func createAPIYaml(apiCPEvent *APICPEvent) (string, string, string) {
364378 //data["data"].(map[string]interface{})["egress"] = true
365379 }
366380 // TODO when we start to process sandbox we need to have this if condition. For now we remove sandbox endpoint always.
367- // if apiCPEvent.API.SandEndpoint == "" {
368- delete (data ["data" ].(map [string ]interface {})["endpointConfig" ].(map [string ]interface {}), "sandbox_endpoints" )
369- // }
381+ if apiCPEvent .API .SandEndpoint == "" {
382+ logger .LoggerMgtServer .Debug ("Sandbox endpoint is empty. Removing sandbox endpoints from the endpoint config" )
383+ delete (data ["data" ].(map [string ]interface {})["endpointConfig" ].(map [string ]interface {}), "sandbox_endpoints" )
384+ }
370385 if apiCPEvent .API .ProdEndpoint == "" {
386+ logger .LoggerMgtServer .Debug ("Production endpoint is empty. Removing production endpoints from the endpoint config" )
371387 delete (data ["data" ].(map [string ]interface {})["endpointConfig" ].(map [string ]interface {}), "production_endpoints" )
372388 }
373389 if apiCPEvent .API .CORSPolicy != nil {
@@ -385,6 +401,7 @@ func createAPIYaml(apiCPEvent *APICPEvent) (string, string, string) {
385401
386402 // Handle Production fields
387403 if apiCPEvent .API .ProdAIRL != nil {
404+ logger .LoggerMgtServer .Infof ("Production AIRL is not nil" )
388405 maxTps ["production" ] = apiCPEvent .API .ProdAIRL .RequestCount
389406 maxTps ["productionTimeUnit" ] = strings .ToUpper (apiCPEvent .API .ProdAIRL .TimeUnit )
390407
@@ -406,6 +423,7 @@ func createAPIYaml(apiCPEvent *APICPEvent) (string, string, string) {
406423
407424 // Handle Sandbox fields
408425 if apiCPEvent .API .SandAIRL != nil {
426+ logger .LoggerMgtServer .Infof ("Sandbox AIRL is not nil" )
409427 maxTps ["sandbox" ] = apiCPEvent .API .SandAIRL .RequestCount
410428 maxTps ["sandboxTimeUnit" ] = strings .ToUpper (apiCPEvent .API .SandAIRL .TimeUnit )
411429
@@ -577,6 +595,7 @@ func createAPIYaml(apiCPEvent *APICPEvent) (string, string, string) {
577595
578596 // Attach endpoint_security to configMap
579597 configMap ["endpoint_security" ] = endpointSecurityMap
598+ logger .LoggerMgtServer .Debugf ("Endpoint Security Map: %+v" , endpointSecurityMap )
580599
581600 // Put endpointConfig in the main endpointMap
582601 endpointMap ["endpointConfig" ] = configMap
@@ -586,15 +605,23 @@ func createAPIYaml(apiCPEvent *APICPEvent) (string, string, string) {
586605 }
587606
588607 var endpointsData map [string ]interface {}
608+ logger .LoggerMgtServer .Debugf ("Prod Count: %d || Sand Count: %d" , prodCount , sandCount )
589609 if prodCount > 1 || sandCount > 1 {
590610 endpointsData = map [string ]interface {}{
591611 "type" : "endpoints" ,
592612 "version" : "v4.6.0" ,
593613 "data" : dataArr ,
594614 }
595615 }
616+ logger .LoggerMgtServer .Debugf ("\n \n Sandbox Endpoint Sec Config: %+v\n \n " , apiCPEvent .API .SandEndpointSecurity )
617+ logger .LoggerMgtServer .Debugf ("\n \n Prod Endpoint Sec Config: %+v\n \n " , apiCPEvent .API .ProdEndpointSecurity )
596618
597619 if primaryProductionEndpointID != "" || primarySandboxEndpointID != "" {
620+ logger .LoggerMgtServer .Debugf ("Multi-endpoint config enabled" )
621+ logger .LoggerMgtServer .Debugf ("\n \n Primary Production Endpoint ID: %s || Primary Sandbox Endpoint ID: %s\n \n " , primaryProductionEndpointID , primarySandboxEndpointID )
622+ logger .LoggerMgtServer .Debugf ("Primary Production URL: %s" , primaryProdcutionURL )
623+ logger .LoggerMgtServer .Debugf ("Primary Sandbox URL: %s" , primarySandboxURL )
624+
598625 data ["data" ].(map [string ]interface {})["primaryProductionEndpointId" ] = primaryProductionEndpointID
599626 data ["data" ].(map [string ]interface {})["primarySandboxEndpointId" ] = primarySandboxEndpointID
600627 data ["data" ].(map [string ]interface {})["endpointImplementationType" ] = "ENDPOINT"
0 commit comments