@@ -107,19 +107,36 @@ func StartInternalServer(port uint) {
107107 if strings .ToUpper (event .API .APIType ) == "GRAPHQL" {
108108 definitionPath = fmt .Sprintf ("%s-%s/Definitions/schema.graphql" , event .API .APIName , event .API .APIVersion )
109109 }
110- zipFiles := []utils.ZipFile {{
111- Path : fmt .Sprintf ("%s-%s/api.yaml" , event .API .APIName , event .API .APIVersion ),
112- Content : apiYaml ,
113- }, {
114- Path : fmt .Sprintf ("%s-%s/endpoints.yaml" , event .API .APIName , event .API .APIVersion ),
115- Content : endpointsYaml ,
116- }, {
117- Path : fmt .Sprintf ("%s-%s/deployment_environments.yaml" , event .API .APIName , event .API .APIVersion ),
118- Content : deploymentContent ,
119- }, {
120- Path : definitionPath ,
121- Content : definition ,
122- }}
110+ var zipFiles []utils.ZipFile
111+ logger .LoggerMgtServer .Debugf ("endpoints yaml: %s" , endpointsYaml )
112+ if endpointsYaml != "{}\n " {
113+ logger .LoggerMgtServer .Debugf ("Creating zip file with endpoints" )
114+ zipFiles = []utils.ZipFile {{
115+ Path : fmt .Sprintf ("%s-%s/api.yaml" , event .API .APIName , event .API .APIVersion ),
116+ Content : apiYaml ,
117+ }, {
118+ Path : fmt .Sprintf ("%s-%s/endpoints.yaml" , event .API .APIName , event .API .APIVersion ),
119+ Content : endpointsYaml ,
120+ }, {
121+ Path : fmt .Sprintf ("%s-%s/deployment_environments.yaml" , event .API .APIName , event .API .APIVersion ),
122+ Content : deploymentContent ,
123+ }, {
124+ Path : definitionPath ,
125+ Content : definition ,
126+ }}
127+ } else {
128+ logger .LoggerMgtServer .Debugf ("Creating zip file without endpoints" )
129+ zipFiles = []utils.ZipFile {{
130+ Path : fmt .Sprintf ("%s-%s/api.yaml" , event .API .APIName , event .API .APIVersion ),
131+ Content : apiYaml ,
132+ }, {
133+ Path : fmt .Sprintf ("%s-%s/deployment_environments.yaml" , event .API .APIName , event .API .APIVersion ),
134+ Content : deploymentContent ,
135+ }, {
136+ Path : definitionPath ,
137+ Content : definition ,
138+ }}
139+ }
123140 var buf bytes.Buffer
124141 if err := utils .CreateZipFile (& buf , zipFiles ); err != nil {
125142 logger .LoggerMgtServer .Errorf ("Error while creating apim zip file for api uuid: %s. Error: %+v" , event .API .APIUUID , err )
@@ -479,8 +496,8 @@ func createAPIYaml(apiCPEvent *APICPEvent) (string, string, string) {
479496 for _ , e := range apimEndpints {
480497 // Build the top-level map for this endpoint
481498 endpointMap := map [string ]interface {}{
482- "endpointUuid" : e .EndpointUUID ,
483- "endpointName" : e .EndpointName ,
499+ "id" : e .EndpointUUID ,
500+ "name" : e .EndpointName ,
484501 "deploymentStage" : e .DeploymentStage , // e.g. "PRODUCTION" or "SANDBOX"
485502 }
486503
@@ -513,7 +530,7 @@ func createAPIYaml(apiCPEvent *APICPEvent) (string, string, string) {
513530 "apiKeyValue" : sec .APIKeyValue ,
514531 "apiKeyIdentifierType" : sec .APIKeyIdentifierType ,
515532 "username" : sec .Username ,
516- "customParameters" : sec . CustomParameters , // Or map[string]string{}
533+ "customParameters" : "{}" , // Or map[string]string{}
517534 "connectionTimeoutDuration" : sec .ConnectionTimeoutDuration ,
518535 "connectionRequestTimeoutDuration" : sec .ConnectionRequestTimeoutDuration ,
519536 "socketTimeoutDuration" : sec .SocketTimeoutDuration ,
@@ -537,7 +554,7 @@ func createAPIYaml(apiCPEvent *APICPEvent) (string, string, string) {
537554 "apiKeyValue" : sec .APIKeyValue ,
538555 "apiKeyIdentifierType" : sec .APIKeyIdentifierType ,
539556 "username" : sec .Username ,
540- "customParameters" : sec . CustomParameters ,
557+ "customParameters" : "{}" ,
541558 "connectionTimeoutDuration" : sec .ConnectionTimeoutDuration ,
542559 "connectionRequestTimeoutDuration" : sec .ConnectionRequestTimeoutDuration ,
543560 "socketTimeoutDuration" : sec .SocketTimeoutDuration ,
@@ -566,7 +583,7 @@ func createAPIYaml(apiCPEvent *APICPEvent) (string, string, string) {
566583 }
567584
568585 var endpointsData map [string ]interface {}
569- if prodCount > 0 || sandCount > 0 {
586+ if prodCount > 1 || sandCount > 1 {
570587 endpointsData = map [string ]interface {}{
571588 "type" : "endpoints" ,
572589 "version" : "v4.5.0" ,
@@ -586,12 +603,42 @@ func createAPIYaml(apiCPEvent *APICPEvent) (string, string, string) {
586603 "production_endpoints" : map [string ]interface {}{
587604 "url" : primaryProdcutionURL ,
588605 },
606+ "endpoint_security" : map [string ]interface {}{
607+ "sandbox" : map [string ]interface {}{
608+ "apiKeyValue" : apiCPEvent .API .SandEndpointSecurity .APIKeyValue ,
609+ "apiKeyIdentifier" : apiCPEvent .API .SandEndpointSecurity .APIKeyName ,
610+ "apiKeyIdentifierType" : "HEADER" ,
611+ "type" : apiCPEvent .API .SandEndpointSecurity .SecurityType ,
612+ "username" : apiCPEvent .API .SandEndpointSecurity .BasicUsername ,
613+ "password" : apiCPEvent .API .SandEndpointSecurity .BasicPassword ,
614+ "enabled" : apiCPEvent .API .SandEndpointSecurity .Enabled ,
615+ "additionalProperties" : map [string ]interface {}{},
616+ "customParameters" : map [string ]interface {}{},
617+ "connectionTimeoutDuration" : - 1.0 ,
618+ "socketTimeoutDuration" : - 1.0 ,
619+ "connectionRequestTimeoutDuration" : - 1.0 ,
620+ },
621+ "production" : map [string ]interface {}{
622+ "apiKeyValue" : apiCPEvent .API .ProdEndpointSecurity .APIKeyValue ,
623+ "apiKeyIdentifier" : apiCPEvent .API .ProdEndpointSecurity .APIKeyName ,
624+ "apiKeyIdentifierType" : "HEADER" ,
625+ "type" : apiCPEvent .API .ProdEndpointSecurity .SecurityType ,
626+ "username" : apiCPEvent .API .ProdEndpointSecurity .BasicUsername ,
627+ "password" : apiCPEvent .API .ProdEndpointSecurity .BasicPassword ,
628+ "enabled" : apiCPEvent .API .ProdEndpointSecurity .Enabled ,
629+ "additionalProperties" : map [string ]interface {}{},
630+ "customParameters" : map [string ]interface {}{},
631+ "connectionTimeoutDuration" : - 1.0 ,
632+ "socketTimeoutDuration" : - 1.0 ,
633+ "connectionRequestTimeoutDuration" : - 1.0 ,
634+ },
635+ },
589636 }
590637 }
591638
592- logger .LoggerMgtServer .Infof ("API Yaml: %+v" , data )
639+ logger .LoggerMgtServer .Debugf ("API Yaml: %+v" , data )
593640 yamlBytes , _ := yaml .Marshal (data )
594- logger .LoggerMgtServer .Infof ("Endpoint Yaml: %v" , endpointsData )
641+ logger .LoggerMgtServer .Debugf ("Endpoint Yaml: %v" , endpointsData )
595642 endpointBytes , _ := yaml .Marshal (endpointsData )
596643 return string (yamlBytes ), definition , string (endpointBytes )
597644}
0 commit comments