lifecycle.go 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. package s3
  2. import (
  3. "github.com/ks3sdklib/aws-sdk-go/aws"
  4. "time"
  5. )
  6. type PutBucketLifecycleInput struct {
  7. Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
  8. LifecycleConfiguration *LifecycleConfiguration `locationName:"LifecycleConfiguration" type:"structure"`
  9. ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
  10. // Specifies whether lifecycle rules allow prefix overlap.
  11. AllowSameActionOverlap *bool `location:"header" locationName:"x-amz-allow-same-action-overlap" type:"boolean"`
  12. // Set extend request headers. If the existing fields do not support setting the request header you need, you can set it through this field.
  13. ExtendHeaders map[string]*string `location:"extendHeaders" type:"map"`
  14. // Set extend query params. If the existing fields do not support setting the query param you need, you can set it through this field.
  15. ExtendQueryParams map[string]*string `location:"extendQueryParams" type:"map"`
  16. metadataPutBucketLifecycleInput `json:"-" xml:"-"`
  17. }
  18. type metadataPutBucketLifecycleInput struct {
  19. SDKShapeTraits bool `type:"structure" payload:"LifecycleConfiguration"`
  20. AutoFillMD5 bool
  21. }
  22. type LifecycleConfiguration struct {
  23. Rules []*LifecycleRule `locationName:"Rule" type:"list" flattened:"true" required:"true"`
  24. }
  25. type LifecycleRule struct {
  26. // Unique identifier for the rule. The value cannot be longer than 255 characters.
  27. ID *string `type:"string"`
  28. // If 'Enabled', the rule is currently being applied. If 'Disabled', the rule
  29. // is not currently being applied.
  30. Status *string `type:"string" required:"true"`
  31. // Specifies the prefix, each Rule can only have one Filter, and the prefixes of different
  32. // Rules cannot conflict.
  33. Filter *LifecycleFilter `type:"structure"`
  34. // Specifies the time when the object is deleted
  35. Expiration *LifecycleExpiration `type:"structure"`
  36. // Specifies when an object transitions to a specified storage class.
  37. Transitions []*Transition `locationName:"Transition" type:"list" flattened:"true"`
  38. // Specifies the expiration time for multipart uploads.
  39. AbortIncompleteMultipartUpload *AbortIncompleteMultipartUpload `type:"structure"`
  40. }
  41. type LifecycleFilter struct {
  42. Prefix *string `type:"string"`
  43. And *And `locationName:"And" type:"structure"`
  44. }
  45. type And struct {
  46. Prefix *string `type:"string"`
  47. Tags []*Tag `locationName:"Tag" type:"list" flattened:"true"`
  48. }
  49. type LifecycleExpiration struct {
  50. // Indicates at what date the object is to be moved or deleted. Should be in
  51. // GMT ISO 8601 Format.
  52. Date *time.Time `type:"timestamp" timestampFormat:"iso8601"`
  53. // Indicates the lifetime, in days, of the objects that are subject to the rule.
  54. // The value must be a non-zero positive integer.
  55. Days *int64 `type:"integer"`
  56. }
  57. type Transition struct {
  58. // Indicates at what date the object is to be moved or deleted. Should be in
  59. // GMT ISO 8601 Format.
  60. Date *time.Time `type:"timestamp" timestampFormat:"iso8601"`
  61. // Specifies the number of days after the object is last modified or accessed that the lifecycle rule takes effect.
  62. // When the value of IsAccessTime in the request is true, this parameter indicates that the lifecycle rule takes
  63. // effect based on the last access time of the object. When IsAccessTime is not set in the request or is set to false,
  64. // this parameter indicates that the lifecycle rule takes effect based on the last modification time of the object.
  65. // This parameter is mutually exclusive with Date.
  66. Days *int64 `type:"integer"`
  67. // The class of storage used to store the object.
  68. StorageClass *string `type:"string"`
  69. // Specifies whether to use the last access time matching rule.
  70. // true: indicates that the last access time of the object is used for matching.
  71. // false: indicates that the last modification time of the object is used for matching.
  72. IsAccessTime *bool `type:"boolean"`
  73. // Specifies whether to convert the object to the source storage type when accessed again after the object is
  74. // converted to another storage type. This is only valid when IsAccessTime is set to true.
  75. // true: Indicates that the object is converted to the source storage type when accessed again.
  76. // false: Indicates that the object is still the target storage type when accessed again.
  77. ReturnToStdWhenVisit *bool `type:"boolean"`
  78. }
  79. type AbortIncompleteMultipartUpload struct {
  80. // Relative expiration time: The expiration time in days after the last modified time
  81. DaysAfterInitiation *int64 `type:"integer"`
  82. // objects created before the date will be expired
  83. Date *string `type:"string"`
  84. }
  85. type PutBucketLifecycleOutput struct {
  86. // The HTTP headers of the response.
  87. Metadata map[string]*string `location:"headers" type:"map"`
  88. // The HTTP status code of the response.
  89. StatusCode *int64 `location:"statusCode" type:"integer"`
  90. }
  91. // PutBucketLifecycleRequest generates a request for the PutBucketLifecycle operation.
  92. func (c *S3) PutBucketLifecycleRequest(input *PutBucketLifecycleInput) (req *aws.Request, output *PutBucketLifecycleOutput) {
  93. op := &aws.Operation{
  94. Name: "PutBucketLifecycle",
  95. HTTPMethod: "PUT",
  96. HTTPPath: "/{Bucket}?lifecycle",
  97. }
  98. if input == nil {
  99. input = &PutBucketLifecycleInput{}
  100. }
  101. input.AutoFillMD5 = true
  102. req = c.newRequest(op, input, output)
  103. output = &PutBucketLifecycleOutput{}
  104. req.Data = output
  105. return
  106. }
  107. // PutBucketLifecycle Sets lifecycle configuration for your bucket. If a lifecycle configuration
  108. // exists, it replaces it.
  109. func (c *S3) PutBucketLifecycle(input *PutBucketLifecycleInput) (*PutBucketLifecycleOutput, error) {
  110. req, out := c.PutBucketLifecycleRequest(input)
  111. err := req.Send()
  112. return out, err
  113. }
  114. func (c *S3) PutBucketLifecycleWithContext(ctx aws.Context, input *PutBucketLifecycleInput) (*PutBucketLifecycleOutput, error) {
  115. req, out := c.PutBucketLifecycleRequest(input)
  116. req.SetContext(ctx)
  117. err := req.Send()
  118. return out, err
  119. }
  120. type GetBucketLifecycleInput struct {
  121. Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
  122. ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
  123. // Set extend request headers. If the existing fields do not support setting the request header you need, you can set it through this field.
  124. ExtendHeaders map[string]*string `location:"extendHeaders" type:"map"`
  125. // Set extend query params. If the existing fields do not support setting the query param you need, you can set it through this field.
  126. ExtendQueryParams map[string]*string `location:"extendQueryParams" type:"map"`
  127. }
  128. type GetBucketLifecycleOutput struct {
  129. Rules []*LifecycleRule `locationName:"Rule" type:"list" flattened:"true"`
  130. metadataGetBucketLifecycleOutput `json:"-" xml:"-"`
  131. Metadata map[string]*string `location:"headers" type:"map"`
  132. StatusCode *int64 `location:"statusCode" type:"integer"`
  133. }
  134. type metadataGetBucketLifecycleOutput struct {
  135. SDKShapeTraits bool `type:"structure"`
  136. }
  137. // GetBucketLifecycleRequest generates a request for the GetBucketLifecycle operation.
  138. func (c *S3) GetBucketLifecycleRequest(input *GetBucketLifecycleInput) (req *aws.Request, output *GetBucketLifecycleOutput) {
  139. op := &aws.Operation{
  140. Name: "GetBucketLifecycle",
  141. HTTPMethod: "GET",
  142. HTTPPath: "/{Bucket}?lifecycle",
  143. }
  144. if input == nil {
  145. input = &GetBucketLifecycleInput{}
  146. }
  147. req = c.newRequest(op, input, output)
  148. output = &GetBucketLifecycleOutput{}
  149. req.Data = output
  150. return
  151. }
  152. // GetBucketLifecycle Returns the lifecycle configuration information set on the bucket.
  153. func (c *S3) GetBucketLifecycle(input *GetBucketLifecycleInput) (*GetBucketLifecycleOutput, error) {
  154. req, out := c.GetBucketLifecycleRequest(input)
  155. err := req.Send()
  156. return out, err
  157. }
  158. func (c *S3) GetBucketLifecycleWithContext(ctx aws.Context, input *GetBucketLifecycleInput) (*GetBucketLifecycleOutput, error) {
  159. req, out := c.GetBucketLifecycleRequest(input)
  160. req.SetContext(ctx)
  161. err := req.Send()
  162. return out, err
  163. }
  164. type DeleteBucketLifecycleInput struct {
  165. Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
  166. ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
  167. // Set extend request headers. If the existing fields do not support setting the request header you need, you can set it through this field.
  168. ExtendHeaders map[string]*string `location:"extendHeaders" type:"map"`
  169. // Set extend query params. If the existing fields do not support setting the query param you need, you can set it through this field.
  170. ExtendQueryParams map[string]*string `location:"extendQueryParams" type:"map"`
  171. }
  172. type DeleteBucketLifecycleOutput struct {
  173. Metadata map[string]*string `location:"headers" type:"map"`
  174. StatusCode *int64 `location:"statusCode" type:"integer"`
  175. }
  176. // DeleteBucketLifecycleRequest generates a request for the DeleteBucketLifecycle operation.
  177. func (c *S3) DeleteBucketLifecycleRequest(input *DeleteBucketLifecycleInput) (req *aws.Request, output *DeleteBucketLifecycleOutput) {
  178. op := &aws.Operation{
  179. Name: "DeleteBucketLifecycle",
  180. HTTPMethod: "DELETE",
  181. HTTPPath: "/{Bucket}?lifecycle",
  182. }
  183. if input == nil {
  184. input = &DeleteBucketLifecycleInput{}
  185. }
  186. req = c.newRequest(op, input, output)
  187. output = &DeleteBucketLifecycleOutput{}
  188. req.Data = output
  189. return
  190. }
  191. // DeleteBucketLifecycle Deletes the lifecycle configuration from the bucket.
  192. func (c *S3) DeleteBucketLifecycle(input *DeleteBucketLifecycleInput) (*DeleteBucketLifecycleOutput, error) {
  193. req, out := c.DeleteBucketLifecycleRequest(input)
  194. err := req.Send()
  195. return out, err
  196. }
  197. func (c *S3) DeleteBucketLifecycleWithContext(ctx aws.Context, input *DeleteBucketLifecycleInput) (*DeleteBucketLifecycleOutput, error) {
  198. req, out := c.DeleteBucketLifecycleRequest(input)
  199. req.SetContext(ctx)
  200. err := req.Send()
  201. return out, err
  202. }