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

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package mono_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  
    13  	"github.com/ActiveState/cli/pkg/platform/api/mono/mono_client/authentication"
    14  	"github.com/ActiveState/cli/pkg/platform/api/mono/mono_client/github"
    15  	"github.com/ActiveState/cli/pkg/platform/api/mono/mono_client/invoices"
    16  	"github.com/ActiveState/cli/pkg/platform/api/mono/mono_client/limits"
    17  	"github.com/ActiveState/cli/pkg/platform/api/mono/mono_client/oauth"
    18  	"github.com/ActiveState/cli/pkg/platform/api/mono/mono_client/organizations"
    19  	"github.com/ActiveState/cli/pkg/platform/api/mono/mono_client/projects"
    20  	"github.com/ActiveState/cli/pkg/platform/api/mono/mono_client/s3"
    21  	"github.com/ActiveState/cli/pkg/platform/api/mono/mono_client/status"
    22  	"github.com/ActiveState/cli/pkg/platform/api/mono/mono_client/tiers"
    23  	"github.com/ActiveState/cli/pkg/platform/api/mono/mono_client/users"
    24  	"github.com/ActiveState/cli/pkg/platform/api/mono/mono_client/version_control"
    25  )
    26  
    27  // Default mono HTTP client.
    28  var Default = NewHTTPClient(nil)
    29  
    30  const (
    31  	// DefaultHost is the default Host
    32  	// found in Meta (info) section of spec file
    33  	DefaultHost string = "localhost"
    34  	// DefaultBasePath is the default BasePath
    35  	// found in Meta (info) section of spec file
    36  	DefaultBasePath string = "/api/v1"
    37  )
    38  
    39  // DefaultSchemes are the default schemes found in Meta (info) section of spec file
    40  var DefaultSchemes = []string{"http", "https"}
    41  
    42  // NewHTTPClient creates a new mono HTTP client.
    43  func NewHTTPClient(formats strfmt.Registry) *Mono {
    44  	return NewHTTPClientWithConfig(formats, nil)
    45  }
    46  
    47  // NewHTTPClientWithConfig creates a new mono HTTP client,
    48  // using a customizable transport config.
    49  func NewHTTPClientWithConfig(formats strfmt.Registry, cfg *TransportConfig) *Mono {
    50  	// ensure nullable parameters have default
    51  	if cfg == nil {
    52  		cfg = DefaultTransportConfig()
    53  	}
    54  
    55  	// create transport and client
    56  	transport := httptransport.New(cfg.Host, cfg.BasePath, cfg.Schemes)
    57  	return New(transport, formats)
    58  }
    59  
    60  // New creates a new mono client
    61  func New(transport runtime.ClientTransport, formats strfmt.Registry) *Mono {
    62  	// ensure nullable parameters have default
    63  	if formats == nil {
    64  		formats = strfmt.Default
    65  	}
    66  
    67  	cli := new(Mono)
    68  	cli.Transport = transport
    69  	cli.Authentication = authentication.New(transport, formats)
    70  	cli.Github = github.New(transport, formats)
    71  	cli.Invoices = invoices.New(transport, formats)
    72  	cli.Limits = limits.New(transport, formats)
    73  	cli.Oauth = oauth.New(transport, formats)
    74  	cli.Organizations = organizations.New(transport, formats)
    75  	cli.Projects = projects.New(transport, formats)
    76  	cli.S3 = s3.New(transport, formats)
    77  	cli.Status = status.New(transport, formats)
    78  	cli.Tiers = tiers.New(transport, formats)
    79  	cli.Users = users.New(transport, formats)
    80  	cli.VersionControl = version_control.New(transport, formats)
    81  	return cli
    82  }
    83  
    84  // DefaultTransportConfig creates a TransportConfig with the
    85  // default settings taken from the meta section of the spec file.
    86  func DefaultTransportConfig() *TransportConfig {
    87  	return &TransportConfig{
    88  		Host:     DefaultHost,
    89  		BasePath: DefaultBasePath,
    90  		Schemes:  DefaultSchemes,
    91  	}
    92  }
    93  
    94  // TransportConfig contains the transport related info,
    95  // found in the meta section of the spec file.
    96  type TransportConfig struct {
    97  	Host     string
    98  	BasePath string
    99  	Schemes  []string
   100  }
   101  
   102  // WithHost overrides the default host,
   103  // provided by the meta section of the spec file.
   104  func (cfg *TransportConfig) WithHost(host string) *TransportConfig {
   105  	cfg.Host = host
   106  	return cfg
   107  }
   108  
   109  // WithBasePath overrides the default basePath,
   110  // provided by the meta section of the spec file.
   111  func (cfg *TransportConfig) WithBasePath(basePath string) *TransportConfig {
   112  	cfg.BasePath = basePath
   113  	return cfg
   114  }
   115  
   116  // WithSchemes overrides the default schemes,
   117  // provided by the meta section of the spec file.
   118  func (cfg *TransportConfig) WithSchemes(schemes []string) *TransportConfig {
   119  	cfg.Schemes = schemes
   120  	return cfg
   121  }
   122  
   123  // Mono is a client for mono
   124  type Mono struct {
   125  	Authentication authentication.ClientService
   126  
   127  	Github github.ClientService
   128  
   129  	Invoices invoices.ClientService
   130  
   131  	Limits limits.ClientService
   132  
   133  	Oauth oauth.ClientService
   134  
   135  	Organizations organizations.ClientService
   136  
   137  	Projects projects.ClientService
   138  
   139  	S3 s3.ClientService
   140  
   141  	Status status.ClientService
   142  
   143  	Tiers tiers.ClientService
   144  
   145  	Users users.ClientService
   146  
   147  	VersionControl version_control.ClientService
   148  
   149  	Transport runtime.ClientTransport
   150  }
   151  
   152  // SetTransport changes the transport on the client and all its subresources
   153  func (c *Mono) SetTransport(transport runtime.ClientTransport) {
   154  	c.Transport = transport
   155  	c.Authentication.SetTransport(transport)
   156  	c.Github.SetTransport(transport)
   157  	c.Invoices.SetTransport(transport)
   158  	c.Limits.SetTransport(transport)
   159  	c.Oauth.SetTransport(transport)
   160  	c.Organizations.SetTransport(transport)
   161  	c.Projects.SetTransport(transport)
   162  	c.S3.SetTransport(transport)
   163  	c.Status.SetTransport(transport)
   164  	c.Tiers.SetTransport(transport)
   165  	c.Users.SetTransport(transport)
   166  	c.VersionControl.SetTransport(transport)
   167  }