github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/pkg/platform/api/secrets/secrets_client/secrets_client.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package secrets_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/ActiveState/cli/pkg/platform/api/secrets/secrets_client/authentication"
    15  	"github.com/ActiveState/cli/pkg/platform/api/secrets/secrets_client/keys"
    16  	"github.com/ActiveState/cli/pkg/platform/api/secrets/secrets_client/secrets"
    17  )
    18  
    19  // Default secrets 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 = "/api/secrets/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 secrets HTTP client.
    35  func NewHTTPClient(formats strfmt.Registry) *Secrets {
    36  	return NewHTTPClientWithConfig(formats, nil)
    37  }
    38  
    39  // NewHTTPClientWithConfig creates a new secrets HTTP client,
    40  // using a customizable transport config.
    41  func NewHTTPClientWithConfig(formats strfmt.Registry, cfg *TransportConfig) *Secrets {
    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 secrets client
    53  func New(transport runtime.ClientTransport, formats strfmt.Registry) *Secrets {
    54  	// ensure nullable parameters have default
    55  	if formats == nil {
    56  		formats = strfmt.Default
    57  	}
    58  
    59  	cli := new(Secrets)
    60  	cli.Transport = transport
    61  
    62  	cli.Authentication = authentication.New(transport, formats)
    63  
    64  	cli.Keys = keys.New(transport, formats)
    65  
    66  	cli.Secrets = secrets.New(transport, formats)
    67  
    68  	return cli
    69  }
    70  
    71  // DefaultTransportConfig creates a TransportConfig with the
    72  // default settings taken from the meta section of the spec file.
    73  func DefaultTransportConfig() *TransportConfig {
    74  	return &TransportConfig{
    75  		Host:     DefaultHost,
    76  		BasePath: DefaultBasePath,
    77  		Schemes:  DefaultSchemes,
    78  	}
    79  }
    80  
    81  // TransportConfig contains the transport related info,
    82  // found in the meta section of the spec file.
    83  type TransportConfig struct {
    84  	Host     string
    85  	BasePath string
    86  	Schemes  []string
    87  }
    88  
    89  // WithHost overrides the default host,
    90  // provided by the meta section of the spec file.
    91  func (cfg *TransportConfig) WithHost(host string) *TransportConfig {
    92  	cfg.Host = host
    93  	return cfg
    94  }
    95  
    96  // WithBasePath overrides the default basePath,
    97  // provided by the meta section of the spec file.
    98  func (cfg *TransportConfig) WithBasePath(basePath string) *TransportConfig {
    99  	cfg.BasePath = basePath
   100  	return cfg
   101  }
   102  
   103  // WithSchemes overrides the default schemes,
   104  // provided by the meta section of the spec file.
   105  func (cfg *TransportConfig) WithSchemes(schemes []string) *TransportConfig {
   106  	cfg.Schemes = schemes
   107  	return cfg
   108  }
   109  
   110  // Secrets is a client for secrets
   111  type Secrets struct {
   112  	Authentication *authentication.Client
   113  
   114  	Keys *keys.Client
   115  
   116  	Secrets *secrets.Client
   117  
   118  	Transport runtime.ClientTransport
   119  }
   120  
   121  // SetTransport changes the transport on the client and all its subresources
   122  func (c *Secrets) SetTransport(transport runtime.ClientTransport) {
   123  	c.Transport = transport
   124  
   125  	c.Authentication.SetTransport(transport)
   126  
   127  	c.Keys.SetTransport(transport)
   128  
   129  	c.Secrets.SetTransport(transport)
   130  
   131  }