Delete all versions (#1376)

* delete all versions

* style

Co-authored-by: Prakash Senthil Vel <23444145+prakashsvmx@users.noreply.github.com>
Co-authored-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
This commit is contained in:
adfost
2022-01-20 17:28:52 -08:00
committed by GitHub
parent d9531f9617
commit 3ba7b34b25
12 changed files with 211 additions and 16 deletions

View File

@@ -30,6 +30,7 @@ import (
"github.com/go-openapi/runtime"
"github.com/go-openapi/runtime/middleware"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
"github.com/minio/console/models"
)
@@ -51,6 +52,10 @@ type DeleteMultipleObjectsParams struct {
// HTTP Request Object
HTTPRequest *http.Request `json:"-"`
/*
In: query
*/
AllVersions *bool
/*
Required: true
In: path
@@ -72,6 +77,13 @@ func (o *DeleteMultipleObjectsParams) BindRequest(r *http.Request, route *middle
o.HTTPRequest = r
qs := runtime.Values(r.URL.Query())
qAllVersions, qhkAllVersions, _ := qs.GetOK("all_versions")
if err := o.bindAllVersions(qAllVersions, qhkAllVersions, route.Formats); err != nil {
res = append(res, err)
}
rBucketName, rhkBucketName, _ := route.Params.GetOK("bucket_name")
if err := o.bindBucketName(rBucketName, rhkBucketName, route.Formats); err != nil {
res = append(res, err)
@@ -112,6 +124,29 @@ func (o *DeleteMultipleObjectsParams) BindRequest(r *http.Request, route *middle
return nil
}
// bindAllVersions binds and validates parameter AllVersions from query.
func (o *DeleteMultipleObjectsParams) bindAllVersions(rawData []string, hasKey bool, formats strfmt.Registry) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
// Required: false
// AllowEmptyValue: false
if raw == "" { // empty values pass all other validations
return nil
}
value, err := swag.ConvertBool(raw)
if err != nil {
return errors.InvalidType("all_versions", "query", "bool", raw)
}
o.AllVersions = &value
return nil
}
// bindBucketName binds and validates parameter BucketName from path.
func (o *DeleteMultipleObjectsParams) bindBucketName(rawData []string, hasKey bool, formats strfmt.Registry) error {
var raw string

View File

@@ -27,12 +27,16 @@ import (
"net/url"
golangswaggerpaths "path"
"strings"
"github.com/go-openapi/swag"
)
// DeleteMultipleObjectsURL generates an URL for the delete multiple objects operation
type DeleteMultipleObjectsURL struct {
BucketName string
AllVersions *bool
_basePath string
// avoid unkeyed usage
_ struct{}
@@ -72,6 +76,18 @@ func (o *DeleteMultipleObjectsURL) Build() (*url.URL, error) {
}
_result.Path = golangswaggerpaths.Join(_basePath, _path)
qs := make(url.Values)
var allVersionsQ string
if o.AllVersions != nil {
allVersionsQ = swag.FormatBool(*o.AllVersions)
}
if allVersionsQ != "" {
qs.Set("all_versions", allVersionsQ)
}
_result.RawQuery = qs.Encode()
return &_result, nil
}

View File

@@ -50,6 +50,10 @@ type DeleteObjectParams struct {
// HTTP Request Object
HTTPRequest *http.Request `json:"-"`
/*
In: query
*/
AllVersions *bool
/*
Required: true
In: path
@@ -81,6 +85,11 @@ func (o *DeleteObjectParams) BindRequest(r *http.Request, route *middleware.Matc
qs := runtime.Values(r.URL.Query())
qAllVersions, qhkAllVersions, _ := qs.GetOK("all_versions")
if err := o.bindAllVersions(qAllVersions, qhkAllVersions, route.Formats); err != nil {
res = append(res, err)
}
rBucketName, rhkBucketName, _ := route.Params.GetOK("bucket_name")
if err := o.bindBucketName(rBucketName, rhkBucketName, route.Formats); err != nil {
res = append(res, err)
@@ -106,6 +115,29 @@ func (o *DeleteObjectParams) BindRequest(r *http.Request, route *middleware.Matc
return nil
}
// bindAllVersions binds and validates parameter AllVersions from query.
func (o *DeleteObjectParams) bindAllVersions(rawData []string, hasKey bool, formats strfmt.Registry) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
// Required: false
// AllowEmptyValue: false
if raw == "" { // empty values pass all other validations
return nil
}
value, err := swag.ConvertBool(raw)
if err != nil {
return errors.InvalidType("all_versions", "query", "bool", raw)
}
o.AllVersions = &value
return nil
}
// bindBucketName binds and validates parameter BucketName from path.
func (o *DeleteObjectParams) bindBucketName(rawData []string, hasKey bool, formats strfmt.Registry) error {
var raw string

View File

@@ -35,9 +35,10 @@ import (
type DeleteObjectURL struct {
BucketName string
Path string
Recursive *bool
VersionID *string
AllVersions *bool
Path string
Recursive *bool
VersionID *string
_basePath string
// avoid unkeyed usage
@@ -80,6 +81,14 @@ func (o *DeleteObjectURL) Build() (*url.URL, error) {
qs := make(url.Values)
var allVersionsQ string
if o.AllVersions != nil {
allVersionsQ = swag.FormatBool(*o.AllVersions)
}
if allVersionsQ != "" {
qs.Set("all_versions", allVersionsQ)
}
pathQ := o.Path
if pathQ != "" {
qs.Set("path", pathQ)