access rule delete bug fix (#978)
Co-authored-by: Adam Stafford <adamstafford@Adams-MacBook-Pro.local>
This commit is contained in:
67
models/prefix_wrapper.go
Normal file
67
models/prefix_wrapper.go
Normal file
@@ -0,0 +1,67 @@
|
||||
// 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 models
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
|
||||
// PrefixWrapper prefix wrapper
|
||||
//
|
||||
// swagger:model prefixWrapper
|
||||
type PrefixWrapper struct {
|
||||
|
||||
// prefix
|
||||
Prefix string `json:"prefix,omitempty"`
|
||||
}
|
||||
|
||||
// Validate validates this prefix wrapper
|
||||
func (m *PrefixWrapper) Validate(formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// ContextValidate validates this prefix wrapper based on context it is used
|
||||
func (m *PrefixWrapper) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *PrefixWrapper) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *PrefixWrapper) UnmarshalBinary(b []byte) error {
|
||||
var res PrefixWrapper
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
||||
@@ -64,7 +64,10 @@ const DeleteAccessRule = ({
|
||||
}: IDeleteAccessRule) => {
|
||||
const deleteProcess = () => {
|
||||
api
|
||||
.invoke("DELETE", `/api/v1/bucket/${bucket}/access-rules/${toDelete}`)
|
||||
.invoke("DELETE", `/api/v1/bucket/${bucket}/access-rules`,
|
||||
{
|
||||
prefix: toDelete,
|
||||
})
|
||||
.then((res: any) => {})
|
||||
.catch((err: ErrorResponseHandler) => {
|
||||
setErrorSnackMessage(err);
|
||||
|
||||
@@ -146,9 +146,9 @@ func getSetAccessRuleWithBucketResponse(session *models.Principal, bucket string
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func getDeleteAccessRuleWithBucketResponse(session *models.Principal, bucket string, prefix string) (bool, *models.Error) {
|
||||
func getDeleteAccessRuleWithBucketResponse(session *models.Principal, bucket string, prefix *models.PrefixWrapper) (bool, *models.Error) {
|
||||
ctx := context.Background()
|
||||
client, err := newS3BucketClient(session, bucket, prefix)
|
||||
client, err := newS3BucketClient(session, bucket, prefix.Prefix)
|
||||
if err != nil {
|
||||
return false, prepareError(err)
|
||||
}
|
||||
|
||||
@@ -570,9 +570,7 @@ func init() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/bucket/{bucket}/access-rules/{prefix}": {
|
||||
},
|
||||
"delete": {
|
||||
"tags": [
|
||||
"AdminAPI"
|
||||
@@ -587,10 +585,12 @@ func init() {
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"name": "prefix",
|
||||
"in": "path",
|
||||
"required": true
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/prefixWrapper"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
@@ -4655,6 +4655,14 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"prefixWrapper": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"prefix": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"principal": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -5963,9 +5971,7 @@ func init() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/bucket/{bucket}/access-rules/{prefix}": {
|
||||
},
|
||||
"delete": {
|
||||
"tags": [
|
||||
"AdminAPI"
|
||||
@@ -5980,10 +5986,12 @@ func init() {
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"name": "prefix",
|
||||
"in": "path",
|
||||
"required": true
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/prefixWrapper"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
@@ -10102,6 +10110,14 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"prefixWrapper": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"prefix": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"principal": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
||||
@@ -48,7 +48,7 @@ func NewDeleteAccessRuleWithBucket(ctx *middleware.Context, handler DeleteAccess
|
||||
return &DeleteAccessRuleWithBucket{Context: ctx, Handler: handler}
|
||||
}
|
||||
|
||||
/* DeleteAccessRuleWithBucket swagger:route DELETE /bucket/{bucket}/access-rules/{prefix} AdminAPI deleteAccessRuleWithBucket
|
||||
/* DeleteAccessRuleWithBucket swagger:route DELETE /bucket/{bucket}/access-rules AdminAPI deleteAccessRuleWithBucket
|
||||
|
||||
Delete Access Rule From Given Bucket
|
||||
|
||||
|
||||
@@ -23,11 +23,17 @@ package admin_api
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/validate"
|
||||
|
||||
"github.com/minio/console/models"
|
||||
)
|
||||
|
||||
// NewDeleteAccessRuleWithBucketParams creates a new DeleteAccessRuleWithBucketParams object
|
||||
@@ -54,9 +60,9 @@ type DeleteAccessRuleWithBucketParams struct {
|
||||
Bucket string
|
||||
/*
|
||||
Required: true
|
||||
In: path
|
||||
In: body
|
||||
*/
|
||||
Prefix string
|
||||
Prefix *models.PrefixWrapper
|
||||
}
|
||||
|
||||
// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
|
||||
@@ -73,9 +79,32 @@ func (o *DeleteAccessRuleWithBucketParams) BindRequest(r *http.Request, route *m
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
rPrefix, rhkPrefix, _ := route.Params.GetOK("prefix")
|
||||
if err := o.bindPrefix(rPrefix, rhkPrefix, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
if runtime.HasBody(r) {
|
||||
defer r.Body.Close()
|
||||
var body models.PrefixWrapper
|
||||
if err := route.Consumer.Consume(r.Body, &body); err != nil {
|
||||
if err == io.EOF {
|
||||
res = append(res, errors.Required("prefix", "body", ""))
|
||||
} else {
|
||||
res = append(res, errors.NewParseError("prefix", "body", "", err))
|
||||
}
|
||||
} else {
|
||||
// validate body object
|
||||
if err := body.Validate(route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
ctx := validate.WithOperationRequest(context.Background())
|
||||
if err := body.ContextValidate(ctx, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) == 0 {
|
||||
o.Prefix = &body
|
||||
}
|
||||
}
|
||||
} else {
|
||||
res = append(res, errors.Required("prefix", "body", ""))
|
||||
}
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
@@ -96,17 +125,3 @@ func (o *DeleteAccessRuleWithBucketParams) bindBucket(rawData []string, hasKey b
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// bindPrefix binds and validates parameter Prefix from path.
|
||||
func (o *DeleteAccessRuleWithBucketParams) bindPrefix(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.Prefix = raw
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -32,7 +32,6 @@ import (
|
||||
// DeleteAccessRuleWithBucketURL generates an URL for the delete access rule with bucket operation
|
||||
type DeleteAccessRuleWithBucketURL struct {
|
||||
Bucket string
|
||||
Prefix string
|
||||
|
||||
_basePath string
|
||||
// avoid unkeyed usage
|
||||
@@ -58,7 +57,7 @@ func (o *DeleteAccessRuleWithBucketURL) SetBasePath(bp string) {
|
||||
func (o *DeleteAccessRuleWithBucketURL) Build() (*url.URL, error) {
|
||||
var _result url.URL
|
||||
|
||||
var _path = "/bucket/{bucket}/access-rules/{prefix}"
|
||||
var _path = "/bucket/{bucket}/access-rules"
|
||||
|
||||
bucket := o.Bucket
|
||||
if bucket != "" {
|
||||
@@ -67,13 +66,6 @@ func (o *DeleteAccessRuleWithBucketURL) Build() (*url.URL, error) {
|
||||
return nil, errors.New("bucket is required on DeleteAccessRuleWithBucketURL")
|
||||
}
|
||||
|
||||
prefix := o.Prefix
|
||||
if prefix != "" {
|
||||
_path = strings.Replace(_path, "{prefix}", prefix, -1)
|
||||
} else {
|
||||
return nil, errors.New("prefix is required on DeleteAccessRuleWithBucketURL")
|
||||
}
|
||||
|
||||
_basePath := o._basePath
|
||||
if _basePath == "" {
|
||||
_basePath = "/api/v1"
|
||||
|
||||
@@ -1156,7 +1156,7 @@ func (o *ConsoleAPI) initHandlerCache() {
|
||||
if o.handlers["DELETE"] == nil {
|
||||
o.handlers["DELETE"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["DELETE"]["/bucket/{bucket}/access-rules/{prefix}"] = admin_api.NewDeleteAccessRuleWithBucket(o.context, o.AdminAPIDeleteAccessRuleWithBucketHandler)
|
||||
o.handlers["DELETE"]["/bucket/{bucket}/access-rules"] = admin_api.NewDeleteAccessRuleWithBucket(o.context, o.AdminAPIDeleteAccessRuleWithBucketHandler)
|
||||
if o.handlers["DELETE"] == nil {
|
||||
o.handlers["DELETE"] = make(map[string]http.Handler)
|
||||
}
|
||||
|
||||
@@ -1649,8 +1649,6 @@ paths:
|
||||
$ref: "#/definitions/error"
|
||||
tags:
|
||||
- AdminAPI
|
||||
|
||||
/bucket/{bucket}/access-rules/{prefix}:
|
||||
delete:
|
||||
summary: Delete Access Rule From Given Bucket
|
||||
operationId: DeleteAccessRuleWithBucket
|
||||
@@ -1660,9 +1658,10 @@ paths:
|
||||
required: true
|
||||
type: string
|
||||
- name: prefix
|
||||
in: path
|
||||
in: body
|
||||
required: true
|
||||
type: string
|
||||
schema:
|
||||
$ref: "#/definitions/prefixWrapper"
|
||||
responses:
|
||||
200:
|
||||
description: A successful response.
|
||||
@@ -3517,6 +3516,12 @@ definitions:
|
||||
access:
|
||||
type: string
|
||||
|
||||
prefixWrapper:
|
||||
type: object
|
||||
properties:
|
||||
prefix:
|
||||
type: string
|
||||
|
||||
setConfigResponse:
|
||||
type: object
|
||||
properties:
|
||||
|
||||
Reference in New Issue
Block a user