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