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