Skip to content

Commit

Permalink
Removed the region variable from tagging and search private api const…
Browse files Browse the repository at this point in the history
…ruction
  • Loading branch information
ujjwal-ibm committed Dec 3, 2024
1 parent d841442 commit 8e5251c
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 14 deletions.
41 changes: 41 additions & 0 deletions TestRandomCode/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package main

import "fmt"

var cloudEndpoint = "cloud.ibm.com"

func main() {
var visibility, region string
region = "us-south"
visibility = "private"
fmt.Println("Hello")
globalTaggingEndpoint := "https://tags.global-search-tagging.cloud.ibm.com"
if visibility == "private" || visibility == "public-and-private" {
var globalTaggingRegion string
if region != "us-south" && region != "us-east" {
globalTaggingRegion = "us-south"
} else {
globalTaggingRegion = region
}
globalTaggingEndpoint = ContructEndpoint(fmt.Sprintf("tags.private.%s", globalTaggingRegion), fmt.Sprintf("global-search-tagging.%s", cloudEndpoint))
}
fmt.Println(globalTaggingEndpoint)
// if fileMap != nil && visibility != "public-and-private" {
// globalTaggingEndpoint = fileFallBack(fileMap, visibility, "IBMCLOUD_GT_API_ENDPOINT", region, globalTaggingEndpoint)
// }
}
func ContructEndpoint(subdomain, domain string) string {
endpoint := fmt.Sprintf("https://%s.%s", subdomain, domain)
return endpoint
}

func fileFallBack(fileMap map[string]interface{}, visibility, key, region, defaultValue string) string {
if val, ok := fileMap[key]; ok {
if v, ok := val.(map[string]interface{})[visibility]; ok {
if r, ok := v.(map[string]interface{})[region]; ok && r.(string) != "" {
return r.(string)
}
}
}
return defaultValue
}
16 changes: 2 additions & 14 deletions ibm/conns/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2136,13 +2136,7 @@ func (c *Config) ClientSession() (interface{}, error) {
// GLOBAL TAGGING Service
globalTaggingEndpoint := "https://tags.global-search-tagging.cloud.ibm.com"
if c.Visibility == "private" || c.Visibility == "public-and-private" {
var globalTaggingRegion string
if c.Region != "us-south" && c.Region != "us-east" {
globalTaggingRegion = "us-south"
} else {
globalTaggingRegion = c.Region
}
globalTaggingEndpoint = ContructEndpoint(fmt.Sprintf("tags.private.%s", globalTaggingRegion), fmt.Sprintf("global-search-tagging.%s", cloudEndpoint))
globalTaggingEndpoint = ContructEndpoint("tags.private.", fmt.Sprintf("global-search-tagging.%s", cloudEndpoint))
}
if fileMap != nil && c.Visibility != "public-and-private" {
globalTaggingEndpoint = fileFallBack(fileMap, c.Visibility, "IBMCLOUD_GT_API_ENDPOINT", c.Region, globalTaggingEndpoint)
Expand All @@ -2165,13 +2159,7 @@ func (c *Config) ClientSession() (interface{}, error) {
// GLOBAL TAGGING Service
globalSearchEndpoint := "https://api.global-search-tagging.cloud.ibm.com"
if c.Visibility == "private" || c.Visibility == "public-and-private" {
var globalSearchRegion string
if c.Region != "us-south" && c.Region != "au-syd" && c.Region != "eu-gb" {
globalSearchRegion = "us-south"
} else {
globalSearchRegion = c.Region
}
globalSearchEndpoint = ContructEndpoint(fmt.Sprintf("api.private.%s", globalSearchRegion), fmt.Sprintf("global-search-tagging.%s", cloudEndpoint))
globalSearchEndpoint = ContructEndpoint("api.private.", fmt.Sprintf("global-search-tagging.%s", cloudEndpoint))
}
if fileMap != nil && c.Visibility != "public-and-private" {
globalSearchEndpoint = fileFallBack(fileMap, c.Visibility, "IBMCLOUD_GS_API_ENDPOINT", c.Region, searchv2.DefaultServiceURL)
Expand Down

0 comments on commit 8e5251c

Please sign in to comment.