frostfs-rest-gw/gen/restapi/operations/delete_storage_group.go
Denis Kirillov e83cef6d24 [#36] Add route to get and delete storage group
Signed-off-by: Denis Kirillov <denis@nspcc.ru>
2023-01-12 15:47:53 +03:00

71 lines
2.2 KiB
Go

// Code generated by go-swagger; DO NOT EDIT.
package operations
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the generate command
import (
"net/http"
"github.com/go-openapi/runtime/middleware"
"github.com/nspcc-dev/neofs-rest-gw/gen/models"
)
// DeleteStorageGroupHandlerFunc turns a function with the right signature into a delete storage group handler
type DeleteStorageGroupHandlerFunc func(DeleteStorageGroupParams, *models.Principal) middleware.Responder
// Handle executing the request and returning a response
func (fn DeleteStorageGroupHandlerFunc) Handle(params DeleteStorageGroupParams, principal *models.Principal) middleware.Responder {
return fn(params, principal)
}
// DeleteStorageGroupHandler interface for that can handle valid delete storage group params
type DeleteStorageGroupHandler interface {
Handle(DeleteStorageGroupParams, *models.Principal) middleware.Responder
}
// NewDeleteStorageGroup creates a new http.Handler for the delete storage group operation
func NewDeleteStorageGroup(ctx *middleware.Context, handler DeleteStorageGroupHandler) *DeleteStorageGroup {
return &DeleteStorageGroup{Context: ctx, Handler: handler}
}
/* DeleteStorageGroup swagger:route DELETE /containers/{containerId}/storagegroups/{storageGroupId} deleteStorageGroup
Delete storage group from container.
*/
type DeleteStorageGroup struct {
Context *middleware.Context
Handler DeleteStorageGroupHandler
}
func (o *DeleteStorageGroup) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
route, rCtx, _ := o.Context.RouteInfo(r)
if rCtx != nil {
*r = *rCtx
}
var Params = NewDeleteStorageGroupParams()
uprinc, aCtx, err := o.Context.Authorize(r, route)
if err != nil {
o.Context.Respond(rw, r, route.Produces, route, err)
return
}
if aCtx != nil {
*r = *aCtx
}
var principal *models.Principal
if uprinc != nil {
principal = uprinc.(*models.Principal) // this is really a models.Principal, I promise
}
if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
o.Context.Respond(rw, r, route.Produces, route, err)
return
}
res := o.Handler.Handle(Params, principal) // actually handle the request
o.Context.Respond(rw, r, route.Produces, route, res)
}