github.com/minio/minio@v0.0.0-20240328213742-3f72439b8a27/cmd/api-datatypes.go (about)

     1  // Copyright (c) 2015-2021 MinIO, Inc.
     2  //
     3  // This file is part of MinIO Object Storage stack
     4  //
     5  // This program is free software: you can redistribute it and/or modify
     6  // it under the terms of the GNU Affero General Public License as published by
     7  // the Free Software Foundation, either version 3 of the License, or
     8  // (at your option) any later version.
     9  //
    10  // This program is distributed in the hope that it will be useful
    11  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    12  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    13  // GNU Affero General Public License for more details.
    14  //
    15  // You should have received a copy of the GNU Affero General Public License
    16  // along with this program.  If not, see <http://www.gnu.org/licenses/>.
    17  
    18  package cmd
    19  
    20  import (
    21  	"encoding/xml"
    22  	"time"
    23  )
    24  
    25  // DeletedObject objects deleted
    26  type DeletedObject struct {
    27  	DeleteMarker          bool   `xml:"DeleteMarker,omitempty"`
    28  	DeleteMarkerVersionID string `xml:"DeleteMarkerVersionId,omitempty"`
    29  	ObjectName            string `xml:"Key,omitempty"`
    30  	VersionID             string `xml:"VersionId,omitempty"`
    31  	// MTime of DeleteMarker on source that needs to be propagated to replica
    32  	DeleteMarkerMTime DeleteMarkerMTime `xml:"-"`
    33  	// MinIO extensions to support delete marker replication
    34  	ReplicationState ReplicationState `xml:"-"`
    35  }
    36  
    37  // DeleteMarkerMTime is an embedded type containing time.Time for XML marshal
    38  type DeleteMarkerMTime struct {
    39  	time.Time
    40  }
    41  
    42  // MarshalXML encodes expiration date if it is non-zero and encodes
    43  // empty string otherwise
    44  func (t DeleteMarkerMTime) MarshalXML(e *xml.Encoder, startElement xml.StartElement) error {
    45  	if t.Time.IsZero() {
    46  		return nil
    47  	}
    48  	return e.EncodeElement(t.Time.Format(time.RFC3339), startElement)
    49  }
    50  
    51  // ObjectV object version key/versionId
    52  type ObjectV struct {
    53  	ObjectName string `xml:"Key"`
    54  	VersionID  string `xml:"VersionId"`
    55  }
    56  
    57  // ObjectToDelete carries key name for the object to delete.
    58  type ObjectToDelete struct {
    59  	ObjectV
    60  	// Replication status of DeleteMarker
    61  	DeleteMarkerReplicationStatus string `xml:"DeleteMarkerReplicationStatus"`
    62  	// Status of versioned delete (of object or DeleteMarker)
    63  	VersionPurgeStatus VersionPurgeStatusType `xml:"VersionPurgeStatus"`
    64  	// VersionPurgeStatuses holds the internal
    65  	VersionPurgeStatuses string `xml:"VersionPurgeStatuses"`
    66  	// ReplicateDecisionStr stringified representation of replication decision
    67  	ReplicateDecisionStr string `xml:"-"`
    68  }
    69  
    70  // createBucketConfiguration container for bucket configuration request from client.
    71  // Used for parsing the location from the request body for Makebucket.
    72  type createBucketLocationConfiguration struct {
    73  	XMLName  xml.Name `xml:"CreateBucketConfiguration" json:"-"`
    74  	Location string   `xml:"LocationConstraint"`
    75  }
    76  
    77  // DeleteObjectsRequest - xml carrying the object key names which needs to be deleted.
    78  type DeleteObjectsRequest struct {
    79  	// Element to enable quiet mode for the request
    80  	Quiet bool
    81  	// List of objects to be deleted
    82  	Objects []ObjectToDelete `xml:"Object"`
    83  }