github.com/minio/minio-go/v6@v6.0.57/api-datatypes.go (about)

     1  /*
     2   * MinIO Go Library for Amazon S3 Compatible Cloud Storage
     3   * Copyright 2015-2017 MinIO, Inc.
     4   *
     5   * Licensed under the Apache License, Version 2.0 (the "License");
     6   * you may not use this file except in compliance with the License.
     7   * You may obtain a copy of the License at
     8   *
     9   *     http://www.apache.org/licenses/LICENSE-2.0
    10   *
    11   * Unless required by applicable law or agreed to in writing, software
    12   * distributed under the License is distributed on an "AS IS" BASIS,
    13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14   * See the License for the specific language governing permissions and
    15   * limitations under the License.
    16   */
    17  
    18  package minio
    19  
    20  import (
    21  	"encoding/xml"
    22  	"io"
    23  	"net/http"
    24  	"time"
    25  )
    26  
    27  // BucketInfo container for bucket metadata.
    28  type BucketInfo struct {
    29  	// The name of the bucket.
    30  	Name string `json:"name"`
    31  	// Date the bucket was created.
    32  	CreationDate time.Time `json:"creationDate"`
    33  }
    34  
    35  // StringMap represents map with custom UnmarshalXML
    36  type StringMap map[string]string
    37  
    38  // UnmarshalXML unmarshals the XML into a map of string to strings,
    39  // creating a key in the map for each tag and setting it's value to the
    40  // tags contents.
    41  //
    42  // The fact this function is on the pointer of Map is important, so that
    43  // if m is nil it can be initialized, which is often the case if m is
    44  // nested in another xml structural. This is also why the first thing done
    45  // on the first line is initialize it.
    46  func (m *StringMap) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
    47  	*m = StringMap{}
    48  	type xmlMapEntry struct {
    49  		XMLName xml.Name
    50  		Value   string `xml:",chardata"`
    51  	}
    52  	for {
    53  		var e xmlMapEntry
    54  		err := d.Decode(&e)
    55  		if err == io.EOF {
    56  			break
    57  		} else if err != nil {
    58  			return err
    59  		}
    60  		(*m)[e.XMLName.Local] = e.Value
    61  	}
    62  	return nil
    63  }
    64  
    65  // ObjectInfo container for object metadata.
    66  type ObjectInfo struct {
    67  	// An ETag is optionally set to md5sum of an object.  In case of multipart objects,
    68  	// ETag is of the form MD5SUM-N where MD5SUM is md5sum of all individual md5sums of
    69  	// each parts concatenated into one string.
    70  	ETag string `json:"etag"`
    71  
    72  	Key          string    `json:"name"`         // Name of the object
    73  	LastModified time.Time `json:"lastModified"` // Date and time the object was last modified.
    74  	Size         int64     `json:"size"`         // Size in bytes of the object.
    75  	ContentType  string    `json:"contentType"`  // A standard MIME type describing the format of the object data.
    76  	Expires      time.Time `json:"expires"`      // The date and time at which the object is no longer able to be cached.
    77  
    78  	// Collection of additional metadata on the object.
    79  	// eg: x-amz-meta-*, content-encoding etc.
    80  	Metadata http.Header `json:"metadata" xml:"-"`
    81  
    82  	// x-amz-meta-* headers stripped "x-amz-meta-" prefix containing the first value.
    83  	UserMetadata StringMap `json:"userMetadata"`
    84  
    85  	// x-amz-tagging values in their k/v values.
    86  	UserTags map[string]string `json:"userTags"`
    87  
    88  	// Owner name.
    89  	Owner struct {
    90  		DisplayName string `json:"name"`
    91  		ID          string `json:"id"`
    92  	} `json:"owner"`
    93  
    94  	// ACL grant.
    95  	Grant []struct {
    96  		Grantee struct {
    97  			ID          string `xml:"ID"`
    98  			DisplayName string `xml:"DisplayName"`
    99  			URI         string `xml:"URI"`
   100  		} `xml:"Grantee"`
   101  		Permission string `xml:"Permission"`
   102  	} `xml:"Grant"`
   103  
   104  	// The class of storage used to store the object.
   105  	StorageClass string `json:"storageClass"`
   106  
   107  	// Error
   108  	Err error `json:"-"`
   109  }
   110  
   111  // ObjectMultipartInfo container for multipart object metadata.
   112  type ObjectMultipartInfo struct {
   113  	// Date and time at which the multipart upload was initiated.
   114  	Initiated time.Time `type:"timestamp" timestampFormat:"iso8601"`
   115  
   116  	Initiator initiator
   117  	Owner     owner
   118  
   119  	// The type of storage to use for the object. Defaults to 'STANDARD'.
   120  	StorageClass string
   121  
   122  	// Key of the object for which the multipart upload was initiated.
   123  	Key string
   124  
   125  	// Size in bytes of the object.
   126  	Size int64
   127  
   128  	// Upload ID that identifies the multipart upload.
   129  	UploadID string `xml:"UploadId"`
   130  
   131  	// Error
   132  	Err error
   133  }