diff --git a/portal-ui/src/screens/Console/Buckets/BucketDetails/BucketReplicationPanel.tsx b/portal-ui/src/screens/Console/Buckets/BucketDetails/BucketReplicationPanel.tsx index 7ee2b6092..5ffd234e4 100644 --- a/portal-ui/src/screens/Console/Buckets/BucketDetails/BucketReplicationPanel.tsx +++ b/portal-ui/src/screens/Console/Buckets/BucketDetails/BucketReplicationPanel.tsx @@ -20,8 +20,6 @@ import { Theme } from "@mui/material/styles"; import createStyles from "@mui/styles/createStyles"; import withStyles from "@mui/styles/withStyles"; import Grid from "@mui/material/Grid"; -import AddIcon from "../../../../icons/AddIcon"; -import BucketsIcon from "../../../../icons/BucketsIcon"; import { setErrorSnackMessage } from "../../../../actions"; import { actionsTray, @@ -35,17 +33,16 @@ import { } from "../types"; import { ErrorResponseHandler } from "../../../../common/types"; import { AppState } from "../../../../store"; -import api from "../../../../common/api"; -import TableWrapper from "../../Common/TableWrapper/TableWrapper"; - -import HelpBox from "../../../../common/HelpBox"; -import PanelTitle from "../../Common/PanelTitle/PanelTitle"; import { SecureComponent, hasPermission, } from "../../../../common/SecureComponent"; import { IAM_SCOPES } from "../../../../common/SecureComponent/permissions"; - +import { AddIcon, DeleteIcon, BucketsIcon } from "../../../../icons"; +import api from "../../../../common/api"; +import TableWrapper from "../../Common/TableWrapper/TableWrapper"; +import HelpBox from "../../../../common/HelpBox"; +import PanelTitle from "../../Common/PanelTitle/PanelTitle"; import withSuspense from "../../Common/Components/withSuspense"; import RBIconButton from "./SummaryItems/RBIconButton"; import EditReplicationModal from "./EditReplicationModal"; @@ -79,7 +76,6 @@ const BucketReplicationPanel = ({ match, setErrorSnackMessage, loadingBucket, - bucketInfo, }: IBucketReplicationProps) => { const [loadingReplication, setLoadingReplication] = useState(true); const [replicationRules, setReplicationRules] = useState< @@ -91,6 +87,7 @@ const BucketReplicationPanel = ({ const [editReplicationModal, setEditReplicationModal] = useState(false); const [selectedRRule, setSelectedRRule] = useState(""); + const [deleteAllRules, setDeleteAllRules] = useState(false); const bucketName = match.params["bucketName"]; @@ -159,6 +156,13 @@ const BucketReplicationPanel = ({ const confirmDeleteReplication = (replication: BucketReplicationRule) => { setSelectedRRule(replication.id); + setDeleteAllRules(false); + setDeleteReplicationModal(true); + }; + + const confirmDeleteAllReplicationRules = () => { + setSelectedRRule("allRules"); + setDeleteAllRules(true); setDeleteReplicationModal(true); }; @@ -179,7 +183,6 @@ const BucketReplicationPanel = ({ { type: "delete", onClick: confirmDeleteReplication, - disableButtonFunction: () => replicationRules.length === 1, }, { type: "view", @@ -209,6 +212,8 @@ const BucketReplicationPanel = ({ selectedBucket={bucketName} closeDeleteModalAndRefresh={closeReplicationModalDelete} ruleToDelete={selectedRRule} + remainingRules={replicationRules.length} + deleteAllRules={deleteAllRules} /> )} @@ -223,23 +228,43 @@ const BucketReplicationPanel = ({ Replication - - { - setOpenReplicationOpen(true); - }} - text={"Add Replication Rule"} - icon={} - color="primary" - variant={"contained"} - /> - +
+ + { + confirmDeleteAllReplicationRules(); + }} + text={"Remove All Rules"} + icon={} + color={"secondary"} + variant={"outlined"} + disabled={replicationRules.length === 0} + /> + + + { + setOpenReplicationOpen(true); + }} + text={"Add Replication Rule"} + icon={} + color="primary" + variant={"contained"} + /> + +
+
} diff --git a/portal-ui/src/screens/Console/Buckets/BucketDetails/DeleteReplicationRule.tsx b/portal-ui/src/screens/Console/Buckets/BucketDetails/DeleteReplicationRule.tsx index 7f5a940c4..aa2991c13 100644 --- a/portal-ui/src/screens/Console/Buckets/BucketDetails/DeleteReplicationRule.tsx +++ b/portal-ui/src/screens/Console/Buckets/BucketDetails/DeleteReplicationRule.tsx @@ -14,7 +14,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -import React from "react"; +import React, { Fragment, useState } from "react"; import { connect } from "react-redux"; import { DialogContentText } from "@mui/material"; import { setErrorSnackMessage } from "../../../../actions"; @@ -22,12 +22,16 @@ import { ErrorResponseHandler } from "../../../../common/types"; import useApi from "../../Common/Hooks/useApi"; import ConfirmDialog from "../../Common/ModalWrapper/ConfirmDialog"; import { ConfirmDeleteIcon } from "../../../../icons"; +import Grid from "@mui/material/Grid"; +import InputBoxWrapper from "../../Common/FormComponents/InputBoxWrapper/InputBoxWrapper"; interface IDeleteReplicationProps { closeDeleteModalAndRefresh: (refresh: boolean) => void; deleteOpen: boolean; selectedBucket: string; - ruleToDelete: string; + ruleToDelete?: string; + remainingRules: number; + deleteAllRules?: boolean; setErrorSnackMessage: typeof setErrorSnackMessage; } @@ -36,8 +40,12 @@ const DeleteReplicationRule = ({ deleteOpen, selectedBucket, ruleToDelete, + remainingRules, setErrorSnackMessage, + deleteAllRules = false, }: IDeleteReplicationProps) => { + const [confirmationText, setConfirmationText] = useState(""); + const onDelSuccess = () => closeDeleteModalAndRefresh(true); const onDelError = (err: ErrorResponseHandler) => setErrorSnackMessage(err); const onClose = () => closeDeleteModalAndRefresh(false); @@ -49,27 +57,57 @@ const DeleteReplicationRule = ({ } const onConfirmDelete = () => { - invokeDeleteApi( - "DELETE", - `/api/v1/buckets/${selectedBucket}/replication/${ruleToDelete}` - ); + let url = `/api/v1/buckets/${selectedBucket}/replication/${ruleToDelete}`; + + if (deleteAllRules || remainingRules === 1) { + url = `/api/v1/buckets/${selectedBucket}/delete-all-replication-rules`; + } + + invokeDeleteApi("DELETE", url); }; return ( } isLoading={deleteLoading} onConfirm={onConfirmDelete} onClose={onClose} + confirmButtonProps={{ + disabled: deleteAllRules && confirmationText !== "Yes, I am sure", + }} confirmationContent={ - Are you sure you want to delete replication rule {ruleToDelete} - ?
- Remember, at lease one rule must be present once replication has been - enabled + {deleteAllRules ? ( + + Are you sure you want to remove all replication rules for bucket{" "} + {selectedBucket}?
+
+ To continue please type Yes, I am sure in the box. + + ) => { + setConfirmationText(event.target.value); + }} + label="" + value={confirmationText} + /> + +
+ ) : ( + + Are you sure you want to delete replication rule{" "} + {ruleToDelete}? + + )}
} /> diff --git a/restapi/admin_remote_buckets.go b/restapi/admin_remote_buckets.go index 4f8b0adc4..464084aac 100644 --- a/restapi/admin_remote_buckets.go +++ b/restapi/admin_remote_buckets.go @@ -109,6 +109,17 @@ func registerAdminBucketRemoteHandlers(api *operations.ConsoleAPI) { return user_api.NewDeleteBucketReplicationRuleNoContent() }) + // delete all replication rules for a bucket + api.UserAPIDeleteAllReplicationRulesHandler = user_api.DeleteAllReplicationRulesHandlerFunc(func(params user_api.DeleteAllReplicationRulesParams, session *models.Principal) middleware.Responder { + err := deleteBucketReplicationRulesResponse(session, params) + + if err != nil { + return user_api.NewDeleteAllReplicationRulesDefault(500).WithPayload(err) + } + + return user_api.NewDeleteAllReplicationRulesNoContent() + }) + //update local bucket replication config item api.UserAPIUpdateMultiBucketReplicationHandler = user_api.UpdateMultiBucketReplicationHandlerFunc(func(params user_api.UpdateMultiBucketReplicationParams, session *models.Principal) middleware.Responder { err := updateBucketReplicationResponse(session, params) @@ -591,6 +602,26 @@ func deleteReplicationRule(ctx context.Context, session *models.Principal, bucke return nil } +func deleteAllReplicationRules(ctx context.Context, session *models.Principal, bucketName string) error { + s3Client, err := newS3BucketClient(session, bucketName, "") + if err != nil { + LogError("error creating S3Client: %v", err) + return err + } + // create a mc S3Client interface implementation + // defining the client to be used + mcClient := mcClient{client: s3Client} + + err2 := mcClient.deleteAllReplicationRules(ctx) + + if err2 != nil { + return err + } + + return nil + +} + func deleteReplicationRuleResponse(session *models.Principal, params user_api.DeleteBucketReplicationRuleParams) *models.Error { ctx := context.Background() @@ -602,6 +633,17 @@ func deleteReplicationRuleResponse(session *models.Principal, params user_api.De return nil } +func deleteBucketReplicationRulesResponse(session *models.Principal, params user_api.DeleteAllReplicationRulesParams) *models.Error { + ctx := context.Background() + + err := deleteAllReplicationRules(ctx, session, params.BucketName) + + if err != nil { + return prepareError(err) + } + return nil +} + func updateBucketReplicationResponse(session *models.Principal, params user_api.UpdateMultiBucketReplicationParams) *models.Error { ctx := context.Background() diff --git a/restapi/client.go b/restapi/client.go index 713ba3977..bdb2f7f64 100644 --- a/restapi/client.go +++ b/restapi/client.go @@ -262,6 +262,10 @@ func (c mcClient) setReplication(ctx context.Context, cfg *replication.Config, o return c.client.SetReplication(ctx, cfg, opts) } +func (c mcClient) deleteAllReplicationRules(ctx context.Context) *probe.Error { + return c.client.RemoveReplication(ctx) +} + func (c mcClient) setVersioning(ctx context.Context, status string) *probe.Error { return c.client.SetVersion(ctx, status) } diff --git a/restapi/embedded_spec.go b/restapi/embedded_spec.go index ccd0b9c19..104ee6c39 100644 --- a/restapi/embedded_spec.go +++ b/restapi/embedded_spec.go @@ -776,6 +776,34 @@ func init() { } } }, + "/buckets/{bucket_name}/delete-all-replication-rules": { + "delete": { + "tags": [ + "UserAPI" + ], + "summary": "Deletes all replication rules on a bucket", + "operationId": "DeleteAllReplicationRules", + "parameters": [ + { + "type": "string", + "name": "bucket_name", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "A successful response." + }, + "default": { + "description": "Generic error response.", + "schema": { + "$ref": "#/definitions/error" + } + } + } + } + }, "/buckets/{bucket_name}/delete-objects": { "post": { "tags": [ @@ -7192,6 +7220,34 @@ func init() { } } }, + "/buckets/{bucket_name}/delete-all-replication-rules": { + "delete": { + "tags": [ + "UserAPI" + ], + "summary": "Deletes all replication rules on a bucket", + "operationId": "DeleteAllReplicationRules", + "parameters": [ + { + "type": "string", + "name": "bucket_name", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "A successful response." + }, + "default": { + "description": "Generic error response.", + "schema": { + "$ref": "#/definitions/error" + } + } + } + } + }, "/buckets/{bucket_name}/delete-objects": { "post": { "tags": [ diff --git a/restapi/operations/console_api.go b/restapi/operations/console_api.go index e09481a90..eaecbb587 100644 --- a/restapi/operations/console_api.go +++ b/restapi/operations/console_api.go @@ -134,6 +134,9 @@ func NewConsoleAPI(spec *loads.Document) *ConsoleAPI { AdminAPIDeleteAccessRuleWithBucketHandler: admin_api.DeleteAccessRuleWithBucketHandlerFunc(func(params admin_api.DeleteAccessRuleWithBucketParams, principal *models.Principal) middleware.Responder { return middleware.NotImplemented("operation admin_api.DeleteAccessRuleWithBucket has not yet been implemented") }), + UserAPIDeleteAllReplicationRulesHandler: user_api.DeleteAllReplicationRulesHandlerFunc(func(params user_api.DeleteAllReplicationRulesParams, principal *models.Principal) middleware.Responder { + return middleware.NotImplemented("operation user_api.DeleteAllReplicationRules has not yet been implemented") + }), UserAPIDeleteBucketHandler: user_api.DeleteBucketHandlerFunc(func(params user_api.DeleteBucketParams, principal *models.Principal) middleware.Responder { return middleware.NotImplemented("operation user_api.DeleteBucket has not yet been implemented") }), @@ -502,6 +505,8 @@ type ConsoleAPI struct { AdminAPIDashboardWidgetDetailsHandler admin_api.DashboardWidgetDetailsHandler // AdminAPIDeleteAccessRuleWithBucketHandler sets the operation handler for the delete access rule with bucket operation AdminAPIDeleteAccessRuleWithBucketHandler admin_api.DeleteAccessRuleWithBucketHandler + // UserAPIDeleteAllReplicationRulesHandler sets the operation handler for the delete all replication rules operation + UserAPIDeleteAllReplicationRulesHandler user_api.DeleteAllReplicationRulesHandler // UserAPIDeleteBucketHandler sets the operation handler for the delete bucket operation UserAPIDeleteBucketHandler user_api.DeleteBucketHandler // UserAPIDeleteBucketEventHandler sets the operation handler for the delete bucket event operation @@ -836,6 +841,9 @@ func (o *ConsoleAPI) Validate() error { if o.AdminAPIDeleteAccessRuleWithBucketHandler == nil { unregistered = append(unregistered, "admin_api.DeleteAccessRuleWithBucketHandler") } + if o.UserAPIDeleteAllReplicationRulesHandler == nil { + unregistered = append(unregistered, "user_api.DeleteAllReplicationRulesHandler") + } if o.UserAPIDeleteBucketHandler == nil { unregistered = append(unregistered, "user_api.DeleteBucketHandler") } @@ -1300,6 +1308,10 @@ func (o *ConsoleAPI) initHandlerCache() { if o.handlers["DELETE"] == nil { o.handlers["DELETE"] = make(map[string]http.Handler) } + o.handlers["DELETE"]["/buckets/{bucket_name}/delete-all-replication-rules"] = user_api.NewDeleteAllReplicationRules(o.context, o.UserAPIDeleteAllReplicationRulesHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } o.handlers["DELETE"]["/buckets/{name}"] = user_api.NewDeleteBucket(o.context, o.UserAPIDeleteBucketHandler) if o.handlers["DELETE"] == nil { o.handlers["DELETE"] = make(map[string]http.Handler) diff --git a/restapi/operations/user_api/delete_all_replication_rules.go b/restapi/operations/user_api/delete_all_replication_rules.go new file mode 100644 index 000000000..077b5eea3 --- /dev/null +++ b/restapi/operations/user_api/delete_all_replication_rules.go @@ -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 . +// + +package user_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" +) + +// DeleteAllReplicationRulesHandlerFunc turns a function with the right signature into a delete all replication rules handler +type DeleteAllReplicationRulesHandlerFunc func(DeleteAllReplicationRulesParams, *models.Principal) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteAllReplicationRulesHandlerFunc) Handle(params DeleteAllReplicationRulesParams, principal *models.Principal) middleware.Responder { + return fn(params, principal) +} + +// DeleteAllReplicationRulesHandler interface for that can handle valid delete all replication rules params +type DeleteAllReplicationRulesHandler interface { + Handle(DeleteAllReplicationRulesParams, *models.Principal) middleware.Responder +} + +// NewDeleteAllReplicationRules creates a new http.Handler for the delete all replication rules operation +func NewDeleteAllReplicationRules(ctx *middleware.Context, handler DeleteAllReplicationRulesHandler) *DeleteAllReplicationRules { + return &DeleteAllReplicationRules{Context: ctx, Handler: handler} +} + +/* DeleteAllReplicationRules swagger:route DELETE /buckets/{bucket_name}/delete-all-replication-rules UserAPI deleteAllReplicationRules + +Deletes all replication rules on a bucket + +*/ +type DeleteAllReplicationRules struct { + Context *middleware.Context + Handler DeleteAllReplicationRulesHandler +} + +func (o *DeleteAllReplicationRules) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteAllReplicationRulesParams() + 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) + +} diff --git a/restapi/operations/user_api/delete_all_replication_rules_parameters.go b/restapi/operations/user_api/delete_all_replication_rules_parameters.go new file mode 100644 index 000000000..523fbdd31 --- /dev/null +++ b/restapi/operations/user_api/delete_all_replication_rules_parameters.go @@ -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 . +// + +package user_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" +) + +// NewDeleteAllReplicationRulesParams creates a new DeleteAllReplicationRulesParams object +// +// There are no default values defined in the spec. +func NewDeleteAllReplicationRulesParams() DeleteAllReplicationRulesParams { + + return DeleteAllReplicationRulesParams{} +} + +// DeleteAllReplicationRulesParams contains all the bound params for the delete all replication rules operation +// typically these are obtained from a http.Request +// +// swagger:parameters DeleteAllReplicationRules +type DeleteAllReplicationRulesParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: path + */ + BucketName 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 NewDeleteAllReplicationRulesParams() beforehand. +func (o *DeleteAllReplicationRulesParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rBucketName, rhkBucketName, _ := route.Params.GetOK("bucket_name") + if err := o.bindBucketName(rBucketName, rhkBucketName, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindBucketName binds and validates parameter BucketName from path. +func (o *DeleteAllReplicationRulesParams) bindBucketName(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.BucketName = raw + + return nil +} diff --git a/restapi/operations/user_api/delete_all_replication_rules_responses.go b/restapi/operations/user_api/delete_all_replication_rules_responses.go new file mode 100644 index 000000000..3fdfc66a6 --- /dev/null +++ b/restapi/operations/user_api/delete_all_replication_rules_responses.go @@ -0,0 +1,113 @@ +// 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 . +// + +package user_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" +) + +// DeleteAllReplicationRulesNoContentCode is the HTTP code returned for type DeleteAllReplicationRulesNoContent +const DeleteAllReplicationRulesNoContentCode int = 204 + +/*DeleteAllReplicationRulesNoContent A successful response. + +swagger:response deleteAllReplicationRulesNoContent +*/ +type DeleteAllReplicationRulesNoContent struct { +} + +// NewDeleteAllReplicationRulesNoContent creates DeleteAllReplicationRulesNoContent with default headers values +func NewDeleteAllReplicationRulesNoContent() *DeleteAllReplicationRulesNoContent { + + return &DeleteAllReplicationRulesNoContent{} +} + +// WriteResponse to the client +func (o *DeleteAllReplicationRulesNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +/*DeleteAllReplicationRulesDefault Generic error response. + +swagger:response deleteAllReplicationRulesDefault +*/ +type DeleteAllReplicationRulesDefault struct { + _statusCode int + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteAllReplicationRulesDefault creates DeleteAllReplicationRulesDefault with default headers values +func NewDeleteAllReplicationRulesDefault(code int) *DeleteAllReplicationRulesDefault { + if code <= 0 { + code = 500 + } + + return &DeleteAllReplicationRulesDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete all replication rules default response +func (o *DeleteAllReplicationRulesDefault) WithStatusCode(code int) *DeleteAllReplicationRulesDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete all replication rules default response +func (o *DeleteAllReplicationRulesDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithPayload adds the payload to the delete all replication rules default response +func (o *DeleteAllReplicationRulesDefault) WithPayload(payload *models.Error) *DeleteAllReplicationRulesDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete all replication rules default response +func (o *DeleteAllReplicationRulesDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteAllReplicationRulesDefault) 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 + } + } +} diff --git a/restapi/operations/user_api/delete_all_replication_rules_urlbuilder.go b/restapi/operations/user_api/delete_all_replication_rules_urlbuilder.go new file mode 100644 index 000000000..5619dbc89 --- /dev/null +++ b/restapi/operations/user_api/delete_all_replication_rules_urlbuilder.go @@ -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 . +// + +package user_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" +) + +// DeleteAllReplicationRulesURL generates an URL for the delete all replication rules operation +type DeleteAllReplicationRulesURL struct { + BucketName 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 *DeleteAllReplicationRulesURL) WithBasePath(bp string) *DeleteAllReplicationRulesURL { + 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 *DeleteAllReplicationRulesURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteAllReplicationRulesURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/buckets/{bucket_name}/delete-all-replication-rules" + + bucketName := o.BucketName + if bucketName != "" { + _path = strings.Replace(_path, "{bucket_name}", bucketName, -1) + } else { + return nil, errors.New("bucketName is required on DeleteAllReplicationRulesURL") + } + + _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 *DeleteAllReplicationRulesURL) 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 *DeleteAllReplicationRulesURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteAllReplicationRulesURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteAllReplicationRulesURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteAllReplicationRulesURL") + } + + 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 *DeleteAllReplicationRulesURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/swagger-console.yml b/swagger-console.yml index b2dddbccc..97746bc8d 100644 --- a/swagger-console.yml +++ b/swagger-console.yml @@ -934,6 +934,26 @@ paths: in: path required: true type: string + + responses: + 204: + description: A successful response. + default: + description: Generic error response. + schema: + $ref: "#/definitions/error" + tags: + - UserAPI + + /buckets/{bucket_name}/delete-all-replication-rules: + delete: + summary: Deletes all replication rules on a bucket + operationId: DeleteAllReplicationRules + parameters: + - name: bucket_name + in: path + required: true + type: string responses: 204: description: A successful response.