You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

88 lines
2.1 KiB

3 years ago
  1. package s3api
  2. import (
  3. "encoding/xml"
  4. "time"
  5. )
  6. // Status represents lifecycle configuration status
  7. type ruleStatus string
  8. // Supported status types
  9. const (
  10. Enabled ruleStatus = "Enabled"
  11. Disabled ruleStatus = "Disabled"
  12. )
  13. // Lifecycle - Configuration for bucket lifecycle.
  14. type Lifecycle struct {
  15. XMLName xml.Name `xml:"LifecycleConfiguration"`
  16. Rules []Rule `xml:"Rule"`
  17. }
  18. // Rule - a rule for lifecycle configuration.
  19. type Rule struct {
  20. XMLName xml.Name `xml:"Rule"`
  21. ID string `xml:"ID,omitempty"`
  22. Status ruleStatus `xml:"Status"`
  23. Filter Filter `xml:"Filter,omitempty"`
  24. Prefix Prefix `xml:"Prefix,omitempty"`
  25. Expiration Expiration `xml:"Expiration,omitempty"`
  26. Transition Transition `xml:"Transition,omitempty"`
  27. }
  28. // Filter - a filter for a lifecycle configuration Rule.
  29. type Filter struct {
  30. XMLName xml.Name `xml:"Filter"`
  31. set bool
  32. Prefix Prefix
  33. And And
  34. andSet bool
  35. Tag Tag
  36. tagSet bool
  37. }
  38. // Prefix holds the prefix xml tag in <Rule> and <Filter>
  39. type Prefix struct {
  40. string
  41. set bool
  42. }
  43. // And - a tag to combine a prefix and multiple tags for lifecycle configuration rule.
  44. type And struct {
  45. XMLName xml.Name `xml:"And"`
  46. Prefix Prefix `xml:"Prefix,omitempty"`
  47. Tags []Tag `xml:"Tag,omitempty"`
  48. }
  49. // Expiration - expiration actions for a rule in lifecycle configuration.
  50. type Expiration struct {
  51. XMLName xml.Name `xml:"Expiration"`
  52. Days int `xml:"Days,omitempty"`
  53. Date time.Time `xml:"Date,omitempty"`
  54. DeleteMarker ExpireDeleteMarker `xml:"ExpiredObjectDeleteMarker"`
  55. set bool
  56. }
  57. // ExpireDeleteMarker represents value of ExpiredObjectDeleteMarker field in Expiration XML element.
  58. type ExpireDeleteMarker struct {
  59. val bool
  60. set bool
  61. }
  62. // Transition - transition actions for a rule in lifecycle configuration.
  63. type Transition struct {
  64. XMLName xml.Name `xml:"Transition"`
  65. Days int `xml:"Days,omitempty"`
  66. Date time.Time `xml:"Date,omitempty"`
  67. StorageClass string `xml:"StorageClass,omitempty"`
  68. set bool
  69. }
  70. // TransitionDays is a type alias to unmarshal Days in Transition
  71. type TransitionDays int