github.com/NaverCloudPlatform/ncloud-sdk-go-v2@v1.6.13/services/vsourcedeploy/configuration.go (about)

     1  /*
     2   * vsourcedeploy
     3   *
     4   * <br/>https://vpcsourcedeploy.apigw.ntruss.com/api/v1
     5   *
     6   * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
     7   */
     8  
     9  package vsourcedeploy
    10  
    11  import (
    12  	"github.com/NaverCloudPlatform/ncloud-sdk-go-v2/ncloud"
    13  	"os"
    14  	"strings"
    15  )
    16  
    17  // contextKeys are used to identify the type of value in the context.
    18  // Since these are string, it is possible to get a short description of the
    19  // context key for logging and debugging using key.String().
    20  
    21  type contextKey string
    22  
    23  func (c contextKey) String() string {
    24  	return "auth " + string(c)
    25  }
    26  
    27  func NewConfiguration(region string, apiKeys ...*ncloud.APIKey) *ncloud.Configuration {
    28  	cfg := &ncloud.Configuration{
    29  		BasePath:      "https://vpcsourcedeploy.apigw.ntruss.com/api/v1",
    30  		DefaultHeader: make(map[string]string),
    31  		UserAgent:     "vsourcedeploy/1.0.0/go",
    32  	}
    33  	if len(apiKeys) > 0 {
    34  		cfg.APIKey = apiKeys[0]
    35  	}
    36  	cfg.InitCredentials()
    37  	if os.Getenv("NCLOUD_API_GW") != "" {
    38  		cfg.BasePath = os.Getenv("NCLOUD_API_GW") + "/api/v1"
    39  		cfg.BasePath = strings.Replace(cfg.BasePath, "fin-ncloud", "vpcsourcedeploy", 1)
    40  		cfg.BasePath = strings.Replace(cfg.BasePath, "ncloud", "vpcsourcedeploy", 1)
    41  	}
    42  	switch region {
    43  	case "SGN":
    44  		cfg.BasePath = strings.Replace(cfg.BasePath, "/v1", "/sg-v1", 1)
    45  	}
    46  
    47  	return cfg
    48  }