@@ -156,6 +156,7 @@ func StartInternalServer(port uint) {
156156}
157157
158158func createAPIYaml (apiCPEvent * APICPEvent ) (string , string , string ) {
159+
159160 config , err := config .ReadConfigs ()
160161 provider := "admin"
161162 if err == nil {
@@ -171,6 +172,7 @@ func createAPIYaml(apiCPEvent *APICPEvent) (string, string, string) {
171172 primarySandboxEndpointID := ""
172173 primaryProdcutionURL := ""
173174 primarySandboxURL := ""
175+ logger .LoggerMgtServer .Debugf ("Production Multi-endpoint configs: %d" , len (multiEndpoints .ProdEndpoints ))
174176 for _ , endpoint := range multiEndpoints .ProdEndpoints {
175177 prodCount ++
176178 var endpointName string
@@ -214,6 +216,7 @@ func createAPIYaml(apiCPEvent *APICPEvent) (string, string, string) {
214216 },
215217 })
216218 }
219+ logger .LoggerMgtServer .Debugf ("Sandbox Multi-endpoint configs: %d" , len (multiEndpoints .SandEndpoints ))
217220 for _ , endpoint := range multiEndpoints .SandEndpoints {
218221 sandCount ++
219222 var endpointName string
@@ -264,11 +267,12 @@ func createAPIYaml(apiCPEvent *APICPEvent) (string, string, string) {
264267 logger .LoggerMgtServer .Errorf ("Error occured while extracting operations from open API: %s, \n Error: %+v" , apiCPEvent .API .Definition , operationsErr )
265268 operations = []APIOperation {}
266269 }
267- sandEndpoint := ""
270+ sandEndpoint := apiCPEvent . API . SandEndpoint
268271 if apiCPEvent .API .SandEndpoint != "" {
269272 sandEndpoint = fmt .Sprintf ("%s://%s" , apiCPEvent .API .EndpointProtocol , apiCPEvent .API .SandEndpoint )
270273 }
271- prodEndpoint := ""
274+ prodEndpoint := apiCPEvent .API .ProdEndpoint
275+ logger .LoggerMgtServer .Infof ("Sandbox Endpoint: %s, Production Endpoint: %s" , sandEndpoint , prodEndpoint )
272276 if apiCPEvent .API .ProdEndpoint != "" {
273277 prodEndpoint = fmt .Sprintf ("%s://%s" , apiCPEvent .API .EndpointProtocol , apiCPEvent .API .ProdEndpoint )
274278 }
@@ -289,7 +293,14 @@ func createAPIYaml(apiCPEvent *APICPEvent) (string, string, string) {
289293 apiCPEvent .API .AIConfiguration .LLMProviderID + "\" }"
290294 }
291295 logger .LoggerMgtServer .Debugf ("Subtype Configuration: %+v" , subTypeConfiguration )
292-
296+ sandboxSecType := apiCPEvent .API .SandEndpointSecurity .SecurityType
297+ if sandboxSecType == "" {
298+ sandboxSecType = "NONE"
299+ }
300+ prodSecType := apiCPEvent .API .ProdEndpointSecurity .SecurityType
301+ if prodSecType == "" {
302+ prodSecType = "NONE"
303+ }
293304 data := map [string ]interface {}{
294305 "type" : "api" ,
295306 "version" : "v4.6.0" ,
@@ -322,7 +333,7 @@ func createAPIYaml(apiCPEvent *APICPEvent) (string, string, string) {
322333 "apiKeyValue" : apiCPEvent .API .SandEndpointSecurity .APIKeyValue ,
323334 "apiKeyIdentifier" : apiCPEvent .API .SandEndpointSecurity .APIKeyName ,
324335 "apiKeyIdentifierType" : "HEADER" ,
325- "type" : apiCPEvent . API . SandEndpointSecurity . SecurityType ,
336+ "type" : sandboxSecType ,
326337 "username" : apiCPEvent .API .SandEndpointSecurity .BasicUsername ,
327338 "password" : apiCPEvent .API .SandEndpointSecurity .BasicPassword ,
328339 "enabled" : apiCPEvent .API .SandEndpointSecurity .Enabled ,
@@ -336,7 +347,7 @@ func createAPIYaml(apiCPEvent *APICPEvent) (string, string, string) {
336347 "apiKeyValue" : apiCPEvent .API .ProdEndpointSecurity .APIKeyValue ,
337348 "apiKeyIdentifier" : apiCPEvent .API .ProdEndpointSecurity .APIKeyName ,
338349 "apiKeyIdentifierType" : "HEADER" ,
339- "type" : apiCPEvent . API . ProdEndpointSecurity . SecurityType ,
350+ "type" : prodSecType ,
340351 "username" : apiCPEvent .API .ProdEndpointSecurity .BasicUsername ,
341352 "password" : apiCPEvent .API .ProdEndpointSecurity .BasicPassword ,
342353 "enabled" : apiCPEvent .API .ProdEndpointSecurity .Enabled ,
@@ -364,10 +375,12 @@ func createAPIYaml(apiCPEvent *APICPEvent) (string, string, string) {
364375 //data["data"].(map[string]interface{})["egress"] = true
365376 }
366377 // 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- // }
378+ if apiCPEvent .API .SandEndpoint == "" {
379+ logger .LoggerMgtServer .Debug ("Sandbox endpoint is empty. Removing sandbox endpoints from the endpoint config" )
380+ delete (data ["data" ].(map [string ]interface {})["endpointConfig" ].(map [string ]interface {}), "sandbox_endpoints" )
381+ }
370382 if apiCPEvent .API .ProdEndpoint == "" {
383+ logger .LoggerMgtServer .Debug ("Production endpoint is empty. Removing production endpoints from the endpoint config" )
371384 delete (data ["data" ].(map [string ]interface {})["endpointConfig" ].(map [string ]interface {}), "production_endpoints" )
372385 }
373386 if apiCPEvent .API .CORSPolicy != nil {
@@ -385,6 +398,7 @@ func createAPIYaml(apiCPEvent *APICPEvent) (string, string, string) {
385398
386399 // Handle Production fields
387400 if apiCPEvent .API .ProdAIRL != nil {
401+ logger .LoggerMgtServer .Infof ("Production AIRL is not nil" )
388402 maxTps ["production" ] = apiCPEvent .API .ProdAIRL .RequestCount
389403 maxTps ["productionTimeUnit" ] = strings .ToUpper (apiCPEvent .API .ProdAIRL .TimeUnit )
390404
@@ -406,6 +420,7 @@ func createAPIYaml(apiCPEvent *APICPEvent) (string, string, string) {
406420
407421 // Handle Sandbox fields
408422 if apiCPEvent .API .SandAIRL != nil {
423+ logger .LoggerMgtServer .Infof ("Sandbox AIRL is not nil" )
409424 maxTps ["sandbox" ] = apiCPEvent .API .SandAIRL .RequestCount
410425 maxTps ["sandboxTimeUnit" ] = strings .ToUpper (apiCPEvent .API .SandAIRL .TimeUnit )
411426
@@ -577,6 +592,7 @@ func createAPIYaml(apiCPEvent *APICPEvent) (string, string, string) {
577592
578593 // Attach endpoint_security to configMap
579594 configMap ["endpoint_security" ] = endpointSecurityMap
595+ logger .LoggerMgtServer .Debugf ("Endpoint Security Map: %+v" , endpointSecurityMap )
580596
581597 // Put endpointConfig in the main endpointMap
582598 endpointMap ["endpointConfig" ] = configMap
@@ -586,15 +602,23 @@ func createAPIYaml(apiCPEvent *APICPEvent) (string, string, string) {
586602 }
587603
588604 var endpointsData map [string ]interface {}
605+ logger .LoggerMgtServer .Debugf ("Prod Count: %d || Sand Count: %d" , prodCount , sandCount )
589606 if prodCount > 1 || sandCount > 1 {
590607 endpointsData = map [string ]interface {}{
591608 "type" : "endpoints" ,
592609 "version" : "v4.6.0" ,
593610 "data" : dataArr ,
594611 }
595612 }
613+ logger .LoggerMgtServer .Debugf ("\n \n Sandbox Endpoint Sec Config: %+v\n \n " , apiCPEvent .API .SandEndpointSecurity )
614+ logger .LoggerMgtServer .Debugf ("\n \n Prod Endpoint Sec Config: %+v\n \n " , apiCPEvent .API .ProdEndpointSecurity )
596615
597616 if primaryProductionEndpointID != "" || primarySandboxEndpointID != "" {
617+ logger .LoggerMgtServer .Debugf ("Multi-endpoint config enabled" )
618+ logger .LoggerMgtServer .Debugf ("\n \n Primary Production Endpoint ID: %s || Primary Sandbox Endpoint ID: %s\n \n " , primaryProductionEndpointID , primarySandboxEndpointID )
619+ logger .LoggerMgtServer .Debugf ("Primary Production URL: %s" , primaryProdcutionURL )
620+ logger .LoggerMgtServer .Debugf ("Primary Sandbox URL: %s" , primarySandboxURL )
621+
598622 data ["data" ].(map [string ]interface {})["primaryProductionEndpointId" ] = primaryProductionEndpointID
599623 data ["data" ].(map [string ]interface {})["primarySandboxEndpointId" ] = primarySandboxEndpointID
600624 data ["data" ].(map [string ]interface {})["endpointImplementationType" ] = "ENDPOINT"
@@ -640,7 +664,7 @@ func createAPIYaml(apiCPEvent *APICPEvent) (string, string, string) {
640664 }
641665
642666 var requestOperationPolicies []OperationPolicy
643- if apiCPEvent .API .AIModelBasedRoundRobin != nil {
667+ if apiCPEvent .API .AIModelBasedRoundRobin != nil && apiCPEvent . API . APIType != "GraphQL" {
644668 aiModelBasedRoundRobin := apiCPEvent .API .AIModelBasedRoundRobin
645669 logger .LoggerMgtServer .Debugf ("AIModelBasedRoundRobin : %+v" , aiModelBasedRoundRobin )
646670 wrr := ModelBasedRoundRobinConfig {
0 commit comments