configuration.go 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * HCS API
  3. *
  4. * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
  5. *
  6. * API version: 2.1
  7. * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
  8. */
  9. package hcsschema
  10. import (
  11. "net/http"
  12. )
  13. // contextKeys are used to identify the type of value in the context.
  14. // Since these are string, it is possible to get a short description of the
  15. // context key for logging and debugging using key.String().
  16. type contextKey string
  17. func (c contextKey) String() string {
  18. return "auth " + string(c)
  19. }
  20. var (
  21. // ContextOAuth2 takes a oauth2.TokenSource as authentication for the request.
  22. ContextOAuth2 = contextKey("token")
  23. // ContextBasicAuth takes BasicAuth as authentication for the request.
  24. ContextBasicAuth = contextKey("basic")
  25. // ContextAccessToken takes a string oauth2 access token as authentication for the request.
  26. ContextAccessToken = contextKey("accesstoken")
  27. // ContextAPIKey takes an APIKey as authentication for the request
  28. ContextAPIKey = contextKey("apikey")
  29. )
  30. // BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth
  31. type BasicAuth struct {
  32. UserName string `json:"userName,omitempty"`
  33. Password string `json:"password,omitempty"`
  34. }
  35. // APIKey provides API key based authentication to a request passed via context using ContextAPIKey
  36. type APIKey struct {
  37. Key string
  38. Prefix string
  39. }
  40. type Configuration struct {
  41. BasePath string `json:"basePath,omitempty"`
  42. Host string `json:"host,omitempty"`
  43. Scheme string `json:"scheme,omitempty"`
  44. DefaultHeader map[string]string `json:"defaultHeader,omitempty"`
  45. UserAgent string `json:"userAgent,omitempty"`
  46. HTTPClient *http.Client
  47. }
  48. func NewConfiguration() *Configuration {
  49. cfg := &Configuration{
  50. BasePath: "https://localhost",
  51. DefaultHeader: make(map[string]string),
  52. UserAgent: "Swagger-Codegen/2.1.0/go",
  53. }
  54. return cfg
  55. }
  56. func (c *Configuration) AddDefaultHeader(key string, value string) {
  57. c.DefaultHeader[key] = value
  58. }