github.com/aliyun/aliyun-oss-go-sdk@v3.0.2+incompatible/oss/type.go (about)

     1  package oss
     2  
     3  import (
     4  	"encoding/base64"
     5  	"encoding/xml"
     6  	"fmt"
     7  	"net/url"
     8  	"strconv"
     9  	"strings"
    10  	"time"
    11  )
    12  
    13  // ListBucketsResult defines the result object from ListBuckets request
    14  type ListBucketsResult struct {
    15  	XMLName     xml.Name           `xml:"ListAllMyBucketsResult"`
    16  	Prefix      string             `xml:"Prefix"`         // The prefix in this query
    17  	Marker      string             `xml:"Marker"`         // The marker filter
    18  	MaxKeys     int                `xml:"MaxKeys"`        // The max entry count to return. This information is returned when IsTruncated is true.
    19  	IsTruncated bool               `xml:"IsTruncated"`    // Flag true means there's remaining buckets to return.
    20  	NextMarker  string             `xml:"NextMarker"`     // The marker filter for the next list call
    21  	Owner       Owner              `xml:"Owner"`          // The owner information
    22  	Buckets     []BucketProperties `xml:"Buckets>Bucket"` // The bucket list
    23  }
    24  
    25  // BucketProperties defines bucket properties
    26  type BucketProperties struct {
    27  	XMLName      xml.Name  `xml:"Bucket"`
    28  	Name         string    `xml:"Name"`         // Bucket name
    29  	Location     string    `xml:"Location"`     // Bucket datacenter
    30  	CreationDate time.Time `xml:"CreationDate"` // Bucket create time
    31  	StorageClass string    `xml:"StorageClass"` // Bucket storage class
    32  	Region       string    `xml:"Region"`       // Bucket region
    33  }
    34  
    35  // ListCloudBoxResult defines the result object from ListBuckets request
    36  type ListCloudBoxResult struct {
    37  	XMLName     xml.Name             `xml:"ListCloudBoxResult"`
    38  	Prefix      string               `xml:"Prefix"`              // The prefix in this query
    39  	Marker      string               `xml:"Marker"`              // The marker filter
    40  	MaxKeys     int                  `xml:"MaxKeys"`             // The max entry count to return. This information is returned when IsTruncated is true.
    41  	IsTruncated bool                 `xml:"IsTruncated"`         // Flag true means there's remaining cloudboxes to return.
    42  	NextMarker  string               `xml:"NextMarker"`          // The marker filter for the next list call
    43  	Owner       string               `xml:"Owner>DisplayName"`   // The owner information
    44  	CloudBoxes  []CloudBoxProperties `xml:"CloudBoxes>CloudBox"` // The cloudbox list
    45  }
    46  
    47  // CloudBoxProperties defines cloudbox properties
    48  type CloudBoxProperties struct {
    49  	XMLName         xml.Name `xml:"CloudBox"`
    50  	ID              string   `xml:"ID"`
    51  	Name            string   `xml:"Name"`
    52  	Region          string   `xml:"Region"`
    53  	ControlEndpoint string   `xml:"ControlEndpoint"`
    54  	DataEndpoint    string   `xml:"DataEndpoint"`
    55  }
    56  
    57  // GetBucketACLResult defines GetBucketACL request's result
    58  type GetBucketACLResult struct {
    59  	XMLName xml.Name `xml:"AccessControlPolicy"`
    60  	ACL     string   `xml:"AccessControlList>Grant"` // Bucket ACL
    61  	Owner   Owner    `xml:"Owner"`                   // Bucket owner
    62  }
    63  
    64  // LifecycleConfiguration is the Bucket Lifecycle configuration
    65  type LifecycleConfiguration struct {
    66  	XMLName xml.Name        `xml:"LifecycleConfiguration"`
    67  	Rules   []LifecycleRule `xml:"Rule"`
    68  }
    69  
    70  // LifecycleRule defines Lifecycle rules
    71  type LifecycleRule struct {
    72  	XMLName              xml.Name                       `xml:"Rule"`
    73  	ID                   string                         `xml:"ID,omitempty"`                   // The rule ID
    74  	Prefix               string                         `xml:"Prefix"`                         // The object key prefix
    75  	Status               string                         `xml:"Status"`                         // The rule status (enabled or not)
    76  	Tags                 []Tag                          `xml:"Tag,omitempty"`                  // the tags property
    77  	Expiration           *LifecycleExpiration           `xml:"Expiration,omitempty"`           // The expiration property
    78  	Transitions          []LifecycleTransition          `xml:"Transition,omitempty"`           // The transition property
    79  	AbortMultipartUpload *LifecycleAbortMultipartUpload `xml:"AbortMultipartUpload,omitempty"` // The AbortMultipartUpload property
    80  	NonVersionExpiration *LifecycleVersionExpiration    `xml:"NoncurrentVersionExpiration,omitempty"`
    81  	// Deprecated: Use NonVersionTransitions instead.
    82  	NonVersionTransition  *LifecycleVersionTransition  `xml:"-"` // NonVersionTransition is not suggested to use
    83  	NonVersionTransitions []LifecycleVersionTransition `xml:"NoncurrentVersionTransition,omitempty"`
    84  	Filter                *LifecycleFilter             `xml:Filter,omitempty` //condition parameter container of this exclusion rule
    85  }
    86  
    87  // LifecycleExpiration defines the rule's expiration property
    88  type LifecycleExpiration struct {
    89  	XMLName                   xml.Name `xml:"Expiration"`
    90  	Days                      int      `xml:"Days,omitempty"`                      // Relative expiration time: The expiration time in days after the last modified time
    91  	Date                      string   `xml:"Date,omitempty"`                      // Absolute expiration time: The expiration time in date, not recommended
    92  	CreatedBeforeDate         string   `xml:"CreatedBeforeDate,omitempty"`         // objects created before the date will be expired
    93  	ExpiredObjectDeleteMarker *bool    `xml:"ExpiredObjectDeleteMarker,omitempty"` // Specifies whether the expired delete tag is automatically deleted
    94  }
    95  
    96  // LifecycleTransition defines the rule's transition propery
    97  type LifecycleTransition struct {
    98  	XMLName              xml.Name         `xml:"Transition"`
    99  	Days                 int              `xml:"Days,omitempty"`                 // Relative transition time: The transition time in days after the last modified time
   100  	CreatedBeforeDate    string           `xml:"CreatedBeforeDate,omitempty"`    // objects created before the date will be expired
   101  	StorageClass         StorageClassType `xml:"StorageClass,omitempty"`         // Specifies the target storage type
   102  	IsAccessTime         *bool            `xml:"IsAccessTime,omitempty"`         // access time
   103  	ReturnToStdWhenVisit *bool            `xml:"ReturnToStdWhenVisit,omitempty"` // Return To Std When Visit
   104  	AllowSmallFile       *bool            `xml:AllowSmallFile,omitempty`
   105  }
   106  
   107  // LifecycleAbortMultipartUpload defines the rule's abort multipart upload propery
   108  type LifecycleAbortMultipartUpload struct {
   109  	XMLName           xml.Name `xml:"AbortMultipartUpload"`
   110  	Days              int      `xml:"Days,omitempty"`              // Relative expiration time: The expiration time in days after the last modified time
   111  	CreatedBeforeDate string   `xml:"CreatedBeforeDate,omitempty"` // objects created before the date will be expired
   112  }
   113  
   114  // LifecycleVersionExpiration defines the rule's NoncurrentVersionExpiration propery
   115  type LifecycleVersionExpiration struct {
   116  	XMLName        xml.Name `xml:"NoncurrentVersionExpiration"`
   117  	NoncurrentDays int      `xml:"NoncurrentDays,omitempty"` // How many days after the Object becomes a non-current version
   118  }
   119  
   120  // LifecycleVersionTransition defines the rule's NoncurrentVersionTransition propery
   121  type LifecycleVersionTransition struct {
   122  	XMLName              xml.Name         `xml:"NoncurrentVersionTransition"`
   123  	NoncurrentDays       int              `xml:"NoncurrentDays,omitempty"` // How many days after the Object becomes a non-current version
   124  	StorageClass         StorageClassType `xml:"StorageClass,omitempty"`
   125  	IsAccessTime         *bool            `xml:"IsAccessTime,omitempty"`         // access time
   126  	ReturnToStdWhenVisit *bool            `xml:"ReturnToStdWhenVisit,omitempty"` // Return To Std When Visit
   127  	AllowSmallFile       *bool            `xml:AllowSmallFile,omitempty`
   128  }
   129  
   130  // LifecycleFilter defines the rule's Filter propery
   131  type LifecycleFilter struct {
   132  	XMLName               xml.Name             `xml:"Filter"`
   133  	Not                   []LifecycleFilterNot `xml:"Not,omitempty"`
   134  	ObjectSizeGreaterThan *int64               `xml:"ObjectSizeGreaterThan,omitempty"`
   135  	ObjectSizeLessThan    *int64               `xml:"ObjectSizeLessThan,omitempty"`
   136  }
   137  
   138  // LifecycleFilterNot defines the rule's Filter Not propery
   139  type LifecycleFilterNot struct {
   140  	XMLName xml.Name `xml:"Not"`
   141  	Prefix  string   `xml:"Prefix"`        //Object prefix applicable to this exclusion rule
   142  	Tag     *Tag     `xml:"Tag,omitempty"` //the tags applicable to this exclusion rule
   143  }
   144  
   145  const iso8601DateFormat = "2006-01-02T15:04:05.000Z"
   146  const iso8601DateFormatSecond = "2006-01-02T15:04:05Z"
   147  
   148  // BuildLifecycleRuleByDays builds a lifecycle rule objects will expiration in days after the last modified time
   149  func BuildLifecycleRuleByDays(id, prefix string, status bool, days int) LifecycleRule {
   150  	var statusStr = "Enabled"
   151  	if !status {
   152  		statusStr = "Disabled"
   153  	}
   154  	return LifecycleRule{ID: id, Prefix: prefix, Status: statusStr,
   155  		Expiration: &LifecycleExpiration{Days: days}}
   156  }
   157  
   158  // BuildLifecycleRuleByDate builds a lifecycle rule objects will expiration in specified date
   159  func BuildLifecycleRuleByDate(id, prefix string, status bool, year, month, day int) LifecycleRule {
   160  	var statusStr = "Enabled"
   161  	if !status {
   162  		statusStr = "Disabled"
   163  	}
   164  	date := time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC).Format(iso8601DateFormat)
   165  	return LifecycleRule{ID: id, Prefix: prefix, Status: statusStr,
   166  		Expiration: &LifecycleExpiration{Date: date}}
   167  }
   168  
   169  // ValidateLifecycleRule Determine if a lifecycle rule is valid, if it is invalid, it will return an error.
   170  func verifyLifecycleRules(rules []LifecycleRule) error {
   171  	if len(rules) == 0 {
   172  		return fmt.Errorf("invalid rules, the length of rules is zero")
   173  	}
   174  	for k, rule := range rules {
   175  		if rule.Status != "Enabled" && rule.Status != "Disabled" {
   176  			return fmt.Errorf("invalid rule, the value of status must be Enabled or Disabled")
   177  		}
   178  
   179  		abortMPU := rule.AbortMultipartUpload
   180  		if abortMPU != nil {
   181  			if (abortMPU.Days != 0 && abortMPU.CreatedBeforeDate != "") || (abortMPU.Days == 0 && abortMPU.CreatedBeforeDate == "") {
   182  				return fmt.Errorf("invalid abort multipart upload lifecycle, must be set one of CreatedBeforeDate and Days")
   183  			}
   184  		}
   185  
   186  		transitions := rule.Transitions
   187  		if len(transitions) > 0 {
   188  			for _, transition := range transitions {
   189  				if (transition.Days != 0 && transition.CreatedBeforeDate != "") || (transition.Days == 0 && transition.CreatedBeforeDate == "") {
   190  					return fmt.Errorf("invalid transition lifecycle, must be set one of CreatedBeforeDate and Days")
   191  				}
   192  			}
   193  		}
   194  
   195  		// NonVersionTransition is not suggested to use
   196  		// to keep compatible
   197  		if rule.NonVersionTransition != nil && len(rule.NonVersionTransitions) > 0 {
   198  			return fmt.Errorf("NonVersionTransition and NonVersionTransitions cannot both have values")
   199  		} else if rule.NonVersionTransition != nil {
   200  			rules[k].NonVersionTransitions = append(rules[k].NonVersionTransitions, *rule.NonVersionTransition)
   201  		}
   202  	}
   203  
   204  	return nil
   205  }
   206  
   207  // GetBucketLifecycleResult defines GetBucketLifecycle's result object
   208  type GetBucketLifecycleResult LifecycleConfiguration
   209  
   210  // RefererXML defines Referer configuration
   211  type RefererXML struct {
   212  	XMLName                  xml.Name          `xml:"RefererConfiguration"`
   213  	AllowEmptyReferer        bool              `xml:"AllowEmptyReferer"` // Allow empty referrer
   214  	AllowTruncateQueryString *bool             `xml:"AllowTruncateQueryString,omitempty"`
   215  	RefererList              []string          `xml:"RefererList>Referer"`        // Referer whitelist
   216  	RefererBlacklist         *RefererBlacklist `xml:"RefererBlacklist,omitempty"` // Referer blacklist
   217  }
   218  
   219  // GetBucketRefererResult defines result object for GetBucketReferer request
   220  type GetBucketRefererResult RefererXML
   221  
   222  type RefererBlacklist struct {
   223  	Referer []string `xml:"Referer,omitempty"`
   224  }
   225  
   226  // LoggingXML defines logging configuration
   227  type LoggingXML struct {
   228  	XMLName        xml.Name       `xml:"BucketLoggingStatus"`
   229  	LoggingEnabled LoggingEnabled `xml:"LoggingEnabled"` // The logging configuration information
   230  }
   231  
   232  type loggingXMLEmpty struct {
   233  	XMLName xml.Name `xml:"BucketLoggingStatus"`
   234  }
   235  
   236  // LoggingEnabled defines the logging configuration information
   237  type LoggingEnabled struct {
   238  	XMLName      xml.Name `xml:"LoggingEnabled"`
   239  	TargetBucket string   `xml:"TargetBucket"` // The bucket name for storing the log files
   240  	TargetPrefix string   `xml:"TargetPrefix"` // The log file prefix
   241  }
   242  
   243  // GetBucketLoggingResult defines the result from GetBucketLogging request
   244  type GetBucketLoggingResult LoggingXML
   245  
   246  // WebsiteXML defines Website configuration
   247  type WebsiteXML struct {
   248  	XMLName       xml.Name      `xml:"WebsiteConfiguration"`
   249  	IndexDocument IndexDocument `xml:"IndexDocument,omitempty"`            // The index page
   250  	ErrorDocument ErrorDocument `xml:"ErrorDocument,omitempty"`            // The error page
   251  	RoutingRules  []RoutingRule `xml:"RoutingRules>RoutingRule,omitempty"` // The routing Rule list
   252  }
   253  
   254  // IndexDocument defines the index page info
   255  type IndexDocument struct {
   256  	XMLName xml.Name `xml:"IndexDocument"`
   257  	Suffix  string   `xml:"Suffix"` // The file name for the index page
   258  }
   259  
   260  // ErrorDocument defines the 404 error page info
   261  type ErrorDocument struct {
   262  	XMLName xml.Name `xml:"ErrorDocument"`
   263  	Key     string   `xml:"Key"` // 404 error file name
   264  }
   265  
   266  // RoutingRule defines the routing rules
   267  type RoutingRule struct {
   268  	XMLName    xml.Name  `xml:"RoutingRule"`
   269  	RuleNumber int       `xml:"RuleNumber,omitempty"` // The routing number
   270  	Condition  Condition `xml:"Condition,omitempty"`  // The routing condition
   271  	Redirect   Redirect  `xml:"Redirect,omitempty"`   // The routing redirect
   272  
   273  }
   274  
   275  // Condition defines codition in the RoutingRule
   276  type Condition struct {
   277  	XMLName                     xml.Name        `xml:"Condition"`
   278  	KeyPrefixEquals             string          `xml:"KeyPrefixEquals,omitempty"`             // Matching objcet prefix
   279  	HTTPErrorCodeReturnedEquals int             `xml:"HttpErrorCodeReturnedEquals,omitempty"` // The rule is for Accessing to the specified object
   280  	IncludeHeader               []IncludeHeader `xml:"IncludeHeader"`                         // The rule is for request which include header
   281  }
   282  
   283  // IncludeHeader defines includeHeader in the RoutingRule's Condition
   284  type IncludeHeader struct {
   285  	XMLName xml.Name `xml:"IncludeHeader"`
   286  	Key     string   `xml:"Key,omitempty"`    // The Include header key
   287  	Equals  string   `xml:"Equals,omitempty"` // The Include header value
   288  }
   289  
   290  // Redirect defines redirect in the RoutingRule
   291  type Redirect struct {
   292  	XMLName               xml.Name      `xml:"Redirect"`
   293  	RedirectType          string        `xml:"RedirectType,omitempty"`         // The redirect type, it have Mirror,External,Internal,AliCDN
   294  	PassQueryString       *bool         `xml:"PassQueryString"`                // Whether to send the specified request's parameters, true or false
   295  	MirrorURL             string        `xml:"MirrorURL,omitempty"`            // Mirror of the website address back to the source.
   296  	MirrorPassQueryString *bool         `xml:"MirrorPassQueryString"`          // To Mirror of the website Whether to send the specified request's parameters, true or false
   297  	MirrorFollowRedirect  *bool         `xml:"MirrorFollowRedirect"`           // Redirect the location, if the mirror return 3XX
   298  	MirrorCheckMd5        *bool         `xml:"MirrorCheckMd5"`                 // Check the mirror is MD5.
   299  	MirrorHeaders         MirrorHeaders `xml:"MirrorHeaders,omitempty"`        // Mirror headers
   300  	Protocol              string        `xml:"Protocol,omitempty"`             // The redirect Protocol
   301  	HostName              string        `xml:"HostName,omitempty"`             // The redirect HostName
   302  	ReplaceKeyPrefixWith  string        `xml:"ReplaceKeyPrefixWith,omitempty"` // object name'Prefix replace the value
   303  	HttpRedirectCode      int           `xml:"HttpRedirectCode,omitempty"`     // THe redirect http code
   304  	ReplaceKeyWith        string        `xml:"ReplaceKeyWith,omitempty"`       // object name replace the value
   305  }
   306  
   307  // MirrorHeaders defines MirrorHeaders in the Redirect
   308  type MirrorHeaders struct {
   309  	XMLName xml.Name          `xml:"MirrorHeaders"`
   310  	PassAll *bool             `xml:"PassAll"` // Penetrating all of headers to source website.
   311  	Pass    []string          `xml:"Pass"`    // Penetrating some of headers to source website.
   312  	Remove  []string          `xml:"Remove"`  // Prohibit passthrough some of headers to source website
   313  	Set     []MirrorHeaderSet `xml:"Set"`     // Setting some of headers send to source website
   314  }
   315  
   316  // MirrorHeaderSet defines Set for Redirect's MirrorHeaders
   317  type MirrorHeaderSet struct {
   318  	XMLName xml.Name `xml:"Set"`
   319  	Key     string   `xml:"Key,omitempty"`   // The mirror header key
   320  	Value   string   `xml:"Value,omitempty"` // The mirror header value
   321  }
   322  
   323  // GetBucketWebsiteResult defines the result from GetBucketWebsite request.
   324  type GetBucketWebsiteResult WebsiteXML
   325  
   326  // CORSXML defines CORS configuration
   327  type CORSXML struct {
   328  	XMLName      xml.Name   `xml:"CORSConfiguration"`
   329  	CORSRules    []CORSRule `xml:"CORSRule"`               // CORS rules
   330  	ResponseVary *bool      `xml:"ResponseVary,omitempty"` // return Vary or not
   331  }
   332  
   333  // CORSRule defines CORS rules
   334  type CORSRule struct {
   335  	XMLName       xml.Name `xml:"CORSRule"`
   336  	AllowedOrigin []string `xml:"AllowedOrigin"` // Allowed origins. By default it's wildcard '*'
   337  	AllowedMethod []string `xml:"AllowedMethod"` // Allowed methods
   338  	AllowedHeader []string `xml:"AllowedHeader"` // Allowed headers
   339  	ExposeHeader  []string `xml:"ExposeHeader"`  // Allowed response headers
   340  	MaxAgeSeconds int      `xml:"MaxAgeSeconds"` // Max cache ages in seconds
   341  }
   342  
   343  // GetBucketCORSResult defines the result from GetBucketCORS request.
   344  type GetBucketCORSResult CORSXML
   345  
   346  // PutBucketCORS defines the PutBucketCORS config xml.
   347  type PutBucketCORS CORSXML
   348  
   349  // GetBucketInfoResult defines the result from GetBucketInfo request.
   350  type GetBucketInfoResult struct {
   351  	XMLName    xml.Name   `xml:"BucketInfo"`
   352  	BucketInfo BucketInfo `xml:"Bucket"`
   353  }
   354  
   355  // BucketInfo defines Bucket information
   356  type BucketInfo struct {
   357  	XMLName                xml.Name  `xml:"Bucket"`
   358  	Name                   string    `xml:"Name"`                     // Bucket name
   359  	AccessMonitor          string    `xml:"AccessMonitor"`            // Bucket Access Monitor
   360  	Location               string    `xml:"Location"`                 // Bucket datacenter
   361  	CreationDate           time.Time `xml:"CreationDate"`             // Bucket creation time
   362  	ExtranetEndpoint       string    `xml:"ExtranetEndpoint"`         // Bucket external endpoint
   363  	IntranetEndpoint       string    `xml:"IntranetEndpoint"`         // Bucket internal endpoint
   364  	ACL                    string    `xml:"AccessControlList>Grant"`  // Bucket ACL
   365  	RedundancyType         string    `xml:"DataRedundancyType"`       // Bucket DataRedundancyType
   366  	Owner                  Owner     `xml:"Owner"`                    // Bucket owner
   367  	StorageClass           string    `xml:"StorageClass"`             // Bucket storage class
   368  	SseRule                SSERule   `xml:"ServerSideEncryptionRule"` // Bucket ServerSideEncryptionRule
   369  	Versioning             string    `xml:"Versioning"`               // Bucket Versioning
   370  	TransferAcceleration   string    `xml:"TransferAcceleration"`     // bucket TransferAcceleration
   371  	CrossRegionReplication string    `xml:"CrossRegionReplication"`   // bucket CrossRegionReplication
   372  }
   373  
   374  type SSERule struct {
   375  	XMLName           xml.Name `xml:"ServerSideEncryptionRule"`    // Bucket ServerSideEncryptionRule
   376  	KMSMasterKeyID    string   `xml:"KMSMasterKeyID,omitempty"`    // Bucket KMSMasterKeyID
   377  	SSEAlgorithm      string   `xml:"SSEAlgorithm,omitempty"`      // Bucket SSEAlgorithm
   378  	KMSDataEncryption string   `xml:"KMSDataEncryption,omitempty"` //Bucket KMSDataEncryption
   379  }
   380  
   381  // ListObjectsResult defines the result from ListObjects request
   382  type ListObjectsResult struct {
   383  	XMLName        xml.Name           `xml:"ListBucketResult"`
   384  	Prefix         string             `xml:"Prefix"`                // The object prefix
   385  	Marker         string             `xml:"Marker"`                // The marker filter.
   386  	MaxKeys        int                `xml:"MaxKeys"`               // Max keys to return
   387  	Delimiter      string             `xml:"Delimiter"`             // The delimiter for grouping objects' name
   388  	IsTruncated    bool               `xml:"IsTruncated"`           // Flag indicates if all results are returned (when it's false)
   389  	NextMarker     string             `xml:"NextMarker"`            // The start point of the next query
   390  	Objects        []ObjectProperties `xml:"Contents"`              // Object list
   391  	CommonPrefixes []string           `xml:"CommonPrefixes>Prefix"` // You can think of commonprefixes as "folders" whose names end with the delimiter
   392  }
   393  
   394  // ObjectProperties defines Objecct properties
   395  type ObjectProperties struct {
   396  	XMLName      xml.Name  `xml:"Contents"`
   397  	Key          string    `xml:"Key"`                   // Object key
   398  	Type         string    `xml:"Type"`                  // Object type
   399  	Size         int64     `xml:"Size"`                  // Object size
   400  	ETag         string    `xml:"ETag"`                  // Object ETag
   401  	Owner        Owner     `xml:"Owner"`                 // Object owner information
   402  	LastModified time.Time `xml:"LastModified"`          // Object last modified time
   403  	StorageClass string    `xml:"StorageClass"`          // Object storage class (Standard, IA, Archive)
   404  	RestoreInfo  string    `xml:"RestoreInfo,omitempty"` // Object restoreInfo
   405  }
   406  
   407  // ListObjectsResultV2 defines the result from ListObjectsV2 request
   408  type ListObjectsResultV2 struct {
   409  	XMLName               xml.Name           `xml:"ListBucketResult"`
   410  	Prefix                string             `xml:"Prefix"`                // The object prefix
   411  	StartAfter            string             `xml:"StartAfter"`            // the input StartAfter
   412  	ContinuationToken     string             `xml:"ContinuationToken"`     // the input ContinuationToken
   413  	MaxKeys               int                `xml:"MaxKeys"`               // Max keys to return
   414  	Delimiter             string             `xml:"Delimiter"`             // The delimiter for grouping objects' name
   415  	IsTruncated           bool               `xml:"IsTruncated"`           // Flag indicates if all results are returned (when it's false)
   416  	NextContinuationToken string             `xml:"NextContinuationToken"` // The start point of the next NextContinuationToken
   417  	Objects               []ObjectProperties `xml:"Contents"`              // Object list
   418  	CommonPrefixes        []string           `xml:"CommonPrefixes>Prefix"` // You can think of commonprefixes as "folders" whose names end with the delimiter
   419  }
   420  
   421  // ListObjectVersionsResult defines the result from ListObjectVersions request
   422  type ListObjectVersionsResult struct {
   423  	XMLName             xml.Name                       `xml:"ListVersionsResult"`
   424  	Name                string                         `xml:"Name"`                  // The Bucket Name
   425  	Owner               Owner                          `xml:"Owner"`                 // The owner of bucket
   426  	Prefix              string                         `xml:"Prefix"`                // The object prefix
   427  	KeyMarker           string                         `xml:"KeyMarker"`             // The start marker filter.
   428  	VersionIdMarker     string                         `xml:"VersionIdMarker"`       // The start VersionIdMarker filter.
   429  	MaxKeys             int                            `xml:"MaxKeys"`               // Max keys to return
   430  	Delimiter           string                         `xml:"Delimiter"`             // The delimiter for grouping objects' name
   431  	IsTruncated         bool                           `xml:"IsTruncated"`           // Flag indicates if all results are returned (when it's false)
   432  	NextKeyMarker       string                         `xml:"NextKeyMarker"`         // The start point of the next query
   433  	NextVersionIdMarker string                         `xml:"NextVersionIdMarker"`   // The start point of the next query
   434  	CommonPrefixes      []string                       `xml:"CommonPrefixes>Prefix"` // You can think of commonprefixes as "folders" whose names end with the delimiter
   435  	ObjectDeleteMarkers []ObjectDeleteMarkerProperties `xml:"DeleteMarker"`          // DeleteMarker list
   436  	ObjectVersions      []ObjectVersionProperties      `xml:"Version"`               // version list
   437  }
   438  
   439  type ObjectDeleteMarkerProperties struct {
   440  	XMLName      xml.Name  `xml:"DeleteMarker"`
   441  	Key          string    `xml:"Key"`          // The Object Key
   442  	VersionId    string    `xml:"VersionId"`    // The Object VersionId
   443  	IsLatest     bool      `xml:"IsLatest"`     // is current version or not
   444  	LastModified time.Time `xml:"LastModified"` // Object last modified time
   445  	Owner        Owner     `xml:"Owner"`        // bucket owner element
   446  }
   447  
   448  type ObjectVersionProperties struct {
   449  	XMLName      xml.Name  `xml:"Version"`
   450  	Key          string    `xml:"Key"`                   // The Object Key
   451  	VersionId    string    `xml:"VersionId"`             // The Object VersionId
   452  	IsLatest     bool      `xml:"IsLatest"`              // is latest version or not
   453  	LastModified time.Time `xml:"LastModified"`          // Object last modified time
   454  	Type         string    `xml:"Type"`                  // Object type
   455  	Size         int64     `xml:"Size"`                  // Object size
   456  	ETag         string    `xml:"ETag"`                  // Object ETag
   457  	StorageClass string    `xml:"StorageClass"`          // Object storage class (Standard, IA, Archive)
   458  	Owner        Owner     `xml:"Owner"`                 // bucket owner element
   459  	RestoreInfo  string    `xml:"RestoreInfo,omitempty"` // Object restoreInfo
   460  }
   461  
   462  // Owner defines Bucket/Object's owner
   463  type Owner struct {
   464  	XMLName     xml.Name `xml:"Owner"`
   465  	ID          string   `xml:"ID"`          // Owner ID
   466  	DisplayName string   `xml:"DisplayName"` // Owner's display name
   467  }
   468  
   469  // CopyObjectResult defines result object of CopyObject
   470  type CopyObjectResult struct {
   471  	XMLName      xml.Name  `xml:"CopyObjectResult"`
   472  	LastModified time.Time `xml:"LastModified"` // New object's last modified time.
   473  	ETag         string    `xml:"ETag"`         // New object's ETag
   474  }
   475  
   476  // GetObjectACLResult defines result of GetObjectACL request
   477  type GetObjectACLResult GetBucketACLResult
   478  
   479  type deleteXML struct {
   480  	XMLName xml.Name       `xml:"Delete"`
   481  	Objects []DeleteObject `xml:"Object"` // Objects to delete
   482  	Quiet   bool           `xml:"Quiet"`  // Flag of quiet mode.
   483  }
   484  
   485  // DeleteObject defines the struct for deleting object
   486  type DeleteObject struct {
   487  	XMLName   xml.Name `xml:"Object"`
   488  	Key       string   `xml:"Key"`                 // Object name
   489  	VersionId string   `xml:"VersionId,omitempty"` // Object VersionId
   490  }
   491  
   492  // DeleteObjectsResult defines result of DeleteObjects request
   493  type DeleteObjectsResult struct {
   494  	XMLName        xml.Name
   495  	DeletedObjects []string // Deleted object key list
   496  }
   497  
   498  // DeleteObjectVersionsResult defines result of DeleteObjects request
   499  type DeleteObjectVersionsResult struct {
   500  	XMLName              xml.Name         `xml:"DeleteResult"`
   501  	DeletedObjectsDetail []DeletedKeyInfo `xml:"Deleted"` // Deleted object detail info
   502  }
   503  
   504  // DeletedKeyInfo defines object delete info
   505  type DeletedKeyInfo struct {
   506  	XMLName               xml.Name `xml:"Deleted"`
   507  	Key                   string   `xml:"Key"`                   // Object key
   508  	VersionId             string   `xml:"VersionId"`             // VersionId
   509  	DeleteMarker          bool     `xml:"DeleteMarker"`          // Object DeleteMarker
   510  	DeleteMarkerVersionId string   `xml:"DeleteMarkerVersionId"` // Object DeleteMarkerVersionId
   511  }
   512  
   513  // InitiateMultipartUploadResult defines result of InitiateMultipartUpload request
   514  type InitiateMultipartUploadResult struct {
   515  	XMLName  xml.Name `xml:"InitiateMultipartUploadResult"`
   516  	Bucket   string   `xml:"Bucket"`   // Bucket name
   517  	Key      string   `xml:"Key"`      // Object name to upload
   518  	UploadID string   `xml:"UploadId"` // Generated UploadId
   519  }
   520  
   521  // UploadPart defines the upload/copy part
   522  type UploadPart struct {
   523  	XMLName    xml.Name `xml:"Part"`
   524  	PartNumber int      `xml:"PartNumber"` // Part number
   525  	ETag       string   `xml:"ETag"`       // ETag value of the part's data
   526  }
   527  
   528  type UploadParts []UploadPart
   529  
   530  func (slice UploadParts) Len() int {
   531  	return len(slice)
   532  }
   533  
   534  func (slice UploadParts) Less(i, j int) bool {
   535  	return slice[i].PartNumber < slice[j].PartNumber
   536  }
   537  
   538  func (slice UploadParts) Swap(i, j int) {
   539  	slice[i], slice[j] = slice[j], slice[i]
   540  }
   541  
   542  // UploadPartCopyResult defines result object of multipart copy request.
   543  type UploadPartCopyResult struct {
   544  	XMLName      xml.Name  `xml:"CopyPartResult"`
   545  	LastModified time.Time `xml:"LastModified"` // Last modified time
   546  	ETag         string    `xml:"ETag"`         // ETag
   547  }
   548  
   549  type completeMultipartUploadXML struct {
   550  	XMLName xml.Name     `xml:"CompleteMultipartUpload"`
   551  	Part    []UploadPart `xml:"Part"`
   552  }
   553  
   554  // CompleteMultipartUploadResult defines result object of CompleteMultipartUploadRequest
   555  type CompleteMultipartUploadResult struct {
   556  	XMLName  xml.Name `xml:"CompleteMultipartUploadResult"`
   557  	Location string   `xml:"Location"` // Object URL
   558  	Bucket   string   `xml:"Bucket"`   // Bucket name
   559  	ETag     string   `xml:"ETag"`     // Object ETag
   560  	Key      string   `xml:"Key"`      // Object name
   561  }
   562  
   563  // ListUploadedPartsResult defines result object of ListUploadedParts
   564  type ListUploadedPartsResult struct {
   565  	XMLName              xml.Name       `xml:"ListPartsResult"`
   566  	Bucket               string         `xml:"Bucket"`               // Bucket name
   567  	Key                  string         `xml:"Key"`                  // Object name
   568  	UploadID             string         `xml:"UploadId"`             // Upload ID
   569  	NextPartNumberMarker string         `xml:"NextPartNumberMarker"` // Next part number
   570  	MaxParts             int            `xml:"MaxParts"`             // Max parts count
   571  	IsTruncated          bool           `xml:"IsTruncated"`          // Flag indicates all entries returned.false: all entries returned.
   572  	UploadedParts        []UploadedPart `xml:"Part"`                 // Uploaded parts
   573  }
   574  
   575  // UploadedPart defines uploaded part
   576  type UploadedPart struct {
   577  	XMLName      xml.Name  `xml:"Part"`
   578  	PartNumber   int       `xml:"PartNumber"`   // Part number
   579  	LastModified time.Time `xml:"LastModified"` // Last modified time
   580  	ETag         string    `xml:"ETag"`         // ETag cache
   581  	Size         int       `xml:"Size"`         // Part size
   582  }
   583  
   584  // ListMultipartUploadResult defines result object of ListMultipartUpload
   585  type ListMultipartUploadResult struct {
   586  	XMLName            xml.Name            `xml:"ListMultipartUploadsResult"`
   587  	Bucket             string              `xml:"Bucket"`                // Bucket name
   588  	Delimiter          string              `xml:"Delimiter"`             // Delimiter for grouping object.
   589  	Prefix             string              `xml:"Prefix"`                // Object prefix
   590  	KeyMarker          string              `xml:"KeyMarker"`             // Object key marker
   591  	UploadIDMarker     string              `xml:"UploadIdMarker"`        // UploadId marker
   592  	NextKeyMarker      string              `xml:"NextKeyMarker"`         // Next key marker, if not all entries returned.
   593  	NextUploadIDMarker string              `xml:"NextUploadIdMarker"`    // Next uploadId marker, if not all entries returned.
   594  	MaxUploads         int                 `xml:"MaxUploads"`            // Max uploads to return
   595  	IsTruncated        bool                `xml:"IsTruncated"`           // Flag indicates all entries are returned.
   596  	Uploads            []UncompletedUpload `xml:"Upload"`                // Ongoing uploads (not completed, not aborted)
   597  	CommonPrefixes     []string            `xml:"CommonPrefixes>Prefix"` // Common prefixes list.
   598  }
   599  
   600  // UncompletedUpload structure wraps an uncompleted upload task
   601  type UncompletedUpload struct {
   602  	XMLName   xml.Name  `xml:"Upload"`
   603  	Key       string    `xml:"Key"`       // Object name
   604  	UploadID  string    `xml:"UploadId"`  // The UploadId
   605  	Initiated time.Time `xml:"Initiated"` // Initialization time in the format such as 2012-02-23T04:18:23.000Z
   606  }
   607  
   608  // ProcessObjectResult defines result object of ProcessObject
   609  type ProcessObjectResult struct {
   610  	Bucket   string `json:"bucket"`
   611  	FileSize int    `json:"fileSize"`
   612  	Object   string `json:"object"`
   613  	Status   string `json:"status"`
   614  }
   615  
   616  // AsyncProcessObjectResult defines result object of AsyncProcessObject
   617  type AsyncProcessObjectResult struct {
   618  	EventId   string `json:"EventId"`
   619  	RequestId string `json:"RequestId"`
   620  	TaskId    string `json:"TaskId"`
   621  }
   622  
   623  // decodeDeleteObjectsResult decodes deleting objects result in URL encoding
   624  func decodeDeleteObjectsResult(result *DeleteObjectVersionsResult) error {
   625  	var err error
   626  	for i := 0; i < len(result.DeletedObjectsDetail); i++ {
   627  		result.DeletedObjectsDetail[i].Key, err = url.QueryUnescape(result.DeletedObjectsDetail[i].Key)
   628  		if err != nil {
   629  			return err
   630  		}
   631  	}
   632  	return nil
   633  }
   634  
   635  // decodeListObjectsResult decodes list objects result in URL encoding
   636  func decodeListObjectsResult(result *ListObjectsResult) error {
   637  	var err error
   638  	result.Prefix, err = url.QueryUnescape(result.Prefix)
   639  	if err != nil {
   640  		return err
   641  	}
   642  	result.Marker, err = url.QueryUnescape(result.Marker)
   643  	if err != nil {
   644  		return err
   645  	}
   646  	result.Delimiter, err = url.QueryUnescape(result.Delimiter)
   647  	if err != nil {
   648  		return err
   649  	}
   650  	result.NextMarker, err = url.QueryUnescape(result.NextMarker)
   651  	if err != nil {
   652  		return err
   653  	}
   654  	for i := 0; i < len(result.Objects); i++ {
   655  		result.Objects[i].Key, err = url.QueryUnescape(result.Objects[i].Key)
   656  		if err != nil {
   657  			return err
   658  		}
   659  	}
   660  	for i := 0; i < len(result.CommonPrefixes); i++ {
   661  		result.CommonPrefixes[i], err = url.QueryUnescape(result.CommonPrefixes[i])
   662  		if err != nil {
   663  			return err
   664  		}
   665  	}
   666  	return nil
   667  }
   668  
   669  // decodeListObjectsResult decodes list objects result in URL encoding
   670  func decodeListObjectsResultV2(result *ListObjectsResultV2) error {
   671  	var err error
   672  	result.Prefix, err = url.QueryUnescape(result.Prefix)
   673  	if err != nil {
   674  		return err
   675  	}
   676  	result.StartAfter, err = url.QueryUnescape(result.StartAfter)
   677  	if err != nil {
   678  		return err
   679  	}
   680  	result.Delimiter, err = url.QueryUnescape(result.Delimiter)
   681  	if err != nil {
   682  		return err
   683  	}
   684  	result.NextContinuationToken, err = url.QueryUnescape(result.NextContinuationToken)
   685  	if err != nil {
   686  		return err
   687  	}
   688  	for i := 0; i < len(result.Objects); i++ {
   689  		result.Objects[i].Key, err = url.QueryUnescape(result.Objects[i].Key)
   690  		if err != nil {
   691  			return err
   692  		}
   693  	}
   694  	for i := 0; i < len(result.CommonPrefixes); i++ {
   695  		result.CommonPrefixes[i], err = url.QueryUnescape(result.CommonPrefixes[i])
   696  		if err != nil {
   697  			return err
   698  		}
   699  	}
   700  	return nil
   701  }
   702  
   703  // decodeListObjectVersionsResult decodes list version objects result in URL encoding
   704  func decodeListObjectVersionsResult(result *ListObjectVersionsResult) error {
   705  	var err error
   706  
   707  	// decode:Delimiter
   708  	result.Delimiter, err = url.QueryUnescape(result.Delimiter)
   709  	if err != nil {
   710  		return err
   711  	}
   712  
   713  	// decode Prefix
   714  	result.Prefix, err = url.QueryUnescape(result.Prefix)
   715  	if err != nil {
   716  		return err
   717  	}
   718  
   719  	// decode KeyMarker
   720  	result.KeyMarker, err = url.QueryUnescape(result.KeyMarker)
   721  	if err != nil {
   722  		return err
   723  	}
   724  
   725  	// decode VersionIdMarker
   726  	result.VersionIdMarker, err = url.QueryUnescape(result.VersionIdMarker)
   727  	if err != nil {
   728  		return err
   729  	}
   730  
   731  	// decode NextKeyMarker
   732  	result.NextKeyMarker, err = url.QueryUnescape(result.NextKeyMarker)
   733  	if err != nil {
   734  		return err
   735  	}
   736  
   737  	// decode NextVersionIdMarker
   738  	result.NextVersionIdMarker, err = url.QueryUnescape(result.NextVersionIdMarker)
   739  	if err != nil {
   740  		return err
   741  	}
   742  
   743  	// decode CommonPrefixes
   744  	for i := 0; i < len(result.CommonPrefixes); i++ {
   745  		result.CommonPrefixes[i], err = url.QueryUnescape(result.CommonPrefixes[i])
   746  		if err != nil {
   747  			return err
   748  		}
   749  	}
   750  
   751  	// decode deleteMarker
   752  	for i := 0; i < len(result.ObjectDeleteMarkers); i++ {
   753  		result.ObjectDeleteMarkers[i].Key, err = url.QueryUnescape(result.ObjectDeleteMarkers[i].Key)
   754  		if err != nil {
   755  			return err
   756  		}
   757  	}
   758  
   759  	// decode ObjectVersions
   760  	for i := 0; i < len(result.ObjectVersions); i++ {
   761  		result.ObjectVersions[i].Key, err = url.QueryUnescape(result.ObjectVersions[i].Key)
   762  		if err != nil {
   763  			return err
   764  		}
   765  	}
   766  
   767  	return nil
   768  }
   769  
   770  // decodeListUploadedPartsResult decodes
   771  func decodeListUploadedPartsResult(result *ListUploadedPartsResult) error {
   772  	var err error
   773  	result.Key, err = url.QueryUnescape(result.Key)
   774  	if err != nil {
   775  		return err
   776  	}
   777  	return nil
   778  }
   779  
   780  // decodeListMultipartUploadResult decodes list multipart upload result in URL encoding
   781  func decodeListMultipartUploadResult(result *ListMultipartUploadResult) error {
   782  	var err error
   783  	result.Prefix, err = url.QueryUnescape(result.Prefix)
   784  	if err != nil {
   785  		return err
   786  	}
   787  	result.Delimiter, err = url.QueryUnescape(result.Delimiter)
   788  	if err != nil {
   789  		return err
   790  	}
   791  	result.KeyMarker, err = url.QueryUnescape(result.KeyMarker)
   792  	if err != nil {
   793  		return err
   794  	}
   795  	result.NextKeyMarker, err = url.QueryUnescape(result.NextKeyMarker)
   796  	if err != nil {
   797  		return err
   798  	}
   799  	for i := 0; i < len(result.Uploads); i++ {
   800  		result.Uploads[i].Key, err = url.QueryUnescape(result.Uploads[i].Key)
   801  		if err != nil {
   802  			return err
   803  		}
   804  	}
   805  	for i := 0; i < len(result.CommonPrefixes); i++ {
   806  		result.CommonPrefixes[i], err = url.QueryUnescape(result.CommonPrefixes[i])
   807  		if err != nil {
   808  			return err
   809  		}
   810  	}
   811  	return nil
   812  }
   813  
   814  // marshalDeleteObjectToXml deleteXML struct to xml
   815  func marshalDeleteObjectToXml(dxml deleteXML) string {
   816  	var builder strings.Builder
   817  	builder.WriteString("<Delete>")
   818  	builder.WriteString("<Quiet>")
   819  	builder.WriteString(strconv.FormatBool(dxml.Quiet))
   820  	builder.WriteString("</Quiet>")
   821  	if len(dxml.Objects) > 0 {
   822  		for _, object := range dxml.Objects {
   823  			builder.WriteString("<Object>")
   824  			if object.Key != "" {
   825  				builder.WriteString("<Key>")
   826  				builder.WriteString(EscapeXml(object.Key))
   827  				builder.WriteString("</Key>")
   828  			}
   829  			if object.VersionId != "" {
   830  				builder.WriteString("<VersionId>")
   831  				builder.WriteString(object.VersionId)
   832  				builder.WriteString("</VersionId>")
   833  			}
   834  			builder.WriteString("</Object>")
   835  		}
   836  	}
   837  	builder.WriteString("</Delete>")
   838  	return builder.String()
   839  }
   840  
   841  // createBucketConfiguration defines the configuration for creating a bucket.
   842  type createBucketConfiguration struct {
   843  	XMLName            xml.Name           `xml:"CreateBucketConfiguration"`
   844  	StorageClass       StorageClassType   `xml:"StorageClass,omitempty"`
   845  	DataRedundancyType DataRedundancyType `xml:"DataRedundancyType,omitempty"`
   846  	ObjectHashFunction ObjecthashFuncType `xml:"ObjectHashFunction,omitempty"`
   847  }
   848  
   849  // LiveChannelConfiguration defines the configuration for live-channel
   850  type LiveChannelConfiguration struct {
   851  	XMLName     xml.Name          `xml:"LiveChannelConfiguration"`
   852  	Description string            `xml:"Description,omitempty"` //Description of live-channel, up to 128 bytes
   853  	Status      string            `xml:"Status,omitempty"`      //Specify the status of livechannel
   854  	Target      LiveChannelTarget `xml:"Target"`                //target configuration of live-channel
   855  	// use point instead of struct to avoid omit empty snapshot
   856  	Snapshot *LiveChannelSnapshot `xml:"Snapshot,omitempty"` //snapshot configuration of live-channel
   857  }
   858  
   859  // LiveChannelTarget target configuration of live-channel
   860  type LiveChannelTarget struct {
   861  	XMLName      xml.Name `xml:"Target"`
   862  	Type         string   `xml:"Type"`                   //the type of object, only supports HLS
   863  	FragDuration int      `xml:"FragDuration,omitempty"` //the length of each ts object (in seconds), in the range [1,100]
   864  	FragCount    int      `xml:"FragCount,omitempty"`    //the number of ts objects in the m3u8 object, in the range of [1,100]
   865  	PlaylistName string   `xml:"PlaylistName,omitempty"` //the name of m3u8 object, which must end with ".m3u8" and the length range is [6,128]
   866  }
   867  
   868  // LiveChannelSnapshot snapshot configuration of live-channel
   869  type LiveChannelSnapshot struct {
   870  	XMLName     xml.Name `xml:"Snapshot"`
   871  	RoleName    string   `xml:"RoleName,omitempty"`    //The role of snapshot operations, it sholud has write permission of DestBucket and the permission to send messages to the NotifyTopic.
   872  	DestBucket  string   `xml:"DestBucket,omitempty"`  //Bucket the snapshots will be written to. should be the same owner as the source bucket.
   873  	NotifyTopic string   `xml:"NotifyTopic,omitempty"` //Topics of MNS for notifying users of high frequency screenshot operation results
   874  	Interval    int      `xml:"Interval,omitempty"`    //interval of snapshots, threre is no snapshot if no I-frame during the interval time
   875  }
   876  
   877  // CreateLiveChannelResult the result of crete live-channel
   878  type CreateLiveChannelResult struct {
   879  	XMLName     xml.Name `xml:"CreateLiveChannelResult"`
   880  	PublishUrls []string `xml:"PublishUrls>Url"` //push urls list
   881  	PlayUrls    []string `xml:"PlayUrls>Url"`    //play urls list
   882  }
   883  
   884  // LiveChannelStat the result of get live-channel state
   885  type LiveChannelStat struct {
   886  	XMLName       xml.Name         `xml:"LiveChannelStat"`
   887  	Status        string           `xml:"Status"`        //Current push status of live-channel: Disabled,Live,Idle
   888  	ConnectedTime time.Time        `xml:"ConnectedTime"` //The time when the client starts pushing, format: ISO8601
   889  	RemoteAddr    string           `xml:"RemoteAddr"`    //The ip address of the client
   890  	Video         LiveChannelVideo `xml:"Video"`         //Video stream information
   891  	Audio         LiveChannelAudio `xml:"Audio"`         //Audio stream information
   892  }
   893  
   894  // LiveChannelVideo video stream information
   895  type LiveChannelVideo struct {
   896  	XMLName   xml.Name `xml:"Video"`
   897  	Width     int      `xml:"Width"`     //Width (unit: pixels)
   898  	Height    int      `xml:"Height"`    //Height (unit: pixels)
   899  	FrameRate int      `xml:"FrameRate"` //FramRate
   900  	Bandwidth int      `xml:"Bandwidth"` //Bandwidth (unit: B/s)
   901  }
   902  
   903  // LiveChannelAudio audio stream information
   904  type LiveChannelAudio struct {
   905  	XMLName    xml.Name `xml:"Audio"`
   906  	SampleRate int      `xml:"SampleRate"` //SampleRate
   907  	Bandwidth  int      `xml:"Bandwidth"`  //Bandwidth (unit: B/s)
   908  	Codec      string   `xml:"Codec"`      //Encoding forma
   909  }
   910  
   911  // LiveChannelHistory the result of GetLiveChannelHistory, at most return up to lastest 10 push records
   912  type LiveChannelHistory struct {
   913  	XMLName xml.Name     `xml:"LiveChannelHistory"`
   914  	Record  []LiveRecord `xml:"LiveRecord"` //push records list
   915  }
   916  
   917  // LiveRecord push recode
   918  type LiveRecord struct {
   919  	XMLName    xml.Name  `xml:"LiveRecord"`
   920  	StartTime  time.Time `xml:"StartTime"`  //StartTime, format: ISO8601
   921  	EndTime    time.Time `xml:"EndTime"`    //EndTime, format: ISO8601
   922  	RemoteAddr string    `xml:"RemoteAddr"` //The ip address of remote client
   923  }
   924  
   925  // ListLiveChannelResult the result of ListLiveChannel
   926  type ListLiveChannelResult struct {
   927  	XMLName     xml.Name          `xml:"ListLiveChannelResult"`
   928  	Prefix      string            `xml:"Prefix"`      //Filter by the name start with the value of "Prefix"
   929  	Marker      string            `xml:"Marker"`      //cursor from which starting list
   930  	MaxKeys     int               `xml:"MaxKeys"`     //The maximum count returned. the default value is 100. it cannot be greater than 1000.
   931  	IsTruncated bool              `xml:"IsTruncated"` //Indicates whether all results have been returned, "true" indicates partial results returned while "false" indicates all results have been returned
   932  	NextMarker  string            `xml:"NextMarker"`  //NextMarker indicate the Marker value of the next request
   933  	LiveChannel []LiveChannelInfo `xml:"LiveChannel"` //The infomation of live-channel
   934  }
   935  
   936  // LiveChannelInfo the infomation of live-channel
   937  type LiveChannelInfo struct {
   938  	XMLName      xml.Name  `xml:"LiveChannel"`
   939  	Name         string    `xml:"Name"`            //The name of live-channel
   940  	Description  string    `xml:"Description"`     //Description of live-channel
   941  	Status       string    `xml:"Status"`          //Status: disabled or enabled
   942  	LastModified time.Time `xml:"LastModified"`    //Last modification time, format: ISO8601
   943  	PublishUrls  []string  `xml:"PublishUrls>Url"` //push urls list
   944  	PlayUrls     []string  `xml:"PlayUrls>Url"`    //play urls list
   945  }
   946  
   947  // Tag a tag for the object
   948  type Tag struct {
   949  	XMLName xml.Name `xml:"Tag"`
   950  	Key     string   `xml:"Key"`
   951  	Value   string   `xml:"Value"`
   952  }
   953  
   954  // Tagging tag set for the object
   955  type Tagging struct {
   956  	XMLName xml.Name `xml:"Tagging"`
   957  	Tags    []Tag    `xml:"TagSet>Tag,omitempty"`
   958  }
   959  
   960  // GetObjectTaggingResult for GetObjectTagging return value
   961  type GetObjectTaggingResult Tagging
   962  
   963  // VersioningConfig for the bucket
   964  type VersioningConfig struct {
   965  	XMLName xml.Name `xml:"VersioningConfiguration"`
   966  	Status  string   `xml:"Status"`
   967  }
   968  
   969  type GetBucketVersioningResult VersioningConfig
   970  
   971  // ServerEncryptionRule Server Encryption rule for the bucket
   972  type ServerEncryptionRule struct {
   973  	XMLName    xml.Name       `xml:"ServerSideEncryptionRule"`
   974  	SSEDefault SSEDefaultRule `xml:"ApplyServerSideEncryptionByDefault"`
   975  }
   976  
   977  // SSEDefaultRule Server Encryption deafult rule for the bucket
   978  type SSEDefaultRule struct {
   979  	XMLName           xml.Name `xml:"ApplyServerSideEncryptionByDefault"`
   980  	SSEAlgorithm      string   `xml:"SSEAlgorithm,omitempty"`
   981  	KMSMasterKeyID    string   `xml:"KMSMasterKeyID,omitempty"`
   982  	KMSDataEncryption string   `xml:"KMSDataEncryption,,omitempty"`
   983  }
   984  
   985  type GetBucketEncryptionResult ServerEncryptionRule
   986  type GetBucketTaggingResult Tagging
   987  
   988  type BucketStat struct {
   989  	XMLName                     xml.Name `xml:"BucketStat"`
   990  	Storage                     int64    `xml:"Storage"`
   991  	ObjectCount                 int64    `xml:"ObjectCount"`
   992  	MultipartUploadCount        int64    `xml:"MultipartUploadCount"`
   993  	LiveChannelCount            int64    `xml:"LiveChannelCount"`
   994  	LastModifiedTime            int64    `xml:"LastModifiedTime"`
   995  	StandardStorage             int64    `xml:"StandardStorage"`
   996  	StandardObjectCount         int64    `xml:"StandardObjectCount"`
   997  	InfrequentAccessStorage     int64    `xml:"InfrequentAccessStorage"`
   998  	InfrequentAccessRealStorage int64    `xml:"InfrequentAccessRealStorage"`
   999  	InfrequentAccessObjectCount int64    `xml:"InfrequentAccessObjectCount"`
  1000  	ArchiveStorage              int64    `xml:"ArchiveStorage"`
  1001  	ArchiveRealStorage          int64    `xml:"ArchiveRealStorage"`
  1002  	ArchiveObjectCount          int64    `xml:"ArchiveObjectCount"`
  1003  	ColdArchiveStorage          int64    `xml:"ColdArchiveStorage"`
  1004  	ColdArchiveRealStorage      int64    `xml:"ColdArchiveRealStorage"`
  1005  	ColdArchiveObjectCount      int64    `xml:"ColdArchiveObjectCount"`
  1006  }
  1007  type GetBucketStatResult BucketStat
  1008  
  1009  // RequestPaymentConfiguration define the request payment configuration
  1010  type RequestPaymentConfiguration struct {
  1011  	XMLName xml.Name `xml:"RequestPaymentConfiguration"`
  1012  	Payer   string   `xml:"Payer,omitempty"`
  1013  }
  1014  
  1015  // BucketQoSConfiguration define QoS configuration
  1016  type BucketQoSConfiguration struct {
  1017  	XMLName                   xml.Name `xml:"QoSConfiguration"`
  1018  	TotalUploadBandwidth      *int     `xml:"TotalUploadBandwidth"`      // Total upload bandwidth
  1019  	IntranetUploadBandwidth   *int     `xml:"IntranetUploadBandwidth"`   // Intranet upload bandwidth
  1020  	ExtranetUploadBandwidth   *int     `xml:"ExtranetUploadBandwidth"`   // Extranet upload bandwidth
  1021  	TotalDownloadBandwidth    *int     `xml:"TotalDownloadBandwidth"`    // Total download bandwidth
  1022  	IntranetDownloadBandwidth *int     `xml:"IntranetDownloadBandwidth"` // Intranet download bandwidth
  1023  	ExtranetDownloadBandwidth *int     `xml:"ExtranetDownloadBandwidth"` // Extranet download bandwidth
  1024  	TotalQPS                  *int     `xml:"TotalQps"`                  // Total Qps
  1025  	IntranetQPS               *int     `xml:"IntranetQps"`               // Intranet Qps
  1026  	ExtranetQPS               *int     `xml:"ExtranetQps"`               // Extranet Qps
  1027  }
  1028  
  1029  // UserQoSConfiguration define QoS and Range configuration
  1030  type UserQoSConfiguration struct {
  1031  	XMLName xml.Name `xml:"QoSConfiguration"`
  1032  	Region  string   `xml:"Region,omitempty"` // Effective area of Qos configuration
  1033  	BucketQoSConfiguration
  1034  }
  1035  
  1036  //////////////////////////////////////////////////////////////
  1037  /////////////////// Select OBject ////////////////////////////
  1038  //////////////////////////////////////////////////////////////
  1039  
  1040  type CsvMetaRequest struct {
  1041  	XMLName            xml.Name           `xml:"CsvMetaRequest"`
  1042  	InputSerialization InputSerialization `xml:"InputSerialization"`
  1043  	OverwriteIfExists  *bool              `xml:"OverwriteIfExists,omitempty"`
  1044  }
  1045  
  1046  // encodeBase64 encode base64 of the CreateSelectObjectMeta api request params
  1047  func (meta *CsvMetaRequest) encodeBase64() {
  1048  	meta.InputSerialization.CSV.RecordDelimiter =
  1049  		base64.StdEncoding.EncodeToString([]byte(meta.InputSerialization.CSV.RecordDelimiter))
  1050  	meta.InputSerialization.CSV.FieldDelimiter =
  1051  		base64.StdEncoding.EncodeToString([]byte(meta.InputSerialization.CSV.FieldDelimiter))
  1052  	meta.InputSerialization.CSV.QuoteCharacter =
  1053  		base64.StdEncoding.EncodeToString([]byte(meta.InputSerialization.CSV.QuoteCharacter))
  1054  }
  1055  
  1056  type JsonMetaRequest struct {
  1057  	XMLName            xml.Name           `xml:"JsonMetaRequest"`
  1058  	InputSerialization InputSerialization `xml:"InputSerialization"`
  1059  	OverwriteIfExists  *bool              `xml:"OverwriteIfExists,omitempty"`
  1060  }
  1061  
  1062  type InputSerialization struct {
  1063  	XMLName         xml.Name `xml:"InputSerialization"`
  1064  	CSV             CSV      `xml:CSV,omitempty`
  1065  	JSON            JSON     `xml:JSON,omitempty`
  1066  	CompressionType string   `xml:"CompressionType,omitempty"`
  1067  }
  1068  type CSV struct {
  1069  	XMLName         xml.Name `xml:"CSV"`
  1070  	RecordDelimiter string   `xml:"RecordDelimiter,omitempty"`
  1071  	FieldDelimiter  string   `xml:"FieldDelimiter,omitempty"`
  1072  	QuoteCharacter  string   `xml:"QuoteCharacter,omitempty"`
  1073  }
  1074  
  1075  type JSON struct {
  1076  	XMLName  xml.Name `xml:"JSON"`
  1077  	JSONType string   `xml:"Type,omitempty"`
  1078  }
  1079  
  1080  // SelectRequest is for the SelectObject request params of json file
  1081  type SelectRequest struct {
  1082  	XMLName                   xml.Name                  `xml:"SelectRequest"`
  1083  	Expression                string                    `xml:"Expression"`
  1084  	InputSerializationSelect  InputSerializationSelect  `xml:"InputSerialization"`
  1085  	OutputSerializationSelect OutputSerializationSelect `xml:"OutputSerialization"`
  1086  	SelectOptions             SelectOptions             `xml:"Options,omitempty"`
  1087  }
  1088  type InputSerializationSelect struct {
  1089  	XMLName         xml.Name        `xml:"InputSerialization"`
  1090  	CsvBodyInput    CSVSelectInput  `xml:CSV,omitempty`
  1091  	JsonBodyInput   JSONSelectInput `xml:JSON,omitempty`
  1092  	CompressionType string          `xml:"CompressionType,omitempty"`
  1093  }
  1094  type CSVSelectInput struct {
  1095  	XMLName          xml.Name `xml:"CSV"`
  1096  	FileHeaderInfo   string   `xml:"FileHeaderInfo,omitempty"`
  1097  	RecordDelimiter  string   `xml:"RecordDelimiter,omitempty"`
  1098  	FieldDelimiter   string   `xml:"FieldDelimiter,omitempty"`
  1099  	QuoteCharacter   string   `xml:"QuoteCharacter,omitempty"`
  1100  	CommentCharacter string   `xml:"CommentCharacter,omitempty"`
  1101  	Range            string   `xml:"Range,omitempty"`
  1102  	SplitRange       string
  1103  }
  1104  type JSONSelectInput struct {
  1105  	XMLName                 xml.Name `xml:"JSON"`
  1106  	JSONType                string   `xml:"Type,omitempty"`
  1107  	Range                   string   `xml:"Range,omitempty"`
  1108  	ParseJSONNumberAsString *bool    `xml:"ParseJsonNumberAsString"`
  1109  	SplitRange              string
  1110  }
  1111  
  1112  func (jsonInput *JSONSelectInput) JsonIsEmpty() bool {
  1113  	if jsonInput.JSONType != "" {
  1114  		return false
  1115  	}
  1116  	return true
  1117  }
  1118  
  1119  type OutputSerializationSelect struct {
  1120  	XMLName          xml.Name         `xml:"OutputSerialization"`
  1121  	CsvBodyOutput    CSVSelectOutput  `xml:CSV,omitempty`
  1122  	JsonBodyOutput   JSONSelectOutput `xml:JSON,omitempty`
  1123  	OutputRawData    *bool            `xml:"OutputRawData,omitempty"`
  1124  	KeepAllColumns   *bool            `xml:"KeepAllColumns,omitempty"`
  1125  	EnablePayloadCrc *bool            `xml:"EnablePayloadCrc,omitempty"`
  1126  	OutputHeader     *bool            `xml:"OutputHeader,omitempty"`
  1127  }
  1128  type CSVSelectOutput struct {
  1129  	XMLName         xml.Name `xml:"CSV"`
  1130  	RecordDelimiter string   `xml:"RecordDelimiter,omitempty"`
  1131  	FieldDelimiter  string   `xml:"FieldDelimiter,omitempty"`
  1132  }
  1133  type JSONSelectOutput struct {
  1134  	XMLName         xml.Name `xml:"JSON"`
  1135  	RecordDelimiter string   `xml:"RecordDelimiter,omitempty"`
  1136  }
  1137  
  1138  func (selectReq *SelectRequest) encodeBase64() {
  1139  	if selectReq.InputSerializationSelect.JsonBodyInput.JsonIsEmpty() {
  1140  		selectReq.csvEncodeBase64()
  1141  	} else {
  1142  		selectReq.jsonEncodeBase64()
  1143  	}
  1144  }
  1145  
  1146  // csvEncodeBase64 encode base64 of the SelectObject api request params
  1147  func (selectReq *SelectRequest) csvEncodeBase64() {
  1148  	selectReq.Expression = base64.StdEncoding.EncodeToString([]byte(selectReq.Expression))
  1149  	selectReq.InputSerializationSelect.CsvBodyInput.RecordDelimiter =
  1150  		base64.StdEncoding.EncodeToString([]byte(selectReq.InputSerializationSelect.CsvBodyInput.RecordDelimiter))
  1151  	selectReq.InputSerializationSelect.CsvBodyInput.FieldDelimiter =
  1152  		base64.StdEncoding.EncodeToString([]byte(selectReq.InputSerializationSelect.CsvBodyInput.FieldDelimiter))
  1153  	selectReq.InputSerializationSelect.CsvBodyInput.QuoteCharacter =
  1154  		base64.StdEncoding.EncodeToString([]byte(selectReq.InputSerializationSelect.CsvBodyInput.QuoteCharacter))
  1155  	selectReq.InputSerializationSelect.CsvBodyInput.CommentCharacter =
  1156  		base64.StdEncoding.EncodeToString([]byte(selectReq.InputSerializationSelect.CsvBodyInput.CommentCharacter))
  1157  	selectReq.OutputSerializationSelect.CsvBodyOutput.FieldDelimiter =
  1158  		base64.StdEncoding.EncodeToString([]byte(selectReq.OutputSerializationSelect.CsvBodyOutput.FieldDelimiter))
  1159  	selectReq.OutputSerializationSelect.CsvBodyOutput.RecordDelimiter =
  1160  		base64.StdEncoding.EncodeToString([]byte(selectReq.OutputSerializationSelect.CsvBodyOutput.RecordDelimiter))
  1161  
  1162  	// handle Range
  1163  	if selectReq.InputSerializationSelect.CsvBodyInput.Range != "" {
  1164  		selectReq.InputSerializationSelect.CsvBodyInput.Range = "line-range=" + selectReq.InputSerializationSelect.CsvBodyInput.Range
  1165  	}
  1166  
  1167  	if selectReq.InputSerializationSelect.CsvBodyInput.SplitRange != "" {
  1168  		selectReq.InputSerializationSelect.CsvBodyInput.Range = "split-range=" + selectReq.InputSerializationSelect.CsvBodyInput.SplitRange
  1169  	}
  1170  }
  1171  
  1172  // jsonEncodeBase64 encode base64 of the SelectObject api request params
  1173  func (selectReq *SelectRequest) jsonEncodeBase64() {
  1174  	selectReq.Expression = base64.StdEncoding.EncodeToString([]byte(selectReq.Expression))
  1175  	selectReq.OutputSerializationSelect.JsonBodyOutput.RecordDelimiter =
  1176  		base64.StdEncoding.EncodeToString([]byte(selectReq.OutputSerializationSelect.JsonBodyOutput.RecordDelimiter))
  1177  
  1178  	// handle Range
  1179  	if selectReq.InputSerializationSelect.JsonBodyInput.Range != "" {
  1180  		selectReq.InputSerializationSelect.JsonBodyInput.Range = "line-range=" + selectReq.InputSerializationSelect.JsonBodyInput.Range
  1181  	}
  1182  
  1183  	if selectReq.InputSerializationSelect.JsonBodyInput.SplitRange != "" {
  1184  		selectReq.InputSerializationSelect.JsonBodyInput.Range = "split-range=" + selectReq.InputSerializationSelect.JsonBodyInput.SplitRange
  1185  	}
  1186  }
  1187  
  1188  // SelectOptions is a element in the SelectObject api request's params
  1189  type SelectOptions struct {
  1190  	XMLName                  xml.Name `xml:"Options"`
  1191  	SkipPartialDataRecord    *bool    `xml:"SkipPartialDataRecord,omitempty"`
  1192  	MaxSkippedRecordsAllowed string   `xml:"MaxSkippedRecordsAllowed,omitempty"`
  1193  }
  1194  
  1195  // SelectObjectResult is the SelectObject api's return
  1196  type SelectObjectResult struct {
  1197  	Version          byte
  1198  	FrameType        int32
  1199  	PayloadLength    int32
  1200  	HeaderCheckSum   uint32
  1201  	Offset           uint64
  1202  	Data             string           // DataFrame
  1203  	EndFrame         EndFrame         // EndFrame
  1204  	MetaEndFrameCSV  MetaEndFrameCSV  // MetaEndFrameCSV
  1205  	MetaEndFrameJSON MetaEndFrameJSON // MetaEndFrameJSON
  1206  	PayloadChecksum  uint32
  1207  	ReadFlagInfo
  1208  }
  1209  
  1210  // ReadFlagInfo if reading the frame data, recode the reading status
  1211  type ReadFlagInfo struct {
  1212  	OpenLine            bool
  1213  	ConsumedBytesLength int32
  1214  	EnablePayloadCrc    bool
  1215  	OutputRawData       bool
  1216  }
  1217  
  1218  // EndFrame is EndFrameType of SelectObject api
  1219  type EndFrame struct {
  1220  	TotalScanned   int64
  1221  	HTTPStatusCode int32
  1222  	ErrorMsg       string
  1223  }
  1224  
  1225  // MetaEndFrameCSV is MetaEndFrameCSVType of CreateSelectObjectMeta
  1226  type MetaEndFrameCSV struct {
  1227  	TotalScanned int64
  1228  	Status       int32
  1229  	SplitsCount  int32
  1230  	RowsCount    int64
  1231  	ColumnsCount int32
  1232  	ErrorMsg     string
  1233  }
  1234  
  1235  // MetaEndFrameJSON is MetaEndFrameJSON of CreateSelectObjectMeta
  1236  type MetaEndFrameJSON struct {
  1237  	TotalScanned int64
  1238  	Status       int32
  1239  	SplitsCount  int32
  1240  	RowsCount    int64
  1241  	ErrorMsg     string
  1242  }
  1243  
  1244  // InventoryConfiguration is Inventory config
  1245  type InventoryConfiguration struct {
  1246  	XMLName                xml.Name             `xml:"InventoryConfiguration"`
  1247  	Id                     string               `xml:"Id,omitempty"`
  1248  	IsEnabled              *bool                `xml:"IsEnabled,omitempty"`
  1249  	Prefix                 string               `xml:"Filter>Prefix,omitempty"`
  1250  	OSSBucketDestination   OSSBucketDestination `xml:"Destination>OSSBucketDestination,omitempty"`
  1251  	Frequency              string               `xml:"Schedule>Frequency,omitempty"`
  1252  	IncludedObjectVersions string               `xml:"IncludedObjectVersions,omitempty"`
  1253  	OptionalFields         OptionalFields       `xml:OptionalFields,omitempty`
  1254  }
  1255  
  1256  type OptionalFields struct {
  1257  	XMLName xml.Name `xml:"OptionalFields,omitempty`
  1258  	Field   []string `xml:"Field,omitempty`
  1259  }
  1260  
  1261  type OSSBucketDestination struct {
  1262  	XMLName    xml.Name       `xml:"OSSBucketDestination"`
  1263  	Format     string         `xml:"Format,omitempty"`
  1264  	AccountId  string         `xml:"AccountId,omitempty"`
  1265  	RoleArn    string         `xml:"RoleArn,omitempty"`
  1266  	Bucket     string         `xml:"Bucket,omitempty"`
  1267  	Prefix     string         `xml:"Prefix,omitempty"`
  1268  	Encryption *InvEncryption `xml:"Encryption,omitempty"`
  1269  }
  1270  
  1271  type InvEncryption struct {
  1272  	XMLName xml.Name   `xml:"Encryption"`
  1273  	SseOss  *InvSseOss `xml:"SSE-OSS"`
  1274  	SseKms  *InvSseKms `xml:"SSE-KMS"`
  1275  }
  1276  
  1277  type InvSseOss struct {
  1278  	XMLName xml.Name `xml:"SSE-OSS"`
  1279  }
  1280  
  1281  type InvSseKms struct {
  1282  	XMLName xml.Name `xml:"SSE-KMS"`
  1283  	KmsId   string   `xml:"KeyId,omitempty"`
  1284  }
  1285  
  1286  type ListInventoryConfigurationsResult struct {
  1287  	XMLName                xml.Name                 `xml:"ListInventoryConfigurationsResult"`
  1288  	InventoryConfiguration []InventoryConfiguration `xml:"InventoryConfiguration,omitempty`
  1289  	IsTruncated            *bool                    `xml:"IsTruncated,omitempty"`
  1290  	NextContinuationToken  string                   `xml:"NextContinuationToken,omitempty"`
  1291  }
  1292  
  1293  // RestoreConfiguration for RestoreObject
  1294  type RestoreConfiguration struct {
  1295  	XMLName xml.Name `xml:"RestoreRequest"`
  1296  	Days    int32    `xml:"Days,omitempty"`
  1297  	Tier    string   `xml:"JobParameters>Tier,omitempty"`
  1298  }
  1299  
  1300  // AsyncFetchTaskConfiguration for SetBucketAsyncFetchTask
  1301  type AsyncFetchTaskConfiguration struct {
  1302  	XMLName       xml.Name `xml:"AsyncFetchTaskConfiguration"`
  1303  	Url           string   `xml:"Url,omitempty"`
  1304  	Object        string   `xml:"Object,omitempty"`
  1305  	Host          string   `xml:"Host,omitempty"`
  1306  	ContentMD5    string   `xml:"ContentMD5,omitempty"`
  1307  	Callback      string   `xml:"Callback,omitempty"`
  1308  	StorageClass  string   `xml:"StorageClass,omitempty"`
  1309  	IgnoreSameKey bool     `xml:"IgnoreSameKey"`
  1310  }
  1311  
  1312  // AsyncFetchTaskResult for SetBucketAsyncFetchTask result
  1313  type AsyncFetchTaskResult struct {
  1314  	XMLName xml.Name `xml:"AsyncFetchTaskResult"`
  1315  	TaskId  string   `xml:"TaskId,omitempty"`
  1316  }
  1317  
  1318  // AsynFetchTaskInfo for GetBucketAsyncFetchTask result
  1319  type AsynFetchTaskInfo struct {
  1320  	XMLName  xml.Name      `xml:"AsyncFetchTaskInfo"`
  1321  	TaskId   string        `xml:"TaskId,omitempty"`
  1322  	State    string        `xml:"State,omitempty"`
  1323  	ErrorMsg string        `xml:"ErrorMsg,omitempty"`
  1324  	TaskInfo AsyncTaskInfo `xml:"TaskInfo,omitempty"`
  1325  }
  1326  
  1327  // AsyncTaskInfo for async task information
  1328  type AsyncTaskInfo struct {
  1329  	XMLName       xml.Name `xml:"TaskInfo"`
  1330  	Url           string   `xml:"Url,omitempty"`
  1331  	Object        string   `xml:"Object,omitempty"`
  1332  	Host          string   `xml:"Host,omitempty"`
  1333  	ContentMD5    string   `xml:"ContentMD5,omitempty"`
  1334  	Callback      string   `xml:"Callback,omitempty"`
  1335  	StorageClass  string   `xml:"StorageClass,omitempty"`
  1336  	IgnoreSameKey bool     `xml:"IgnoreSameKey"`
  1337  }
  1338  
  1339  // InitiateWormConfiguration define InitiateBucketWorm configuration
  1340  type InitiateWormConfiguration struct {
  1341  	XMLName               xml.Name `xml:"InitiateWormConfiguration"`
  1342  	RetentionPeriodInDays int      `xml:"RetentionPeriodInDays"` // specify retention days
  1343  }
  1344  
  1345  // ExtendWormConfiguration define ExtendWormConfiguration configuration
  1346  type ExtendWormConfiguration struct {
  1347  	XMLName               xml.Name `xml:"ExtendWormConfiguration"`
  1348  	RetentionPeriodInDays int      `xml:"RetentionPeriodInDays"` // specify retention days
  1349  }
  1350  
  1351  // WormConfiguration define WormConfiguration
  1352  type WormConfiguration struct {
  1353  	XMLName               xml.Name `xml:"WormConfiguration"`
  1354  	WormId                string   `xml:"WormId,omitempty"`
  1355  	State                 string   `xml:"State,omitempty"`
  1356  	RetentionPeriodInDays int      `xml:"RetentionPeriodInDays"` // specify retention days
  1357  	CreationDate          string   `xml:"CreationDate,omitempty"`
  1358  }
  1359  
  1360  // TransferAccConfiguration define transfer acceleration configuration
  1361  type TransferAccConfiguration struct {
  1362  	XMLName xml.Name `xml:"TransferAccelerationConfiguration"`
  1363  	Enabled bool     `xml:"Enabled"`
  1364  }
  1365  
  1366  // ReplicationXML defines simple replication xml, and ReplicationXML is used for "DeleteBucketReplication" in client.go
  1367  type ReplicationXML struct {
  1368  	XMLName xml.Name `xml:"ReplicationRules"`
  1369  	ID      string   `xml:"ID,omitempty"`
  1370  }
  1371  
  1372  // PutBucketReplication define the bucket replication config
  1373  type PutBucketReplication BucketReplicationXml
  1374  
  1375  // GetBucketReplicationResult define get bucket's replication config
  1376  type GetBucketReplicationResult BucketReplicationXml
  1377  
  1378  // GetBucketReplicationLocationResult define get bucket's replication location
  1379  type GetBucketReplicationLocationResult BucketReplicationLocationXml
  1380  
  1381  // GetBucketReplicationProgressResult define get bucket's replication progress
  1382  type GetBucketReplicationProgressResult BucketReplicationProgressXml
  1383  
  1384  // PutBucketRTC define the bucket rtc config
  1385  type PutBucketRTC BucketRTCXml
  1386  
  1387  // BucketReplicationXml define the xml of bucket replication config
  1388  type BucketReplicationXml struct {
  1389  	XMLName xml.Name          `xml:"ReplicationConfiguration"`
  1390  	Rule    []ReplicationRule `xml:"Rule,omitempty"`
  1391  }
  1392  
  1393  // BucketReplicationProgressXml define the xml of bucket replication config
  1394  type BucketReplicationProgressXml struct {
  1395  	XMLName xml.Name          `xml:"ReplicationProgress"`
  1396  	Rule    []ReplicationRule `xml:"Rule,omitempty"`
  1397  }
  1398  
  1399  // BucketRTCXml define the xml of bucket rtc config
  1400  type BucketRTCXml struct {
  1401  	XMLName xml.Name `xml:"ReplicationRule"`
  1402  	RTC     *string  `xml:"RTC>Status,omitempty"`
  1403  	ID      string   `xml:"ID,omitempty"`
  1404  }
  1405  
  1406  // ReplicationRule define the xml of bucket replication config rule
  1407  type ReplicationRule struct {
  1408  	ID                          string                      `xml:"ID,omitempty"`
  1409  	RTC                         *string                     `xml:"RTC>Status,omitempty"`
  1410  	PrefixSet                   *ReplicationRulePrefix      `xml:"PrefixSet,omitempty"`
  1411  	Action                      string                      `xml:"Action,omitempty"`
  1412  	Destination                 *ReplicationRuleDestination `xml:"Destination,omitempty"`
  1413  	HistoricalObjectReplication string                      `xml:"HistoricalObjectReplication,omitempty"`
  1414  	Status                      string                      `xml:"Status,omitempty"`
  1415  	SyncRole                    string                      `xml:"SyncRole,omitempty"`
  1416  	SourceSelectionCriteria     *string                     `xml:"SourceSelectionCriteria>SseKmsEncryptedObjects>Status,omitempty"`
  1417  	EncryptionConfiguration     *string                     `xml:"EncryptionConfiguration>ReplicaKmsKeyID,omitempty"`
  1418  	Progress                    *ReplicationRuleProgress    `xml:"Progress,omitempty"`
  1419  	HistoricalObject            string                      `xml:"HistoricalObject,omitempty"`
  1420  }
  1421  
  1422  type ReplicationRulePrefix struct {
  1423  	Prefix []*string `xml:"Prefix,omitempty"`
  1424  }
  1425  
  1426  type ReplicationRuleDestination struct {
  1427  	Bucket       string `xml:"Bucket,omitempty"`
  1428  	Location     string `xml:"Location,omitempty"`
  1429  	TransferType string `xml:"TransferType,omitempty"`
  1430  }
  1431  
  1432  // BucketReplicationLocationXml define the xml of bucket replication location info
  1433  type BucketReplicationLocationXml struct {
  1434  	XMLName              xml.Name                          `xml:"ReplicationLocation"`
  1435  	Location             []string                          `xml:"Location,omitempty"`
  1436  	LocationTransferType []ReplicationLocationTransferType `xml:"LocationTransferTypeConstraint>LocationTransferType,omitempty"`
  1437  	RTCLocation          []string                          `xml:"LocationRTCConstraint>Location,omitempty"`
  1438  }
  1439  
  1440  type ReplicationLocation struct {
  1441  	Location string `xml:"Location,omitempty"`
  1442  }
  1443  
  1444  type ReplicationLocationTransferType struct {
  1445  	Location      string `xml:"Location,omitempty"`
  1446  	TransferTypes string `xml:"TransferTypes>Type,omitempty"`
  1447  }
  1448  
  1449  type ReplicationRuleProgress struct {
  1450  	HistoricalObject string `xml:"HistoricalObject,omitempty"`
  1451  	NewObject        string `xml:"NewObject,omitempty"`
  1452  }
  1453  
  1454  // CnameConfigurationXML define cname configuration
  1455  type CnameConfigurationXML struct {
  1456  	XMLName xml.Name `xml:"BucketCnameConfiguration"`
  1457  	Domain  string   `xml:"Cname>Domain"`
  1458  }
  1459  
  1460  type PutBucketCname PutBucketCnameXml
  1461  
  1462  // PutBucketCnameXml define cname configuration
  1463  type PutBucketCnameXml struct {
  1464  	XMLName                  xml.Name                  `xml:"BucketCnameConfiguration"`
  1465  	Cname                    string                    `xml:"Cname>Domain"`
  1466  	CertificateConfiguration *CertificateConfiguration `xml:"Cname>CertificateConfiguration"`
  1467  }
  1468  
  1469  type CertificateConfiguration struct {
  1470  	CertId            string `xml:"CertId,omitempty"`
  1471  	Certificate       string `xml:"Certificate,omitempty"`
  1472  	PrivateKey        string `xml:"PrivateKey,omitempty"`
  1473  	PreviousCertId    string `xml:"PreviousCertId,omitempty"`
  1474  	Force             bool   `xml:"Force,omitempty"`
  1475  	DeleteCertificate bool   `xml:"DeleteCertificate,omitempty"`
  1476  }
  1477  
  1478  // CnameTokenXML define cname token information
  1479  type CnameTokenXML struct {
  1480  	XMLName    xml.Name `xml:"CnameToken"`
  1481  	Bucket     string   `xml:"Bucket,omitempty"`
  1482  	Cname      string   `xml:"Cname,omitempty"`
  1483  	Token      string   `xml:"Token,omitempty"`
  1484  	ExpireTime string   `xml:"ExpireTime,omitempty"`
  1485  }
  1486  
  1487  // CreateBucketCnameTokenResult defines result object for CreateBucketCnameToken request
  1488  type CreateBucketCnameTokenResult CnameTokenXML
  1489  
  1490  // GetBucketCnameTokenResult defines result object for GetBucketCnameToken request
  1491  type GetBucketCnameTokenResult CnameTokenXML
  1492  
  1493  // GetMetaQueryStatusResult defines result for GetMetaQueryStatus result
  1494  type GetMetaQueryStatusResult GetMetaQueryStatusResultXml
  1495  
  1496  // GetMetaQueryStatusResultXml define get meta query status information
  1497  type GetMetaQueryStatusResultXml struct {
  1498  	XMLName    xml.Name `xml:"MetaQueryStatus"`
  1499  	State      string   `xml:"State"`
  1500  	Phase      string   `xml:"Phase"`
  1501  	CreateTime string   `xml:"CreateTime"`
  1502  	UpdateTime string   `xml:"UpdateTime"`
  1503  }
  1504  
  1505  // MetaQuery defines meta query struct
  1506  type MetaQuery struct {
  1507  	XMLName      xml.Name                      `xml:"MetaQuery"`
  1508  	NextToken    string                        `xml:"NextToken,omitempty"`
  1509  	MaxResults   int64                         `xml:"MaxResults,omitempty"`
  1510  	Query        string                        `xml:"Query"`
  1511  	Sort         string                        `xml:"Sort,omitempty"`
  1512  	Order        string                        `xml:"Order,omitempty"`
  1513  	Aggregations []MetaQueryAggregationRequest `xml:"Aggregations>Aggregation,omitempty"`
  1514  }
  1515  
  1516  // MetaQueryAggregationRequest defines meta query aggregation request
  1517  type MetaQueryAggregationRequest struct {
  1518  	XMLName   xml.Name `xml:"Aggregation"`
  1519  	Field     string   `xml:"Field,omitempty"`
  1520  	Operation string   `xml:"Operation,omitempty"`
  1521  }
  1522  
  1523  // MetaQueryAggregationResponse defines meta query aggregation response
  1524  type MetaQueryAggregationResponse struct {
  1525  	XMLName   xml.Name         `xml:"Aggregation"`
  1526  	Field     string           `xml:"Field,omitempty"`
  1527  	Operation string           `xml:"Operation,omitempty"`
  1528  	Value     float64          `xml:"Value,omitempty"`
  1529  	Groups    []MetaQueryGroup `xml:"Groups>Group,omitempty"`
  1530  }
  1531  
  1532  // DoMetaQueryResult defines result for DoMetaQuery result
  1533  type DoMetaQueryResult DoMetaQueryResultXml
  1534  
  1535  // DoMetaQueryResultXml defines do meta query information
  1536  type DoMetaQueryResultXml struct {
  1537  	XMLName      xml.Name                       `xml:"MetaQuery"`
  1538  	NextToken    string                         `xml:"NextToken,omitempty"`                 // next token
  1539  	Files        []MetaQueryFile                `xml:"Files>File,omitempty"`                // file
  1540  	Aggregations []MetaQueryAggregationResponse `xml:"Aggregations>Aggregation,omitempty"'` // Aggregation
  1541  }
  1542  
  1543  // MetaQueryFile defines do meta query result file information
  1544  type MetaQueryFile struct {
  1545  	XMLName                               xml.Name            `xml:"File"`
  1546  	Filename                              string              `xml:"Filename"`                                        //file name
  1547  	Size                                  int64               `xml:"Size"`                                            // file size
  1548  	FileModifiedTime                      string              `xml:"FileModifiedTime"`                                // file Modified Time
  1549  	OssObjectType                         string              `xml:"OSSObjectType"`                                   // Oss Object Type
  1550  	OssStorageClass                       string              `xml:"OSSStorageClass"`                                 // Oss Storage Class
  1551  	ObjectACL                             string              `xml:"ObjectACL"`                                       // Object Acl
  1552  	ETag                                  string              `xml:"ETag"`                                            // ETag
  1553  	OssCRC64                              string              `xml:"OSSCRC64"`                                        // Oss CRC64
  1554  	OssTaggingCount                       int64               `xml:"OSSTaggingCount,omitempty"`                       // Oss Tagging Count
  1555  	OssTagging                            []MetaQueryTagging  `xml:"OSSTagging>Tagging,omitempty"`                    // Tagging
  1556  	OssUserMeta                           []MetaQueryUserMeta `xml:"OSSUserMeta>UserMeta,omitempty"`                  // UserMeta
  1557  	ServerSideEncryption                  string              `xml:"ServerSideEncryption,omitempty"`                  //Server Side Encryption
  1558  	ServerSideEncryptionCustomerAlgorithm string              `xml:"ServerSideEncryptionCustomerAlgorithm,omitempty"` // Server Side Encryption Customer Algorithm
  1559  }
  1560  
  1561  // MetaQueryTagging defines do meta query result tagging information
  1562  type MetaQueryTagging struct {
  1563  	XMLName xml.Name `xml:"Tagging"`
  1564  	Key     string   `xml:"Key"`
  1565  	Value   string   `xml:"Value"`
  1566  }
  1567  
  1568  // MetaQueryUserMeta defines do meta query result user meta information
  1569  type MetaQueryUserMeta struct {
  1570  	XMLName xml.Name `xml:"UserMeta"`
  1571  	Key     string   `xml:"Key"`
  1572  	Value   string   `xml:"Value"`
  1573  }
  1574  
  1575  // MetaQueryGroup defines do meta query result group information
  1576  type MetaQueryGroup struct {
  1577  	XMLName xml.Name `xml:"Group"`
  1578  	Value   string   `xml:"Value"`
  1579  	Count   int64    `xml:"Count"`
  1580  }
  1581  
  1582  // GetBucketAccessMonitorResult define config for get bucket access monitor
  1583  type GetBucketAccessMonitorResult BucketAccessMonitorXml
  1584  
  1585  // PutBucketAccessMonitor define the xml of bucket access monitor config
  1586  type PutBucketAccessMonitor BucketAccessMonitorXml
  1587  
  1588  // BucketAccessMonitorXml define get bucket access monitor information
  1589  type BucketAccessMonitorXml struct {
  1590  	XMLName xml.Name `xml:"AccessMonitorConfiguration"`
  1591  	Status  string   `xml:"Status"` // access monitor status
  1592  }
  1593  
  1594  // ListBucketCnameResult define the cname list of the bucket
  1595  type ListBucketCnameResult BucketCnameXml
  1596  
  1597  // BucketCnameXml define get the bucket cname information
  1598  type BucketCnameXml struct {
  1599  	XMLName xml.Name `xml:"ListCnameResult"`
  1600  	Bucket  string   `xml:"Bucket"`
  1601  	Owner   string   `xml:"Owner"`
  1602  	Cname   []Cname  `xml:"Cname"`
  1603  }
  1604  
  1605  // Cname define the cname information
  1606  type Cname struct {
  1607  	Domain       string      `xml:"Domain"`
  1608  	LastModified string      `xml:"LastModified"`
  1609  	Status       string      `xml:"Status"`
  1610  	Certificate  Certificate `xml:"Certificate"`
  1611  }
  1612  
  1613  // Certificate define Details of domain name certificate
  1614  type Certificate struct {
  1615  	Type           string `xml:"Type"`
  1616  	CertId         string `xml:"CertId"`
  1617  	Status         string `xml:"Status"`
  1618  	CreationDate   string `xml:"CreationDate"`
  1619  	Fingerprint    string `xml:"Fingerprint"`
  1620  	ValidStartDate string `xml:"ValidStartDate"`
  1621  	ValidEndDate   string `xml:"ValidEndDate"`
  1622  }
  1623  
  1624  // GetBucketResourceGroupResult define resource group for the bucket
  1625  type GetBucketResourceGroupResult BucketResourceGroupXml
  1626  
  1627  // PutBucketResourceGroup define the xml of bucket's resource group config
  1628  type PutBucketResourceGroup BucketResourceGroupXml
  1629  
  1630  // BucketResourceGroupXml define the information of the bucket's resource group
  1631  type BucketResourceGroupXml struct {
  1632  	XMLName         xml.Name `xml:"BucketResourceGroupConfiguration"`
  1633  	ResourceGroupId string   `xml:"ResourceGroupId"` // resource groupId
  1634  }
  1635  
  1636  // GetBucketStyleResult define style for the bucket
  1637  type GetBucketStyleResult BucketStyleXml
  1638  
  1639  // GetBucketListStyleResult define the list style for the bucket
  1640  type GetBucketListStyleResult BucketListStyleXml
  1641  
  1642  // BucketListStyleXml define the list style of the bucket
  1643  type BucketListStyleXml struct {
  1644  	XMLName xml.Name         `xml:"StyleList"`
  1645  	Style   []BucketStyleXml `xml:"Style,omitempty"` // style
  1646  }
  1647  
  1648  // BucketStyleXml define the information of the bucket's style
  1649  type BucketStyleXml struct {
  1650  	XMLName        xml.Name `xml:"Style"`
  1651  	Name           string   `xml:"Name,omitempty"`           // style name
  1652  	Content        string   `xml:"Content"`                  // style content
  1653  	CreateTime     string   `xml:"CreateTime,omitempty"`     // style create time
  1654  	LastModifyTime string   `xml:"LastModifyTime,omitempty"` // style last modify time
  1655  }
  1656  
  1657  // DescribeRegionsResult define get the describe regions result
  1658  type DescribeRegionsResult RegionInfoList
  1659  
  1660  type RegionInfo struct {
  1661  	Region             string `xml:"Region"`
  1662  	InternetEndpoint   string `xml:"InternetEndpoint"`
  1663  	InternalEndpoint   string `xml:"InternalEndpoint"`
  1664  	AccelerateEndpoint string `xml:"AccelerateEndpoint"`
  1665  }
  1666  
  1667  type RegionInfoList struct {
  1668  	XMLName xml.Name     `xml:"RegionInfoList"`
  1669  	Regions []RegionInfo `xml:"RegionInfo"`
  1670  }
  1671  
  1672  //PutBucketResponseHeader define the xml of bucket's response header config
  1673  type PutBucketResponseHeader ResponseHeaderXml
  1674  
  1675  //GetBucketResponseHeaderResult define the xml of bucket's response header result
  1676  type GetBucketResponseHeaderResult ResponseHeaderXml
  1677  
  1678  type ResponseHeaderXml struct {
  1679  	XMLName xml.Name             `xml:"ResponseHeaderConfiguration"`
  1680  	Rule    []ResponseHeaderRule `xml:Rule,omitempty"` // rule
  1681  }
  1682  
  1683  type ResponseHeaderRule struct {
  1684  	Name        string                    `xml:"Name"`                  // rule name
  1685  	Filters     ResponseHeaderRuleFilters `xml:"Filters,omitempty"`     // rule filters Operation
  1686  	HideHeaders ResponseHeaderRuleHeaders `xml:"HideHeaders,omitempty"` // rule hide header
  1687  }
  1688  
  1689  type ResponseHeaderRuleFilters struct {
  1690  	Operation []string `xml:"Operation,omitempty"`
  1691  }
  1692  
  1693  type ResponseHeaderRuleHeaders struct {
  1694  	Header []string `xml:"Header,omitempty"`
  1695  }