github.com/kubearmor/cilium@v1.6.12/api/v1/health/client/cilium_health_client.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package client 4 5 // This file was generated by the swagger tool. 6 // Editing this file might prove futile when you re-run the swagger generate command 7 8 import ( 9 "github.com/go-openapi/runtime" 10 httptransport "github.com/go-openapi/runtime/client" 11 12 strfmt "github.com/go-openapi/strfmt" 13 14 "github.com/cilium/cilium/api/v1/health/client/connectivity" 15 "github.com/cilium/cilium/api/v1/health/client/restapi" 16 ) 17 18 // Default cilium health HTTP client. 19 var Default = NewHTTPClient(nil) 20 21 const ( 22 // DefaultHost is the default Host 23 // found in Meta (info) section of spec file 24 DefaultHost string = "localhost" 25 // DefaultBasePath is the default BasePath 26 // found in Meta (info) section of spec file 27 DefaultBasePath string = "/v1beta" 28 ) 29 30 // DefaultSchemes are the default schemes found in Meta (info) section of spec file 31 var DefaultSchemes = []string{"http"} 32 33 // NewHTTPClient creates a new cilium health HTTP client. 34 func NewHTTPClient(formats strfmt.Registry) *CiliumHealth { 35 return NewHTTPClientWithConfig(formats, nil) 36 } 37 38 // NewHTTPClientWithConfig creates a new cilium health HTTP client, 39 // using a customizable transport config. 40 func NewHTTPClientWithConfig(formats strfmt.Registry, cfg *TransportConfig) *CiliumHealth { 41 // ensure nullable parameters have default 42 if cfg == nil { 43 cfg = DefaultTransportConfig() 44 } 45 46 // create transport and client 47 transport := httptransport.New(cfg.Host, cfg.BasePath, cfg.Schemes) 48 return New(transport, formats) 49 } 50 51 // New creates a new cilium health client 52 func New(transport runtime.ClientTransport, formats strfmt.Registry) *CiliumHealth { 53 // ensure nullable parameters have default 54 if formats == nil { 55 formats = strfmt.Default 56 } 57 58 cli := new(CiliumHealth) 59 cli.Transport = transport 60 61 cli.Connectivity = connectivity.New(transport, formats) 62 63 cli.Restapi = restapi.New(transport, formats) 64 65 return cli 66 } 67 68 // DefaultTransportConfig creates a TransportConfig with the 69 // default settings taken from the meta section of the spec file. 70 func DefaultTransportConfig() *TransportConfig { 71 return &TransportConfig{ 72 Host: DefaultHost, 73 BasePath: DefaultBasePath, 74 Schemes: DefaultSchemes, 75 } 76 } 77 78 // TransportConfig contains the transport related info, 79 // found in the meta section of the spec file. 80 type TransportConfig struct { 81 Host string 82 BasePath string 83 Schemes []string 84 } 85 86 // WithHost overrides the default host, 87 // provided by the meta section of the spec file. 88 func (cfg *TransportConfig) WithHost(host string) *TransportConfig { 89 cfg.Host = host 90 return cfg 91 } 92 93 // WithBasePath overrides the default basePath, 94 // provided by the meta section of the spec file. 95 func (cfg *TransportConfig) WithBasePath(basePath string) *TransportConfig { 96 cfg.BasePath = basePath 97 return cfg 98 } 99 100 // WithSchemes overrides the default schemes, 101 // provided by the meta section of the spec file. 102 func (cfg *TransportConfig) WithSchemes(schemes []string) *TransportConfig { 103 cfg.Schemes = schemes 104 return cfg 105 } 106 107 // CiliumHealth is a client for cilium health 108 type CiliumHealth struct { 109 Connectivity *connectivity.Client 110 111 Restapi *restapi.Client 112 113 Transport runtime.ClientTransport 114 } 115 116 // SetTransport changes the transport on the client and all its subresources 117 func (c *CiliumHealth) SetTransport(transport runtime.ClientTransport) { 118 c.Transport = transport 119 120 c.Connectivity.SetTransport(transport) 121 122 c.Restapi.SetTransport(transport) 123 124 }