diff --git a/models/bucket_encryption_info_response.go b/models/bucket_encryption_info_response.go
deleted file mode 100644
index f4f5a581a0..0000000000
--- a/models/bucket_encryption_info_response.go
+++ /dev/null
@@ -1,129 +0,0 @@
-// Code generated by go-swagger; DO NOT EDIT.
-
-// This file is part of MinIO Console Server
-// Copyright (c) 2020 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 models
-
-// This file was generated by the swagger tool.
-// Editing this file might prove futile when you re-run the swagger generate command
-
-import (
- "github.com/go-openapi/errors"
- "github.com/go-openapi/strfmt"
- "github.com/go-openapi/swag"
-)
-
-// BucketEncryptionInfoResponse bucket encryption info response
-//
-// swagger:model bucketEncryptionInfoResponse
-type BucketEncryptionInfoResponse struct {
-
- // encryption
- Encryption *BucketEncryptionInfoResponseEncryption `json:"encryption,omitempty"`
-
- // op
- Op string `json:"op,omitempty"`
-
- // status
- Status string `json:"status,omitempty"`
-
- // url
- URL string `json:"url,omitempty"`
-}
-
-// Validate validates this bucket encryption info response
-func (m *BucketEncryptionInfoResponse) Validate(formats strfmt.Registry) error {
- var res []error
-
- if err := m.validateEncryption(formats); err != nil {
- res = append(res, err)
- }
-
- if len(res) > 0 {
- return errors.CompositeValidationError(res...)
- }
- return nil
-}
-
-func (m *BucketEncryptionInfoResponse) validateEncryption(formats strfmt.Registry) error {
-
- if swag.IsZero(m.Encryption) { // not required
- return nil
- }
-
- if m.Encryption != nil {
- if err := m.Encryption.Validate(formats); err != nil {
- if ve, ok := err.(*errors.Validation); ok {
- return ve.ValidateName("encryption")
- }
- return err
- }
- }
-
- return nil
-}
-
-// MarshalBinary interface implementation
-func (m *BucketEncryptionInfoResponse) MarshalBinary() ([]byte, error) {
- if m == nil {
- return nil, nil
- }
- return swag.WriteJSON(m)
-}
-
-// UnmarshalBinary interface implementation
-func (m *BucketEncryptionInfoResponse) UnmarshalBinary(b []byte) error {
- var res BucketEncryptionInfoResponse
- if err := swag.ReadJSON(b, &res); err != nil {
- return err
- }
- *m = res
- return nil
-}
-
-// BucketEncryptionInfoResponseEncryption bucket encryption info response encryption
-//
-// swagger:model BucketEncryptionInfoResponseEncryption
-type BucketEncryptionInfoResponseEncryption struct {
-
- // algorithm
- Algorithm string `json:"algorithm,omitempty"`
-}
-
-// Validate validates this bucket encryption info response encryption
-func (m *BucketEncryptionInfoResponseEncryption) Validate(formats strfmt.Registry) error {
- return nil
-}
-
-// MarshalBinary interface implementation
-func (m *BucketEncryptionInfoResponseEncryption) MarshalBinary() ([]byte, error) {
- if m == nil {
- return nil, nil
- }
- return swag.WriteJSON(m)
-}
-
-// UnmarshalBinary interface implementation
-func (m *BucketEncryptionInfoResponseEncryption) UnmarshalBinary(b []byte) error {
- var res BucketEncryptionInfoResponseEncryption
- if err := swag.ReadJSON(b, &res); err != nil {
- return err
- }
- *m = res
- return nil
-}
diff --git a/models/bucket_object.go b/models/bucket_object.go
index d30e5b4fe7..32172080ca 100644
--- a/models/bucket_object.go
+++ b/models/bucket_object.go
@@ -65,6 +65,9 @@ type BucketObject struct {
// size
Size int64 `json:"size,omitempty"`
+ // tags
+ Tags map[string]string `json:"tags,omitempty"`
+
// user tags
UserTags map[string]string `json:"user_tags,omitempty"`
diff --git a/models/put_object_tags_request.go b/models/put_object_tags_request.go
new file mode 100644
index 0000000000..7c4588a3a1
--- /dev/null
+++ b/models/put_object_tags_request.go
@@ -0,0 +1,60 @@
+// Code generated by go-swagger; DO NOT EDIT.
+
+// This file is part of MinIO Console Server
+// Copyright (c) 2020 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 models
+
+// This file was generated by the swagger tool.
+// Editing this file might prove futile when you re-run the swagger generate command
+
+import (
+ "github.com/go-openapi/strfmt"
+ "github.com/go-openapi/swag"
+)
+
+// PutObjectTagsRequest put object tags request
+//
+// swagger:model putObjectTagsRequest
+type PutObjectTagsRequest struct {
+
+ // tags
+ Tags map[string]string `json:"tags,omitempty"`
+}
+
+// Validate validates this put object tags request
+func (m *PutObjectTagsRequest) Validate(formats strfmt.Registry) error {
+ return nil
+}
+
+// MarshalBinary interface implementation
+func (m *PutObjectTagsRequest) MarshalBinary() ([]byte, error) {
+ if m == nil {
+ return nil, nil
+ }
+ return swag.WriteJSON(m)
+}
+
+// UnmarshalBinary interface implementation
+func (m *PutObjectTagsRequest) UnmarshalBinary(b []byte) error {
+ var res PutObjectTagsRequest
+ if err := swag.ReadJSON(b, &res); err != nil {
+ return err
+ }
+ *m = res
+ return nil
+}
diff --git a/restapi/client.go b/restapi/client.go
index 8fa4bf54f2..b88c9cb447 100644
--- a/restapi/client.go
+++ b/restapi/client.go
@@ -38,6 +38,7 @@ import (
"github.com/minio/minio-go/v7"
"github.com/minio/minio-go/v7/pkg/credentials"
"github.com/minio/minio-go/v7/pkg/notification"
+ "github.com/minio/minio-go/v7/pkg/tags"
)
func init() {
@@ -65,6 +66,8 @@ type MinioClient interface {
setBucketEncryption(ctx context.Context, bucketName string, config *sse.Configuration) error
removeBucketEncryption(ctx context.Context, bucketName string) error
getBucketEncryption(ctx context.Context, bucketName string) (*sse.Configuration, error)
+ putObjectTagging(ctx context.Context, bucketName, objectName string, otags *tags.Tags, opts minio.PutObjectTaggingOptions) error
+ getObjectTagging(ctx context.Context, bucketName, objectName string, opts minio.GetObjectTaggingOptions) (*tags.Tags, error)
}
// Interface implementation
@@ -75,7 +78,7 @@ type minioClient struct {
client *minio.Client
}
-// implements minio.ListBucketsWithContext(ctx)
+// implements minio.ListBuckets(ctx)
func (c minioClient) listBucketsWithContext(ctx context.Context) ([]minio.BucketInfo, error) {
return c.client.ListBuckets(ctx)
}
@@ -162,6 +165,14 @@ func (c minioClient) getBucketEncryption(ctx context.Context, bucketName string)
return c.client.GetBucketEncryption(ctx, bucketName)
}
+func (c minioClient) putObjectTagging(ctx context.Context, bucketName, objectName string, otags *tags.Tags, opts minio.PutObjectTaggingOptions) error {
+ return c.client.PutObjectTagging(ctx, bucketName, objectName, otags, opts)
+}
+
+func (c minioClient) getObjectTagging(ctx context.Context, bucketName, objectName string, opts minio.GetObjectTaggingOptions) (*tags.Tags, error) {
+ return c.client.GetObjectTagging(ctx, bucketName, objectName, opts)
+}
+
// MCClient interface with all functions to be implemented
// by mock when testing, it should include all mc/S3Client respective api calls
// that are used within this project.
diff --git a/restapi/embedded_spec.go b/restapi/embedded_spec.go
index 39919ea453..402ce684b1 100644
--- a/restapi/embedded_spec.go
+++ b/restapi/embedded_spec.go
@@ -708,6 +708,54 @@ func init() {
}
}
},
+ "/buckets/{bucket_name}/objects/tags": {
+ "put": {
+ "tags": [
+ "UserAPI"
+ ],
+ "summary": "Put Object's tags",
+ "operationId": "PutObjectTags",
+ "parameters": [
+ {
+ "type": "string",
+ "name": "bucket_name",
+ "in": "path",
+ "required": true
+ },
+ {
+ "type": "string",
+ "name": "prefix",
+ "in": "query",
+ "required": true
+ },
+ {
+ "type": "string",
+ "name": "version_id",
+ "in": "query",
+ "required": true
+ },
+ {
+ "name": "body",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/putObjectTagsRequest"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "A successful response."
+ },
+ "default": {
+ "description": "Generic error response.",
+ "schema": {
+ "$ref": "#/definitions/error"
+ }
+ }
+ }
+ }
+ },
"/buckets/{bucket_name}/objects/upload": {
"post": {
"consumes": [
@@ -2957,6 +3005,12 @@ func init() {
"type": "integer",
"format": "int64"
},
+ "tags": {
+ "type": "object",
+ "additionalProperties": {
+ "type": "string"
+ }
+ },
"user_tags": {
"type": "object",
"additionalProperties": {
@@ -4089,6 +4143,16 @@ func init() {
}
}
},
+ "putObjectTagsRequest": {
+ "type": "object",
+ "properties": {
+ "tags": {
+ "additionalProperties": {
+ "type": "string"
+ }
+ }
+ }
+ },
"remoteBucket": {
"type": "object",
"required": [
@@ -5513,6 +5577,54 @@ func init() {
}
}
},
+ "/buckets/{bucket_name}/objects/tags": {
+ "put": {
+ "tags": [
+ "UserAPI"
+ ],
+ "summary": "Put Object's tags",
+ "operationId": "PutObjectTags",
+ "parameters": [
+ {
+ "type": "string",
+ "name": "bucket_name",
+ "in": "path",
+ "required": true
+ },
+ {
+ "type": "string",
+ "name": "prefix",
+ "in": "query",
+ "required": true
+ },
+ {
+ "type": "string",
+ "name": "version_id",
+ "in": "query",
+ "required": true
+ },
+ {
+ "name": "body",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/putObjectTagsRequest"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "A successful response."
+ },
+ "default": {
+ "description": "Generic error response.",
+ "schema": {
+ "$ref": "#/definitions/error"
+ }
+ }
+ }
+ }
+ },
"/buckets/{bucket_name}/objects/upload": {
"post": {
"consumes": [
@@ -8285,6 +8397,12 @@ func init() {
"type": "integer",
"format": "int64"
},
+ "tags": {
+ "type": "object",
+ "additionalProperties": {
+ "type": "string"
+ }
+ },
"user_tags": {
"type": "object",
"additionalProperties": {
@@ -9351,6 +9469,16 @@ func init() {
}
}
},
+ "putObjectTagsRequest": {
+ "type": "object",
+ "properties": {
+ "tags": {
+ "additionalProperties": {
+ "type": "string"
+ }
+ }
+ }
+ },
"remoteBucket": {
"type": "object",
"required": [
diff --git a/restapi/operations/console_api.go b/restapi/operations/console_api.go
index 37940da323..b559ff32ff 100644
--- a/restapi/operations/console_api.go
+++ b/restapi/operations/console_api.go
@@ -238,6 +238,9 @@ func NewConsoleAPI(spec *loads.Document) *ConsoleAPI {
UserAPIPutObjectRetentionHandler: user_api.PutObjectRetentionHandlerFunc(func(params user_api.PutObjectRetentionParams, principal *models.Principal) middleware.Responder {
return middleware.NotImplemented("operation user_api.PutObjectRetention has not yet been implemented")
}),
+ UserAPIPutObjectTagsHandler: user_api.PutObjectTagsHandlerFunc(func(params user_api.PutObjectTagsParams, principal *models.Principal) middleware.Responder {
+ return middleware.NotImplemented("operation user_api.PutObjectTags has not yet been implemented")
+ }),
UserAPIRemoteBucketDetailsHandler: user_api.RemoteBucketDetailsHandlerFunc(func(params user_api.RemoteBucketDetailsParams, principal *models.Principal) middleware.Responder {
return middleware.NotImplemented("operation user_api.RemoteBucketDetails has not yet been implemented")
}),
@@ -466,6 +469,8 @@ type ConsoleAPI struct {
UserAPIPutObjectLegalHoldHandler user_api.PutObjectLegalHoldHandler
// UserAPIPutObjectRetentionHandler sets the operation handler for the put object retention operation
UserAPIPutObjectRetentionHandler user_api.PutObjectRetentionHandler
+ // UserAPIPutObjectTagsHandler sets the operation handler for the put object tags operation
+ UserAPIPutObjectTagsHandler user_api.PutObjectTagsHandler
// UserAPIRemoteBucketDetailsHandler sets the operation handler for the remote bucket details operation
UserAPIRemoteBucketDetailsHandler user_api.RemoteBucketDetailsHandler
// AdminAPIRemoveGroupHandler sets the operation handler for the remove group operation
@@ -756,6 +761,9 @@ func (o *ConsoleAPI) Validate() error {
if o.UserAPIPutObjectRetentionHandler == nil {
unregistered = append(unregistered, "user_api.PutObjectRetentionHandler")
}
+ if o.UserAPIPutObjectTagsHandler == nil {
+ unregistered = append(unregistered, "user_api.PutObjectTagsHandler")
+ }
if o.UserAPIRemoteBucketDetailsHandler == nil {
unregistered = append(unregistered, "user_api.RemoteBucketDetailsHandler")
}
@@ -1150,6 +1158,10 @@ func (o *ConsoleAPI) initHandlerCache() {
o.handlers["PUT"] = make(map[string]http.Handler)
}
o.handlers["PUT"]["/buckets/{bucket_name}/objects/retention"] = user_api.NewPutObjectRetention(o.context, o.UserAPIPutObjectRetentionHandler)
+ if o.handlers["PUT"] == nil {
+ o.handlers["PUT"] = make(map[string]http.Handler)
+ }
+ o.handlers["PUT"]["/buckets/{bucket_name}/objects/tags"] = user_api.NewPutObjectTags(o.context, o.UserAPIPutObjectTagsHandler)
if o.handlers["GET"] == nil {
o.handlers["GET"] = make(map[string]http.Handler)
}
diff --git a/restapi/operations/user_api/put_object_tags.go b/restapi/operations/user_api/put_object_tags.go
new file mode 100644
index 0000000000..e41ac18141
--- /dev/null
+++ b/restapi/operations/user_api/put_object_tags.go
@@ -0,0 +1,90 @@
+// Code generated by go-swagger; DO NOT EDIT.
+
+// This file is part of MinIO Console Server
+// Copyright (c) 2020 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"
+)
+
+// PutObjectTagsHandlerFunc turns a function with the right signature into a put object tags handler
+type PutObjectTagsHandlerFunc func(PutObjectTagsParams, *models.Principal) middleware.Responder
+
+// Handle executing the request and returning a response
+func (fn PutObjectTagsHandlerFunc) Handle(params PutObjectTagsParams, principal *models.Principal) middleware.Responder {
+ return fn(params, principal)
+}
+
+// PutObjectTagsHandler interface for that can handle valid put object tags params
+type PutObjectTagsHandler interface {
+ Handle(PutObjectTagsParams, *models.Principal) middleware.Responder
+}
+
+// NewPutObjectTags creates a new http.Handler for the put object tags operation
+func NewPutObjectTags(ctx *middleware.Context, handler PutObjectTagsHandler) *PutObjectTags {
+ return &PutObjectTags{Context: ctx, Handler: handler}
+}
+
+/*PutObjectTags swagger:route PUT /buckets/{bucket_name}/objects/tags UserAPI putObjectTags
+
+Put Object's tags
+
+*/
+type PutObjectTags struct {
+ Context *middleware.Context
+ Handler PutObjectTagsHandler
+}
+
+func (o *PutObjectTags) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
+ route, rCtx, _ := o.Context.RouteInfo(r)
+ if rCtx != nil {
+ r = rCtx
+ }
+ var Params = NewPutObjectTagsParams()
+
+ 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/put_object_tags_parameters.go b/restapi/operations/user_api/put_object_tags_parameters.go
new file mode 100644
index 0000000000..7932db3058
--- /dev/null
+++ b/restapi/operations/user_api/put_object_tags_parameters.go
@@ -0,0 +1,185 @@
+// Code generated by go-swagger; DO NOT EDIT.
+
+// This file is part of MinIO Console Server
+// Copyright (c) 2020 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 (
+ "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"
+)
+
+// NewPutObjectTagsParams creates a new PutObjectTagsParams object
+// no default values defined in spec.
+func NewPutObjectTagsParams() PutObjectTagsParams {
+
+ return PutObjectTagsParams{}
+}
+
+// PutObjectTagsParams contains all the bound params for the put object tags operation
+// typically these are obtained from a http.Request
+//
+// swagger:parameters PutObjectTags
+type PutObjectTagsParams struct {
+
+ // HTTP Request Object
+ HTTPRequest *http.Request `json:"-"`
+
+ /*
+ Required: true
+ In: body
+ */
+ Body *models.PutObjectTagsRequest
+ /*
+ Required: true
+ In: path
+ */
+ BucketName string
+ /*
+ Required: true
+ In: query
+ */
+ Prefix string
+ /*
+ Required: true
+ In: query
+ */
+ VersionID 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 NewPutObjectTagsParams() beforehand.
+func (o *PutObjectTagsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
+ var res []error
+
+ o.HTTPRequest = r
+
+ qs := runtime.Values(r.URL.Query())
+
+ if runtime.HasBody(r) {
+ defer r.Body.Close()
+ var body models.PutObjectTagsRequest
+ if err := route.Consumer.Consume(r.Body, &body); err != nil {
+ if err == io.EOF {
+ res = append(res, errors.Required("body", "body", ""))
+ } else {
+ res = append(res, errors.NewParseError("body", "body", "", err))
+ }
+ } else {
+ // validate body object
+ if err := body.Validate(route.Formats); err != nil {
+ res = append(res, err)
+ }
+
+ if len(res) == 0 {
+ o.Body = &body
+ }
+ }
+ } else {
+ res = append(res, errors.Required("body", "body", ""))
+ }
+ rBucketName, rhkBucketName, _ := route.Params.GetOK("bucket_name")
+ if err := o.bindBucketName(rBucketName, rhkBucketName, route.Formats); err != nil {
+ res = append(res, err)
+ }
+
+ qPrefix, qhkPrefix, _ := qs.GetOK("prefix")
+ if err := o.bindPrefix(qPrefix, qhkPrefix, route.Formats); err != nil {
+ res = append(res, err)
+ }
+
+ qVersionID, qhkVersionID, _ := qs.GetOK("version_id")
+ if err := o.bindVersionID(qVersionID, qhkVersionID, 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 *PutObjectTagsParams) 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
+}
+
+// bindPrefix binds and validates parameter Prefix from query.
+func (o *PutObjectTagsParams) bindPrefix(rawData []string, hasKey bool, formats strfmt.Registry) error {
+ if !hasKey {
+ return errors.Required("prefix", "query", rawData)
+ }
+ var raw string
+ if len(rawData) > 0 {
+ raw = rawData[len(rawData)-1]
+ }
+
+ // Required: true
+ // AllowEmptyValue: false
+ if err := validate.RequiredString("prefix", "query", raw); err != nil {
+ return err
+ }
+
+ o.Prefix = raw
+
+ return nil
+}
+
+// bindVersionID binds and validates parameter VersionID from query.
+func (o *PutObjectTagsParams) bindVersionID(rawData []string, hasKey bool, formats strfmt.Registry) error {
+ if !hasKey {
+ return errors.Required("version_id", "query", rawData)
+ }
+ var raw string
+ if len(rawData) > 0 {
+ raw = rawData[len(rawData)-1]
+ }
+
+ // Required: true
+ // AllowEmptyValue: false
+ if err := validate.RequiredString("version_id", "query", raw); err != nil {
+ return err
+ }
+
+ o.VersionID = raw
+
+ return nil
+}
diff --git a/restapi/operations/user_api/put_object_tags_responses.go b/restapi/operations/user_api/put_object_tags_responses.go
new file mode 100644
index 0000000000..7d66de788c
--- /dev/null
+++ b/restapi/operations/user_api/put_object_tags_responses.go
@@ -0,0 +1,113 @@
+// Code generated by go-swagger; DO NOT EDIT.
+
+// This file is part of MinIO Console Server
+// Copyright (c) 2020 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"
+)
+
+// PutObjectTagsOKCode is the HTTP code returned for type PutObjectTagsOK
+const PutObjectTagsOKCode int = 200
+
+/*PutObjectTagsOK A successful response.
+
+swagger:response putObjectTagsOK
+*/
+type PutObjectTagsOK struct {
+}
+
+// NewPutObjectTagsOK creates PutObjectTagsOK with default headers values
+func NewPutObjectTagsOK() *PutObjectTagsOK {
+
+ return &PutObjectTagsOK{}
+}
+
+// WriteResponse to the client
+func (o *PutObjectTagsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
+
+ rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses
+
+ rw.WriteHeader(200)
+}
+
+/*PutObjectTagsDefault Generic error response.
+
+swagger:response putObjectTagsDefault
+*/
+type PutObjectTagsDefault struct {
+ _statusCode int
+
+ /*
+ In: Body
+ */
+ Payload *models.Error `json:"body,omitempty"`
+}
+
+// NewPutObjectTagsDefault creates PutObjectTagsDefault with default headers values
+func NewPutObjectTagsDefault(code int) *PutObjectTagsDefault {
+ if code <= 0 {
+ code = 500
+ }
+
+ return &PutObjectTagsDefault{
+ _statusCode: code,
+ }
+}
+
+// WithStatusCode adds the status to the put object tags default response
+func (o *PutObjectTagsDefault) WithStatusCode(code int) *PutObjectTagsDefault {
+ o._statusCode = code
+ return o
+}
+
+// SetStatusCode sets the status to the put object tags default response
+func (o *PutObjectTagsDefault) SetStatusCode(code int) {
+ o._statusCode = code
+}
+
+// WithPayload adds the payload to the put object tags default response
+func (o *PutObjectTagsDefault) WithPayload(payload *models.Error) *PutObjectTagsDefault {
+ o.Payload = payload
+ return o
+}
+
+// SetPayload sets the payload to the put object tags default response
+func (o *PutObjectTagsDefault) SetPayload(payload *models.Error) {
+ o.Payload = payload
+}
+
+// WriteResponse to the client
+func (o *PutObjectTagsDefault) 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/put_object_tags_urlbuilder.go b/restapi/operations/user_api/put_object_tags_urlbuilder.go
new file mode 100644
index 0000000000..3f620d1323
--- /dev/null
+++ b/restapi/operations/user_api/put_object_tags_urlbuilder.go
@@ -0,0 +1,133 @@
+// Code generated by go-swagger; DO NOT EDIT.
+
+// This file is part of MinIO Console Server
+// Copyright (c) 2020 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"
+)
+
+// PutObjectTagsURL generates an URL for the put object tags operation
+type PutObjectTagsURL struct {
+ BucketName string
+
+ Prefix string
+ VersionID 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 *PutObjectTagsURL) WithBasePath(bp string) *PutObjectTagsURL {
+ 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 *PutObjectTagsURL) SetBasePath(bp string) {
+ o._basePath = bp
+}
+
+// Build a url path and query string
+func (o *PutObjectTagsURL) Build() (*url.URL, error) {
+ var _result url.URL
+
+ var _path = "/buckets/{bucket_name}/objects/tags"
+
+ bucketName := o.BucketName
+ if bucketName != "" {
+ _path = strings.Replace(_path, "{bucket_name}", bucketName, -1)
+ } else {
+ return nil, errors.New("bucketName is required on PutObjectTagsURL")
+ }
+
+ _basePath := o._basePath
+ if _basePath == "" {
+ _basePath = "/api/v1"
+ }
+ _result.Path = golangswaggerpaths.Join(_basePath, _path)
+
+ qs := make(url.Values)
+
+ prefixQ := o.Prefix
+ if prefixQ != "" {
+ qs.Set("prefix", prefixQ)
+ }
+
+ versionIDQ := o.VersionID
+ if versionIDQ != "" {
+ qs.Set("version_id", versionIDQ)
+ }
+
+ _result.RawQuery = qs.Encode()
+
+ return &_result, nil
+}
+
+// Must is a helper function to panic when the url builder returns an error
+func (o *PutObjectTagsURL) 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 *PutObjectTagsURL) String() string {
+ return o.Must(o.Build()).String()
+}
+
+// BuildFull builds a full url with scheme, host, path and query string
+func (o *PutObjectTagsURL) BuildFull(scheme, host string) (*url.URL, error) {
+ if scheme == "" {
+ return nil, errors.New("scheme is required for a full url on PutObjectTagsURL")
+ }
+ if host == "" {
+ return nil, errors.New("host is required for a full url on PutObjectTagsURL")
+ }
+
+ 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 *PutObjectTagsURL) StringFull(scheme, host string) string {
+ return o.Must(o.BuildFull(scheme, host)).String()
+}
diff --git a/restapi/user_objects.go b/restapi/user_objects.go
index 2e9243e50e..ce8d891420 100644
--- a/restapi/user_objects.go
+++ b/restapi/user_objects.go
@@ -37,6 +37,7 @@ import (
mc "github.com/minio/mc/cmd"
"github.com/minio/mc/pkg/probe"
"github.com/minio/minio-go/v7"
+ "github.com/minio/minio-go/v7/pkg/tags"
)
// enum types
@@ -106,6 +107,12 @@ func registerObjectsHandlers(api *operations.ConsoleAPI) {
}
return user_api.NewPutObjectRetentionOK()
})
+ api.UserAPIPutObjectTagsHandler = user_api.PutObjectTagsHandlerFunc(func(params user_api.PutObjectTagsParams, session *models.Principal) middleware.Responder {
+ if err := getPutObjectTagsResponse(session, params); err != nil {
+ return user_api.NewPutObjectTagsDefault(int(err.Code)).WithPayload(err)
+ }
+ return user_api.NewPutObjectTagsOK()
+ })
}
// getListObjectsResponse returns a list of objects
@@ -165,7 +172,8 @@ func listBucketObjects(ctx context.Context, client MinioClient, bucketName strin
IsDeleteMarker: lsObj.IsDeleteMarker,
UserTags: lsObj.UserTags,
}
- if !lsObj.IsDeleteMarker {
+ // only if single object with or without versions; get legalhold, retention and tags
+ if !lsObj.IsDeleteMarker && prefix != "" && !strings.HasSuffix(prefix, "/") {
// Add Legal Hold Status if available
legalHoldStatus, err := client.getObjectLegalHold(ctx, bucketName, lsObj.Key, minio.GetObjectLegalHoldOptions{VersionID: lsObj.VersionID})
if err != nil {
@@ -192,6 +200,12 @@ func listBucketObjects(ctx context.Context, client MinioClient, bucketName strin
obj.RetentionUntilDate = date.String()
}
}
+ tags, err := client.getObjectTagging(ctx, bucketName, lsObj.Key, minio.GetObjectTaggingOptions{VersionID: lsObj.VersionID})
+ if err != nil {
+ log.Printf("error getting object tags for %s : %s", lsObj.VersionID, err)
+ } else {
+ obj.Tags = tags.ToMap()
+ }
}
objects = append(objects, obj)
}
@@ -494,6 +508,34 @@ func setObjectRetention(ctx context.Context, client MinioClient, bucketName, pre
return client.putObjectRetention(ctx, bucketName, prefix, opts)
}
+func getPutObjectTagsResponse(session *models.Principal, params user_api.PutObjectTagsParams) *models.Error {
+ ctx, cancel := context.WithTimeout(context.Background(), time.Second*20)
+ defer cancel()
+ mClient, err := newMinioClient(session)
+ if err != nil {
+ return prepareError(err)
+ }
+ // create a minioClient interface implementation
+ // defining the client to be used
+ minioClient := minioClient{client: mClient}
+ err = putObjectTags(ctx, minioClient, params.BucketName, params.Prefix, params.VersionID, params.Body.Tags)
+ if err != nil {
+ return prepareError(err)
+ }
+ return nil
+}
+
+func putObjectTags(ctx context.Context, client MinioClient, bucketName, prefix, versionID string, tagMap map[string]string) error {
+ opt := minio.PutObjectTaggingOptions{
+ VersionID: versionID,
+ }
+ otags, err := tags.MapToObjectTags(tagMap)
+ if err != nil {
+ return err
+ }
+ return client.putObjectTagging(ctx, bucketName, prefix, otags, opt)
+}
+
// newClientURL returns an abstracted URL for filesystems and object storage.
func newClientURL(urlStr string) *mc.ClientURL {
scheme, rest := getScheme(urlStr)
diff --git a/restapi/user_objects_test.go b/restapi/user_objects_test.go
index cf750fad0c..08ec96a7bb 100644
--- a/restapi/user_objects_test.go
+++ b/restapi/user_objects_test.go
@@ -31,6 +31,7 @@ import (
mc "github.com/minio/mc/cmd"
"github.com/minio/mc/pkg/probe"
"github.com/minio/minio-go/v7"
+ "github.com/minio/minio-go/v7/pkg/tags"
"github.com/stretchr/testify/assert"
)
@@ -40,6 +41,8 @@ var minioGetObjectRetentionMock func(ctx context.Context, bucketName, objectName
var minioPutObjectMock func(ctx context.Context, bucketName, objectName string, reader io.Reader, objectSize int64, opts minio.PutObjectOptions) (info minio.UploadInfo, err error)
var minioPutObjectLegalHoldMock func(ctx context.Context, bucketName, objectName string, opts minio.PutObjectLegalHoldOptions) error
var miinoPutObjectRetentionMock func(ctx context.Context, bucketName, objectName string, opts minio.PutObjectRetentionOptions) error
+var minioGetObjectTaggingMock func(ctx context.Context, bucketName, objectName string, opts minio.GetObjectTaggingOptions) (*tags.Tags, error)
+var minioPutObjectTaggingMock func(ctx context.Context, bucketName, objectName string, otags *tags.Tags, opts minio.PutObjectTaggingOptions) error
var mcListMock func(ctx context.Context, opts mc.ListOptions) <-chan *mc.ClientContent
var mcRemoveMock func(ctx context.Context, isIncomplete, isRemoveBucket, isBypass bool, contentCh <-chan *mc.ClientContent) <-chan *probe.Error
@@ -70,6 +73,14 @@ func (ac minioClientMock) putObjectRetention(ctx context.Context, bucketName, ob
return miinoPutObjectRetentionMock(ctx, bucketName, objectName, opts)
}
+func (ac minioClientMock) getObjectTagging(ctx context.Context, bucketName, objectName string, opts minio.GetObjectTaggingOptions) (*tags.Tags, error) {
+ return minioGetObjectTaggingMock(ctx, bucketName, objectName, opts)
+}
+
+func (ac minioClientMock) putObjectTagging(ctx context.Context, bucketName, objectName string, otags *tags.Tags, opts minio.PutObjectTaggingOptions) error {
+ return minioPutObjectTaggingMock(ctx, bucketName, objectName, otags, opts)
+}
+
// mock functions for s3ClientMock
func (c s3ClientMock) list(ctx context.Context, opts mc.ListOptions) <-chan *mc.ClientContent {
return mcListMock(ctx, opts)
@@ -92,13 +103,14 @@ func Test_listObjects(t *testing.T) {
tretention := time.Now()
minClient := minioClientMock{}
type args struct {
- bucketName string
- prefix string
- recursive bool
- withVersions bool
- listFunc func(ctx context.Context, bucket string, opts minio.ListObjectsOptions) <-chan minio.ObjectInfo
- objectLegalHoldFunc func(ctx context.Context, bucketName, objectName string, opts minio.GetObjectLegalHoldOptions) (status *minio.LegalHoldStatus, err error)
- objectRetentionFunc func(ctx context.Context, bucketName, objectName, versionID string) (mode *minio.RetentionMode, retainUntilDate *time.Time, err error)
+ bucketName string
+ prefix string
+ recursive bool
+ withVersions bool
+ listFunc func(ctx context.Context, bucket string, opts minio.ListObjectsOptions) <-chan minio.ObjectInfo
+ objectLegalHoldFunc func(ctx context.Context, bucketName, objectName string, opts minio.GetObjectLegalHoldOptions) (status *minio.LegalHoldStatus, err error)
+ objectRetentionFunc func(ctx context.Context, bucketName, objectName, versionID string) (mode *minio.RetentionMode, retainUntilDate *time.Time, err error)
+ objectGetTaggingFunc func(ctx context.Context, bucketName, objectName string, opts minio.GetObjectTaggingOptions) (*tags.Tags, error)
}
tests := []struct {
test string
@@ -144,6 +156,16 @@ func Test_listObjects(t *testing.T) {
m := minio.Governance
return &m, &tretention, nil
},
+ objectGetTaggingFunc: func(ctx context.Context, bucketName, objectName string, opts minio.GetObjectTaggingOptions) (*tags.Tags, error) {
+ tagMap := map[string]string{
+ "tag1": "value1",
+ }
+ otags, err := tags.MapToObjectTags(tagMap)
+ if err != nil {
+ return nil, err
+ }
+ return otags, nil
+ },
},
expectedResp: []*models.BucketObject{
&models.BucketObject{
@@ -154,6 +176,9 @@ func Test_listObjects(t *testing.T) {
LegalHoldStatus: string(minio.LegalHoldEnabled),
RetentionMode: string(minio.Governance),
RetentionUntilDate: tretention.String(),
+ Tags: map[string]string{
+ "tag1": "value1",
+ },
}, &models.BucketObject{
Name: "obj2",
LastModified: t1.String(),
@@ -162,6 +187,9 @@ func Test_listObjects(t *testing.T) {
LegalHoldStatus: string(minio.LegalHoldEnabled),
RetentionMode: string(minio.Governance),
RetentionUntilDate: tretention.String(),
+ Tags: map[string]string{
+ "tag1": "value1",
+ },
},
},
wantError: nil,
@@ -186,6 +214,16 @@ func Test_listObjects(t *testing.T) {
m := minio.Governance
return &m, &tretention, nil
},
+ objectGetTaggingFunc: func(ctx context.Context, bucketName, objectName string, opts minio.GetObjectTaggingOptions) (*tags.Tags, error) {
+ tagMap := map[string]string{
+ "tag1": "value1",
+ }
+ otags, err := tags.MapToObjectTags(tagMap)
+ if err != nil {
+ return nil, err
+ }
+ return otags, nil
+ },
},
expectedResp: nil,
wantError: nil,
@@ -225,13 +263,23 @@ func Test_listObjects(t *testing.T) {
m := minio.Governance
return &m, &tretention, nil
},
+ objectGetTaggingFunc: func(ctx context.Context, bucketName, objectName string, opts minio.GetObjectTaggingOptions) (*tags.Tags, error) {
+ tagMap := map[string]string{
+ "tag1": "value1",
+ }
+ otags, err := tags.MapToObjectTags(tagMap)
+ if err != nil {
+ return nil, err
+ }
+ return otags, nil
+ },
},
expectedResp: nil,
wantError: errors.New("error here"),
},
{
// Description: deleted objects with IsDeleteMarker
- // should not call legsalhold or retention funcs
+ // should not call legsalhold, tag or retention funcs
test: "Return deleted objects",
args: args{
bucketName: "bucket1",
@@ -270,6 +318,16 @@ func Test_listObjects(t *testing.T) {
m := minio.Governance
return &m, &tretention, nil
},
+ objectGetTaggingFunc: func(ctx context.Context, bucketName, objectName string, opts minio.GetObjectTaggingOptions) (*tags.Tags, error) {
+ tagMap := map[string]string{
+ "tag1": "value1",
+ }
+ otags, err := tags.MapToObjectTags(tagMap)
+ if err != nil {
+ return nil, err
+ }
+ return otags, nil
+ },
},
expectedResp: []*models.BucketObject{
&models.BucketObject{
@@ -286,13 +344,16 @@ func Test_listObjects(t *testing.T) {
LegalHoldStatus: string(minio.LegalHoldEnabled),
RetentionMode: string(minio.Governance),
RetentionUntilDate: tretention.String(),
+ Tags: map[string]string{
+ "tag1": "value1",
+ },
},
},
wantError: nil,
},
{
// Description: deleted objects with
- // error on legalhold and retention funcs
+ // error on legalhold, tags or retention funcs
// should only log errors
test: "Return deleted objects, error on legalhold and retention",
args: args{
@@ -323,6 +384,9 @@ func Test_listObjects(t *testing.T) {
objectRetentionFunc: func(ctx context.Context, bucketName, objectName, versionID string) (mode *minio.RetentionMode, retainUntilDate *time.Time, err error) {
return nil, nil, errors.New("error retention")
},
+ objectGetTaggingFunc: func(ctx context.Context, bucketName, objectName string, opts minio.GetObjectTaggingOptions) (*tags.Tags, error) {
+ return nil, errors.New("error get tags")
+ },
},
expectedResp: []*models.BucketObject{
&models.BucketObject{
@@ -335,13 +399,13 @@ func Test_listObjects(t *testing.T) {
wantError: nil,
},
{
- // Description: deleted objects with
- // error on legalhold and retention funcs
- // should only log errors
- test: "Return deleted objects, error on legalhold and retention",
+ // Description: if the prefix end with a `/` meaning it is a folder,
+ // it should not fetch retention, legalhold nor tags for each object
+ // it should only fetch it for single objects with or without versionID
+ test: "Don't get object retention/legalhold/tags for folders",
args: args{
bucketName: "bucket1",
- prefix: "prefix",
+ prefix: "prefix/folder/",
recursive: true,
withVersions: false,
listFunc: func(ctx context.Context, bucket string, opts minio.ListObjectsOptions) <-chan minio.ObjectInfo {
@@ -355,6 +419,12 @@ func Test_listObjects(t *testing.T) {
Size: int64(1024),
ContentType: "content",
},
+ minio.ObjectInfo{
+ Key: "obj2",
+ LastModified: t1,
+ Size: int64(512),
+ ContentType: "content",
+ },
} {
objectStatCh <- bucket
}
@@ -362,10 +432,89 @@ func Test_listObjects(t *testing.T) {
return objectStatCh
},
objectLegalHoldFunc: func(ctx context.Context, bucketName, objectName string, opts minio.GetObjectLegalHoldOptions) (status *minio.LegalHoldStatus, err error) {
- return nil, errors.New("error legal")
+ s := minio.LegalHoldEnabled
+ return &s, nil
},
objectRetentionFunc: func(ctx context.Context, bucketName, objectName, versionID string) (mode *minio.RetentionMode, retainUntilDate *time.Time, err error) {
- return nil, nil, errors.New("error retention")
+ m := minio.Governance
+ return &m, &tretention, nil
+ },
+ objectGetTaggingFunc: func(ctx context.Context, bucketName, objectName string, opts minio.GetObjectTaggingOptions) (*tags.Tags, error) {
+ tagMap := map[string]string{
+ "tag1": "value1",
+ }
+ otags, err := tags.MapToObjectTags(tagMap)
+ if err != nil {
+ return nil, err
+ }
+ return otags, nil
+ },
+ },
+ expectedResp: []*models.BucketObject{
+ &models.BucketObject{
+ Name: "obj1",
+ LastModified: t1.String(),
+ Size: int64(1024),
+ ContentType: "content",
+ }, &models.BucketObject{
+ Name: "obj2",
+ LastModified: t1.String(),
+ Size: int64(512),
+ ContentType: "content",
+ },
+ },
+ wantError: nil,
+ },
+ {
+ // Description: if the prefix is "" meaning it is all contents within a bucket,
+ // it should not fetch retention, legalhold nor tags for each object
+ // it should only fetch it for single objects with or without versionID
+ test: "Don't get object retention/legalhold/tags for empty prefix",
+ args: args{
+ bucketName: "bucket1",
+ prefix: "",
+ recursive: true,
+ withVersions: false,
+ listFunc: func(ctx context.Context, bucket string, opts minio.ListObjectsOptions) <-chan minio.ObjectInfo {
+ objectStatCh := make(chan minio.ObjectInfo, 1)
+ go func(objectStatCh chan<- minio.ObjectInfo) {
+ defer close(objectStatCh)
+ for _, bucket := range []minio.ObjectInfo{
+ minio.ObjectInfo{
+ Key: "obj1",
+ LastModified: t1,
+ Size: int64(1024),
+ ContentType: "content",
+ },
+ minio.ObjectInfo{
+ Key: "obj2",
+ LastModified: t1,
+ Size: int64(512),
+ ContentType: "content",
+ },
+ } {
+ objectStatCh <- bucket
+ }
+ }(objectStatCh)
+ return objectStatCh
+ },
+ objectLegalHoldFunc: func(ctx context.Context, bucketName, objectName string, opts minio.GetObjectLegalHoldOptions) (status *minio.LegalHoldStatus, err error) {
+ s := minio.LegalHoldEnabled
+ return &s, nil
+ },
+ objectRetentionFunc: func(ctx context.Context, bucketName, objectName, versionID string) (mode *minio.RetentionMode, retainUntilDate *time.Time, err error) {
+ m := minio.Governance
+ return &m, &tretention, nil
+ },
+ objectGetTaggingFunc: func(ctx context.Context, bucketName, objectName string, opts minio.GetObjectTaggingOptions) (*tags.Tags, error) {
+ tagMap := map[string]string{
+ "tag1": "value1",
+ }
+ otags, err := tags.MapToObjectTags(tagMap)
+ if err != nil {
+ return nil, err
+ }
+ return otags, nil
},
},
expectedResp: []*models.BucketObject{
@@ -374,6 +523,11 @@ func Test_listObjects(t *testing.T) {
LastModified: t1.String(),
Size: int64(1024),
ContentType: "content",
+ }, &models.BucketObject{
+ Name: "obj2",
+ LastModified: t1.String(),
+ Size: int64(512),
+ ContentType: "content",
},
},
wantError: nil,
@@ -385,6 +539,7 @@ func Test_listObjects(t *testing.T) {
minioListObjectsMock = tt.args.listFunc
minioGetObjectLegalHoldMock = tt.args.objectLegalHoldFunc
minioGetObjectRetentionMock = tt.args.objectRetentionFunc
+ minioGetObjectTaggingMock = tt.args.objectGetTaggingFunc
resp, err := listBucketObjects(ctx, minClient, tt.args.bucketName, tt.args.prefix, tt.args.recursive, tt.args.withVersions)
if !reflect.DeepEqual(err, tt.wantError) {
t.Errorf("listBucketObjects() error: %v, wantErr: %v", err, tt.wantError)
diff --git a/swagger.yml b/swagger.yml
index a42714efe0..1bd125ee29 100644
--- a/swagger.yml
+++ b/swagger.yml
@@ -437,6 +437,38 @@ paths:
tags:
- UserAPI
+ /buckets/{bucket_name}/objects/tags:
+ put:
+ summary: Put Object's tags
+ operationId: PutObjectTags
+ parameters:
+ - name: bucket_name
+ in: path
+ required: true
+ type: string
+ - name: prefix
+ in: query
+ required: true
+ type: string
+ - name: version_id
+ in: query
+ required: true
+ type: string
+ - name: body
+ in: body
+ required: true
+ schema:
+ $ref: "#/definitions/putObjectTagsRequest"
+ responses:
+ 200:
+ description: A successful response.
+ default:
+ description: Generic error response.
+ schema:
+ $ref: "#/definitions/error"
+ tags:
+ - UserAPI
+
/buckets/{name}/set-policy:
put:
summary: Bucket Set Policy
@@ -1924,6 +1956,10 @@ definitions:
type: string
retention_until_date:
type: string
+ tags:
+ type: object
+ additionalProperties:
+ type: string
makeBucketRequest:
type: object
@@ -3483,3 +3519,10 @@ definitions:
type: string
governance_bypass:
type: boolean
+
+ putObjectTagsRequest:
+ type: object
+ properties:
+ tags:
+ additionalProperties:
+ type: string