Added delete governance bypass option when deleting file versions (#2536)

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
This commit is contained in:
Alex
2023-01-03 12:35:37 -06:00
committed by GitHub
parent 25e486ef18
commit 255e3d14d0
15 changed files with 364 additions and 49 deletions

View File

@@ -61,6 +61,10 @@ type DeleteMultipleObjectsParams struct {
In: path
*/
BucketName string
/*
In: query
*/
Bypass *bool
/*
Required: true
In: body
@@ -89,6 +93,11 @@ func (o *DeleteMultipleObjectsParams) BindRequest(r *http.Request, route *middle
res = append(res, err)
}
qBypass, qhkBypass, _ := qs.GetOK("bypass")
if err := o.bindBypass(qBypass, qhkBypass, route.Formats); err != nil {
res = append(res, err)
}
if runtime.HasBody(r) {
defer r.Body.Close()
var body []*models.DeleteFile
@@ -160,3 +169,26 @@ func (o *DeleteMultipleObjectsParams) bindBucketName(rawData []string, hasKey bo
return nil
}
// bindBypass binds and validates parameter Bypass from query.
func (o *DeleteMultipleObjectsParams) bindBypass(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("bypass", "query", "bool", raw)
}
o.Bypass = &value
return nil
}

View File

@@ -36,6 +36,7 @@ type DeleteMultipleObjectsURL struct {
BucketName string
AllVersions *bool
Bypass *bool
_basePath string
// avoid unkeyed usage
@@ -86,6 +87,14 @@ func (o *DeleteMultipleObjectsURL) Build() (*url.URL, error) {
qs.Set("all_versions", allVersionsQ)
}
var bypassQ string
if o.Bypass != nil {
bypassQ = swag.FormatBool(*o.Bypass)
}
if bypassQ != "" {
qs.Set("bypass", bypassQ)
}
_result.RawQuery = qs.Encode()
return &_result, nil

View File

@@ -62,6 +62,10 @@ type DeleteObjectParams struct {
/*
In: query
*/
Bypass *bool
/*
In: query
*/
NonCurrentVersions *bool
/*
Required: true
@@ -99,6 +103,11 @@ func (o *DeleteObjectParams) BindRequest(r *http.Request, route *middleware.Matc
res = append(res, err)
}
qBypass, qhkBypass, _ := qs.GetOK("bypass")
if err := o.bindBypass(qBypass, qhkBypass, route.Formats); err != nil {
res = append(res, err)
}
qNonCurrentVersions, qhkNonCurrentVersions, _ := qs.GetOK("non_current_versions")
if err := o.bindNonCurrentVersions(qNonCurrentVersions, qhkNonCurrentVersions, route.Formats); err != nil {
res = append(res, err)
@@ -161,6 +170,29 @@ func (o *DeleteObjectParams) bindBucketName(rawData []string, hasKey bool, forma
return nil
}
// bindBypass binds and validates parameter Bypass from query.
func (o *DeleteObjectParams) bindBypass(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("bypass", "query", "bool", raw)
}
o.Bypass = &value
return nil
}
// bindNonCurrentVersions binds and validates parameter NonCurrentVersions from query.
func (o *DeleteObjectParams) bindNonCurrentVersions(rawData []string, hasKey bool, formats strfmt.Registry) error {
var raw string

View File

@@ -36,6 +36,7 @@ type DeleteObjectURL struct {
BucketName string
AllVersions *bool
Bypass *bool
NonCurrentVersions *bool
Path string
Recursive *bool
@@ -90,6 +91,14 @@ func (o *DeleteObjectURL) Build() (*url.URL, error) {
qs.Set("all_versions", allVersionsQ)
}
var bypassQ string
if o.Bypass != nil {
bypassQ = swag.FormatBool(*o.Bypass)
}
if bypassQ != "" {
qs.Set("bypass", bypassQ)
}
var nonCurrentVersionsQ string
if o.NonCurrentVersions != nil {
nonCurrentVersionsQ = swag.FormatBool(*o.NonCurrentVersions)