From def97263c4123c571adba5ad3432343aadac395c Mon Sep 17 00:00:00 2001 From: srinandan <13950006+srinandan@users.noreply.github.com> Date: Fri, 1 Dec 2023 10:01:26 -0800 Subject: [PATCH] chore: fix linting issues --- cmd/apidocs/updatedocs.go | 6 ++++-- cmd/securityprofiles/export.go | 3 ++- internal/client/apidocs/apidocs.go | 2 +- internal/client/orgs/orgs.go | 34 ++++++++++++++++++++++++++++++ 4 files changed, 41 insertions(+), 4 deletions(-) diff --git a/cmd/apidocs/updatedocs.go b/cmd/apidocs/updatedocs.go index 4ed6716ed..525f0b821 100644 --- a/cmd/apidocs/updatedocs.go +++ b/cmd/apidocs/updatedocs.go @@ -72,8 +72,10 @@ var UpdateDocCmd = &cobra.Command{ }, } -var openAPIPath, graphQLPath string -var endpointUri string +var ( + openAPIPath, graphQLPath string + endpointUri string +) func init() { UpdateDocCmd.Flags().StringVarP(&id, "id", "i", diff --git a/cmd/securityprofiles/export.go b/cmd/securityprofiles/export.go index c0e4c9556..99816e2b0 100644 --- a/cmd/securityprofiles/export.go +++ b/cmd/securityprofiles/export.go @@ -15,9 +15,10 @@ package securityprofiles import ( - "internal/apiclient" "os" + "internal/apiclient" + "internal/client/securityprofiles" "github.com/spf13/cobra" diff --git a/internal/client/apidocs/apidocs.go b/internal/client/apidocs/apidocs.go index 8fc15c777..affc67ff3 100644 --- a/internal/client/apidocs/apidocs.go +++ b/internal/client/apidocs/apidocs.go @@ -139,7 +139,7 @@ func UpdateDocumentation(siteid string, id string, displayName string, openAPIDo if graphQLDoc != "" { payload = "{\"graphqlDocumentation\":{\"endpointUri\":\"" + endpointUri + - "\",\"schema\":{\"displayName\":\"" + displayName + + "\",\"schema\":{\"displayName\":\"" + displayName + "\",\"contents\":" + graphQLDoc + "}}}" } diff --git a/internal/client/orgs/orgs.go b/internal/client/orgs/orgs.go index f196f4456..94ef0d676 100644 --- a/internal/client/orgs/orgs.go +++ b/internal/client/orgs/orgs.go @@ -181,6 +181,7 @@ func Delete(retension string) (respBody []byte, err error) { return respBody, err } +// GetOrgField func GetOrgField(key string) (value string, err error) { u, _ := url.Parse(apiclient.BaseURL) u.Path = path.Join(u.Path, apiclient.GetApigeeOrg()) @@ -198,6 +199,39 @@ func GetOrgField(key string) (value string, err error) { return fmt.Sprintf("%v", orgMap[key]), nil } +// GetAddOn +func GetAddOn(addon string) (enabled bool) { + u, _ := url.Parse(apiclient.BaseURL) + u.Path = path.Join(u.Path, apiclient.GetApigeeOrg()) + + apiclient.DisableCmdPrintHttpResponse() + defer apiclient.EnableCmdPrintHttpResponse() + + orgBody, err := apiclient.HttpClient(u.String()) + if err != nil { + return false + } + o := organization{} + err = json.Unmarshal(orgBody, &o) + if err != nil { + return false + } + switch addon { + case "advancedApiOpsConfig": + return o.AddOnsConfig.AdvancedApiOpsConfig.Enabled + case "integrationConfig": + return o.AddOnsConfig.IntegrationConfig.Enabled + case "monetizationConfig": + return o.AddOnsConfig.MonetizationConfig.Enabled + case "apiSecurityConfig": + return o.AddOnsConfig.AdvancedApiSecurityConfig.Enabled + case "connectorsPlatformConfig": + return o.AddOnsConfig.ConnectorsPlatformConfig.Enabled + default: + return false + } +} + // List func List() (respBody []byte, err error) { u, _ := url.Parse(apiclient.BaseURL)