github.com/cilium/cilium@v1.16.2/api/v1/health/client/cilium_health_api_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/health/client/connectivity"
    17  	"github.com/cilium/cilium/api/v1/health/client/restapi"
    18  )
    19  
    20  // Default cilium health API HTTP client.
    21  var Default = NewHTTPClient(nil)
    22  
    23  const (
    24  	// DefaultHost is the default Host
    25  	// found in Meta (info) section of spec file
    26  	DefaultHost string = "localhost"
    27  	// DefaultBasePath is the default BasePath
    28  	// found in Meta (info) section of spec file
    29  	DefaultBasePath string = "/v1beta"
    30  )
    31  
    32  // DefaultSchemes are the default schemes found in Meta (info) section of spec file
    33  var DefaultSchemes = []string{"http"}
    34  
    35  // NewHTTPClient creates a new cilium health API HTTP client.
    36  func NewHTTPClient(formats strfmt.Registry) *CiliumHealthAPI {
    37  	return NewHTTPClientWithConfig(formats, nil)
    38  }
    39  
    40  // NewHTTPClientWithConfig creates a new cilium health API HTTP client,
    41  // using a customizable transport config.
    42  func NewHTTPClientWithConfig(formats strfmt.Registry, cfg *TransportConfig) *CiliumHealthAPI {
    43  	// ensure nullable parameters have default
    44  	if cfg == nil {
    45  		cfg = DefaultTransportConfig()
    46  	}
    47  
    48  	// create transport and client
    49  	transport := httptransport.New(cfg.Host, cfg.BasePath, cfg.Schemes)
    50  	return New(transport, formats)
    51  }
    52  
    53  // New creates a new cilium health API client
    54  func New(transport runtime.ClientTransport, formats strfmt.Registry) *CiliumHealthAPI {
    55  	// ensure nullable parameters have default
    56  	if formats == nil {
    57  		formats = strfmt.Default
    58  	}
    59  
    60  	cli := new(CiliumHealthAPI)
    61  	cli.Transport = transport
    62  	cli.Connectivity = connectivity.New(transport, formats)
    63  	cli.Restapi = restapi.New(transport, formats)
    64  	return cli
    65  }
    66  
    67  // DefaultTransportConfig creates a TransportConfig with the
    68  // default settings taken from the meta section of the spec file.
    69  func DefaultTransportConfig() *TransportConfig {
    70  	return &TransportConfig{
    71  		Host:     DefaultHost,
    72  		BasePath: DefaultBasePath,
    73  		Schemes:  DefaultSchemes,
    74  	}
    75  }
    76  
    77  // TransportConfig contains the transport related info,
    78  // found in the meta section of the spec file.
    79  type TransportConfig struct {
    80  	Host     string
    81  	BasePath string
    82  	Schemes  []string
    83  }
    84  
    85  // WithHost overrides the default host,
    86  // provided by the meta section of the spec file.
    87  func (cfg *TransportConfig) WithHost(host string) *TransportConfig {
    88  	cfg.Host = host
    89  	return cfg
    90  }
    91  
    92  // WithBasePath overrides the default basePath,
    93  // provided by the meta section of the spec file.
    94  func (cfg *TransportConfig) WithBasePath(basePath string) *TransportConfig {
    95  	cfg.BasePath = basePath
    96  	return cfg
    97  }
    98  
    99  // WithSchemes overrides the default schemes,
   100  // provided by the meta section of the spec file.
   101  func (cfg *TransportConfig) WithSchemes(schemes []string) *TransportConfig {
   102  	cfg.Schemes = schemes
   103  	return cfg
   104  }
   105  
   106  // CiliumHealthAPI is a client for cilium health API
   107  type CiliumHealthAPI struct {
   108  	Connectivity connectivity.ClientService
   109  
   110  	Restapi restapi.ClientService
   111  
   112  	Transport runtime.ClientTransport
   113  }
   114  
   115  // SetTransport changes the transport on the client and all its subresources
   116  func (c *CiliumHealthAPI) SetTransport(transport runtime.ClientTransport) {
   117  	c.Transport = transport
   118  	c.Connectivity.SetTransport(transport)
   119  	c.Restapi.SetTransport(transport)
   120  }