diff options
| author | Konstantin Lebedev <lebedev_k@tochka.com> | 2021-10-11 15:03:56 +0500 |
|---|---|---|
| committer | Konstantin Lebedev <lebedev_k@tochka.com> | 2021-10-11 15:03:56 +0500 |
| commit | be4b3ed509178b6464452cd91fb06718548f9307 (patch) | |
| tree | f298ec711c279cbb64b9c438bb84d1238feb1ba9 /weed/s3api/s3api_policy.go | |
| parent | 84d2e1bdd099550aaba494c88324c8c0dbc08776 (diff) | |
| download | seaweedfs-be4b3ed509178b6464452cd91fb06718548f9307.tar.xz seaweedfs-be4b3ed509178b6464452cd91fb06718548f9307.zip | |
AclHandlers
Diffstat (limited to 'weed/s3api/s3api_policy.go')
| -rw-r--r-- | weed/s3api/s3api_policy.go | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/weed/s3api/s3api_policy.go b/weed/s3api/s3api_policy.go new file mode 100644 index 000000000..20dac9564 --- /dev/null +++ b/weed/s3api/s3api_policy.go @@ -0,0 +1,88 @@ +package s3api + +import ( + "encoding/xml" + "time" +) + +// Status represents lifecycle configuration status +type ruleStatus string + +// Supported status types +const ( + Enabled ruleStatus = "Enabled" + Disabled ruleStatus = "Disabled" +) + +// Lifecycle - Configuration for bucket lifecycle. +type Lifecycle struct { + XMLName xml.Name `xml:"LifecycleConfiguration"` + Rules []Rule `xml:"Rule"` +} + +// Rule - a rule for lifecycle configuration. +type Rule struct { + XMLName xml.Name `xml:"Rule"` + ID string `xml:"ID,omitempty"` + Status ruleStatus `xml:"Status"` + Filter Filter `xml:"Filter,omitempty"` + Prefix Prefix `xml:"Prefix,omitempty"` + Expiration Expiration `xml:"Expiration,omitempty"` + Transition Transition `xml:"Transition,omitempty"` +} + +// Filter - a filter for a lifecycle configuration Rule. +type Filter struct { + XMLName xml.Name `xml:"Filter"` + set bool + + Prefix Prefix + + And And + andSet bool + + Tag Tag + tagSet bool +} + +// Prefix holds the prefix xml tag in <Rule> and <Filter> +type Prefix struct { + string + set bool +} + +// And - a tag to combine a prefix and multiple tags for lifecycle configuration rule. +type And struct { + XMLName xml.Name `xml:"And"` + Prefix Prefix `xml:"Prefix,omitempty"` + Tags []Tag `xml:"Tag,omitempty"` +} + +// Expiration - expiration actions for a rule in lifecycle configuration. +type Expiration struct { + XMLName xml.Name `xml:"Expiration"` + Days int `xml:"Days,omitempty"` + Date time.Time `xml:"Date,omitempty"` + DeleteMarker ExpireDeleteMarker `xml:"ExpiredObjectDeleteMarker"` + + set bool +} + +// ExpireDeleteMarker represents value of ExpiredObjectDeleteMarker field in Expiration XML element. +type ExpireDeleteMarker struct { + val bool + set bool +} + +// Transition - transition actions for a rule in lifecycle configuration. +type Transition struct { + XMLName xml.Name `xml:"Transition"` + Days int `xml:"Days,omitempty"` + Date time.Time `xml:"Date,omitempty"` + StorageClass string `xml:"StorageClass,omitempty"` + + set bool +} + +// TransitionDays is a type alias to unmarshal Days in Transition +type TransitionDays int |
