types.go 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. package s3
  2. import "encoding/xml"
  3. // CreateBucketResponse represents the S3 CreateBucket response
  4. type CreateBucketResponse struct {
  5. XMLName xml.Name `xml:"CreateBucketResponse"`
  6. Location string `xml:"Location"`
  7. }
  8. // ListAllMyBucketsResult for listing buckets
  9. type ListAllMyBucketsResult struct {
  10. XMLName xml.Name `xml:"ListAllMyBucketsResult"`
  11. Owner Owner `xml:"Owner"`
  12. Buckets []Bucket `xml:"Buckets>Bucket"`
  13. }
  14. type Owner struct {
  15. ID string `xml:"ID"`
  16. DisplayName string `xml:"DisplayName"`
  17. }
  18. type Bucket struct {
  19. Name string `xml:"Name"`
  20. CreationDate string `xml:"CreationDate"`
  21. }
  22. // S3Error represents an S3 error response
  23. type S3Error struct {
  24. XMLName xml.Name `xml:"Error"`
  25. Code string `xml:"Code"`
  26. Message string `xml:"Message"`
  27. Resource string `xml:"Resource,omitempty"`
  28. RequestId string `xml:"RequestId"`
  29. }
  30. // DeleteObjectResponse represents the S3 DeleteObject response
  31. type DeleteObjectResponse struct {
  32. XMLName xml.Name `xml:"DeleteObjectResponse"`
  33. DeleteMarker bool `xml:"DeleteMarker,omitempty"`
  34. VersionId string `xml:"VersionId,omitempty"`
  35. }
  36. // DeleteObjectsRequest represents the S3 DeleteObjects request
  37. type DeleteObjectsRequest struct {
  38. XMLName xml.Name `xml:"Delete"`
  39. Objects []ObjectToDelete `xml:"Object"`
  40. Quiet bool `xml:"Quiet,omitempty"`
  41. }
  42. // ObjectToDelete represents an object to delete in a batch delete operation
  43. type ObjectToDelete struct {
  44. Key string `xml:"Key"`
  45. VersionId string `xml:"VersionId,omitempty"`
  46. }
  47. // DeleteObjectsResponse represents the S3 DeleteObjects response
  48. type DeleteObjectsResponse struct {
  49. XMLName xml.Name `xml:"DeleteResult"`
  50. Deleted []DeletedObject `xml:"Deleted,omitempty"`
  51. Errors []DeleteError `xml:"Error,omitempty"`
  52. }
  53. // DeletedObject represents a successfully deleted object
  54. type DeletedObject struct {
  55. Key string `xml:"Key"`
  56. VersionId string `xml:"VersionId,omitempty"`
  57. DeleteMarker bool `xml:"DeleteMarker,omitempty"`
  58. DeleteMarkerVersionId string `xml:"DeleteMarkerVersionId,omitempty"`
  59. }
  60. // DeleteError represents an error during batch delete
  61. type DeleteError struct {
  62. Key string `xml:"Key"`
  63. VersionId string `xml:"VersionId,omitempty"`
  64. Code string `xml:"Code"`
  65. Message string `xml:"Message"`
  66. }
  67. // Multipart Upload structures
  68. // InitiateMultipartUploadResult represents the response for CreateMultipartUpload
  69. type InitiateMultipartUploadResult struct {
  70. XMLName xml.Name `xml:"InitiateMultipartUploadResult"`
  71. Bucket string `xml:"Bucket"`
  72. Key string `xml:"Key"`
  73. UploadId string `xml:"UploadId"`
  74. }
  75. // CompleteMultipartUploadRequest represents the request to complete a multipart upload
  76. type CompleteMultipartUploadRequest struct {
  77. XMLName xml.Name `xml:"CompleteMultipartUpload"`
  78. Parts []CompletePart `xml:"Part"`
  79. }
  80. // CompletePart represents a part in the complete request
  81. type CompletePart struct {
  82. PartNumber int `xml:"PartNumber"`
  83. ETag string `xml:"ETag"`
  84. }
  85. // CompleteMultipartUploadResult represents the response for CompleteMultipartUpload
  86. type CompleteMultipartUploadResult struct {
  87. XMLName xml.Name `xml:"CompleteMultipartUploadResult"`
  88. Location string `xml:"Location"`
  89. Bucket string `xml:"Bucket"`
  90. Key string `xml:"Key"`
  91. ETag string `xml:"ETag"`
  92. }
  93. // AbortMultipartUploadOutput represents the response for AbortMultipartUpload
  94. type AbortMultipartUploadOutput struct {
  95. XMLName xml.Name `xml:"AbortMultipartUploadOutput"`
  96. }
  97. // ListPartsResult represents the response for ListParts
  98. type ListPartsResult struct {
  99. XMLName xml.Name `xml:"ListPartsResult"`
  100. Bucket string `xml:"Bucket"`
  101. Key string `xml:"Key"`
  102. UploadId string `xml:"UploadId"`
  103. Initiator Initiator `xml:"Initiator"`
  104. Owner Owner `xml:"Owner"`
  105. StorageClass string `xml:"StorageClass"`
  106. PartNumberMarker int `xml:"PartNumberMarker"`
  107. NextPartNumberMarker int `xml:"NextPartNumberMarker"`
  108. MaxParts int `xml:"MaxParts"`
  109. IsTruncated bool `xml:"IsTruncated"`
  110. Parts []Part `xml:"Part"`
  111. }
  112. // Initiator represents the initiator of a multipart upload
  113. type Initiator struct {
  114. ID string `xml:"ID"`
  115. DisplayName string `xml:"DisplayName"`
  116. }
  117. // Part represents an uploaded part
  118. type Part struct {
  119. PartNumber int `xml:"PartNumber"`
  120. LastModified string `xml:"LastModified"`
  121. ETag string `xml:"ETag"`
  122. Size int64 `xml:"Size"`
  123. }
  124. // ListMultipartUploadsResult represents the response for ListMultipartUploads
  125. type ListMultipartUploadsResult struct {
  126. XMLName xml.Name `xml:"ListMultipartUploadsResult"`
  127. Bucket string `xml:"Bucket"`
  128. KeyMarker string `xml:"KeyMarker,omitempty"`
  129. UploadIdMarker string `xml:"UploadIdMarker,omitempty"`
  130. NextKeyMarker string `xml:"NextKeyMarker,omitempty"`
  131. NextUploadIdMarker string `xml:"NextUploadIdMarker,omitempty"`
  132. MaxUploads int `xml:"MaxUploads"`
  133. IsTruncated bool `xml:"IsTruncated"`
  134. Uploads []MultipartUpload `xml:"Upload,omitempty"`
  135. Prefix string `xml:"Prefix,omitempty"`
  136. Delimiter string `xml:"Delimiter,omitempty"`
  137. }
  138. // MultipartUpload represents an in-progress multipart upload
  139. type MultipartUpload struct {
  140. Key string `xml:"Key"`
  141. UploadId string `xml:"UploadId"`
  142. Initiator Initiator `xml:"Initiator"`
  143. Owner Owner `xml:"Owner"`
  144. StorageClass string `xml:"StorageClass"`
  145. Initiated string `xml:"Initiated"`
  146. }
  147. // UploadPartOutput represents the response for UploadPart
  148. type UploadPartOutput struct {
  149. ETag string `xml:"-"` // Returned in header
  150. }