-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathsnapshots_client.go
245 lines (214 loc) · 8.94 KB
/
snapshots_client.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
// Code generated by go-swagger; DO NOT EDIT.
package snapshots
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"fmt"
"github.com/go-openapi/runtime"
httptransport "github.com/go-openapi/runtime/client"
"github.com/go-openapi/strfmt"
)
// New creates a new snapshots API client.
func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService {
return &Client{transport: transport, formats: formats}
}
// New creates a new snapshots API client with basic auth credentials.
// It takes the following parameters:
// - host: http host (github.com).
// - basePath: any base path for the API client ("/v1", "/v3").
// - scheme: http scheme ("http", "https").
// - user: user for basic authentication header.
// - password: password for basic authentication header.
func NewClientWithBasicAuth(host, basePath, scheme, user, password string) ClientService {
transport := httptransport.New(host, basePath, []string{scheme})
transport.DefaultAuthentication = httptransport.BasicAuth(user, password)
return &Client{transport: transport, formats: strfmt.Default}
}
// New creates a new snapshots API client with a bearer token for authentication.
// It takes the following parameters:
// - host: http host (github.com).
// - basePath: any base path for the API client ("/v1", "/v3").
// - scheme: http scheme ("http", "https").
// - bearerToken: bearer token for Bearer authentication header.
func NewClientWithBearerToken(host, basePath, scheme, bearerToken string) ClientService {
transport := httptransport.New(host, basePath, []string{scheme})
transport.DefaultAuthentication = httptransport.BearerToken(bearerToken)
return &Client{transport: transport, formats: strfmt.Default}
}
/*
Client for snapshots API
*/
type Client struct {
transport runtime.ClientTransport
formats strfmt.Registry
}
// ClientOption may be used to customize the behavior of Client methods.
type ClientOption func(*runtime.ClientOperation)
// ClientService is the interface for Client methods
type ClientService interface {
V1SnapshotsGet(params *V1SnapshotsGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*V1SnapshotsGetOK, error)
V1SnapshotsGetall(params *V1SnapshotsGetallParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*V1SnapshotsGetallOK, error)
V1VolumeSnapshotsGet(params *V1VolumeSnapshotsGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*V1VolumeSnapshotsGetOK, error)
V1VolumeSnapshotsGetall(params *V1VolumeSnapshotsGetallParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*V1VolumeSnapshotsGetallOK, error)
SetTransport(transport runtime.ClientTransport)
}
/*
V1SnapshotsGet gets the detail of a snapshot
This API is deprecated for /v1/snapshots.
The API v1/volume-snapshots has replaced this endpoint.
View the usage of a snapshot. The snapshot may take time sync because the data is cached.
*/
func (a *Client) V1SnapshotsGet(params *V1SnapshotsGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*V1SnapshotsGetOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewV1SnapshotsGetParams()
}
op := &runtime.ClientOperation{
ID: "v1.snapshots.get",
Method: "GET",
PathPattern: "/v1/snapshots/{snapshot_id}",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &V1SnapshotsGetReader{formats: a.formats},
AuthInfo: authInfo,
Context: params.Context,
Client: params.HTTPClient,
}
for _, opt := range opts {
opt(op)
}
result, err := a.transport.Submit(op)
if err != nil {
return nil, err
}
success, ok := result.(*V1SnapshotsGetOK)
if ok {
return success, nil
}
// unexpected success response
// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
msg := fmt.Sprintf("unexpected success response for v1.snapshots.get: API contract not enforced by server. Client expected to get an error, but got: %T", result)
panic(msg)
}
/*
V1SnapshotsGetall gets a list of all the snapshots on a workspace
This API is deprecated for /v1/snapshots.
The API v1/volume-snapshots has replaced this endpoint.
View the usage of snapshots on the workspace. The snapshots may take time sync because the data is cached.
*/
func (a *Client) V1SnapshotsGetall(params *V1SnapshotsGetallParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*V1SnapshotsGetallOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewV1SnapshotsGetallParams()
}
op := &runtime.ClientOperation{
ID: "v1.snapshots.getall",
Method: "GET",
PathPattern: "/v1/snapshots",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &V1SnapshotsGetallReader{formats: a.formats},
AuthInfo: authInfo,
Context: params.Context,
Client: params.HTTPClient,
}
for _, opt := range opts {
opt(op)
}
result, err := a.transport.Submit(op)
if err != nil {
return nil, err
}
success, ok := result.(*V1SnapshotsGetallOK)
if ok {
return success, nil
}
// unexpected success response
// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
msg := fmt.Sprintf("unexpected success response for v1.snapshots.getall: API contract not enforced by server. Client expected to get an error, but got: %T", result)
panic(msg)
}
/*
V1VolumeSnapshotsGet gets the detail of a volume snapshot
View the usage of a snapshot. The snapshot may take time sync because the data is cached.
*/
func (a *Client) V1VolumeSnapshotsGet(params *V1VolumeSnapshotsGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*V1VolumeSnapshotsGetOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewV1VolumeSnapshotsGetParams()
}
op := &runtime.ClientOperation{
ID: "v1.volume-snapshots.get",
Method: "GET",
PathPattern: "/v1/volume-snapshots/{volume_snapshot_uuid}",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &V1VolumeSnapshotsGetReader{formats: a.formats},
AuthInfo: authInfo,
Context: params.Context,
Client: params.HTTPClient,
}
for _, opt := range opts {
opt(op)
}
result, err := a.transport.Submit(op)
if err != nil {
return nil, err
}
success, ok := result.(*V1VolumeSnapshotsGetOK)
if ok {
return success, nil
}
// unexpected success response
// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
msg := fmt.Sprintf("unexpected success response for v1.volume-snapshots.get: API contract not enforced by server. Client expected to get an error, but got: %T", result)
panic(msg)
}
/*
V1VolumeSnapshotsGetall gets the list of volume snapshots on a workspace
View the usage of volume snapshots on the workspace. The volume snapshots may take time sync because the data is cached.
*/
func (a *Client) V1VolumeSnapshotsGetall(params *V1VolumeSnapshotsGetallParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*V1VolumeSnapshotsGetallOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewV1VolumeSnapshotsGetallParams()
}
op := &runtime.ClientOperation{
ID: "v1.volume-snapshots.getall",
Method: "GET",
PathPattern: "/v1/volume-snapshots",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &V1VolumeSnapshotsGetallReader{formats: a.formats},
AuthInfo: authInfo,
Context: params.Context,
Client: params.HTTPClient,
}
for _, opt := range opts {
opt(op)
}
result, err := a.transport.Submit(op)
if err != nil {
return nil, err
}
success, ok := result.(*V1VolumeSnapshotsGetallOK)
if ok {
return success, nil
}
// unexpected success response
// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
msg := fmt.Sprintf("unexpected success response for v1.volume-snapshots.getall: API contract not enforced by server. Client expected to get an error, but got: %T", result)
panic(msg)
}
// SetTransport changes the transport on the client
func (a *Client) SetTransport(transport runtime.ClientTransport) {
a.transport = transport
}