github.com/kubearmor/cilium@v1.6.12/api/v1/client/cilium_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/client/daemon"
    15  	"github.com/cilium/cilium/api/v1/client/endpoint"
    16  	"github.com/cilium/cilium/api/v1/client/ipam"
    17  	"github.com/cilium/cilium/api/v1/client/metrics"
    18  	"github.com/cilium/cilium/api/v1/client/policy"
    19  	"github.com/cilium/cilium/api/v1/client/prefilter"
    20  	"github.com/cilium/cilium/api/v1/client/service"
    21  )
    22  
    23  // Default cilium HTTP client.
    24  var Default = NewHTTPClient(nil)
    25  
    26  const (
    27  	// DefaultHost is the default Host
    28  	// found in Meta (info) section of spec file
    29  	DefaultHost string = "localhost"
    30  	// DefaultBasePath is the default BasePath
    31  	// found in Meta (info) section of spec file
    32  	DefaultBasePath string = "/v1"
    33  )
    34  
    35  // DefaultSchemes are the default schemes found in Meta (info) section of spec file
    36  var DefaultSchemes = []string{"http"}
    37  
    38  // NewHTTPClient creates a new cilium HTTP client.
    39  func NewHTTPClient(formats strfmt.Registry) *Cilium {
    40  	return NewHTTPClientWithConfig(formats, nil)
    41  }
    42  
    43  // NewHTTPClientWithConfig creates a new cilium HTTP client,
    44  // using a customizable transport config.
    45  func NewHTTPClientWithConfig(formats strfmt.Registry, cfg *TransportConfig) *Cilium {
    46  	// ensure nullable parameters have default
    47  	if cfg == nil {
    48  		cfg = DefaultTransportConfig()
    49  	}
    50  
    51  	// create transport and client
    52  	transport := httptransport.New(cfg.Host, cfg.BasePath, cfg.Schemes)
    53  	return New(transport, formats)
    54  }
    55  
    56  // New creates a new cilium client
    57  func New(transport runtime.ClientTransport, formats strfmt.Registry) *Cilium {
    58  	// ensure nullable parameters have default
    59  	if formats == nil {
    60  		formats = strfmt.Default
    61  	}
    62  
    63  	cli := new(Cilium)
    64  	cli.Transport = transport
    65  
    66  	cli.Daemon = daemon.New(transport, formats)
    67  
    68  	cli.Endpoint = endpoint.New(transport, formats)
    69  
    70  	cli.IPAM = ipam.New(transport, formats)
    71  
    72  	cli.Metrics = metrics.New(transport, formats)
    73  
    74  	cli.Policy = policy.New(transport, formats)
    75  
    76  	cli.Prefilter = prefilter.New(transport, formats)
    77  
    78  	cli.Service = service.New(transport, formats)
    79  
    80  	return cli
    81  }
    82  
    83  // DefaultTransportConfig creates a TransportConfig with the
    84  // default settings taken from the meta section of the spec file.
    85  func DefaultTransportConfig() *TransportConfig {
    86  	return &TransportConfig{
    87  		Host:     DefaultHost,
    88  		BasePath: DefaultBasePath,
    89  		Schemes:  DefaultSchemes,
    90  	}
    91  }
    92  
    93  // TransportConfig contains the transport related info,
    94  // found in the meta section of the spec file.
    95  type TransportConfig struct {
    96  	Host     string
    97  	BasePath string
    98  	Schemes  []string
    99  }
   100  
   101  // WithHost overrides the default host,
   102  // provided by the meta section of the spec file.
   103  func (cfg *TransportConfig) WithHost(host string) *TransportConfig {
   104  	cfg.Host = host
   105  	return cfg
   106  }
   107  
   108  // WithBasePath overrides the default basePath,
   109  // provided by the meta section of the spec file.
   110  func (cfg *TransportConfig) WithBasePath(basePath string) *TransportConfig {
   111  	cfg.BasePath = basePath
   112  	return cfg
   113  }
   114  
   115  // WithSchemes overrides the default schemes,
   116  // provided by the meta section of the spec file.
   117  func (cfg *TransportConfig) WithSchemes(schemes []string) *TransportConfig {
   118  	cfg.Schemes = schemes
   119  	return cfg
   120  }
   121  
   122  // Cilium is a client for cilium
   123  type Cilium struct {
   124  	Daemon *daemon.Client
   125  
   126  	Endpoint *endpoint.Client
   127  
   128  	IPAM *ipam.Client
   129  
   130  	Metrics *metrics.Client
   131  
   132  	Policy *policy.Client
   133  
   134  	Prefilter *prefilter.Client
   135  
   136  	Service *service.Client
   137  
   138  	Transport runtime.ClientTransport
   139  }
   140  
   141  // SetTransport changes the transport on the client and all its subresources
   142  func (c *Cilium) SetTransport(transport runtime.ClientTransport) {
   143  	c.Transport = transport
   144  
   145  	c.Daemon.SetTransport(transport)
   146  
   147  	c.Endpoint.SetTransport(transport)
   148  
   149  	c.IPAM.SetTransport(transport)
   150  
   151  	c.Metrics.SetTransport(transport)
   152  
   153  	c.Policy.SetTransport(transport)
   154  
   155  	c.Prefilter.SetTransport(transport)
   156  
   157  	c.Service.SetTransport(transport)
   158  
   159  }