Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for advance endpoint config #990

Merged
merged 3 commits into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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