forked from xoanmi/goharbor-client
/
user_client.go
456 lines (407 loc) · 16.5 KB
/
user_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
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
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
// Code generated by go-swagger; DO NOT EDIT.
package user
// 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"
"github.com/go-openapi/strfmt"
)
// New creates a new user API client.
func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService {
return &Client{transport: transport, formats: formats}
}
/*
Client for user API
*/
type Client struct {
transport runtime.ClientTransport
formats strfmt.Registry
}
// ClientService is the interface for Client methods
type ClientService interface {
CreateUser(params *CreateUserParams, authInfo runtime.ClientAuthInfoWriter) (*CreateUserCreated, error)
DeleteUser(params *DeleteUserParams, authInfo runtime.ClientAuthInfoWriter) (*DeleteUserOK, error)
GetCurrentUserInfo(params *GetCurrentUserInfoParams, authInfo runtime.ClientAuthInfoWriter) (*GetCurrentUserInfoOK, error)
GetCurrentUserPermissions(params *GetCurrentUserPermissionsParams, authInfo runtime.ClientAuthInfoWriter) (*GetCurrentUserPermissionsOK, error)
GetUser(params *GetUserParams, authInfo runtime.ClientAuthInfoWriter) (*GetUserOK, error)
ListUsers(params *ListUsersParams, authInfo runtime.ClientAuthInfoWriter) (*ListUsersOK, error)
SearchUsers(params *SearchUsersParams, authInfo runtime.ClientAuthInfoWriter) (*SearchUsersOK, error)
SetCliSecret(params *SetCliSecretParams, authInfo runtime.ClientAuthInfoWriter) (*SetCliSecretOK, error)
SetUserSysAdmin(params *SetUserSysAdminParams, authInfo runtime.ClientAuthInfoWriter) (*SetUserSysAdminOK, error)
UpdateUserPassword(params *UpdateUserPasswordParams, authInfo runtime.ClientAuthInfoWriter) (*UpdateUserPasswordOK, error)
UpdateUserProfile(params *UpdateUserProfileParams, authInfo runtime.ClientAuthInfoWriter) (*UpdateUserProfileOK, error)
SetTransport(transport runtime.ClientTransport)
}
/*
CreateUser creates a local user
This API can be used only when the authentication mode is for local DB. When self registration is disabled.
*/
func (a *Client) CreateUser(params *CreateUserParams, authInfo runtime.ClientAuthInfoWriter) (*CreateUserCreated, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewCreateUserParams()
}
result, err := a.transport.Submit(&runtime.ClientOperation{
ID: "createUser",
Method: "POST",
PathPattern: "/users",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http", "https"},
Params: params,
Reader: &CreateUserReader{formats: a.formats},
AuthInfo: authInfo,
Context: params.Context,
Client: params.HTTPClient,
})
if err != nil {
return nil, err
}
success, ok := result.(*CreateUserCreated)
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 createUser: API contract not enforced by server. Client expected to get an error, but got: %T", result)
panic(msg)
}
/*
DeleteUser marks a registered user as be removed
This endpoint let administrator of Harbor mark a registered user as removed.It actually won't be deleted from DB.
*/
func (a *Client) DeleteUser(params *DeleteUserParams, authInfo runtime.ClientAuthInfoWriter) (*DeleteUserOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewDeleteUserParams()
}
result, err := a.transport.Submit(&runtime.ClientOperation{
ID: "deleteUser",
Method: "DELETE",
PathPattern: "/users/{user_id}",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http", "https"},
Params: params,
Reader: &DeleteUserReader{formats: a.formats},
AuthInfo: authInfo,
Context: params.Context,
Client: params.HTTPClient,
})
if err != nil {
return nil, err
}
success, ok := result.(*DeleteUserOK)
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 deleteUser: API contract not enforced by server. Client expected to get an error, but got: %T", result)
panic(msg)
}
/*
GetCurrentUserInfo gets current user info
*/
func (a *Client) GetCurrentUserInfo(params *GetCurrentUserInfoParams, authInfo runtime.ClientAuthInfoWriter) (*GetCurrentUserInfoOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewGetCurrentUserInfoParams()
}
result, err := a.transport.Submit(&runtime.ClientOperation{
ID: "getCurrentUserInfo",
Method: "GET",
PathPattern: "/users/current",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http", "https"},
Params: params,
Reader: &GetCurrentUserInfoReader{formats: a.formats},
AuthInfo: authInfo,
Context: params.Context,
Client: params.HTTPClient,
})
if err != nil {
return nil, err
}
success, ok := result.(*GetCurrentUserInfoOK)
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 getCurrentUserInfo: API contract not enforced by server. Client expected to get an error, but got: %T", result)
panic(msg)
}
/*
GetCurrentUserPermissions gets current user permissions
*/
func (a *Client) GetCurrentUserPermissions(params *GetCurrentUserPermissionsParams, authInfo runtime.ClientAuthInfoWriter) (*GetCurrentUserPermissionsOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewGetCurrentUserPermissionsParams()
}
result, err := a.transport.Submit(&runtime.ClientOperation{
ID: "getCurrentUserPermissions",
Method: "GET",
PathPattern: "/users/current/permissions",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http", "https"},
Params: params,
Reader: &GetCurrentUserPermissionsReader{formats: a.formats},
AuthInfo: authInfo,
Context: params.Context,
Client: params.HTTPClient,
})
if err != nil {
return nil, err
}
success, ok := result.(*GetCurrentUserPermissionsOK)
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 getCurrentUserPermissions: API contract not enforced by server. Client expected to get an error, but got: %T", result)
panic(msg)
}
/*
GetUser gets a user s profile
*/
func (a *Client) GetUser(params *GetUserParams, authInfo runtime.ClientAuthInfoWriter) (*GetUserOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewGetUserParams()
}
result, err := a.transport.Submit(&runtime.ClientOperation{
ID: "getUser",
Method: "GET",
PathPattern: "/users/{user_id}",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http", "https"},
Params: params,
Reader: &GetUserReader{formats: a.formats},
AuthInfo: authInfo,
Context: params.Context,
Client: params.HTTPClient,
})
if err != nil {
return nil, err
}
success, ok := result.(*GetUserOK)
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 getUser: API contract not enforced by server. Client expected to get an error, but got: %T", result)
panic(msg)
}
/*
ListUsers lists users
*/
func (a *Client) ListUsers(params *ListUsersParams, authInfo runtime.ClientAuthInfoWriter) (*ListUsersOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewListUsersParams()
}
result, err := a.transport.Submit(&runtime.ClientOperation{
ID: "listUsers",
Method: "GET",
PathPattern: "/users",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http", "https"},
Params: params,
Reader: &ListUsersReader{formats: a.formats},
AuthInfo: authInfo,
Context: params.Context,
Client: params.HTTPClient,
})
if err != nil {
return nil, err
}
success, ok := result.(*ListUsersOK)
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 listUsers: API contract not enforced by server. Client expected to get an error, but got: %T", result)
panic(msg)
}
/*
SearchUsers searches users by username
This endpoint is to search the users by username. It's open for all authenticated requests.
*/
func (a *Client) SearchUsers(params *SearchUsersParams, authInfo runtime.ClientAuthInfoWriter) (*SearchUsersOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewSearchUsersParams()
}
result, err := a.transport.Submit(&runtime.ClientOperation{
ID: "searchUsers",
Method: "GET",
PathPattern: "/users/search",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http", "https"},
Params: params,
Reader: &SearchUsersReader{formats: a.formats},
AuthInfo: authInfo,
Context: params.Context,
Client: params.HTTPClient,
})
if err != nil {
return nil, err
}
success, ok := result.(*SearchUsersOK)
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 searchUsers: API contract not enforced by server. Client expected to get an error, but got: %T", result)
panic(msg)
}
/*
SetCliSecret sets c l i secret for a user
This endpoint let user generate a new CLI secret for himself. This API only works when auth mode is set to 'OIDC'. Once this API returns with successful status, the old secret will be invalid, as there will be only one CLI secret for a user.
*/
func (a *Client) SetCliSecret(params *SetCliSecretParams, authInfo runtime.ClientAuthInfoWriter) (*SetCliSecretOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewSetCliSecretParams()
}
result, err := a.transport.Submit(&runtime.ClientOperation{
ID: "setCliSecret",
Method: "PUT",
PathPattern: "/users/{user_id}/cli_secret",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http", "https"},
Params: params,
Reader: &SetCliSecretReader{formats: a.formats},
AuthInfo: authInfo,
Context: params.Context,
Client: params.HTTPClient,
})
if err != nil {
return nil, err
}
success, ok := result.(*SetCliSecretOK)
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 setCliSecret: API contract not enforced by server. Client expected to get an error, but got: %T", result)
panic(msg)
}
/*
SetUserSysAdmin updates a registered user to change to be an administrator of harbor
*/
func (a *Client) SetUserSysAdmin(params *SetUserSysAdminParams, authInfo runtime.ClientAuthInfoWriter) (*SetUserSysAdminOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewSetUserSysAdminParams()
}
result, err := a.transport.Submit(&runtime.ClientOperation{
ID: "setUserSysAdmin",
Method: "PUT",
PathPattern: "/users/{user_id}/sysadmin",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http", "https"},
Params: params,
Reader: &SetUserSysAdminReader{formats: a.formats},
AuthInfo: authInfo,
Context: params.Context,
Client: params.HTTPClient,
})
if err != nil {
return nil, err
}
success, ok := result.(*SetUserSysAdminOK)
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 setUserSysAdmin: API contract not enforced by server. Client expected to get an error, but got: %T", result)
panic(msg)
}
/*
UpdateUserPassword changes the password on a user that already exists
This endpoint is for user to update password. Users with the admin role can change any user's password. Regular users can change only their own password.
*/
func (a *Client) UpdateUserPassword(params *UpdateUserPasswordParams, authInfo runtime.ClientAuthInfoWriter) (*UpdateUserPasswordOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewUpdateUserPasswordParams()
}
result, err := a.transport.Submit(&runtime.ClientOperation{
ID: "updateUserPassword",
Method: "PUT",
PathPattern: "/users/{user_id}/password",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http", "https"},
Params: params,
Reader: &UpdateUserPasswordReader{formats: a.formats},
AuthInfo: authInfo,
Context: params.Context,
Client: params.HTTPClient,
})
if err != nil {
return nil, err
}
success, ok := result.(*UpdateUserPasswordOK)
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 updateUserPassword: API contract not enforced by server. Client expected to get an error, but got: %T", result)
panic(msg)
}
/*
UpdateUserProfile updates user s profile
*/
func (a *Client) UpdateUserProfile(params *UpdateUserProfileParams, authInfo runtime.ClientAuthInfoWriter) (*UpdateUserProfileOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewUpdateUserProfileParams()
}
result, err := a.transport.Submit(&runtime.ClientOperation{
ID: "updateUserProfile",
Method: "PUT",
PathPattern: "/users/{user_id}",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http", "https"},
Params: params,
Reader: &UpdateUserProfileReader{formats: a.formats},
AuthInfo: authInfo,
Context: params.Context,
Client: params.HTTPClient,
})
if err != nil {
return nil, err
}
success, ok := result.(*UpdateUserProfileOK)
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 updateUserProfile: 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
}