From 5415e6c72a71610108fe05ee747ac760dd40094f Mon Sep 17 00:00:00 2001 From: Poorna Date: Wed, 13 Dec 2023 20:33:11 -0800 Subject: [PATCH] Add fields to tagging opts for replication (#1913) --- api-object-tagging.go | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/api-object-tagging.go b/api-object-tagging.go index 305c36de8..6623e262a 100644 --- a/api-object-tagging.go +++ b/api-object-tagging.go @@ -32,6 +32,12 @@ import ( // to update tag(s) of a specific object version type PutObjectTaggingOptions struct { VersionID string + Internal AdvancedObjectTaggingOptions +} + +// AdvancedObjectTaggingOptions for internal use by MinIO server - not intended for client use. +type AdvancedObjectTaggingOptions struct { + ReplicationProxyRequest string } // PutObjectTagging replaces or creates object tag(s) and can target @@ -50,7 +56,10 @@ func (c *Client) PutObjectTagging(ctx context.Context, bucketName, objectName st if opts.VersionID != "" { urlValues.Set("versionId", opts.VersionID) } - + headers := make(http.Header, 0) + if opts.Internal.ReplicationProxyRequest != "" { + headers.Set(minIOBucketReplicationProxyRequest, opts.Internal.ReplicationProxyRequest) + } reqBytes, err := xml.Marshal(otags) if err != nil { return err @@ -63,6 +72,7 @@ func (c *Client) PutObjectTagging(ctx context.Context, bucketName, objectName st contentBody: bytes.NewReader(reqBytes), contentLength: int64(len(reqBytes)), contentMD5Base64: sumMD5Base64(reqBytes), + customHeader: headers, } // Execute PUT to set a object tagging. @@ -83,6 +93,7 @@ func (c *Client) PutObjectTagging(ctx context.Context, bucketName, objectName st // to fetch the tagging key/value pairs type GetObjectTaggingOptions struct { VersionID string + Internal AdvancedObjectTaggingOptions } // GetObjectTagging fetches object tag(s) with options to target @@ -96,12 +107,16 @@ func (c *Client) GetObjectTagging(ctx context.Context, bucketName, objectName st if opts.VersionID != "" { urlValues.Set("versionId", opts.VersionID) } - + headers := make(http.Header, 0) + if opts.Internal.ReplicationProxyRequest != "" { + headers.Set(minIOBucketReplicationProxyRequest, opts.Internal.ReplicationProxyRequest) + } // Execute GET on object to get object tag(s) resp, err := c.executeMethod(ctx, http.MethodGet, requestMetadata{ - bucketName: bucketName, - objectName: objectName, - queryValues: urlValues, + bucketName: bucketName, + objectName: objectName, + queryValues: urlValues, + customHeader: headers, }) defer closeResponse(resp) @@ -121,6 +136,7 @@ func (c *Client) GetObjectTagging(ctx context.Context, bucketName, objectName st // RemoveObjectTaggingOptions holds the version id of the object to remove type RemoveObjectTaggingOptions struct { VersionID string + Internal AdvancedObjectTaggingOptions } // RemoveObjectTagging removes object tag(s) with options to control a specific object @@ -134,12 +150,16 @@ func (c *Client) RemoveObjectTagging(ctx context.Context, bucketName, objectName if opts.VersionID != "" { urlValues.Set("versionId", opts.VersionID) } - + headers := make(http.Header, 0) + if opts.Internal.ReplicationProxyRequest != "" { + headers.Set(minIOBucketReplicationProxyRequest, opts.Internal.ReplicationProxyRequest) + } // Execute DELETE on object to remove object tag(s) resp, err := c.executeMethod(ctx, http.MethodDelete, requestMetadata{ - bucketName: bucketName, - objectName: objectName, - queryValues: urlValues, + bucketName: bucketName, + objectName: objectName, + queryValues: urlValues, + customHeader: headers, }) defer closeResponse(resp)