Parity API (#280)
This commit is contained in:
63
restapi/admin_parity.go
Normal file
63
restapi/admin_parity.go
Normal file
@@ -0,0 +1,63 @@
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2020 MinIO, Inc.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package restapi
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"github.com/minio/console/pkg/utils"
|
||||
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
"github.com/minio/console/models"
|
||||
"github.com/minio/console/restapi/operations"
|
||||
"github.com/minio/console/restapi/operations/admin_api"
|
||||
)
|
||||
|
||||
func registerParityHandlers(api *operations.ConsoleAPI) {
|
||||
api.AdminAPIGetParityHandler = admin_api.GetParityHandlerFunc(func(params admin_api.GetParityParams, principal *models.Principal) middleware.Responder {
|
||||
resp, err := getParityResponse(params)
|
||||
if err != nil {
|
||||
return admin_api.NewGetParityDefault(int(err.Code)).WithPayload(err)
|
||||
}
|
||||
return admin_api.NewGetParityOK().WithPayload(resp)
|
||||
})
|
||||
}
|
||||
|
||||
func GetParityInfo(nodes int64, disksPerNode int64) (models.ParityResponse, error) {
|
||||
parityVals, err := utils.PossibleParityValues(fmt.Sprintf(`http://minio{1...%d}/export/set{1...%d}`, nodes, disksPerNode))
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return parityVals, nil
|
||||
}
|
||||
|
||||
func getParityResponse(params admin_api.GetParityParams) (models.ParityResponse, *models.Error) {
|
||||
nodes := params.Nodes
|
||||
disksPerNode := params.DisksPerNode
|
||||
|
||||
parityValues, err := GetParityInfo(nodes, disksPerNode)
|
||||
|
||||
if err != nil {
|
||||
log.Println("error getting parity info:", err)
|
||||
return nil, prepareError(err)
|
||||
}
|
||||
|
||||
return parityValues, nil
|
||||
}
|
||||
79
restapi/admin_parity_test.go
Normal file
79
restapi/admin_parity_test.go
Normal file
@@ -0,0 +1,79 @@
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2020 MinIO, Inc.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package restapi
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/minio/console/models"
|
||||
)
|
||||
|
||||
func Test_getParityInfo(t *testing.T) {
|
||||
tests := []struct {
|
||||
description string
|
||||
wantErr bool
|
||||
nodes int64
|
||||
disksPerNode int64
|
||||
expectedResp models.ParityResponse
|
||||
}{
|
||||
{
|
||||
description: "Incorrect Number of endpoints provided",
|
||||
wantErr: true,
|
||||
nodes: 1,
|
||||
disksPerNode: 1,
|
||||
expectedResp: nil,
|
||||
},
|
||||
{
|
||||
description: "Number of endpoints is valid",
|
||||
wantErr: false,
|
||||
nodes: 4,
|
||||
disksPerNode: 10,
|
||||
expectedResp: models.ParityResponse{"EC:4", "EC:3", "EC:2"},
|
||||
},
|
||||
{
|
||||
description: "More nodes than disks",
|
||||
wantErr: false,
|
||||
nodes: 4,
|
||||
disksPerNode: 1,
|
||||
expectedResp: models.ParityResponse{"EC:2"},
|
||||
},
|
||||
{
|
||||
description: "More disks than nodes",
|
||||
wantErr: false,
|
||||
nodes: 2,
|
||||
disksPerNode: 50,
|
||||
expectedResp: models.ParityResponse{"EC:5", "EC:4", "EC:3", "EC:2"},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.description, func(t *testing.T) {
|
||||
parity, err := GetParityInfo(tt.nodes, tt.disksPerNode)
|
||||
if (err != nil) != tt.wantErr {
|
||||
t.Errorf("GetParityInfo() error = %v, wantErr %v", err, tt.wantErr)
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(parity, tt.expectedResp) {
|
||||
ji, _ := json.Marshal(parity)
|
||||
vi, _ := json.Marshal(tt.expectedResp)
|
||||
t.Errorf("\ngot: %s \nwant: %s", ji, vi)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -114,6 +114,8 @@ func configureAPI(api *operations.ConsoleAPI) http.Handler {
|
||||
registerResourceQuotaHandlers(api)
|
||||
// Register Nodes' handlers
|
||||
registerNodesHandlers(api)
|
||||
// Register Parity' handlers
|
||||
registerParityHandlers(api)
|
||||
|
||||
api.PreServerShutdown = func() {}
|
||||
|
||||
|
||||
@@ -572,6 +572,45 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"/get-parity/{nodes}/{disksPerNode}": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"AdminAPI"
|
||||
],
|
||||
"summary": "Gets parity by sending number of nodes \u0026 number of disks",
|
||||
"operationId": "GetParity",
|
||||
"parameters": [
|
||||
{
|
||||
"minimum": 2,
|
||||
"type": "integer",
|
||||
"name": "nodes",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"minimum": 1,
|
||||
"type": "integer",
|
||||
"name": "disksPerNode",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/parityResponse"
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"description": "Generic error response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/groups": {
|
||||
"get": {
|
||||
"tags": [
|
||||
@@ -2881,6 +2920,12 @@ func init() {
|
||||
"get"
|
||||
]
|
||||
},
|
||||
"parityResponse": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"podAffinityTerm": {
|
||||
"description": "Required. A pod affinity term, associated with the corresponding weight.",
|
||||
"type": "object",
|
||||
@@ -4223,6 +4268,45 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"/get-parity/{nodes}/{disksPerNode}": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"AdminAPI"
|
||||
],
|
||||
"summary": "Gets parity by sending number of nodes \u0026 number of disks",
|
||||
"operationId": "GetParity",
|
||||
"parameters": [
|
||||
{
|
||||
"minimum": 2,
|
||||
"type": "integer",
|
||||
"name": "nodes",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"minimum": 1,
|
||||
"type": "integer",
|
||||
"name": "disksPerNode",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/parityResponse"
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"description": "Generic error response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/groups": {
|
||||
"get": {
|
||||
"tags": [
|
||||
@@ -7011,6 +7095,12 @@ func init() {
|
||||
"get"
|
||||
]
|
||||
},
|
||||
"parityResponse": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"podAffinityTerm": {
|
||||
"description": "Required. A pod affinity term, associated with the corresponding weight.",
|
||||
"type": "object",
|
||||
|
||||
90
restapi/operations/admin_api/get_parity.go
Normal file
90
restapi/operations/admin_api/get_parity.go
Normal file
@@ -0,0 +1,90 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2020 MinIO, Inc.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
package admin_api
|
||||
|
||||
// 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/minio/console/models"
|
||||
)
|
||||
|
||||
// GetParityHandlerFunc turns a function with the right signature into a get parity handler
|
||||
type GetParityHandlerFunc func(GetParityParams, *models.Principal) middleware.Responder
|
||||
|
||||
// Handle executing the request and returning a response
|
||||
func (fn GetParityHandlerFunc) Handle(params GetParityParams, principal *models.Principal) middleware.Responder {
|
||||
return fn(params, principal)
|
||||
}
|
||||
|
||||
// GetParityHandler interface for that can handle valid get parity params
|
||||
type GetParityHandler interface {
|
||||
Handle(GetParityParams, *models.Principal) middleware.Responder
|
||||
}
|
||||
|
||||
// NewGetParity creates a new http.Handler for the get parity operation
|
||||
func NewGetParity(ctx *middleware.Context, handler GetParityHandler) *GetParity {
|
||||
return &GetParity{Context: ctx, Handler: handler}
|
||||
}
|
||||
|
||||
/*GetParity swagger:route GET /get-parity/{nodes}/{disksPerNode} AdminAPI getParity
|
||||
|
||||
Gets parity by sending number of nodes & number of disks
|
||||
|
||||
*/
|
||||
type GetParity struct {
|
||||
Context *middleware.Context
|
||||
Handler GetParityHandler
|
||||
}
|
||||
|
||||
func (o *GetParity) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
route, rCtx, _ := o.Context.RouteInfo(r)
|
||||
if rCtx != nil {
|
||||
r = rCtx
|
||||
}
|
||||
var Params = NewGetParityParams()
|
||||
|
||||
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)
|
||||
|
||||
}
|
||||
154
restapi/operations/admin_api/get_parity_parameters.go
Normal file
154
restapi/operations/admin_api/get_parity_parameters.go
Normal file
@@ -0,0 +1,154 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2020 MinIO, Inc.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
package admin_api
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/swag"
|
||||
"github.com/go-openapi/validate"
|
||||
)
|
||||
|
||||
// NewGetParityParams creates a new GetParityParams object
|
||||
// no default values defined in spec.
|
||||
func NewGetParityParams() GetParityParams {
|
||||
|
||||
return GetParityParams{}
|
||||
}
|
||||
|
||||
// GetParityParams contains all the bound params for the get parity operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters GetParity
|
||||
type GetParityParams struct {
|
||||
|
||||
// HTTP Request Object
|
||||
HTTPRequest *http.Request `json:"-"`
|
||||
|
||||
/*
|
||||
Required: true
|
||||
Minimum: 1
|
||||
In: path
|
||||
*/
|
||||
DisksPerNode int64
|
||||
/*
|
||||
Required: true
|
||||
Minimum: 2
|
||||
In: path
|
||||
*/
|
||||
Nodes int64
|
||||
}
|
||||
|
||||
// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
|
||||
// for simple values it will use straight method calls.
|
||||
//
|
||||
// To ensure default values, the struct must have been initialized with NewGetParityParams() beforehand.
|
||||
func (o *GetParityParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
|
||||
var res []error
|
||||
|
||||
o.HTTPRequest = r
|
||||
|
||||
rDisksPerNode, rhkDisksPerNode, _ := route.Params.GetOK("disksPerNode")
|
||||
if err := o.bindDisksPerNode(rDisksPerNode, rhkDisksPerNode, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
rNodes, rhkNodes, _ := route.Params.GetOK("nodes")
|
||||
if err := o.bindNodes(rNodes, rhkNodes, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// bindDisksPerNode binds and validates parameter DisksPerNode from path.
|
||||
func (o *GetParityParams) bindDisksPerNode(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
// Required: true
|
||||
// Parameter is provided by construction from the route
|
||||
|
||||
value, err := swag.ConvertInt64(raw)
|
||||
if err != nil {
|
||||
return errors.InvalidType("disksPerNode", "path", "int64", raw)
|
||||
}
|
||||
o.DisksPerNode = value
|
||||
|
||||
if err := o.validateDisksPerNode(formats); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// validateDisksPerNode carries on validations for parameter DisksPerNode
|
||||
func (o *GetParityParams) validateDisksPerNode(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.MinimumInt("disksPerNode", "path", int64(o.DisksPerNode), 1, false); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// bindNodes binds and validates parameter Nodes from path.
|
||||
func (o *GetParityParams) bindNodes(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
// Required: true
|
||||
// Parameter is provided by construction from the route
|
||||
|
||||
value, err := swag.ConvertInt64(raw)
|
||||
if err != nil {
|
||||
return errors.InvalidType("nodes", "path", "int64", raw)
|
||||
}
|
||||
o.Nodes = value
|
||||
|
||||
if err := o.validateNodes(formats); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// validateNodes carries on validations for parameter Nodes
|
||||
func (o *GetParityParams) validateNodes(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.MinimumInt("nodes", "path", int64(o.Nodes), 2, false); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
136
restapi/operations/admin_api/get_parity_responses.go
Normal file
136
restapi/operations/admin_api/get_parity_responses.go
Normal file
@@ -0,0 +1,136 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2020 MinIO, Inc.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
package admin_api
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
|
||||
"github.com/minio/console/models"
|
||||
)
|
||||
|
||||
// GetParityOKCode is the HTTP code returned for type GetParityOK
|
||||
const GetParityOKCode int = 200
|
||||
|
||||
/*GetParityOK A successful response.
|
||||
|
||||
swagger:response getParityOK
|
||||
*/
|
||||
type GetParityOK struct {
|
||||
|
||||
/*
|
||||
In: Body
|
||||
*/
|
||||
Payload models.ParityResponse `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewGetParityOK creates GetParityOK with default headers values
|
||||
func NewGetParityOK() *GetParityOK {
|
||||
|
||||
return &GetParityOK{}
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the get parity o k response
|
||||
func (o *GetParityOK) WithPayload(payload models.ParityResponse) *GetParityOK {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the get parity o k response
|
||||
func (o *GetParityOK) SetPayload(payload models.ParityResponse) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *GetParityOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(200)
|
||||
payload := o.Payload
|
||||
if payload == nil {
|
||||
// return empty array
|
||||
payload = models.ParityResponse{}
|
||||
}
|
||||
|
||||
if err := producer.Produce(rw, payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
}
|
||||
|
||||
/*GetParityDefault Generic error response.
|
||||
|
||||
swagger:response getParityDefault
|
||||
*/
|
||||
type GetParityDefault struct {
|
||||
_statusCode int
|
||||
|
||||
/*
|
||||
In: Body
|
||||
*/
|
||||
Payload *models.Error `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewGetParityDefault creates GetParityDefault with default headers values
|
||||
func NewGetParityDefault(code int) *GetParityDefault {
|
||||
if code <= 0 {
|
||||
code = 500
|
||||
}
|
||||
|
||||
return &GetParityDefault{
|
||||
_statusCode: code,
|
||||
}
|
||||
}
|
||||
|
||||
// WithStatusCode adds the status to the get parity default response
|
||||
func (o *GetParityDefault) WithStatusCode(code int) *GetParityDefault {
|
||||
o._statusCode = code
|
||||
return o
|
||||
}
|
||||
|
||||
// SetStatusCode sets the status to the get parity default response
|
||||
func (o *GetParityDefault) SetStatusCode(code int) {
|
||||
o._statusCode = code
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the get parity default response
|
||||
func (o *GetParityDefault) WithPayload(payload *models.Error) *GetParityDefault {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the get parity default response
|
||||
func (o *GetParityDefault) SetPayload(payload *models.Error) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *GetParityDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(o._statusCode)
|
||||
if o.Payload != nil {
|
||||
payload := o.Payload
|
||||
if err := producer.Produce(rw, payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
}
|
||||
}
|
||||
126
restapi/operations/admin_api/get_parity_urlbuilder.go
Normal file
126
restapi/operations/admin_api/get_parity_urlbuilder.go
Normal file
@@ -0,0 +1,126 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2020 MinIO, Inc.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
package admin_api
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the generate command
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/url"
|
||||
golangswaggerpaths "path"
|
||||
"strings"
|
||||
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
|
||||
// GetParityURL generates an URL for the get parity operation
|
||||
type GetParityURL struct {
|
||||
DisksPerNode int64
|
||||
Nodes int64
|
||||
|
||||
_basePath string
|
||||
// avoid unkeyed usage
|
||||
_ struct{}
|
||||
}
|
||||
|
||||
// WithBasePath sets the base path for this url builder, only required when it's different from the
|
||||
// base path specified in the swagger spec.
|
||||
// When the value of the base path is an empty string
|
||||
func (o *GetParityURL) WithBasePath(bp string) *GetParityURL {
|
||||
o.SetBasePath(bp)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetBasePath sets the base path for this url builder, only required when it's different from the
|
||||
// base path specified in the swagger spec.
|
||||
// When the value of the base path is an empty string
|
||||
func (o *GetParityURL) SetBasePath(bp string) {
|
||||
o._basePath = bp
|
||||
}
|
||||
|
||||
// Build a url path and query string
|
||||
func (o *GetParityURL) Build() (*url.URL, error) {
|
||||
var _result url.URL
|
||||
|
||||
var _path = "/get-parity/{nodes}/{disksPerNode}"
|
||||
|
||||
disksPerNode := swag.FormatInt64(o.DisksPerNode)
|
||||
if disksPerNode != "" {
|
||||
_path = strings.Replace(_path, "{disksPerNode}", disksPerNode, -1)
|
||||
} else {
|
||||
return nil, errors.New("disksPerNode is required on GetParityURL")
|
||||
}
|
||||
|
||||
nodes := swag.FormatInt64(o.Nodes)
|
||||
if nodes != "" {
|
||||
_path = strings.Replace(_path, "{nodes}", nodes, -1)
|
||||
} else {
|
||||
return nil, errors.New("nodes is required on GetParityURL")
|
||||
}
|
||||
|
||||
_basePath := o._basePath
|
||||
if _basePath == "" {
|
||||
_basePath = "/api/v1"
|
||||
}
|
||||
_result.Path = golangswaggerpaths.Join(_basePath, _path)
|
||||
|
||||
return &_result, nil
|
||||
}
|
||||
|
||||
// Must is a helper function to panic when the url builder returns an error
|
||||
func (o *GetParityURL) Must(u *url.URL, err error) *url.URL {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if u == nil {
|
||||
panic("url can't be nil")
|
||||
}
|
||||
return u
|
||||
}
|
||||
|
||||
// String returns the string representation of the path with query string
|
||||
func (o *GetParityURL) String() string {
|
||||
return o.Must(o.Build()).String()
|
||||
}
|
||||
|
||||
// BuildFull builds a full url with scheme, host, path and query string
|
||||
func (o *GetParityURL) BuildFull(scheme, host string) (*url.URL, error) {
|
||||
if scheme == "" {
|
||||
return nil, errors.New("scheme is required for a full url on GetParityURL")
|
||||
}
|
||||
if host == "" {
|
||||
return nil, errors.New("host is required for a full url on GetParityURL")
|
||||
}
|
||||
|
||||
base, err := o.Build()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
base.Scheme = scheme
|
||||
base.Host = host
|
||||
return base, nil
|
||||
}
|
||||
|
||||
// StringFull returns the string representation of a complete url
|
||||
func (o *GetParityURL) StringFull(scheme, host string) string {
|
||||
return o.Must(o.BuildFull(scheme, host)).String()
|
||||
}
|
||||
@@ -117,6 +117,9 @@ func NewConsoleAPI(spec *loads.Document) *ConsoleAPI {
|
||||
AdminAPIGetMaxAllocatableMemHandler: admin_api.GetMaxAllocatableMemHandlerFunc(func(params admin_api.GetMaxAllocatableMemParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation admin_api.GetMaxAllocatableMem has not yet been implemented")
|
||||
}),
|
||||
AdminAPIGetParityHandler: admin_api.GetParityHandlerFunc(func(params admin_api.GetParityParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation admin_api.GetParity has not yet been implemented")
|
||||
}),
|
||||
AdminAPIGetResourceQuotaHandler: admin_api.GetResourceQuotaHandlerFunc(func(params admin_api.GetResourceQuotaParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation admin_api.GetResourceQuota has not yet been implemented")
|
||||
}),
|
||||
@@ -319,6 +322,8 @@ type ConsoleAPI struct {
|
||||
AdminAPIDeleteTenantHandler admin_api.DeleteTenantHandler
|
||||
// AdminAPIGetMaxAllocatableMemHandler sets the operation handler for the get max allocatable mem operation
|
||||
AdminAPIGetMaxAllocatableMemHandler admin_api.GetMaxAllocatableMemHandler
|
||||
// AdminAPIGetParityHandler sets the operation handler for the get parity operation
|
||||
AdminAPIGetParityHandler admin_api.GetParityHandler
|
||||
// AdminAPIGetResourceQuotaHandler sets the operation handler for the get resource quota operation
|
||||
AdminAPIGetResourceQuotaHandler admin_api.GetResourceQuotaHandler
|
||||
// AdminAPIGetTenantUsageHandler sets the operation handler for the get tenant usage operation
|
||||
@@ -524,6 +529,9 @@ func (o *ConsoleAPI) Validate() error {
|
||||
if o.AdminAPIGetMaxAllocatableMemHandler == nil {
|
||||
unregistered = append(unregistered, "admin_api.GetMaxAllocatableMemHandler")
|
||||
}
|
||||
if o.AdminAPIGetParityHandler == nil {
|
||||
unregistered = append(unregistered, "admin_api.GetParityHandler")
|
||||
}
|
||||
if o.AdminAPIGetResourceQuotaHandler == nil {
|
||||
unregistered = append(unregistered, "admin_api.GetResourceQuotaHandler")
|
||||
}
|
||||
@@ -816,6 +824,10 @@ func (o *ConsoleAPI) initHandlerCache() {
|
||||
if o.handlers["GET"] == nil {
|
||||
o.handlers["GET"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["GET"]["/get-parity/{nodes}/{disksPerNode}"] = admin_api.NewGetParity(o.context, o.AdminAPIGetParityHandler)
|
||||
if o.handlers["GET"] == nil {
|
||||
o.handlers["GET"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["GET"]["/namespaces/{namespace}/resourcequotas/{resource-quota-name}"] = admin_api.NewGetResourceQuota(o.context, o.AdminAPIGetResourceQuotaHandler)
|
||||
if o.handlers["GET"] == nil {
|
||||
o.handlers["GET"] = make(map[string]http.Handler)
|
||||
|
||||
Reference in New Issue
Block a user