github.com/launchdarkly/api-client-go@v5.3.0+incompatible/configuration.go (about)

     1  /*
     2   * LaunchDarkly REST API
     3   *
     4   * Build custom integrations with the LaunchDarkly REST API
     5   *
     6   * API version: 5.3.0
     7   * Contact: support@launchdarkly.com
     8   * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
     9   */
    10  
    11  package ldapi
    12  
    13  import (
    14  	"net/http"
    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  var (
    28  	// ContextOAuth2 takes a oauth2.TokenSource as authentication for the request.
    29  	ContextOAuth2 = contextKey("token")
    30  
    31  	// ContextBasicAuth takes BasicAuth as authentication for the request.
    32  	ContextBasicAuth = contextKey("basic")
    33  
    34  	// ContextAccessToken takes a string oauth2 access token as authentication for the request.
    35  	ContextAccessToken = contextKey("accesstoken")
    36  
    37  	// ContextAPIKey takes an APIKey as authentication for the request
    38  	ContextAPIKey = contextKey("apikey")
    39  )
    40  
    41  // BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth
    42  type BasicAuth struct {
    43  	UserName string `json:"userName,omitempty"`
    44  	Password string `json:"password,omitempty"`
    45  }
    46  
    47  // APIKey provides API key based authentication to a request passed via context using ContextAPIKey
    48  type APIKey struct {
    49  	Key    string
    50  	Prefix string
    51  }
    52  
    53  type Configuration struct {
    54  	BasePath      string            `json:"basePath,omitempty"`
    55  	Host          string            `json:"host,omitempty"`
    56  	Scheme        string            `json:"scheme,omitempty"`
    57  	DefaultHeader map[string]string `json:"defaultHeader,omitempty"`
    58  	UserAgent     string            `json:"userAgent,omitempty"`
    59  	HTTPClient    *http.Client
    60  }
    61  
    62  func NewConfiguration() *Configuration {
    63  	cfg := &Configuration{
    64  		BasePath:      "https://app.launchdarkly.com/api/v2",
    65  		DefaultHeader: make(map[string]string),
    66  		UserAgent:     "Swagger-Codegen/1.0.0/go",
    67  	}
    68  	return cfg
    69  }
    70  
    71  func (c *Configuration) AddDefaultHeader(key string, value string) {
    72  	c.DefaultHeader[key] = value
    73  }