Added VersionID support to Metadata Details (#3332)

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
This commit is contained in:
Alex
2024-05-06 15:38:53 -06:00
committed by GitHub
parent 0557514cb4
commit aa161a5365
9 changed files with 67 additions and 7 deletions

View File

@@ -59,6 +59,10 @@ type GetObjectMetadataParams struct {
In: query
*/
Prefix string
/*
In: query
*/
VersionID *string
}
// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
@@ -81,6 +85,11 @@ func (o *GetObjectMetadataParams) BindRequest(r *http.Request, route *middleware
if err := o.bindPrefix(qPrefix, qhkPrefix, route.Formats); err != nil {
res = append(res, err)
}
qVersionID, qhkVersionID, _ := qs.GetOK("versionID")
if err := o.bindVersionID(qVersionID, qhkVersionID, route.Formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
@@ -121,3 +130,21 @@ func (o *GetObjectMetadataParams) bindPrefix(rawData []string, hasKey bool, form
return nil
}
// bindVersionID binds and validates parameter VersionID from query.
func (o *GetObjectMetadataParams) bindVersionID(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
}
o.VersionID = &raw
return nil
}

View File

@@ -33,7 +33,8 @@ import (
type GetObjectMetadataURL struct {
BucketName string
Prefix string
Prefix string
VersionID *string
_basePath string
// avoid unkeyed usage
@@ -81,6 +82,14 @@ func (o *GetObjectMetadataURL) Build() (*url.URL, error) {
qs.Set("prefix", prefixQ)
}
var versionIDQ string
if o.VersionID != nil {
versionIDQ = *o.VersionID
}
if versionIDQ != "" {
qs.Set("versionID", versionIDQ)
}
_result.RawQuery = qs.Encode()
return &_result, nil