github.com/chnsz/golangsdk@v0.0.0-20240506093406-85a3fbfa605b/openstack/obs/model_base.go (about)

     1  // Copyright 2019 Huawei Technologies Co.,Ltd.
     2  // Licensed under the Apache License, Version 2.0 (the "License"); you may not use
     3  // this file except in compliance with the License.  You may obtain a copy of the
     4  // License at
     5  //
     6  // http://www.apache.org/licenses/LICENSE-2.0
     7  //
     8  // Unless required by applicable law or agreed to in writing, software distributed
     9  // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
    10  // CONDITIONS OF ANY KIND, either express or implied.  See the License for the
    11  // specific language governing permissions and limitations under the License.
    12  
    13  package obs
    14  
    15  import (
    16  	"encoding/xml"
    17  	"time"
    18  )
    19  
    20  // Bucket defines bucket properties
    21  type Bucket struct {
    22  	XMLName      xml.Name  `xml:"Bucket"`
    23  	Name         string    `xml:"Name"`
    24  	CreationDate time.Time `xml:"CreationDate"`
    25  	Location     string    `xml:"Location"`
    26  	BucketType   string    `xml:"BucketType,omitempty"`
    27  }
    28  
    29  // Owner defines owner properties
    30  type Owner struct {
    31  	XMLName     xml.Name `xml:"Owner"`
    32  	ID          string   `xml:"ID"`
    33  	DisplayName string   `xml:"DisplayName,omitempty"`
    34  }
    35  
    36  // Initiator defines initiator properties
    37  type Initiator struct {
    38  	XMLName     xml.Name `xml:"Initiator"`
    39  	ID          string   `xml:"ID"`
    40  	DisplayName string   `xml:"DisplayName,omitempty"`
    41  }
    42  
    43  type bucketLocationObs struct {
    44  	XMLName  xml.Name `xml:"Location"`
    45  	Location string   `xml:",chardata"`
    46  }
    47  
    48  // BucketLocation defines bucket location configuration
    49  type BucketLocation struct {
    50  	XMLName  xml.Name `xml:"CreateBucketConfiguration"`
    51  	Location string   `xml:"LocationConstraint,omitempty"`
    52  }
    53  
    54  // BucketStoragePolicy defines the bucket storage class
    55  type BucketStoragePolicy struct {
    56  	XMLName      xml.Name         `xml:"StoragePolicy"`
    57  	StorageClass StorageClassType `xml:"DefaultStorageClass"`
    58  }
    59  
    60  type bucketStoragePolicyObs struct {
    61  	XMLName      xml.Name `xml:"StorageClass"`
    62  	StorageClass string   `xml:",chardata"`
    63  }
    64  
    65  // Content defines the object content properties
    66  type Content struct {
    67  	XMLName      xml.Name         `xml:"Contents"`
    68  	Owner        Owner            `xml:"Owner"`
    69  	ETag         string           `xml:"ETag"`
    70  	Key          string           `xml:"Key"`
    71  	LastModified time.Time        `xml:"LastModified"`
    72  	Size         int64            `xml:"Size"`
    73  	StorageClass StorageClassType `xml:"StorageClass"`
    74  }
    75  
    76  // Version defines the properties of versioning objects
    77  type Version struct {
    78  	DeleteMarker
    79  	XMLName xml.Name `xml:"Version"`
    80  	ETag    string   `xml:"ETag"`
    81  	Size    int64    `xml:"Size"`
    82  }
    83  
    84  // DeleteMarker defines the properties of versioning delete markers
    85  type DeleteMarker struct {
    86  	XMLName      xml.Name         `xml:"DeleteMarker"`
    87  	Key          string           `xml:"Key"`
    88  	VersionId    string           `xml:"VersionId"`
    89  	IsLatest     bool             `xml:"IsLatest"`
    90  	LastModified time.Time        `xml:"LastModified"`
    91  	Owner        Owner            `xml:"Owner"`
    92  	StorageClass StorageClassType `xml:"StorageClass"`
    93  }
    94  
    95  // Upload defines multipart upload properties
    96  type Upload struct {
    97  	XMLName      xml.Name         `xml:"Upload"`
    98  	Key          string           `xml:"Key"`
    99  	UploadId     string           `xml:"UploadId"`
   100  	Initiated    time.Time        `xml:"Initiated"`
   101  	StorageClass StorageClassType `xml:"StorageClass"`
   102  	Owner        Owner            `xml:"Owner"`
   103  	Initiator    Initiator        `xml:"Initiator"`
   104  }
   105  
   106  // BucketQuota defines bucket quota configuration
   107  type BucketQuota struct {
   108  	XMLName xml.Name `xml:"Quota"`
   109  	Quota   int64    `xml:"StorageQuota"`
   110  }
   111  
   112  // Grantee defines grantee properties
   113  type Grantee struct {
   114  	XMLName     xml.Name     `xml:"Grantee"`
   115  	Type        GranteeType  `xml:"type,attr"`
   116  	ID          string       `xml:"ID,omitempty"`
   117  	DisplayName string       `xml:"DisplayName,omitempty"`
   118  	URI         GroupUriType `xml:"URI,omitempty"`
   119  }
   120  
   121  type granteeObs struct {
   122  	XMLName     xml.Name    `xml:"Grantee"`
   123  	Type        GranteeType `xml:"type,attr"`
   124  	ID          string      `xml:"ID,omitempty"`
   125  	DisplayName string      `xml:"DisplayName,omitempty"`
   126  	Canned      string      `xml:"Canned,omitempty"`
   127  }
   128  
   129  // Grant defines grant properties
   130  type Grant struct {
   131  	XMLName    xml.Name       `xml:"Grant"`
   132  	Grantee    Grantee        `xml:"Grantee"`
   133  	Permission PermissionType `xml:"Permission"`
   134  	Delivered  bool           `xml:"Delivered"`
   135  }
   136  
   137  type grantObs struct {
   138  	XMLName    xml.Name       `xml:"Grant"`
   139  	Grantee    granteeObs     `xml:"Grantee"`
   140  	Permission PermissionType `xml:"Permission"`
   141  	Delivered  bool           `xml:"Delivered"`
   142  }
   143  
   144  // AccessControlPolicy defines access control policy properties
   145  type AccessControlPolicy struct {
   146  	XMLName   xml.Name `xml:"AccessControlPolicy"`
   147  	Owner     Owner    `xml:"Owner"`
   148  	Grants    []Grant  `xml:"AccessControlList>Grant"`
   149  	Delivered string   `xml:"Delivered,omitempty"`
   150  }
   151  
   152  type accessControlPolicyObs struct {
   153  	XMLName xml.Name   `xml:"AccessControlPolicy"`
   154  	Owner   Owner      `xml:"Owner"`
   155  	Grants  []grantObs `xml:"AccessControlList>Grant"`
   156  }
   157  
   158  // CorsRule defines the CORS rules
   159  type CorsRule struct {
   160  	XMLName       xml.Name `xml:"CORSRule"`
   161  	ID            string   `xml:"ID,omitempty"`
   162  	AllowedOrigin []string `xml:"AllowedOrigin"`
   163  	AllowedMethod []string `xml:"AllowedMethod"`
   164  	AllowedHeader []string `xml:"AllowedHeader,omitempty"`
   165  	MaxAgeSeconds int      `xml:"MaxAgeSeconds"`
   166  	ExposeHeader  []string `xml:"ExposeHeader,omitempty"`
   167  }
   168  
   169  // BucketCors defines the bucket CORS configuration
   170  type BucketCors struct {
   171  	XMLName   xml.Name   `xml:"CORSConfiguration"`
   172  	CorsRules []CorsRule `xml:"CORSRule"`
   173  }
   174  
   175  // BucketVersioningConfiguration defines the versioning configuration
   176  type BucketVersioningConfiguration struct {
   177  	XMLName xml.Name             `xml:"VersioningConfiguration"`
   178  	Status  VersioningStatusType `xml:"Status"`
   179  }
   180  
   181  // IndexDocument defines the default page configuration
   182  type IndexDocument struct {
   183  	Suffix string `xml:"Suffix"`
   184  }
   185  
   186  // ErrorDocument defines the error page configuration
   187  type ErrorDocument struct {
   188  	Key string `xml:"Key,omitempty"`
   189  }
   190  
   191  // Condition defines condition in RoutingRule
   192  type Condition struct {
   193  	XMLName                     xml.Name `xml:"Condition"`
   194  	KeyPrefixEquals             string   `xml:"KeyPrefixEquals,omitempty"`
   195  	HttpErrorCodeReturnedEquals string   `xml:"HttpErrorCodeReturnedEquals,omitempty"`
   196  }
   197  
   198  // Redirect defines redirect in RoutingRule
   199  type Redirect struct {
   200  	XMLName              xml.Name     `xml:"Redirect"`
   201  	Protocol             ProtocolType `xml:"Protocol,omitempty"`
   202  	HostName             string       `xml:"HostName,omitempty"`
   203  	ReplaceKeyPrefixWith string       `xml:"ReplaceKeyPrefixWith,omitempty"`
   204  	ReplaceKeyWith       string       `xml:"ReplaceKeyWith,omitempty"`
   205  	HttpRedirectCode     string       `xml:"HttpRedirectCode,omitempty"`
   206  }
   207  
   208  // RoutingRule defines routing rules
   209  type RoutingRule struct {
   210  	XMLName   xml.Name  `xml:"RoutingRule"`
   211  	Condition Condition `xml:"Condition,omitempty"`
   212  	Redirect  Redirect  `xml:"Redirect"`
   213  }
   214  
   215  // RedirectAllRequestsTo defines redirect in BucketWebsiteConfiguration
   216  type RedirectAllRequestsTo struct {
   217  	XMLName  xml.Name     `xml:"RedirectAllRequestsTo"`
   218  	Protocol ProtocolType `xml:"Protocol,omitempty"`
   219  	HostName string       `xml:"HostName"`
   220  }
   221  
   222  // BucketWebsiteConfiguration defines the bucket website configuration
   223  type BucketWebsiteConfiguration struct {
   224  	XMLName               xml.Name              `xml:"WebsiteConfiguration"`
   225  	RedirectAllRequestsTo RedirectAllRequestsTo `xml:"RedirectAllRequestsTo,omitempty"`
   226  	IndexDocument         IndexDocument         `xml:"IndexDocument,omitempty"`
   227  	ErrorDocument         ErrorDocument         `xml:"ErrorDocument,omitempty"`
   228  	RoutingRules          []RoutingRule         `xml:"RoutingRules>RoutingRule,omitempty"`
   229  }
   230  
   231  // BucketLoggingStatus defines the bucket logging configuration
   232  type BucketLoggingStatus struct {
   233  	XMLName      xml.Name `xml:"BucketLoggingStatus"`
   234  	Agency       string   `xml:"Agency,omitempty"`
   235  	TargetBucket string   `xml:"LoggingEnabled>TargetBucket,omitempty"`
   236  	TargetPrefix string   `xml:"LoggingEnabled>TargetPrefix,omitempty"`
   237  	TargetGrants []Grant  `xml:"LoggingEnabled>TargetGrants>Grant,omitempty"`
   238  }
   239  
   240  // Transition defines transition property in LifecycleRule
   241  type Transition struct {
   242  	XMLName      xml.Name         `xml:"Transition"`
   243  	Date         time.Time        `xml:"Date,omitempty"`
   244  	Days         int              `xml:"Days,omitempty"`
   245  	StorageClass StorageClassType `xml:"StorageClass"`
   246  }
   247  
   248  // Expiration defines expiration property in LifecycleRule
   249  type Expiration struct {
   250  	XMLName                   xml.Name  `xml:"Expiration"`
   251  	Date                      time.Time `xml:"Date,omitempty"`
   252  	Days                      int       `xml:"Days,omitempty"`
   253  	ExpiredObjectDeleteMarker string    `xml:"ExpiredObjectDeleteMarker,omitempty"`
   254  }
   255  
   256  // NoncurrentVersionTransition defines noncurrentVersion transition property in LifecycleRule
   257  type NoncurrentVersionTransition struct {
   258  	XMLName        xml.Name         `xml:"NoncurrentVersionTransition"`
   259  	NoncurrentDays int              `xml:"NoncurrentDays"`
   260  	StorageClass   StorageClassType `xml:"StorageClass"`
   261  }
   262  
   263  // NoncurrentVersionExpiration defines noncurrentVersion expiration property in LifecycleRule
   264  type NoncurrentVersionExpiration struct {
   265  	XMLName        xml.Name `xml:"NoncurrentVersionExpiration"`
   266  	NoncurrentDays int      `xml:"NoncurrentDays"`
   267  }
   268  
   269  // AbortIncompleteMultipartUpload defines abortIncomplete expiration property in LifecycleRule
   270  type AbortIncompleteMultipartUpload struct {
   271  	XMLName             xml.Name `xml:"AbortIncompleteMultipartUpload"`
   272  	DaysAfterInitiation int      `xml:"DaysAfterInitiation"`
   273  }
   274  
   275  // LifecycleRule defines lifecycle rule
   276  type LifecycleRule struct {
   277  	ID                             string                         `xml:"ID,omitempty"`
   278  	Prefix                         string                         `xml:"Prefix"`
   279  	Status                         RuleStatusType                 `xml:"Status"`
   280  	Transitions                    []Transition                   `xml:"Transition,omitempty"`
   281  	Expiration                     Expiration                     `xml:"Expiration,omitempty"`
   282  	NoncurrentVersionTransitions   []NoncurrentVersionTransition  `xml:"NoncurrentVersionTransition,omitempty"`
   283  	NoncurrentVersionExpiration    NoncurrentVersionExpiration    `xml:"NoncurrentVersionExpiration,omitempty"`
   284  	AbortIncompleteMultipartUpload AbortIncompleteMultipartUpload `xml:"AbortIncompleteMultipartUpload,omitempty"`
   285  	Filter                         LifecycleFilter                `xml:"Filter,omitempty"`
   286  }
   287  
   288  type LifecycleFilter struct {
   289  	XMLName xml.Name `xml:"Filter"`
   290  	Prefix  string   `xml:"And>Prefix,omitempty"`
   291  	Tags    []Tag    `xml:"And>Tag,omitempty"`
   292  }
   293  
   294  // BucketEncryptionConfiguration defines the bucket encryption configuration
   295  type BucketEncryptionConfiguration struct {
   296  	XMLName        xml.Name `xml:"ServerSideEncryptionConfiguration"`
   297  	SSEAlgorithm   string   `xml:"Rule>ApplyServerSideEncryptionByDefault>SSEAlgorithm"`
   298  	KMSMasterKeyID string   `xml:"Rule>ApplyServerSideEncryptionByDefault>KMSMasterKeyID,omitempty"`
   299  	ProjectID      string   `xml:"Rule>ApplyServerSideEncryptionByDefault>ProjectID,omitempty"`
   300  }
   301  
   302  // ReplicationRule defines bucket cross-region replication rule
   303  type ReplicationRule struct {
   304  	ID                          string           `xml:"ID,omitempty"`
   305  	Prefix                      string           `xml:"Prefix"`
   306  	Status                      RuleStatusType   `xml:"Status"`
   307  	DestinationBucket           string           `xml:"Destination>Bucket"`
   308  	StorageClass                StorageClassType `xml:"Destination>StorageClass,omitempty"`
   309  	DeleteDate                  EnabledType      `xml:"Destination>DeleteDate,omitempty"`
   310  	HistoricalObjectReplication EnabledType      `xml:"HistoricalObjectReplication,omitempty"`
   311  }
   312  
   313  // BucketReplicationConfiguration defines the bucket cross-region replication configuration
   314  type BucketReplicationConfiguration struct {
   315  	XMLName          xml.Name          `xml:"ReplicationConfiguration"`
   316  	Agency           string            `xml:"Agency"`
   317  	ReplicationRules []ReplicationRule `xml:"Rule"`
   318  }
   319  
   320  // Tag defines tag property in BucketTagging
   321  type Tag struct {
   322  	XMLName xml.Name `xml:"Tag"`
   323  	Key     string   `xml:"Key"`
   324  	Value   string   `xml:"Value"`
   325  }
   326  
   327  // BucketTagging defines the bucket tag configuration
   328  type BucketTagging struct {
   329  	XMLName xml.Name `xml:"Tagging"`
   330  	Tags    []Tag    `xml:"TagSet>Tag"`
   331  }
   332  
   333  // FilterRule defines filter rule in TopicConfiguration
   334  type FilterRule struct {
   335  	XMLName xml.Name `xml:"FilterRule"`
   336  	Name    string   `xml:"Name,omitempty"`
   337  	Value   string   `xml:"Value,omitempty"`
   338  }
   339  
   340  // TopicConfiguration defines the topic configuration
   341  type TopicConfiguration struct {
   342  	XMLName     xml.Name     `xml:"TopicConfiguration"`
   343  	ID          string       `xml:"Id,omitempty"`
   344  	Topic       string       `xml:"Topic"`
   345  	Events      []EventType  `xml:"Event"`
   346  	FilterRules []FilterRule `xml:"Filter>Object>FilterRule"`
   347  }
   348  
   349  // BucketNotification defines the bucket notification configuration
   350  type BucketNotification struct {
   351  	XMLName             xml.Name             `xml:"NotificationConfiguration"`
   352  	TopicConfigurations []TopicConfiguration `xml:"TopicConfiguration"`
   353  }
   354  
   355  type topicConfigurationS3 struct {
   356  	XMLName     xml.Name     `xml:"TopicConfiguration"`
   357  	ID          string       `xml:"Id,omitempty"`
   358  	Topic       string       `xml:"Topic"`
   359  	Events      []string     `xml:"Event"`
   360  	FilterRules []FilterRule `xml:"Filter>S3Key>FilterRule"`
   361  }
   362  
   363  type bucketNotificationS3 struct {
   364  	XMLName             xml.Name               `xml:"NotificationConfiguration"`
   365  	TopicConfigurations []topicConfigurationS3 `xml:"TopicConfiguration"`
   366  }
   367  
   368  // ObjectToDelete defines the object property in DeleteObjectsInput
   369  type ObjectToDelete struct {
   370  	XMLName   xml.Name `xml:"Object"`
   371  	Key       string   `xml:"Key"`
   372  	VersionId string   `xml:"VersionId,omitempty"`
   373  }
   374  
   375  // Deleted defines the deleted property in DeleteObjectsOutput
   376  type Deleted struct {
   377  	XMLName               xml.Name `xml:"Deleted"`
   378  	Key                   string   `xml:"Key"`
   379  	VersionId             string   `xml:"VersionId"`
   380  	DeleteMarker          bool     `xml:"DeleteMarker"`
   381  	DeleteMarkerVersionId string   `xml:"DeleteMarkerVersionId"`
   382  }
   383  
   384  // Part defines the part properties
   385  type Part struct {
   386  	XMLName      xml.Name  `xml:"Part"`
   387  	PartNumber   int       `xml:"PartNumber"`
   388  	ETag         string    `xml:"ETag"`
   389  	LastModified time.Time `xml:"LastModified,omitempty"`
   390  	Size         int64     `xml:"Size,omitempty"`
   391  }
   392  
   393  // BucketPayer defines the request payment configuration
   394  type BucketPayer struct {
   395  	XMLName xml.Name  `xml:"RequestPaymentConfiguration"`
   396  	Payer   PayerType `xml:"Payer"`
   397  }
   398  
   399  // HttpHeader defines the standard metadata
   400  type HttpHeader struct {
   401  	CacheControl       string
   402  	ContentDisposition string
   403  	ContentEncoding    string
   404  	ContentLanguage    string
   405  	ContentType        string
   406  	HttpExpires        string
   407  }