Skip to content

Commit

Permalink
Merge pull request #990 from shilmyhasan/3.0.x
Browse files Browse the repository at this point in the history
Add support for advance endpoint config
  • Loading branch information
npamudika authored Aug 3, 2023
2 parents 4bee3a3 + a0f133a commit b3f6ddb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
9 changes: 6 additions & 3 deletions import-export-cli/specs/params/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,15 @@ type Configuration struct {
Factor *int `yaml:"factor" json:"factor,string"`
}

type AdvanceConfigForMG struct {
TimeOutInMillis *int `yaml:"timeoutInMillis" json:"timeoutInMillis"`
}

// Endpoint details
type Endpoint struct {
// Url of the endpoint
Url *string `yaml:"url" json:"url"`
Url *string `yaml:"url" json:"url"`
AdvanceEndpointConfig AdvanceConfigForMG `yaml:"advanceEndpointConfig" json:"advanceEndpointConfig"`
// Config of endpoint
Config *Configuration `yaml:"config" json:"config"`
}
Expand Down Expand Up @@ -116,7 +121,6 @@ func ExtractAPIEndpointConfig(b []byte) (string, error) {
return apiConfig.EPConfig, err
}


// GetEnv returns the EndpointData associated for key in the ApiParams, if not found returns nil
func (config ApiParams) GetEnv(key string) *Environment {
for index, env := range config.Environments {
Expand All @@ -126,4 +130,3 @@ func (config ApiParams) GetEnv(key string) *Environment {
}
return nil
}

9 changes: 7 additions & 2 deletions import-export-cli/specs/v2/oai3.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,13 @@ func oai3Tags(exts map[string]interface{}) []string {
}

type Endpoints struct {
Type string `yaml:"type"`
Urls []string `yaml:"urls"`
Type string `yaml:"type"`
Urls []string `yaml:"urls"`
AdvanceEndpointConfig AdvanceConfigForMG `yaml:"advanceEndpointConfig"`
}

type AdvanceConfigForMG struct {
TimeOutInMillis *int `yaml:"timeoutInMillis" json:"timeoutInMillis"`
}

func oai3XWSO2ProductionEndpoints(exts map[string]interface{}) (*Endpoints, bool, error) {
Expand Down
6 changes: 3 additions & 3 deletions import-export-cli/specs/v2/swagger2.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@ package v2

import (
"fmt"
"path"

"github.com/wso2/product-apim-tooling/import-export-cli/specs/params"
"path"

"github.com/Jeffail/gabs"
"github.com/go-openapi/loads"
"github.com/mitchellh/mapstructure"

)

func swagger2XWO2BasePath(document *loads.Document) (string, bool) {
Expand Down Expand Up @@ -186,11 +184,13 @@ func buildHttpEndpoint(production *Endpoints, sandbox *Endpoints) string {
if len(production.Urls) > 0 {
var ep params.Endpoint
ep.Url = &production.Urls[0]
ep.AdvanceEndpointConfig.TimeOutInMillis = production.AdvanceEndpointConfig.TimeOutInMillis
_, _ = jsonObj.SetP(ep, "production_endpoints")
}
if len(sandbox.Urls) > 0 {
var ep params.Endpoint
ep.Url = &sandbox.Urls[0]
ep.AdvanceEndpointConfig.TimeOutInMillis = sandbox.AdvanceEndpointConfig.TimeOutInMillis
_, _ = jsonObj.SetP(ep, "sandbox_endpoints")
}
return jsonObj.String()
Expand Down

0 comments on commit b3f6ddb

Please sign in to comment.