This repository has been archived by the owner on Mar 11, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
clusters.go
324 lines (289 loc) · 10.1 KB
/
clusters.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
// Code generated by goagen v1.3.0, DO NOT EDIT.
//
// API "cluster": clusters Resource Client
//
// Command:
// $ goagen
// --design=github.com/fabric8-services/fabric8-cluster/design
// --out=$(GOPATH)/src/github.com/fabric8-services/fabric8-cluster-client
// --pkg=cluster
// --version=v1.3.0
package cluster
import (
"bytes"
"context"
"fmt"
uuid "github.com/goadesign/goa/uuid"
"net/http"
"net/url"
)
// CreateClustersPayload is the clusters create action payload.
type CreateClustersPayload struct {
Data *CreateClusterData `form:"data" json:"data" xml:"data"`
// An array of mixed types
Included []interface{} `form:"included,omitempty" json:"included,omitempty" xml:"included,omitempty"`
}
// CreateClustersPath computes a request path to the create action of clusters.
func CreateClustersPath() string {
return fmt.Sprintf("/api/clusters/")
}
// Add a cluster configuration
func (c *Client) CreateClusters(ctx context.Context, path string, payload *CreateClustersPayload) (*http.Response, error) {
req, err := c.NewCreateClustersRequest(ctx, path, payload)
if err != nil {
return nil, err
}
return c.Client.Do(ctx, req)
}
// NewCreateClustersRequest create the request corresponding to the create action endpoint of the clusters resource.
func (c *Client) NewCreateClustersRequest(ctx context.Context, path string, payload *CreateClustersPayload) (*http.Request, error) {
var body bytes.Buffer
err := c.Encoder.Encode(payload, &body, "*/*")
if err != nil {
return nil, fmt.Errorf("failed to encode body: %s", err)
}
scheme := c.Scheme
if scheme == "" {
scheme = "http"
}
u := url.URL{Host: c.Host, Scheme: scheme, Path: path}
req, err := http.NewRequest("POST", u.String(), &body)
if err != nil {
return nil, err
}
header := req.Header
header.Set("Content-Type", "application/json")
if c.JWTSigner != nil {
c.JWTSigner.Sign(req)
}
return req, nil
}
// DeleteClustersPath computes a request path to the delete action of clusters.
func DeleteClustersPath(clusterID uuid.UUID) string {
param0 := clusterID.String()
return fmt.Sprintf("/api/clusters/%s", param0)
}
// Delete a cluster configuration
func (c *Client) DeleteClusters(ctx context.Context, path string) (*http.Response, error) {
req, err := c.NewDeleteClustersRequest(ctx, path)
if err != nil {
return nil, err
}
return c.Client.Do(ctx, req)
}
// NewDeleteClustersRequest create the request corresponding to the delete action endpoint of the clusters resource.
func (c *Client) NewDeleteClustersRequest(ctx context.Context, path string) (*http.Request, error) {
scheme := c.Scheme
if scheme == "" {
scheme = "http"
}
u := url.URL{Host: c.Host, Scheme: scheme, Path: path}
req, err := http.NewRequest("DELETE", u.String(), nil)
if err != nil {
return nil, err
}
if c.JWTSigner != nil {
c.JWTSigner.Sign(req)
}
return req, nil
}
// LinkIdentityToClusterClustersPath computes a request path to the linkIdentityToCluster action of clusters.
func LinkIdentityToClusterClustersPath() string {
return fmt.Sprintf("/api/clusters/identities")
}
// create a identitycluster using a service account
func (c *Client) LinkIdentityToClusterClusters(ctx context.Context, path string, payload *LinkIdentityToClusterData) (*http.Response, error) {
req, err := c.NewLinkIdentityToClusterClustersRequest(ctx, path, payload)
if err != nil {
return nil, err
}
return c.Client.Do(ctx, req)
}
// NewLinkIdentityToClusterClustersRequest create the request corresponding to the linkIdentityToCluster action endpoint of the clusters resource.
func (c *Client) NewLinkIdentityToClusterClustersRequest(ctx context.Context, path string, payload *LinkIdentityToClusterData) (*http.Request, error) {
var body bytes.Buffer
err := c.Encoder.Encode(payload, &body, "*/*")
if err != nil {
return nil, fmt.Errorf("failed to encode body: %s", err)
}
scheme := c.Scheme
if scheme == "" {
scheme = "http"
}
u := url.URL{Host: c.Host, Scheme: scheme, Path: path}
req, err := http.NewRequest("POST", u.String(), &body)
if err != nil {
return nil, err
}
header := req.Header
header.Set("Content-Type", "application/json")
if c.JWTSigner != nil {
c.JWTSigner.Sign(req)
}
return req, nil
}
// ListClustersPath computes a request path to the list action of clusters.
func ListClustersPath() string {
return fmt.Sprintf("/api/clusters/")
}
// Get all cluster configurations. If the 'cluster-url' query parameter is set, then a single cluster is returned. If the 'type' query parameter is set then only the clusters with the matchin type are returned
func (c *Client) ListClusters(ctx context.Context, path string, clusterURL *string, type_ *string) (*http.Response, error) {
req, err := c.NewListClustersRequest(ctx, path, clusterURL, type_)
if err != nil {
return nil, err
}
return c.Client.Do(ctx, req)
}
// NewListClustersRequest create the request corresponding to the list action endpoint of the clusters resource.
func (c *Client) NewListClustersRequest(ctx context.Context, path string, clusterURL *string, type_ *string) (*http.Request, error) {
scheme := c.Scheme
if scheme == "" {
scheme = "http"
}
u := url.URL{Host: c.Host, Scheme: scheme, Path: path}
values := u.Query()
if clusterURL != nil {
values.Set("cluster-url", *clusterURL)
}
if type_ != nil {
values.Set("type", *type_)
}
u.RawQuery = values.Encode()
req, err := http.NewRequest("GET", u.String(), nil)
if err != nil {
return nil, err
}
if c.JWTSigner != nil {
c.JWTSigner.Sign(req)
}
return req, nil
}
// ListForAuthClientClustersPath computes a request path to the listForAuthClient action of clusters.
func ListForAuthClientClustersPath() string {
return fmt.Sprintf("/api/clusters/auth")
}
// Get all cluster configurations unless the 'cluster-url' is specified. This endpoint returns all sensitive information
func (c *Client) ListForAuthClientClusters(ctx context.Context, path string, clusterURL *string, type_ *string) (*http.Response, error) {
req, err := c.NewListForAuthClientClustersRequest(ctx, path, clusterURL, type_)
if err != nil {
return nil, err
}
return c.Client.Do(ctx, req)
}
// NewListForAuthClientClustersRequest create the request corresponding to the listForAuthClient action endpoint of the clusters resource.
func (c *Client) NewListForAuthClientClustersRequest(ctx context.Context, path string, clusterURL *string, type_ *string) (*http.Request, error) {
scheme := c.Scheme
if scheme == "" {
scheme = "http"
}
u := url.URL{Host: c.Host, Scheme: scheme, Path: path}
values := u.Query()
if clusterURL != nil {
values.Set("cluster-url", *clusterURL)
}
if type_ != nil {
values.Set("type", *type_)
}
u.RawQuery = values.Encode()
req, err := http.NewRequest("GET", u.String(), nil)
if err != nil {
return nil, err
}
if c.JWTSigner != nil {
c.JWTSigner.Sign(req)
}
return req, nil
}
// RemoveIdentityToClusterLinkClustersPath computes a request path to the removeIdentityToClusterLink action of clusters.
func RemoveIdentityToClusterLinkClustersPath() string {
return fmt.Sprintf("/api/clusters/identities")
}
// Remove a identity cluster relation using a service account
func (c *Client) RemoveIdentityToClusterLinkClusters(ctx context.Context, path string, payload *UnLinkIdentityToClusterdata) (*http.Response, error) {
req, err := c.NewRemoveIdentityToClusterLinkClustersRequest(ctx, path, payload)
if err != nil {
return nil, err
}
return c.Client.Do(ctx, req)
}
// NewRemoveIdentityToClusterLinkClustersRequest create the request corresponding to the removeIdentityToClusterLink action endpoint of the clusters resource.
func (c *Client) NewRemoveIdentityToClusterLinkClustersRequest(ctx context.Context, path string, payload *UnLinkIdentityToClusterdata) (*http.Request, error) {
var body bytes.Buffer
err := c.Encoder.Encode(payload, &body, "*/*")
if err != nil {
return nil, fmt.Errorf("failed to encode body: %s", err)
}
scheme := c.Scheme
if scheme == "" {
scheme = "http"
}
u := url.URL{Host: c.Host, Scheme: scheme, Path: path}
req, err := http.NewRequest("DELETE", u.String(), &body)
if err != nil {
return nil, err
}
header := req.Header
header.Set("Content-Type", "application/json")
if c.JWTSigner != nil {
c.JWTSigner.Sign(req)
}
return req, nil
}
// ShowClustersPath computes a request path to the show action of clusters.
func ShowClustersPath(clusterID uuid.UUID) string {
param0 := clusterID.String()
return fmt.Sprintf("/api/clusters/%s", param0)
}
// Get single cluster configuration
func (c *Client) ShowClusters(ctx context.Context, path string) (*http.Response, error) {
req, err := c.NewShowClustersRequest(ctx, path)
if err != nil {
return nil, err
}
return c.Client.Do(ctx, req)
}
// NewShowClustersRequest create the request corresponding to the show action endpoint of the clusters resource.
func (c *Client) NewShowClustersRequest(ctx context.Context, path string) (*http.Request, error) {
scheme := c.Scheme
if scheme == "" {
scheme = "http"
}
u := url.URL{Host: c.Host, Scheme: scheme, Path: path}
req, err := http.NewRequest("GET", u.String(), nil)
if err != nil {
return nil, err
}
if c.JWTSigner != nil {
c.JWTSigner.Sign(req)
}
return req, nil
}
// ShowForAuthClientClustersPath computes a request path to the showForAuthClient action of clusters.
func ShowForAuthClientClustersPath(clusterID uuid.UUID) string {
param0 := clusterID.String()
return fmt.Sprintf("/api/clusters/%s/auth", param0)
}
// Get single cluster configuration (including Auth information)
func (c *Client) ShowForAuthClientClusters(ctx context.Context, path string) (*http.Response, error) {
req, err := c.NewShowForAuthClientClustersRequest(ctx, path)
if err != nil {
return nil, err
}
return c.Client.Do(ctx, req)
}
// NewShowForAuthClientClustersRequest create the request corresponding to the showForAuthClient action endpoint of the clusters resource.
func (c *Client) NewShowForAuthClientClustersRequest(ctx context.Context, path string) (*http.Request, error) {
scheme := c.Scheme
if scheme == "" {
scheme = "http"
}
u := url.URL{Host: c.Host, Scheme: scheme, Path: path}
req, err := http.NewRequest("GET", u.String(), nil)
if err != nil {
return nil, err
}
if c.JWTSigner != nil {
c.JWTSigner.Sign(req)
}
return req, nil
}