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

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