-
Notifications
You must be signed in to change notification settings - Fork 80
/
proto.go
279 lines (243 loc) · 6.48 KB
/
proto.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
package object
import (
"context"
"errors"
"github.com/bittorrent/go-btfs/s3/hash"
"io"
"time"
)
var (
ErrBucketNotFound = errors.New("bucket not found")
ErrBucketNotEmpty = errors.New("bucket not empty")
ErrObjectNotFound = errors.New("object not found")
ErrUploadNotFound = errors.New("upload not found")
ErrNotAllowed = errors.New("authentication not allowed")
ErrBucketAlreadyExists = errors.New("bucket already exists")
ErrPartNotExists = errors.New("part not exists")
ErrPartETagNotMatch = errors.New("part etag not match")
ErrPartTooSmall = errors.New("part size too small")
ErrCanceled = context.Canceled
ErrTimout = context.DeadlineExceeded
)
type Service interface {
CreateBucket(ctx context.Context, args *CreateBucketArgs) (bucket *Bucket, err error)
GetBucket(ctx context.Context, args *GetBucketArgs) (bucket *Bucket, err error)
DeleteBucket(ctx context.Context, args *DeleteBucketArgs) (err error)
ListBuckets(ctx context.Context, args *ListBucketsArgs) (list *BucketList, err error)
PutBucketACL(ctx context.Context, args *PutBucketACLArgs) (err error)
GetBucketACL(ctx context.Context, args *GetBucketACLArgs) (acl *ACL, err error)
PutObject(ctx context.Context, args *PutObjectArgs) (object *Object, err error)
CopyObject(ctx context.Context, args *CopyObjectArgs) (object *Object, err error)
GetObject(ctx context.Context, args *GetObjectArgs) (object *Object, body io.ReadCloser, err error)
DeleteObject(ctx context.Context, args *DeleteObjectArgs) (err error)
DeleteObjects(ctx context.Context, args *DeleteObjectsArgs) (deletes []*DeletedObject, err error)
ListObjects(ctx context.Context, args *ListObjectsArgs) (list *ObjectsList, err error)
ListObjectsV2(ctx context.Context, args *ListObjectsV2Args) (list *ObjectsListV2, err error)
GetObjectACL(ctx context.Context, args *GetObjectACLArgs) (acl *ACL, err error)
CreateMultipartUpload(ctx context.Context, args *CreateMultipartUploadArgs) (multipart *Multipart, err error)
UploadPart(ctx context.Context, args *UploadPartArgs) (part *Part, err error)
AbortMultipartUpload(ctx context.Context, args *AbortMultipartUploadArgs) (err error)
CompleteMultiPartUpload(ctx context.Context, args *CompleteMultipartUploadArgs) (object *Object, err error)
}
type CreateBucketArgs struct {
UserId string
ACL string
Bucket string
Region string
}
type GetBucketArgs struct {
UserId string
Bucket string
}
type DeleteBucketArgs struct {
UserId string
Bucket string
}
type ListBucketsArgs struct {
UserId string
}
type GetBucketACLArgs struct {
UserId string
Bucket string
}
type PutBucketACLArgs struct {
UserId string
ACL string
Bucket string
}
type PutObjectArgs struct {
UserId string
Body *hash.Reader
Bucket string
Object string
ContentEncoding string
ContentLength int64
ContentType string
Expires time.Time
}
type CopyObjectArgs struct {
UserId string
Bucket string
Object string
SrcBucket string
SrcObject string
ContentEncoding string
ContentType string
Expires time.Time
ReplaceMeta bool
}
type GetObjectArgs struct {
UserId string
Bucket string
Object string
WithBody bool
}
type DeleteObjectArgs struct {
UserId string
Bucket string
Object string
}
type DeleteObjectsArgs struct {
UserId string
Bucket string
ToDeleteObjects []*ToDeleteObject
Quite bool
}
type ToDeleteObject struct {
Object string
ValidateErr error
}
type ListObjectsArgs struct {
UserId string
Bucket string
MaxKeys int64
Marker string
Prefix string
Delimiter string
EncodingType string
}
type ListObjectsV2Args struct {
UserId string
Bucket string
MaxKeys int64
Prefix string
Delimiter string
EncodingType string
Token string
After string
FetchOwner bool
}
type GetObjectACLArgs struct {
UserId string
Bucket string
Object string
}
type CreateMultipartUploadArgs struct {
UserId string
Bucket string
Object string
ContentEncoding string
ContentType string
Expires time.Time
}
type UploadPartArgs struct {
UserId string
Body *hash.Reader
Bucket string
Object string
UploadId string
PartNumber int64
ContentLength int64
}
type AbortMultipartUploadArgs struct {
UserId string
Body *hash.Reader
Bucket string
Object string
UploadId string
}
type CompleteMultipartUploadArgs struct {
UserId string
Bucket string
Object string
UploadId string
CompletedParts CompletedParts
}
type ACL struct {
Owner string
ACL string
}
type DeletedObject struct {
Object string
DeleteErr error
}
type Bucket struct {
Name string
Region string
Owner string
ACL string
Created time.Time
}
type BucketList struct {
Owner string
Buckets []*Bucket
}
type Object struct {
Bucket string
Name string
ModTime time.Time
Size int64
IsDir bool
ETag string
CID string
ACL string
VersionID string
IsLatest bool
DeleteMarker bool
ContentType string
ContentEncoding string
Expires time.Time
AccTime time.Time
SuccessorModTime time.Time
}
type Multipart struct {
Bucket string
Object string
UploadID string
Initiated time.Time
ContentType string
ContentEncoding string
Expires time.Time
Parts []*Part
}
type Part struct {
ETag string `json:"etag,omitempty"`
CID string `json:"cid,omitempty"`
Number int64 `json:"number"`
Size int64 `json:"size"`
ModTime time.Time `json:"mod_time"`
}
type ObjectsList struct {
Args *ListObjectsArgs
Owner string
IsTruncated bool
NextMarker string
Objects []*Object
Prefixes []string
}
type ObjectsListV2 struct {
Args *ListObjectsV2Args
Owner string
IsTruncated bool
NextContinuationToken string
Objects []*Object
Prefixes []string
}
type CompletePart struct {
PartNumber int64
ETag string
}
type CompletedParts []*CompletePart
func (a CompletedParts) Len() int { return len(a) }
func (a CompletedParts) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a CompletedParts) Less(i, j int) bool { return a[i].PartNumber < a[j].PartNumber }