blob: dd3bbbe4ce992861ede0ba0a61d5bfece0ae881b [file] [log] [blame]
Serge Bazanskicc25bdf2018-10-25 14:02:58 +02001// Code generated by go-swagger; DO NOT EDIT.
2
3// Copyright 2018 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
17package client
18
19// This file was generated by the swagger tool.
20// Editing this file might prove futile when you re-run the swagger generate command
21
22import (
23 "github.com/go-openapi/runtime"
24 httptransport "github.com/go-openapi/runtime/client"
25
26 strfmt "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/secrets"
33 "github.com/digitalocean/go-netbox/netbox/client/tenancy"
34 "github.com/digitalocean/go-netbox/netbox/client/virtualization"
35)
36
37// Default net box HTTP client.
38var Default = NewHTTPClient(nil)
39
40const (
41 // DefaultHost is the default Host
42 // found in Meta (info) section of spec file
43 DefaultHost string = "localhost:8000"
44 // DefaultBasePath is the default BasePath
45 // found in Meta (info) section of spec file
46 DefaultBasePath string = "/api"
47)
48
49// DefaultSchemes are the default schemes found in Meta (info) section of spec file
50var DefaultSchemes = []string{"http"}
51
52// NewHTTPClient creates a new net box HTTP client.
53func NewHTTPClient(formats strfmt.Registry) *NetBox {
54 return NewHTTPClientWithConfig(formats, nil)
55}
56
57// NewHTTPClientWithConfig creates a new net box HTTP client,
58// using a customizable transport config.
59func NewHTTPClientWithConfig(formats strfmt.Registry, cfg *TransportConfig) *NetBox {
60 // ensure nullable parameters have default
61 if formats == nil {
62 formats = strfmt.Default
63 }
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 client
74func New(transport runtime.ClientTransport, formats strfmt.Registry) *NetBox {
75 cli := new(NetBox)
76 cli.Transport = transport
77
78 cli.Circuits = circuits.New(transport, formats)
79
80 cli.Dcim = dcim.New(transport, formats)
81
82 cli.Extras = extras.New(transport, formats)
83
84 cli.IPAM = ipam.New(transport, formats)
85
86 cli.Secrets = secrets.New(transport, formats)
87
88 cli.Tenancy = tenancy.New(transport, formats)
89
90 cli.Virtualization = virtualization.New(transport, formats)
91
92 return cli
93}
94
95// DefaultTransportConfig creates a TransportConfig with the
96// default settings taken from the meta section of the spec file.
97func 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.
107type 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.
115func (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.
122func (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.
129func (cfg *TransportConfig) WithSchemes(schemes []string) *TransportConfig {
130 cfg.Schemes = schemes
131 return cfg
132}
133
134// NetBox is a client for net box
135type NetBox struct {
136 Circuits *circuits.Client
137
138 Dcim *dcim.Client
139
140 Extras *extras.Client
141
142 IPAM *ipam.Client
143
144 Secrets *secrets.Client
145
146 Tenancy *tenancy.Client
147
148 Virtualization *virtualization.Client
149
150 Transport runtime.ClientTransport
151}
152
153// SetTransport changes the transport on the client and all its subresources
154func (c *NetBox) SetTransport(transport runtime.ClientTransport) {
155 c.Transport = transport
156
157 c.Circuits.SetTransport(transport)
158
159 c.Dcim.SetTransport(transport)
160
161 c.Extras.SetTransport(transport)
162
163 c.IPAM.SetTransport(transport)
164
165 c.Secrets.SetTransport(transport)
166
167 c.Tenancy.SetTransport(transport)
168
169 c.Virtualization.SetTransport(transport)
170
171}