github.com/digitalocean/go-netbox@v0.0.2/netbox/client/net_box_api_client.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  // Copyright 2020 The go-netbox Authors.
     4  //
     5  // Licensed under the Apache License, Version 2.0 (the "License");
     6  // you may not use this file except in compliance with the License.
     7  // You may obtain a copy of the License at
     8  //
     9  //   http://www.apache.org/licenses/LICENSE-2.0
    10  //
    11  // Unless required by applicable law or agreed to in writing, software
    12  // distributed under the License is distributed on an "AS IS" BASIS,
    13  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14  // See the License for the specific language governing permissions and
    15  // limitations under the License.
    16  //
    17  
    18  package client
    19  
    20  // This file was generated by the swagger tool.
    21  // Editing this file might prove futile when you re-run the swagger generate command
    22  
    23  import (
    24  	"github.com/go-openapi/runtime"
    25  	httptransport "github.com/go-openapi/runtime/client"
    26  	"github.com/go-openapi/strfmt"
    27  
    28  	"github.com/digitalocean/go-netbox/netbox/client/circuits"
    29  	"github.com/digitalocean/go-netbox/netbox/client/dcim"
    30  	"github.com/digitalocean/go-netbox/netbox/client/extras"
    31  	"github.com/digitalocean/go-netbox/netbox/client/ipam"
    32  	"github.com/digitalocean/go-netbox/netbox/client/plugins"
    33  	"github.com/digitalocean/go-netbox/netbox/client/secrets"
    34  	"github.com/digitalocean/go-netbox/netbox/client/status"
    35  	"github.com/digitalocean/go-netbox/netbox/client/tenancy"
    36  	"github.com/digitalocean/go-netbox/netbox/client/users"
    37  	"github.com/digitalocean/go-netbox/netbox/client/virtualization"
    38  )
    39  
    40  // Default net box API HTTP client.
    41  var Default = NewHTTPClient(nil)
    42  
    43  const (
    44  	// DefaultHost is the default Host
    45  	// found in Meta (info) section of spec file
    46  	DefaultHost string = "localhost"
    47  	// DefaultBasePath is the default BasePath
    48  	// found in Meta (info) section of spec file
    49  	DefaultBasePath string = "/api"
    50  )
    51  
    52  // DefaultSchemes are the default schemes found in Meta (info) section of spec file
    53  var DefaultSchemes = []string{"http"}
    54  
    55  // NewHTTPClient creates a new net box API HTTP client.
    56  func NewHTTPClient(formats strfmt.Registry) *NetBoxAPI {
    57  	return NewHTTPClientWithConfig(formats, nil)
    58  }
    59  
    60  // NewHTTPClientWithConfig creates a new net box API HTTP client,
    61  // using a customizable transport config.
    62  func NewHTTPClientWithConfig(formats strfmt.Registry, cfg *TransportConfig) *NetBoxAPI {
    63  	// ensure nullable parameters have default
    64  	if cfg == nil {
    65  		cfg = DefaultTransportConfig()
    66  	}
    67  
    68  	// create transport and client
    69  	transport := httptransport.New(cfg.Host, cfg.BasePath, cfg.Schemes)
    70  	return New(transport, formats)
    71  }
    72  
    73  // New creates a new net box API client
    74  func New(transport runtime.ClientTransport, formats strfmt.Registry) *NetBoxAPI {
    75  	// ensure nullable parameters have default
    76  	if formats == nil {
    77  		formats = strfmt.Default
    78  	}
    79  
    80  	cli := new(NetBoxAPI)
    81  	cli.Transport = transport
    82  	cli.Circuits = circuits.New(transport, formats)
    83  	cli.Dcim = dcim.New(transport, formats)
    84  	cli.Extras = extras.New(transport, formats)
    85  	cli.Ipam = ipam.New(transport, formats)
    86  	cli.Plugins = plugins.New(transport, formats)
    87  	cli.Secrets = secrets.New(transport, formats)
    88  	cli.Status = status.New(transport, formats)
    89  	cli.Tenancy = tenancy.New(transport, formats)
    90  	cli.Users = users.New(transport, formats)
    91  	cli.Virtualization = virtualization.New(transport, formats)
    92  	return cli
    93  }
    94  
    95  // DefaultTransportConfig creates a TransportConfig with the
    96  // default settings taken from the meta section of the spec file.
    97  func DefaultTransportConfig() *TransportConfig {
    98  	return &TransportConfig{
    99  		Host:     DefaultHost,
   100  		BasePath: DefaultBasePath,
   101  		Schemes:  DefaultSchemes,
   102  	}
   103  }
   104  
   105  // TransportConfig contains the transport related info,
   106  // found in the meta section of the spec file.
   107  type TransportConfig struct {
   108  	Host     string
   109  	BasePath string
   110  	Schemes  []string
   111  }
   112  
   113  // WithHost overrides the default host,
   114  // provided by the meta section of the spec file.
   115  func (cfg *TransportConfig) WithHost(host string) *TransportConfig {
   116  	cfg.Host = host
   117  	return cfg
   118  }
   119  
   120  // WithBasePath overrides the default basePath,
   121  // provided by the meta section of the spec file.
   122  func (cfg *TransportConfig) WithBasePath(basePath string) *TransportConfig {
   123  	cfg.BasePath = basePath
   124  	return cfg
   125  }
   126  
   127  // WithSchemes overrides the default schemes,
   128  // provided by the meta section of the spec file.
   129  func (cfg *TransportConfig) WithSchemes(schemes []string) *TransportConfig {
   130  	cfg.Schemes = schemes
   131  	return cfg
   132  }
   133  
   134  // NetBoxAPI is a client for net box API
   135  type NetBoxAPI struct {
   136  	Circuits circuits.ClientService
   137  
   138  	Dcim dcim.ClientService
   139  
   140  	Extras extras.ClientService
   141  
   142  	Ipam ipam.ClientService
   143  
   144  	Plugins plugins.ClientService
   145  
   146  	Secrets secrets.ClientService
   147  
   148  	Status status.ClientService
   149  
   150  	Tenancy tenancy.ClientService
   151  
   152  	Users users.ClientService
   153  
   154  	Virtualization virtualization.ClientService
   155  
   156  	Transport runtime.ClientTransport
   157  }
   158  
   159  // SetTransport changes the transport on the client and all its subresources
   160  func (c *NetBoxAPI) SetTransport(transport runtime.ClientTransport) {
   161  	c.Transport = transport
   162  	c.Circuits.SetTransport(transport)
   163  	c.Dcim.SetTransport(transport)
   164  	c.Extras.SetTransport(transport)
   165  	c.Ipam.SetTransport(transport)
   166  	c.Plugins.SetTransport(transport)
   167  	c.Secrets.SetTransport(transport)
   168  	c.Status.SetTransport(transport)
   169  	c.Tenancy.SetTransport(transport)
   170  	c.Users.SetTransport(transport)
   171  	c.Virtualization.SetTransport(transport)
   172  }