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

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