github.com/minio/console@v1.4.1/api/operations/service_account/create_service_account.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 service_account 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 // CreateServiceAccountHandlerFunc turns a function with the right signature into a create service account handler 34 type CreateServiceAccountHandlerFunc func(CreateServiceAccountParams, *models.Principal) middleware.Responder 35 36 // Handle executing the request and returning a response 37 func (fn CreateServiceAccountHandlerFunc) Handle(params CreateServiceAccountParams, principal *models.Principal) middleware.Responder { 38 return fn(params, principal) 39 } 40 41 // CreateServiceAccountHandler interface for that can handle valid create service account params 42 type CreateServiceAccountHandler interface { 43 Handle(CreateServiceAccountParams, *models.Principal) middleware.Responder 44 } 45 46 // NewCreateServiceAccount creates a new http.Handler for the create service account operation 47 func NewCreateServiceAccount(ctx *middleware.Context, handler CreateServiceAccountHandler) *CreateServiceAccount { 48 return &CreateServiceAccount{Context: ctx, Handler: handler} 49 } 50 51 /* 52 CreateServiceAccount swagger:route POST /service-accounts ServiceAccount createServiceAccount 53 54 Create Service Account 55 */ 56 type CreateServiceAccount struct { 57 Context *middleware.Context 58 Handler CreateServiceAccountHandler 59 } 60 61 func (o *CreateServiceAccount) 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 = NewCreateServiceAccountParams() 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 }