github.com/minio/console@v1.4.1/api/operations/user/update_user_groups.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 // This file is part of MinIO Console Server 4 // Copyright (c) 2023 MinIO, Inc. 5 // 6 // This program is free software: you can redistribute it and/or modify 7 // it under the terms of the GNU Affero General Public License as published by 8 // the Free Software Foundation, either version 3 of the License, or 9 // (at your option) any later version. 10 // 11 // This program is distributed in the hope that it will be useful, 12 // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 // GNU Affero General Public License for more details. 15 // 16 // You should have received a copy of the GNU Affero General Public License 17 // along with this program. If not, see <http://www.gnu.org/licenses/>. 18 // 19 20 package user 21 22 // This file was generated by the swagger tool. 23 // Editing this file might prove futile when you re-run the generate command 24 25 import ( 26 "net/http" 27 28 "github.com/go-openapi/runtime/middleware" 29 30 "github.com/minio/console/models" 31 ) 32 33 // UpdateUserGroupsHandlerFunc turns a function with the right signature into a update user groups handler 34 type UpdateUserGroupsHandlerFunc func(UpdateUserGroupsParams, *models.Principal) middleware.Responder 35 36 // Handle executing the request and returning a response 37 func (fn UpdateUserGroupsHandlerFunc) Handle(params UpdateUserGroupsParams, principal *models.Principal) middleware.Responder { 38 return fn(params, principal) 39 } 40 41 // UpdateUserGroupsHandler interface for that can handle valid update user groups params 42 type UpdateUserGroupsHandler interface { 43 Handle(UpdateUserGroupsParams, *models.Principal) middleware.Responder 44 } 45 46 // NewUpdateUserGroups creates a new http.Handler for the update user groups operation 47 func NewUpdateUserGroups(ctx *middleware.Context, handler UpdateUserGroupsHandler) *UpdateUserGroups { 48 return &UpdateUserGroups{Context: ctx, Handler: handler} 49 } 50 51 /* 52 UpdateUserGroups swagger:route PUT /user/{name}/groups User updateUserGroups 53 54 Update Groups for a user 55 */ 56 type UpdateUserGroups struct { 57 Context *middleware.Context 58 Handler UpdateUserGroupsHandler 59 } 60 61 func (o *UpdateUserGroups) ServeHTTP(rw http.ResponseWriter, r *http.Request) { 62 route, rCtx, _ := o.Context.RouteInfo(r) 63 if rCtx != nil { 64 *r = *rCtx 65 } 66 var Params = NewUpdateUserGroupsParams() 67 uprinc, aCtx, err := o.Context.Authorize(r, route) 68 if err != nil { 69 o.Context.Respond(rw, r, route.Produces, route, err) 70 return 71 } 72 if aCtx != nil { 73 *r = *aCtx 74 } 75 var principal *models.Principal 76 if uprinc != nil { 77 principal = uprinc.(*models.Principal) // this is really a models.Principal, I promise 78 } 79 80 if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params 81 o.Context.Respond(rw, r, route.Produces, route, err) 82 return 83 } 84 85 res := o.Handler.Handle(Params, principal) // actually handle the request 86 o.Context.Respond(rw, r, route.Produces, route, res) 87 88 }