replication.go 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. package s3
  2. import "github.com/ks3sdklib/aws-sdk-go/aws"
  3. // PutBucketReplicationRequest generates a request for the PutBucketReplication operation.
  4. func (c *S3) PutBucketReplicationRequest(input *PutBucketReplicationInput) (req *aws.Request, output *PutBucketReplicationOutput) {
  5. op := &aws.Operation{
  6. Name: "PutBucketReplication",
  7. HTTPMethod: "PUT",
  8. HTTPPath: "/{Bucket}?crr",
  9. }
  10. if input == nil {
  11. input = &PutBucketReplicationInput{}
  12. }
  13. input.AutoFillMD5 = true
  14. req = c.newRequest(op, input, output)
  15. output = &PutBucketReplicationOutput{}
  16. req.Data = output
  17. return
  18. }
  19. // PutBucketReplication creates a new replication configuration.
  20. func (c *S3) PutBucketReplication(input *PutBucketReplicationInput) (*PutBucketReplicationOutput, error) {
  21. req, out := c.PutBucketReplicationRequest(input)
  22. err := req.Send()
  23. return out, err
  24. }
  25. func (c *S3) PutBucketReplicationWithContext(ctx aws.Context, input *PutBucketReplicationInput) (*PutBucketReplicationOutput, error) {
  26. req, out := c.PutBucketReplicationRequest(input)
  27. req.SetContext(ctx)
  28. err := req.Send()
  29. return out, err
  30. }
  31. type PutBucketReplicationInput struct {
  32. Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
  33. ReplicationConfiguration *ReplicationConfiguration `locationName:"Replication" type:"structure" required:"true" xmlURI:"http://s3.amazonaws.com/doc/2006-03-01/"`
  34. ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
  35. // Set extend request headers. If the existing fields do not support setting the request header you need, you can set it through this field.
  36. ExtendHeaders map[string]*string `location:"extendHeaders" type:"map"`
  37. // Set extend query params. If the existing fields do not support setting the query param you need, you can set it through this field.
  38. ExtendQueryParams map[string]*string `location:"extendQueryParams" type:"map"`
  39. metadataPutBucketReplicationInput `json:"-" xml:"-"`
  40. }
  41. type metadataPutBucketReplicationInput struct {
  42. SDKShapeTraits bool `type:"structure" payload:"ReplicationConfiguration"`
  43. AutoFillMD5 bool
  44. }
  45. type PutBucketReplicationOutput struct {
  46. Metadata map[string]*string `location:"headers" type:"map"`
  47. StatusCode *int64 `location:"statusCode" type:"integer"`
  48. }
  49. type ReplicationConfiguration struct {
  50. // Prefix matching, only objects that match prefix rules will be copied. Each copying rule
  51. // can add up to 10 prefix matching rules, and prefixes cannot overlap with each other.
  52. Prefix []*string `locationName:"prefix" type:"list" flattened:"true"`
  53. // Indicate whether to enable delete replication. If set to Enabled, it means enabled; if set to
  54. // Disabled or not, it means disabled. If set to delete replication, when the source bucket deletes
  55. // an object, the replica of that object in the target bucket will also be deleted.
  56. DeleteMarkerStatus *string `locationName:"DeleteMarkerStatus" type:"string" required:"true"`
  57. // Target bucket for copying rules.
  58. TargetBucket *string `locationName:"targetBucket" type:"string" required:"true"`
  59. // Specify whether to copy historical data. Whether to copy the data from the source bucket
  60. // to the target bucket before enabling data replication.
  61. // Enabled: Copy historical data to the target bucket (default value)
  62. // Disabled: Do not copy historical data, only copy new data after enabling the rule to the target bucket.
  63. HistoricalObjectReplication *string `locationName:"HistoricalObjectReplication" type:"string"`
  64. // Region of the target bucket.
  65. Region *string `locationName:"region" type:"string"`
  66. }
  67. // GetBucketReplicationRequest generates a request for the GetBucketReplication operation.
  68. func (c *S3) GetBucketReplicationRequest(input *GetBucketReplicationInput) (req *aws.Request, output *GetBucketReplicationOutput) {
  69. op := &aws.Operation{
  70. Name: "GetBucketReplication",
  71. HTTPMethod: "GET",
  72. HTTPPath: "/{Bucket}?crr",
  73. }
  74. if input == nil {
  75. input = &GetBucketReplicationInput{}
  76. }
  77. req = c.newRequest(op, input, output)
  78. output = &GetBucketReplicationOutput{}
  79. req.Data = output
  80. return
  81. }
  82. // GetBucketReplication gets the replication configuration for the bucket.
  83. func (c *S3) GetBucketReplication(input *GetBucketReplicationInput) (*GetBucketReplicationOutput, error) {
  84. req, out := c.GetBucketReplicationRequest(input)
  85. err := req.Send()
  86. return out, err
  87. }
  88. func (c *S3) GetBucketReplicationWithContext(ctx aws.Context, input *GetBucketReplicationInput) (*GetBucketReplicationOutput, error) {
  89. req, out := c.GetBucketReplicationRequest(input)
  90. req.SetContext(ctx)
  91. err := req.Send()
  92. return out, err
  93. }
  94. type GetBucketReplicationInput struct {
  95. Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
  96. // Set extend request headers. If the existing fields do not support setting the request header you need, you can set it through this field.
  97. ExtendHeaders map[string]*string `location:"extendHeaders" type:"map"`
  98. // Set extend query params. If the existing fields do not support setting the query param you need, you can set it through this field.
  99. ExtendQueryParams map[string]*string `location:"extendQueryParams" type:"map"`
  100. }
  101. type GetBucketReplicationOutput struct {
  102. ReplicationConfiguration *ReplicationConfiguration `locationName:"Replication" type:"structure"`
  103. Metadata map[string]*string `location:"headers" type:"map"`
  104. StatusCode *int64 `location:"statusCode" type:"integer"`
  105. metadataGetBucketReplicationOutput `json:"-" xml:"-"`
  106. }
  107. type metadataGetBucketReplicationOutput struct {
  108. SDKShapeTraits bool `type:"structure" payload:"ReplicationConfiguration"`
  109. }
  110. // DeleteBucketReplicationRequest generates a request for the DeleteBucketReplication operation.
  111. func (c *S3) DeleteBucketReplicationRequest(input *DeleteBucketReplicationInput) (req *aws.Request, output *DeleteBucketReplicationOutput) {
  112. op := &aws.Operation{
  113. Name: "DeleteBucketReplication",
  114. HTTPMethod: "DELETE",
  115. HTTPPath: "/{Bucket}?crr",
  116. }
  117. if input == nil {
  118. input = &DeleteBucketReplicationInput{}
  119. }
  120. req = c.newRequest(op, input, output)
  121. output = &DeleteBucketReplicationOutput{}
  122. req.Data = output
  123. return
  124. }
  125. // DeleteBucketReplication deletes the replication configuration for the bucket.
  126. func (c *S3) DeleteBucketReplication(input *DeleteBucketReplicationInput) (*DeleteBucketReplicationOutput, error) {
  127. req, out := c.DeleteBucketReplicationRequest(input)
  128. err := req.Send()
  129. return out, err
  130. }
  131. func (c *S3) DeleteBucketReplicationWithContext(ctx aws.Context, input *DeleteBucketReplicationInput) (*DeleteBucketReplicationOutput, error) {
  132. req, out := c.DeleteBucketReplicationRequest(input)
  133. req.SetContext(ctx)
  134. err := req.Send()
  135. return out, err
  136. }
  137. type DeleteBucketReplicationInput struct {
  138. Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
  139. // Set extend request headers. If the existing fields do not support setting the request header you need, you can set it through this field.
  140. ExtendHeaders map[string]*string `location:"extendHeaders" type:"map"`
  141. // Set extend query params. If the existing fields do not support setting the query param you need, you can set it through this field.
  142. ExtendQueryParams map[string]*string `location:"extendQueryParams" type:"map"`
  143. }
  144. type DeleteBucketReplicationOutput struct {
  145. Metadata map[string]*string `location:"headers" type:"map"`
  146. StatusCode *int64 `location:"statusCode" type:"integer"`
  147. }