Added reset configuration option to settings pages (#1292)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net> Co-authored-by: Benjamin Perez <benjamin@bexsoft.net>
This commit is contained in:
@@ -38,6 +38,7 @@ import {
|
||||
IElementValue,
|
||||
} from "../../Configurations/types";
|
||||
import { ErrorResponseHandler } from "../../../../common/types";
|
||||
import ResetConfigurationModal from "./ResetConfigurationModal";
|
||||
|
||||
const styles = (theme: Theme) =>
|
||||
createStyles({
|
||||
@@ -84,6 +85,8 @@ const EditConfiguration = ({
|
||||
const [saving, setSaving] = useState<boolean>(false);
|
||||
const [loadingConfig, setLoadingConfig] = useState<boolean>(true);
|
||||
const [configValues, setConfigValues] = useState<IElementValue[]>([]);
|
||||
const [resetConfigurationOpen, setResetConfigurationOpen] =
|
||||
useState<boolean>(false);
|
||||
//Effects
|
||||
useEffect(() => {
|
||||
const configId = get(selectedConfiguration, "configuration_id", false);
|
||||
@@ -147,8 +150,21 @@ const EditConfiguration = ({
|
||||
[setValueObj]
|
||||
);
|
||||
|
||||
const continueReset = (restart: boolean) => {
|
||||
setResetConfigurationOpen(false);
|
||||
serverNeedsRestart(restart);
|
||||
};
|
||||
|
||||
return (
|
||||
<Fragment>
|
||||
{resetConfigurationOpen && (
|
||||
<ResetConfigurationModal
|
||||
configurationName={selectedConfiguration.configuration_id}
|
||||
closeResetModalAndRefresh={continueReset}
|
||||
resetOpen={resetConfigurationOpen}
|
||||
/>
|
||||
)}
|
||||
|
||||
<form noValidate onSubmit={submitForm} className={className}>
|
||||
<Grid item xs={12} className={classes.settingsFormContainer}>
|
||||
{loadingConfig && (
|
||||
@@ -165,6 +181,17 @@ const EditConfiguration = ({
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item xs={12} className={classes.settingsButtonContainer}>
|
||||
<Button
|
||||
type="button"
|
||||
variant="outlined"
|
||||
color="secondary"
|
||||
onClick={() => {
|
||||
setResetConfigurationOpen(true);
|
||||
}}
|
||||
>
|
||||
Restore Defaults
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
type="submit"
|
||||
variant="contained"
|
||||
|
||||
@@ -0,0 +1,163 @@
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2021 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/>.
|
||||
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { connect } from "react-redux";
|
||||
import {
|
||||
Button,
|
||||
Dialog,
|
||||
DialogActions,
|
||||
DialogContent,
|
||||
DialogContentText,
|
||||
DialogTitle,
|
||||
LinearProgress,
|
||||
} from "@mui/material";
|
||||
import { Theme } from "@mui/material/styles";
|
||||
import createStyles from "@mui/styles/createStyles";
|
||||
import withStyles from "@mui/styles/withStyles";
|
||||
import IconButton from "@mui/material/IconButton";
|
||||
import CloseIcon from "@mui/icons-material/Close";
|
||||
import {
|
||||
deleteDialogStyles,
|
||||
modalBasic,
|
||||
} from "../../Common/FormComponents/common/styleLibrary";
|
||||
import { setErrorSnackMessage } from "../../../../actions";
|
||||
import { ErrorResponseHandler } from "../../../../common/types";
|
||||
import api from "../../../../common/api";
|
||||
|
||||
const styles = (theme: Theme) =>
|
||||
createStyles({
|
||||
wrapText: {
|
||||
maxWidth: "200px",
|
||||
whiteSpace: "normal",
|
||||
wordWrap: "break-word",
|
||||
},
|
||||
...modalBasic,
|
||||
...deleteDialogStyles,
|
||||
});
|
||||
|
||||
interface IResetConfiguration {
|
||||
classes: any;
|
||||
configurationName: string;
|
||||
closeResetModalAndRefresh: (reloadConfiguration: boolean) => void;
|
||||
setErrorSnackMessage: typeof setErrorSnackMessage;
|
||||
resetOpen: boolean;
|
||||
}
|
||||
|
||||
const ResetConfigurationModal = ({
|
||||
classes,
|
||||
configurationName,
|
||||
closeResetModalAndRefresh,
|
||||
setErrorSnackMessage,
|
||||
resetOpen,
|
||||
}: IResetConfiguration) => {
|
||||
const [resetLoading, setResetLoading] = useState<boolean>(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (resetLoading) {
|
||||
api
|
||||
.invoke("GET", `/api/v1/configs/${configurationName}/reset`)
|
||||
.then((res) => {
|
||||
setResetLoading(false);
|
||||
closeResetModalAndRefresh(true);
|
||||
})
|
||||
.catch((err: ErrorResponseHandler) => {
|
||||
setResetLoading(false);
|
||||
setErrorSnackMessage(err);
|
||||
});
|
||||
}
|
||||
}, [
|
||||
closeResetModalAndRefresh,
|
||||
configurationName,
|
||||
resetLoading,
|
||||
setErrorSnackMessage,
|
||||
]);
|
||||
|
||||
const resetConfiguration = () => {
|
||||
setResetLoading(true);
|
||||
};
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
open={resetOpen}
|
||||
classes={classes}
|
||||
onClose={() => {
|
||||
closeResetModalAndRefresh(false);
|
||||
}}
|
||||
aria-labelledby="alert-dialog-title"
|
||||
aria-describedby="alert-dialog-description"
|
||||
>
|
||||
<DialogTitle id="alert-dialog-title" className={classes.title}>
|
||||
<div className={classes.titleText}>Restore Defaults</div>
|
||||
<div className={classes.closeContainer}>
|
||||
<IconButton
|
||||
aria-label="close"
|
||||
className={classes.closeButton}
|
||||
onClick={() => {
|
||||
closeResetModalAndRefresh(false);
|
||||
}}
|
||||
disableRipple
|
||||
size="small"
|
||||
>
|
||||
<CloseIcon />
|
||||
</IconButton>
|
||||
</div>
|
||||
</DialogTitle>
|
||||
|
||||
<DialogContent>
|
||||
{resetLoading && <LinearProgress />}
|
||||
<DialogContentText id="alert-dialog-description">
|
||||
Are you sure you want to restore these configurations to default
|
||||
values?
|
||||
<br />
|
||||
<b className={classes.wrapText}>
|
||||
Please note that this may cause your system to not be accessible
|
||||
</b>
|
||||
</DialogContentText>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button
|
||||
type="button"
|
||||
variant="outlined"
|
||||
onClick={() => {
|
||||
closeResetModalAndRefresh(false);
|
||||
}}
|
||||
color="primary"
|
||||
disabled={resetLoading}
|
||||
>
|
||||
Cancel
|
||||
</Button>
|
||||
<Button
|
||||
onClick={resetConfiguration}
|
||||
variant="contained"
|
||||
color="primary"
|
||||
autoFocus
|
||||
disabled={resetLoading}
|
||||
>
|
||||
Yes, Reset Configuration
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
);
|
||||
};
|
||||
|
||||
const mapDispatchToProps = {
|
||||
setErrorSnackMessage,
|
||||
};
|
||||
|
||||
const connector = connect(null, mapDispatchToProps);
|
||||
|
||||
export default withStyles(styles)(connector(ResetConfigurationModal));
|
||||
@@ -55,6 +55,15 @@ func registerConfigHandlers(api *operations.ConsoleAPI) {
|
||||
}
|
||||
return admin_api.NewSetConfigOK().WithPayload(resp)
|
||||
})
|
||||
// Reset Configuration
|
||||
api.AdminAPIResetConfigHandler = admin_api.ResetConfigHandlerFunc(func(params admin_api.ResetConfigParams, session *models.Principal) middleware.Responder {
|
||||
resp, err := resetConfigResponse(session, params.Name)
|
||||
if err != nil {
|
||||
return admin_api.NewResetConfigDefault(int(err.Code)).WithPayload(err)
|
||||
}
|
||||
return admin_api.NewResetConfigOK().WithPayload(resp)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
// listConfig gets all configurations' names and their descriptions
|
||||
@@ -198,3 +207,29 @@ func setConfigResponse(session *models.Principal, name string, configRequest *mo
|
||||
}
|
||||
return &models.SetConfigResponse{Restart: needsRestart}, nil
|
||||
}
|
||||
|
||||
func resetConfig(ctx context.Context, client MinioAdmin, configName *string) (err error) {
|
||||
err = client.delConfigKV(ctx, *configName)
|
||||
return err
|
||||
}
|
||||
|
||||
// resetConfigResponse implements resetConfig() to be used by handler
|
||||
func resetConfigResponse(session *models.Principal, configName string) (*models.SetConfigResponse, *models.Error) {
|
||||
mAdmin, err := NewMinioAdminClient(session)
|
||||
if err != nil {
|
||||
return nil, prepareError(err)
|
||||
}
|
||||
// create a MinIO Admin Client interface implementation
|
||||
// defining the client to be used
|
||||
adminClient := AdminClient{Client: mAdmin}
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
err = resetConfig(ctx, adminClient, &configName)
|
||||
|
||||
if err != nil {
|
||||
return nil, prepareError(err)
|
||||
}
|
||||
|
||||
return &models.SetConfigResponse{Restart: true}, nil
|
||||
}
|
||||
|
||||
@@ -50,6 +50,7 @@ const (
|
||||
var minioHelpConfigKVMock func(subSys, key string, envOnly bool) (madmin.Help, error)
|
||||
var minioGetConfigKVMock func(key string) ([]byte, error)
|
||||
var minioSetConfigKVMock func(kv string) (restart bool, err error)
|
||||
var minioDelConfigKVMock func(name string) (err error)
|
||||
|
||||
// mock function helpConfigKV()
|
||||
func (ac adminClientMock) helpConfigKV(ctx context.Context, subSys, key string, envOnly bool) (madmin.Help, error) {
|
||||
@@ -66,6 +67,10 @@ func (ac adminClientMock) setConfigKV(ctx context.Context, kv string) (restart b
|
||||
return minioSetConfigKVMock(kv)
|
||||
}
|
||||
|
||||
func (ac adminClientMock) delConfigKV(ctx context.Context, name string) (err error) {
|
||||
return minioDelConfigKVMock(name)
|
||||
}
|
||||
|
||||
func TestListConfig(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
adminClient := adminClientMock{}
|
||||
@@ -165,6 +170,34 @@ func TestSetConfig(t *testing.T) {
|
||||
|
||||
}
|
||||
|
||||
func TestDelConfig(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
adminClient := adminClientMock{}
|
||||
function := "resetConfig()"
|
||||
// mock function response from setConfig()
|
||||
minioDelConfigKVMock = func(name string) (err error) {
|
||||
return nil
|
||||
}
|
||||
configName := "region"
|
||||
|
||||
ctx := context.Background()
|
||||
// Test-1 : resetConfig() resets a config with the config name
|
||||
err := resetConfig(ctx, adminClient, &configName)
|
||||
if err != nil {
|
||||
t.Errorf("Failed on %s:, error occurred: %s", function, err.Error())
|
||||
}
|
||||
|
||||
// Test-2 : resetConfig() returns error, handle properly
|
||||
minioDelConfigKVMock = func(name string) (err error) {
|
||||
return errors.New("error")
|
||||
}
|
||||
|
||||
err = resetConfig(ctx, adminClient, &configName)
|
||||
if assert.Error(err) {
|
||||
assert.Equal("error", err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
func Test_buildConfig(t *testing.T) {
|
||||
type args struct {
|
||||
configName *string
|
||||
|
||||
@@ -84,6 +84,7 @@ type MinioAdmin interface {
|
||||
getConfigKV(ctx context.Context, key string) ([]byte, error)
|
||||
helpConfigKV(ctx context.Context, subSys, key string, envOnly bool) (madmin.Help, error)
|
||||
setConfigKV(ctx context.Context, kv string) (restart bool, err error)
|
||||
delConfigKV(ctx context.Context, kv string) (err error)
|
||||
serviceRestart(ctx context.Context) error
|
||||
serverInfo(ctx context.Context) (madmin.InfoMessage, error)
|
||||
startProfiling(ctx context.Context, profiler madmin.ProfilerType) ([]madmin.StartProfilingResult, error)
|
||||
@@ -233,6 +234,11 @@ func (ac AdminClient) setConfigKV(ctx context.Context, kv string) (restart bool,
|
||||
return ac.Client.SetConfigKV(ctx, kv)
|
||||
}
|
||||
|
||||
// implements madmin.DelConfigKV()
|
||||
func (ac AdminClient) delConfigKV(ctx context.Context, kv string) (err error) {
|
||||
return ac.Client.DelConfigKV(ctx, kv)
|
||||
}
|
||||
|
||||
// implements madmin.ServiceRestart()
|
||||
func (ac AdminClient) serviceRestart(ctx context.Context) (err error) {
|
||||
return ac.Client.ServiceRestart(ctx)
|
||||
|
||||
@@ -2099,6 +2099,37 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"/configs/{name}/reset": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"AdminAPI"
|
||||
],
|
||||
"summary": "Configuration reset",
|
||||
"operationId": "ResetConfig",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"name": "name",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/setConfigResponse"
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"description": "Generic error response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/group": {
|
||||
"get": {
|
||||
"tags": [
|
||||
@@ -7796,6 +7827,37 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"/configs/{name}/reset": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"AdminAPI"
|
||||
],
|
||||
"summary": "Configuration reset",
|
||||
"operationId": "ResetConfig",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"name": "name",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/setConfigResponse"
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"description": "Generic error response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/group": {
|
||||
"get": {
|
||||
"tags": [
|
||||
|
||||
88
restapi/operations/admin_api/reset_config.go
Normal file
88
restapi/operations/admin_api/reset_config.go
Normal file
@@ -0,0 +1,88 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2021 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"
|
||||
)
|
||||
|
||||
// ResetConfigHandlerFunc turns a function with the right signature into a reset config handler
|
||||
type ResetConfigHandlerFunc func(ResetConfigParams, *models.Principal) middleware.Responder
|
||||
|
||||
// Handle executing the request and returning a response
|
||||
func (fn ResetConfigHandlerFunc) Handle(params ResetConfigParams, principal *models.Principal) middleware.Responder {
|
||||
return fn(params, principal)
|
||||
}
|
||||
|
||||
// ResetConfigHandler interface for that can handle valid reset config params
|
||||
type ResetConfigHandler interface {
|
||||
Handle(ResetConfigParams, *models.Principal) middleware.Responder
|
||||
}
|
||||
|
||||
// NewResetConfig creates a new http.Handler for the reset config operation
|
||||
func NewResetConfig(ctx *middleware.Context, handler ResetConfigHandler) *ResetConfig {
|
||||
return &ResetConfig{Context: ctx, Handler: handler}
|
||||
}
|
||||
|
||||
/* ResetConfig swagger:route GET /configs/{name}/reset AdminAPI resetConfig
|
||||
|
||||
Configuration reset
|
||||
|
||||
*/
|
||||
type ResetConfig struct {
|
||||
Context *middleware.Context
|
||||
Handler ResetConfigHandler
|
||||
}
|
||||
|
||||
func (o *ResetConfig) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
route, rCtx, _ := o.Context.RouteInfo(r)
|
||||
if rCtx != nil {
|
||||
*r = *rCtx
|
||||
}
|
||||
var Params = NewResetConfigParams()
|
||||
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)
|
||||
|
||||
}
|
||||
88
restapi/operations/admin_api/reset_config_parameters.go
Normal file
88
restapi/operations/admin_api/reset_config_parameters.go
Normal file
@@ -0,0 +1,88 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2021 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"
|
||||
)
|
||||
|
||||
// NewResetConfigParams creates a new ResetConfigParams object
|
||||
//
|
||||
// There are no default values defined in the spec.
|
||||
func NewResetConfigParams() ResetConfigParams {
|
||||
|
||||
return ResetConfigParams{}
|
||||
}
|
||||
|
||||
// ResetConfigParams contains all the bound params for the reset config operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters ResetConfig
|
||||
type ResetConfigParams struct {
|
||||
|
||||
// HTTP Request Object
|
||||
HTTPRequest *http.Request `json:"-"`
|
||||
|
||||
/*
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
Name string
|
||||
}
|
||||
|
||||
// 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 NewResetConfigParams() beforehand.
|
||||
func (o *ResetConfigParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
|
||||
var res []error
|
||||
|
||||
o.HTTPRequest = r
|
||||
|
||||
rName, rhkName, _ := route.Params.GetOK("name")
|
||||
if err := o.bindName(rName, rhkName, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// bindName binds and validates parameter Name from path.
|
||||
func (o *ResetConfigParams) bindName(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
|
||||
o.Name = raw
|
||||
|
||||
return nil
|
||||
}
|
||||
133
restapi/operations/admin_api/reset_config_responses.go
Normal file
133
restapi/operations/admin_api/reset_config_responses.go
Normal file
@@ -0,0 +1,133 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2021 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"
|
||||
)
|
||||
|
||||
// ResetConfigOKCode is the HTTP code returned for type ResetConfigOK
|
||||
const ResetConfigOKCode int = 200
|
||||
|
||||
/*ResetConfigOK A successful response.
|
||||
|
||||
swagger:response resetConfigOK
|
||||
*/
|
||||
type ResetConfigOK struct {
|
||||
|
||||
/*
|
||||
In: Body
|
||||
*/
|
||||
Payload *models.SetConfigResponse `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewResetConfigOK creates ResetConfigOK with default headers values
|
||||
func NewResetConfigOK() *ResetConfigOK {
|
||||
|
||||
return &ResetConfigOK{}
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the reset config o k response
|
||||
func (o *ResetConfigOK) WithPayload(payload *models.SetConfigResponse) *ResetConfigOK {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the reset config o k response
|
||||
func (o *ResetConfigOK) SetPayload(payload *models.SetConfigResponse) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *ResetConfigOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(200)
|
||||
if o.Payload != nil {
|
||||
payload := o.Payload
|
||||
if err := producer.Produce(rw, payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*ResetConfigDefault Generic error response.
|
||||
|
||||
swagger:response resetConfigDefault
|
||||
*/
|
||||
type ResetConfigDefault struct {
|
||||
_statusCode int
|
||||
|
||||
/*
|
||||
In: Body
|
||||
*/
|
||||
Payload *models.Error `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewResetConfigDefault creates ResetConfigDefault with default headers values
|
||||
func NewResetConfigDefault(code int) *ResetConfigDefault {
|
||||
if code <= 0 {
|
||||
code = 500
|
||||
}
|
||||
|
||||
return &ResetConfigDefault{
|
||||
_statusCode: code,
|
||||
}
|
||||
}
|
||||
|
||||
// WithStatusCode adds the status to the reset config default response
|
||||
func (o *ResetConfigDefault) WithStatusCode(code int) *ResetConfigDefault {
|
||||
o._statusCode = code
|
||||
return o
|
||||
}
|
||||
|
||||
// SetStatusCode sets the status to the reset config default response
|
||||
func (o *ResetConfigDefault) SetStatusCode(code int) {
|
||||
o._statusCode = code
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the reset config default response
|
||||
func (o *ResetConfigDefault) WithPayload(payload *models.Error) *ResetConfigDefault {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the reset config default response
|
||||
func (o *ResetConfigDefault) SetPayload(payload *models.Error) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *ResetConfigDefault) 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
|
||||
}
|
||||
}
|
||||
}
|
||||
116
restapi/operations/admin_api/reset_config_urlbuilder.go
Normal file
116
restapi/operations/admin_api/reset_config_urlbuilder.go
Normal file
@@ -0,0 +1,116 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2021 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"
|
||||
)
|
||||
|
||||
// ResetConfigURL generates an URL for the reset config operation
|
||||
type ResetConfigURL struct {
|
||||
Name string
|
||||
|
||||
_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 *ResetConfigURL) WithBasePath(bp string) *ResetConfigURL {
|
||||
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 *ResetConfigURL) SetBasePath(bp string) {
|
||||
o._basePath = bp
|
||||
}
|
||||
|
||||
// Build a url path and query string
|
||||
func (o *ResetConfigURL) Build() (*url.URL, error) {
|
||||
var _result url.URL
|
||||
|
||||
var _path = "/configs/{name}/reset"
|
||||
|
||||
name := o.Name
|
||||
if name != "" {
|
||||
_path = strings.Replace(_path, "{name}", name, -1)
|
||||
} else {
|
||||
return nil, errors.New("name is required on ResetConfigURL")
|
||||
}
|
||||
|
||||
_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 *ResetConfigURL) 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 *ResetConfigURL) String() string {
|
||||
return o.Must(o.Build()).String()
|
||||
}
|
||||
|
||||
// BuildFull builds a full url with scheme, host, path and query string
|
||||
func (o *ResetConfigURL) BuildFull(scheme, host string) (*url.URL, error) {
|
||||
if scheme == "" {
|
||||
return nil, errors.New("scheme is required for a full url on ResetConfigURL")
|
||||
}
|
||||
if host == "" {
|
||||
return nil, errors.New("host is required for a full url on ResetConfigURL")
|
||||
}
|
||||
|
||||
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 *ResetConfigURL) StringFull(scheme, host string) string {
|
||||
return o.Must(o.BuildFull(scheme, host)).String()
|
||||
}
|
||||
@@ -311,6 +311,9 @@ func NewConsoleAPI(spec *loads.Document) *ConsoleAPI {
|
||||
AdminAPIRemoveUserHandler: admin_api.RemoveUserHandlerFunc(func(params admin_api.RemoveUserParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation admin_api.RemoveUser has not yet been implemented")
|
||||
}),
|
||||
AdminAPIResetConfigHandler: admin_api.ResetConfigHandlerFunc(func(params admin_api.ResetConfigParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation admin_api.ResetConfig has not yet been implemented")
|
||||
}),
|
||||
AdminAPIRestartServiceHandler: admin_api.RestartServiceHandlerFunc(func(params admin_api.RestartServiceParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation admin_api.RestartService has not yet been implemented")
|
||||
}),
|
||||
@@ -581,6 +584,8 @@ type ConsoleAPI struct {
|
||||
AdminAPIRemovePolicyHandler admin_api.RemovePolicyHandler
|
||||
// AdminAPIRemoveUserHandler sets the operation handler for the remove user operation
|
||||
AdminAPIRemoveUserHandler admin_api.RemoveUserHandler
|
||||
// AdminAPIResetConfigHandler sets the operation handler for the reset config operation
|
||||
AdminAPIResetConfigHandler admin_api.ResetConfigHandler
|
||||
// AdminAPIRestartServiceHandler sets the operation handler for the restart service operation
|
||||
AdminAPIRestartServiceHandler admin_api.RestartServiceHandler
|
||||
// UserAPISessionCheckHandler sets the operation handler for the session check operation
|
||||
@@ -948,6 +953,9 @@ func (o *ConsoleAPI) Validate() error {
|
||||
if o.AdminAPIRemoveUserHandler == nil {
|
||||
unregistered = append(unregistered, "admin_api.RemoveUserHandler")
|
||||
}
|
||||
if o.AdminAPIResetConfigHandler == nil {
|
||||
unregistered = append(unregistered, "admin_api.ResetConfigHandler")
|
||||
}
|
||||
if o.AdminAPIRestartServiceHandler == nil {
|
||||
unregistered = append(unregistered, "admin_api.RestartServiceHandler")
|
||||
}
|
||||
@@ -1429,6 +1437,10 @@ func (o *ConsoleAPI) initHandlerCache() {
|
||||
o.handlers["DELETE"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["DELETE"]["/user"] = admin_api.NewRemoveUser(o.context, o.AdminAPIRemoveUserHandler)
|
||||
if o.handlers["GET"] == nil {
|
||||
o.handlers["GET"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["GET"]["/configs/{name}/reset"] = admin_api.NewResetConfig(o.context, o.AdminAPIResetConfigHandler)
|
||||
if o.handlers["POST"] == nil {
|
||||
o.handlers["POST"] = make(map[string]http.Handler)
|
||||
}
|
||||
|
||||
@@ -1932,6 +1932,27 @@ paths:
|
||||
tags:
|
||||
- AdminAPI
|
||||
|
||||
/configs/{name}/reset:
|
||||
get:
|
||||
summary: Configuration reset
|
||||
operationId: ResetConfig
|
||||
parameters:
|
||||
- name: name
|
||||
in: path
|
||||
required: true
|
||||
type: string
|
||||
responses:
|
||||
200:
|
||||
description: A successful response.
|
||||
schema:
|
||||
$ref: "#/definitions/setConfigResponse"
|
||||
default:
|
||||
description: Generic error response.
|
||||
schema:
|
||||
$ref: "#/definitions/error"
|
||||
tags:
|
||||
- AdminAPI
|
||||
|
||||
/service/restart:
|
||||
post:
|
||||
summary: Restart Service
|
||||
@@ -2643,7 +2664,7 @@ definitions:
|
||||
name:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
type: string
|
||||
entityType:
|
||||
$ref: "#/definitions/policyEntity"
|
||||
entityName:
|
||||
@@ -3893,7 +3914,6 @@ definitions:
|
||||
items:
|
||||
$ref: "#/definitions/iamPolicyStatement"
|
||||
|
||||
|
||||
iamPolicyStatement:
|
||||
type: object
|
||||
properties:
|
||||
|
||||
Reference in New Issue
Block a user