[#36] Add route to list storage groups
Signed-off-by: Denis Kirillov <denis@nspcc.ru>
This commit is contained in:
parent
e5b9fd5f5a
commit
c20eed98f9
10 changed files with 913 additions and 0 deletions
71
gen/restapi/operations/list_storage_groups.go
Normal file
71
gen/restapi/operations/list_storage_groups.go
Normal file
|
@ -0,0 +1,71 @@
|
|||
// 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"
|
||||
)
|
||||
|
||||
// ListStorageGroupsHandlerFunc turns a function with the right signature into a list storage groups handler
|
||||
type ListStorageGroupsHandlerFunc func(ListStorageGroupsParams, *models.Principal) middleware.Responder
|
||||
|
||||
// Handle executing the request and returning a response
|
||||
func (fn ListStorageGroupsHandlerFunc) Handle(params ListStorageGroupsParams, principal *models.Principal) middleware.Responder {
|
||||
return fn(params, principal)
|
||||
}
|
||||
|
||||
// ListStorageGroupsHandler interface for that can handle valid list storage groups params
|
||||
type ListStorageGroupsHandler interface {
|
||||
Handle(ListStorageGroupsParams, *models.Principal) middleware.Responder
|
||||
}
|
||||
|
||||
// NewListStorageGroups creates a new http.Handler for the list storage groups operation
|
||||
func NewListStorageGroups(ctx *middleware.Context, handler ListStorageGroupsHandler) *ListStorageGroups {
|
||||
return &ListStorageGroups{Context: ctx, Handler: handler}
|
||||
}
|
||||
|
||||
/* ListStorageGroups swagger:route GET /containers/{containerId}/storagegroups listStorageGroups
|
||||
|
||||
Find all storage groups in container.
|
||||
|
||||
*/
|
||||
type ListStorageGroups struct {
|
||||
Context *middleware.Context
|
||||
Handler ListStorageGroupsHandler
|
||||
}
|
||||
|
||||
func (o *ListStorageGroups) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
route, rCtx, _ := o.Context.RouteInfo(r)
|
||||
if rCtx != nil {
|
||||
*r = *rCtx
|
||||
}
|
||||
var Params = NewListStorageGroupsParams()
|
||||
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)
|
||||
|
||||
}
|
Reference in a new issue