github.com/goharbor/go-client@v0.210.0/pkg/sdk/v2.0/client/user/user_client.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package user 4 5 // This file was generated by the swagger tool. 6 // Editing this file might prove futile when you re-run the swagger generate command 7 8 import ( 9 "context" 10 11 "github.com/go-openapi/runtime" 12 13 strfmt "github.com/go-openapi/strfmt" 14 ) 15 16 //go:generate mockery -name API -inpkg 17 18 // API is the interface of the user client 19 type API interface { 20 /* 21 CreateUser creates a local user 22 23 This API can be used only when the authentication mode is for local DB. When self registration is disabled.*/ 24 CreateUser(ctx context.Context, params *CreateUserParams) (*CreateUserCreated, error) 25 /* 26 DeleteUser marks a registered user as be removed 27 28 This endpoint let administrator of Harbor mark a registered user as removed.It actually won't be deleted from DB. 29 */ 30 DeleteUser(ctx context.Context, params *DeleteUserParams) (*DeleteUserOK, error) 31 /* 32 GetCurrentUserInfo gets current user info*/ 33 GetCurrentUserInfo(ctx context.Context, params *GetCurrentUserInfoParams) (*GetCurrentUserInfoOK, error) 34 /* 35 GetCurrentUserPermissions gets current user permissions*/ 36 GetCurrentUserPermissions(ctx context.Context, params *GetCurrentUserPermissionsParams) (*GetCurrentUserPermissionsOK, error) 37 /* 38 GetUser gets a user s profile*/ 39 GetUser(ctx context.Context, params *GetUserParams) (*GetUserOK, error) 40 /* 41 ListUsers lists users*/ 42 ListUsers(ctx context.Context, params *ListUsersParams) (*ListUsersOK, error) 43 /* 44 SearchUsers searches users by username 45 46 This endpoint is to search the users by username. It's open for all authenticated requests. 47 */ 48 SearchUsers(ctx context.Context, params *SearchUsersParams) (*SearchUsersOK, error) 49 /* 50 SetCliSecret sets c l i secret for a user 51 52 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.*/ 53 SetCliSecret(ctx context.Context, params *SetCliSecretParams) (*SetCliSecretOK, error) 54 /* 55 SetUserSysAdmin updates a registered user to change to be an administrator of harbor*/ 56 SetUserSysAdmin(ctx context.Context, params *SetUserSysAdminParams) (*SetUserSysAdminOK, error) 57 /* 58 UpdateUserPassword changes the password on a user that already exists 59 60 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. 61 */ 62 UpdateUserPassword(ctx context.Context, params *UpdateUserPasswordParams) (*UpdateUserPasswordOK, error) 63 /* 64 UpdateUserProfile updates user s profile*/ 65 UpdateUserProfile(ctx context.Context, params *UpdateUserProfileParams) (*UpdateUserProfileOK, error) 66 } 67 68 // New creates a new user API client. 69 func New(transport runtime.ClientTransport, formats strfmt.Registry, authInfo runtime.ClientAuthInfoWriter) *Client { 70 return &Client{ 71 transport: transport, 72 formats: formats, 73 authInfo: authInfo, 74 } 75 } 76 77 /* 78 Client for user API 79 */ 80 type Client struct { 81 transport runtime.ClientTransport 82 formats strfmt.Registry 83 authInfo runtime.ClientAuthInfoWriter 84 } 85 86 /* 87 CreateUser creates a local user 88 89 This API can be used only when the authentication mode is for local DB. When self registration is disabled. 90 */ 91 func (a *Client) CreateUser(ctx context.Context, params *CreateUserParams) (*CreateUserCreated, error) { 92 93 result, err := a.transport.Submit(&runtime.ClientOperation{ 94 ID: "createUser", 95 Method: "POST", 96 PathPattern: "/users", 97 ProducesMediaTypes: []string{"application/json"}, 98 ConsumesMediaTypes: []string{"application/json"}, 99 Schemes: []string{"http", "https"}, 100 Params: params, 101 Reader: &CreateUserReader{formats: a.formats}, 102 AuthInfo: a.authInfo, 103 Context: ctx, 104 Client: params.HTTPClient, 105 }) 106 if err != nil { 107 return nil, err 108 } 109 return result.(*CreateUserCreated), nil 110 111 } 112 113 /* 114 DeleteUser marks a registered user as be removed 115 116 This endpoint let administrator of Harbor mark a registered user as removed.It actually won't be deleted from DB. 117 */ 118 func (a *Client) DeleteUser(ctx context.Context, params *DeleteUserParams) (*DeleteUserOK, error) { 119 120 result, err := a.transport.Submit(&runtime.ClientOperation{ 121 ID: "deleteUser", 122 Method: "DELETE", 123 PathPattern: "/users/{user_id}", 124 ProducesMediaTypes: []string{"application/json"}, 125 ConsumesMediaTypes: []string{"application/json"}, 126 Schemes: []string{"http", "https"}, 127 Params: params, 128 Reader: &DeleteUserReader{formats: a.formats}, 129 AuthInfo: a.authInfo, 130 Context: ctx, 131 Client: params.HTTPClient, 132 }) 133 if err != nil { 134 return nil, err 135 } 136 return result.(*DeleteUserOK), nil 137 138 } 139 140 /* 141 GetCurrentUserInfo gets current user info 142 */ 143 func (a *Client) GetCurrentUserInfo(ctx context.Context, params *GetCurrentUserInfoParams) (*GetCurrentUserInfoOK, error) { 144 145 result, err := a.transport.Submit(&runtime.ClientOperation{ 146 ID: "getCurrentUserInfo", 147 Method: "GET", 148 PathPattern: "/users/current", 149 ProducesMediaTypes: []string{"application/json"}, 150 ConsumesMediaTypes: []string{"application/json"}, 151 Schemes: []string{"http", "https"}, 152 Params: params, 153 Reader: &GetCurrentUserInfoReader{formats: a.formats}, 154 AuthInfo: a.authInfo, 155 Context: ctx, 156 Client: params.HTTPClient, 157 }) 158 if err != nil { 159 return nil, err 160 } 161 return result.(*GetCurrentUserInfoOK), nil 162 163 } 164 165 /* 166 GetCurrentUserPermissions gets current user permissions 167 */ 168 func (a *Client) GetCurrentUserPermissions(ctx context.Context, params *GetCurrentUserPermissionsParams) (*GetCurrentUserPermissionsOK, error) { 169 170 result, err := a.transport.Submit(&runtime.ClientOperation{ 171 ID: "getCurrentUserPermissions", 172 Method: "GET", 173 PathPattern: "/users/current/permissions", 174 ProducesMediaTypes: []string{"application/json"}, 175 ConsumesMediaTypes: []string{"application/json"}, 176 Schemes: []string{"http", "https"}, 177 Params: params, 178 Reader: &GetCurrentUserPermissionsReader{formats: a.formats}, 179 AuthInfo: a.authInfo, 180 Context: ctx, 181 Client: params.HTTPClient, 182 }) 183 if err != nil { 184 return nil, err 185 } 186 return result.(*GetCurrentUserPermissionsOK), nil 187 188 } 189 190 /* 191 GetUser gets a user s profile 192 */ 193 func (a *Client) GetUser(ctx context.Context, params *GetUserParams) (*GetUserOK, error) { 194 195 result, err := a.transport.Submit(&runtime.ClientOperation{ 196 ID: "getUser", 197 Method: "GET", 198 PathPattern: "/users/{user_id}", 199 ProducesMediaTypes: []string{"application/json"}, 200 ConsumesMediaTypes: []string{"application/json"}, 201 Schemes: []string{"http", "https"}, 202 Params: params, 203 Reader: &GetUserReader{formats: a.formats}, 204 AuthInfo: a.authInfo, 205 Context: ctx, 206 Client: params.HTTPClient, 207 }) 208 if err != nil { 209 return nil, err 210 } 211 return result.(*GetUserOK), nil 212 213 } 214 215 /* 216 ListUsers lists users 217 */ 218 func (a *Client) ListUsers(ctx context.Context, params *ListUsersParams) (*ListUsersOK, error) { 219 220 result, err := a.transport.Submit(&runtime.ClientOperation{ 221 ID: "listUsers", 222 Method: "GET", 223 PathPattern: "/users", 224 ProducesMediaTypes: []string{"application/json"}, 225 ConsumesMediaTypes: []string{"application/json"}, 226 Schemes: []string{"http", "https"}, 227 Params: params, 228 Reader: &ListUsersReader{formats: a.formats}, 229 AuthInfo: a.authInfo, 230 Context: ctx, 231 Client: params.HTTPClient, 232 }) 233 if err != nil { 234 return nil, err 235 } 236 return result.(*ListUsersOK), nil 237 238 } 239 240 /* 241 SearchUsers searches users by username 242 243 This endpoint is to search the users by username. It's open for all authenticated requests. 244 */ 245 func (a *Client) SearchUsers(ctx context.Context, params *SearchUsersParams) (*SearchUsersOK, error) { 246 247 result, err := a.transport.Submit(&runtime.ClientOperation{ 248 ID: "searchUsers", 249 Method: "GET", 250 PathPattern: "/users/search", 251 ProducesMediaTypes: []string{"application/json"}, 252 ConsumesMediaTypes: []string{"application/json"}, 253 Schemes: []string{"http", "https"}, 254 Params: params, 255 Reader: &SearchUsersReader{formats: a.formats}, 256 AuthInfo: a.authInfo, 257 Context: ctx, 258 Client: params.HTTPClient, 259 }) 260 if err != nil { 261 return nil, err 262 } 263 return result.(*SearchUsersOK), nil 264 265 } 266 267 /* 268 SetCliSecret sets c l i secret for a user 269 270 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. 271 */ 272 func (a *Client) SetCliSecret(ctx context.Context, params *SetCliSecretParams) (*SetCliSecretOK, error) { 273 274 result, err := a.transport.Submit(&runtime.ClientOperation{ 275 ID: "setCliSecret", 276 Method: "PUT", 277 PathPattern: "/users/{user_id}/cli_secret", 278 ProducesMediaTypes: []string{"application/json"}, 279 ConsumesMediaTypes: []string{"application/json"}, 280 Schemes: []string{"http", "https"}, 281 Params: params, 282 Reader: &SetCliSecretReader{formats: a.formats}, 283 AuthInfo: a.authInfo, 284 Context: ctx, 285 Client: params.HTTPClient, 286 }) 287 if err != nil { 288 return nil, err 289 } 290 return result.(*SetCliSecretOK), nil 291 292 } 293 294 /* 295 SetUserSysAdmin updates a registered user to change to be an administrator of harbor 296 */ 297 func (a *Client) SetUserSysAdmin(ctx context.Context, params *SetUserSysAdminParams) (*SetUserSysAdminOK, error) { 298 299 result, err := a.transport.Submit(&runtime.ClientOperation{ 300 ID: "setUserSysAdmin", 301 Method: "PUT", 302 PathPattern: "/users/{user_id}/sysadmin", 303 ProducesMediaTypes: []string{"application/json"}, 304 ConsumesMediaTypes: []string{"application/json"}, 305 Schemes: []string{"http", "https"}, 306 Params: params, 307 Reader: &SetUserSysAdminReader{formats: a.formats}, 308 AuthInfo: a.authInfo, 309 Context: ctx, 310 Client: params.HTTPClient, 311 }) 312 if err != nil { 313 return nil, err 314 } 315 return result.(*SetUserSysAdminOK), nil 316 317 } 318 319 /* 320 UpdateUserPassword changes the password on a user that already exists 321 322 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. 323 */ 324 func (a *Client) UpdateUserPassword(ctx context.Context, params *UpdateUserPasswordParams) (*UpdateUserPasswordOK, error) { 325 326 result, err := a.transport.Submit(&runtime.ClientOperation{ 327 ID: "updateUserPassword", 328 Method: "PUT", 329 PathPattern: "/users/{user_id}/password", 330 ProducesMediaTypes: []string{"application/json"}, 331 ConsumesMediaTypes: []string{"application/json"}, 332 Schemes: []string{"http", "https"}, 333 Params: params, 334 Reader: &UpdateUserPasswordReader{formats: a.formats}, 335 AuthInfo: a.authInfo, 336 Context: ctx, 337 Client: params.HTTPClient, 338 }) 339 if err != nil { 340 return nil, err 341 } 342 return result.(*UpdateUserPasswordOK), nil 343 344 } 345 346 /* 347 UpdateUserProfile updates user s profile 348 */ 349 func (a *Client) UpdateUserProfile(ctx context.Context, params *UpdateUserProfileParams) (*UpdateUserProfileOK, error) { 350 351 result, err := a.transport.Submit(&runtime.ClientOperation{ 352 ID: "updateUserProfile", 353 Method: "PUT", 354 PathPattern: "/users/{user_id}", 355 ProducesMediaTypes: []string{"application/json"}, 356 ConsumesMediaTypes: []string{"application/json"}, 357 Schemes: []string{"http", "https"}, 358 Params: params, 359 Reader: &UpdateUserProfileReader{formats: a.formats}, 360 AuthInfo: a.authInfo, 361 Context: ctx, 362 Client: params.HTTPClient, 363 }) 364 if err != nil { 365 return nil, err 366 } 367 return result.(*UpdateUserProfileOK), nil 368 369 }