-
Notifications
You must be signed in to change notification settings - Fork 8
/
kubernetes.go
115 lines (99 loc) · 3.91 KB
/
kubernetes.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
// Package kubernetes provides primitives to interact with the openapi HTTP API.
//
// Code generated by github.com/do87/stackit-client-generator version v0.0.2 DO NOT EDIT.
package kubernetes
import (
"net/url"
"strings"
contracts "github.com/SchwarzIT/community-stackit-go-client/pkg/contracts"
"github.com/SchwarzIT/community-stackit-go-client/pkg/services/kubernetes/v1.0/cluster"
"github.com/SchwarzIT/community-stackit-go-client/pkg/services/kubernetes/v1.0/credentials"
"github.com/SchwarzIT/community-stackit-go-client/pkg/services/kubernetes/v1.0/operation"
"github.com/SchwarzIT/community-stackit-go-client/pkg/services/kubernetes/v1.0/project"
provideroptions "github.com/SchwarzIT/community-stackit-go-client/pkg/services/kubernetes/v1.0/provider-options"
)
// Client which conforms to the OpenAPI3 specification for this service.
type Client struct {
// list of connected client services
Cluster *cluster.Client
Credentials *credentials.Client
Operation *operation.Client
ProviderOptions *provideroptions.Client
Project *project.Client
// The endpoint of the server conforming to this interface, with scheme,
// https://api.deepmap.com for example. This can contain a path relative
// to the server, such as https://api.deepmap.com/dev-test, and all the
// paths in the swagger spec will be appended to the server.
Server string
// Doer for performing requests, typically a *http.Client with any
// customized settings, such as certificate chains.
Client contracts.BaseClientInterface
}
// ClientOption allows setting custom parameters during construction
type ClientOption func(*Client) error
func NewRawClient(server string, opts ...ClientOption) (*Client, error) {
// create a factory client
client := Client{
Server: server,
}
// mutate client and add all optional params
for _, o := range opts {
if err := o(&client); err != nil {
return nil, err
}
}
// ensure the server URL always has a trailing slash
if !strings.HasSuffix(client.Server, "/") {
client.Server += "/"
}
client.Cluster = cluster.NewRawClient(server, client.Client)
client.Credentials = credentials.NewRawClient(server, client.Client)
client.Operation = operation.NewRawClient(server, client.Client)
client.ProviderOptions = provideroptions.NewRawClient(server, client.Client)
client.Project = project.NewRawClient(server, client.Client)
return &client, nil
}
// WithHTTPClient allows overriding the default Doer, which is
// automatically created using http.Client. This is useful for tests.
func WithHTTPClient(doer contracts.BaseClientInterface) ClientOption {
return func(c *Client) error {
c.Client = doer
return nil
}
}
// WithBaseURL overrides the baseURL.
func WithBaseURL(baseURL string) ClientOption {
return func(c *Client) error {
newBaseURL, err := url.Parse(baseURL)
if err != nil {
return err
}
c.Server = newBaseURL.String()
return nil
}
}
// ClientWithResponses builds on rawClientInterface to offer response payloads
type ClientWithResponses struct {
Client *Client
// list of connected client services
Cluster *cluster.ClientWithResponses
Credentials *credentials.ClientWithResponses
Operation *operation.ClientWithResponses
ProviderOptions *provideroptions.ClientWithResponses
Project *project.ClientWithResponses
}
// NewClient creates a new ClientWithResponses, which wraps
// Client with return type handling
func NewClient(server string, opts ...ClientOption) (*ClientWithResponses, error) {
client, err := NewRawClient(server, opts...)
if err != nil {
return nil, err
}
cwr := &ClientWithResponses{Client: client}
cwr.Cluster = cluster.NewClient(server, client.Client)
cwr.Credentials = credentials.NewClient(server, client.Client)
cwr.Operation = operation.NewClient(server, client.Client)
cwr.ProviderOptions = provideroptions.NewClient(server, client.Client)
cwr.Project = project.NewClient(server, client.Client)
return cwr, nil
}