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